| 1 | // Copyright 2024 Google LLC |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package aesgcm_testscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/ |
| 16 | |
| 17 | import ( |
| 18 | "bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/" |
| 19 | "testingscip-go gomod github.com/golang/go/src go1.24.0 testing/" |
| 20 | |
| 21 | "github.com/google/go-cmp/cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/" |
| 22 | "github.com/tink-crypto/tink-go/v2/aead/aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/" |
| 23 | "github.com/tink-crypto/tink-go/v2/core/cryptofmtscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/cryptofmt`/" |
| 24 | "github.com/tink-crypto/tink-go/v2/insecuresecretdataaccessscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/" |
| 25 | "github.com/tink-crypto/tink-go/v2/internal/keygenregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/keygenregistry`/" |
| 26 | "github.com/tink-crypto/tink-go/v2/keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/key`/" |
| 27 | "github.com/tink-crypto/tink-go/v2/secretdatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/" |
| 28 | ) |
| 29 | |
| 30 | var ( |
| 31 | key128Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key128Bits. = []byte{ |
| 32 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| 33 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| 34 | } |
| 35 | key256Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key256Bits. = []byte{ |
| 36 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| 37 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| 38 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| 39 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| 40 | } |
| 41 | ) |
| 42 | |
| 43 | func TestNewParametersInvalidKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestNewParametersInvalidKeySize().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 44 | for _, keySize := range []int{1, 15, 17, 31, 33} { |
| 45 | opts := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#{ |
| 46 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: keySize, |
| 47 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 48 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 49 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#Variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 50 | } |
| 51 | if _, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewParameters().(opts); err == nil { |
| 52 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("aesgcm.NewParameters(%v) err = nil, want error", opts) |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | func TestNewParametersInvalidIVSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestNewParametersInvalidIVSize().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 58 | for _, ivSize := range []int{-1, 0} { |
| 59 | opts := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#{ |
| 60 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: 16, |
| 61 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: ivSize, |
| 62 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 63 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#Variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 64 | } |
| 65 | if _, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewParameters().(opts); err == nil { |
| 66 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("aesgcm.NewParameters(%v) err = nil, want error", opts) |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | func TestNewParametersInvalidTagSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestNewParametersInvalidTagSize().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 72 | for _, tagSize := range []int{1, 11, 17} { |
| 73 | opts := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#{ |
| 74 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: 16, |
| 75 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 76 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: tagSize, |
| 77 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#Variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 78 | } |
| 79 | if _, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewParameters().(opts); err == nil { |
| 80 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("aesgcm.NewParameters(%v) err = nil, want error", opts) |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | func TestNewParametersInvalidVariantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestNewParametersInvalidVariant().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 86 | opts := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#{ |
| 87 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: 16, |
| 88 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 89 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 90 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#Variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantUnknownscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantUnknown., |
| 91 | } |
| 92 | if _, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewParameters().(opts); err == nil { |
| 93 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("aesgcm.NewParameters(%v) err = nil, want error", opts) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | func TestNewKeyFailsIfParametersIsNilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestNewKeyFailsIfParametersIsNil().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 98 | keyBytes, err := secretdatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/.NewBytesFromRandscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/NewBytesFromRand().(32) |
| 99 | if err != nil { |
| 100 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("secretdata.NewBytesFromRand(32) err = %v, want nil", err) |
| 101 | } |
| 102 | if _, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewKey().(keyBytes, 123, nil); err == nil { |
| 103 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("aesgcm.NewKey(keyBytes, 123, nil) err = nil, want error") |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | func TestNewKeyFailsIfKeySizeIsDifferentThanParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestNewKeyFailsIfKeySizeIsDifferentThanParameters().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 108 | for _, tc := range []struct { |
| 109 | name string |
| 110 | keyBytes secretdatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/.Bytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/Bytes# |
| 111 | opts aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts# |
| 112 | }{ |
| 113 | { |
| 114 | name: "key size is 16 but parameters is 32", |
| 115 | keyBytes: secretdatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/.NewBytesFromDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/NewBytesFromData().(key128Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key128Bits., insecuresecretdataaccessscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/.Tokenscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/Token#{}), |
| 116 | opts: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#{ |
| 117 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: 32, |
| 118 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 119 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 120 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#Variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 121 | }, |
| 122 | }, |
| 123 | { |
| 124 | name: "key size is 32 but parameters is 16", |
| 125 | keyBytes: secretdatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/.NewBytesFromDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/NewBytesFromData().(key256Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key256Bits., insecuresecretdataaccessscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/.Tokenscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/Token#{}), |
| 126 | opts: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#{ |
| 127 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: 16, |
| 128 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 129 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 130 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#Variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 131 | }, |
| 132 | }, |
| 133 | } { |
| 134 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(tc.name, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 135 | params, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewParameters().(tc.opts) |
| 136 | if err != nil { |
| 137 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewParameters(%v) err = %v, want nil", tc.opts, err) |
| 138 | } |
| 139 | if _, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewKey().(tc.keyBytes, 123, params); err == nil { |
| 140 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("aesgcm.NewKey(%v, 123, %v) err = nil, want error", tc.keyBytes, params) |
| 141 | } |
| 142 | }) |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | // TestNewKeyFailsIfInvalidParams tests that NewKey fails if the parameters are invalid. |
| 147 | // |
| 148 | // The only way to create invalid parameters is to create a struct literal with default |
| 149 | // values. |
| 150 | func TestNewKeyFailsIfInvalidParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestNewKeyFailsIfInvalidParams().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 151 | keyBytes, err := secretdatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/.NewBytesFromRandscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/NewBytesFromRand().(32) |
| 152 | if err != nil { |
| 153 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("secretdata.NewBytesFromRand(32) err = %v, want nil", err) |
| 154 | } |
| 155 | params := &aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Parameters#{} |
| 156 | if _, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewKey().(keyBytes, 123, params); err == nil { |
| 157 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("aesgcm.NewKey(keyBytes, 123, nil) err = nil, want error") |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | func TestNewKeyFailsIfNoPrefixAndIDIsNotZeroscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestNewKeyFailsIfNoPrefixAndIDIsNotZero().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 162 | opts := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#{ |
| 163 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: 32, |
| 164 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 165 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 166 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#Variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantNoPrefix., |
| 167 | } |
| 168 | params, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewParameters().(opts) |
| 169 | if err != nil { |
| 170 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewParameters(%v) err = %v, want nil", opts, err) |
| 171 | } |
| 172 | keyBytes := secretdatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/.NewBytesFromDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/NewBytesFromData().(key128Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key128Bits., insecuresecretdataaccessscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/.Tokenscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/Token#{}) |
| 173 | if _, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewKey().(keyBytes, 123, params); err == nil { |
| 174 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("aesgcm.NewKey(keyBytes, 123, %v) err = nil, want error", params) |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | func TestOutputPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestOutputPrefix().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 179 | for _, test := range []struct { |
| 180 | name string |
| 181 | variant aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Variant# |
| 182 | id uint32 |
| 183 | want []byte |
| 184 | }{ |
| 185 | { |
| 186 | name: "Tink", |
| 187 | variant: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 188 | id: uint32(0x01020304), |
| 189 | want: []byte{cryptofmtscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/cryptofmt`/.TinkStartBytescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/cryptofmt`/TinkStartByte., 0x01, 0x02, 0x03, 0x04}, |
| 190 | }, |
| 191 | { |
| 192 | name: "Crunchy", |
| 193 | variant: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantCrunchyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantCrunchy., |
| 194 | id: uint32(0x01020304), |
| 195 | want: []byte{cryptofmtscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/cryptofmt`/.LegacyStartBytescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/cryptofmt`/LegacyStartByte., 0x01, 0x02, 0x03, 0x04}, |
| 196 | }, |
| 197 | { |
| 198 | name: "No prefix", |
| 199 | variant: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantNoPrefix., |
| 200 | id: 0, |
| 201 | want: nil, |
| 202 | }, |
| 203 | } { |
| 204 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(test.name, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 205 | opts := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#{ |
| 206 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: 32, |
| 207 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 208 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 209 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#Variant.: test.variant, |
| 210 | } |
| 211 | params, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewParameters().(opts) |
| 212 | if err != nil { |
| 213 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewParameters(%v) err = %v, want nil", opts, err) |
| 214 | } |
| 215 | keyBytes, err := secretdatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/.NewBytesFromRandscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/NewBytesFromRand().(32) |
| 216 | if err != nil { |
| 217 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("secretdata.NewBytes(32fNewBytesFromRand() err = %v, want nil", err) |
| 218 | } |
| 219 | key, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewKey().(keyBytes, test.id, params) |
| 220 | if err != nil { |
| 221 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewKey(keyBytes, %v, %v) err = %v, want nil", test.id, params, err) |
| 222 | } |
| 223 | if got := key.OutputPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Key#OutputPrefix().(); !bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.Equalscip-go gomod github.com/golang/go/src go1.24.0 bytes/Equal().(got, test.want) { |
| 224 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("params.OutputPrefix() = %v, want %v", got, test.want) |
| 225 | } |
| 226 | }) |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | func TestNewParametersWorksscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestNewParametersWorks().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 231 | for _, test := range []struct { |
| 232 | name string |
| 233 | keySize int |
| 234 | variant aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Variant# |
| 235 | }{ |
| 236 | { |
| 237 | name: "128-bit key with Tink prefix", |
| 238 | keySize: 16, |
| 239 | variant: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 240 | }, |
| 241 | { |
| 242 | name: "128-bit key with Crunchy prefix", |
| 243 | keySize: 16, |
| 244 | variant: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantCrunchyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantCrunchy., |
| 245 | }, |
| 246 | { |
| 247 | name: "128-bit key with NoPrefix prefix", |
| 248 | keySize: 16, |
| 249 | variant: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantNoPrefix., |
| 250 | }, |
| 251 | { |
| 252 | name: "256-bit key with Tink prefix", |
| 253 | keySize: 32, |
| 254 | variant: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 255 | }, |
| 256 | { |
| 257 | name: "256-bit key with Crunchy prefix", |
| 258 | keySize: 32, |
| 259 | variant: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantCrunchyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantCrunchy., |
| 260 | }, |
| 261 | { |
| 262 | name: "256-bit key with NoPrefix prefix", |
| 263 | keySize: 32, |
| 264 | variant: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantNoPrefix., |
| 265 | }, |
| 266 | } { |
| 267 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(test.name, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 268 | opts := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#{ |
| 269 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: test.keySize, |
| 270 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 271 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 272 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#Variant.: test.variant, |
| 273 | } |
| 274 | params, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewParameters().(opts) |
| 275 | if err != nil { |
| 276 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewParameters(%v) err = %v, want nil", opts, err) |
| 277 | } |
| 278 | if params.HasIDRequirementscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Parameters#HasIDRequirement().() != (test.variant != aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantNoPrefix.) { |
| 279 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("params.HasIDRequirement() = %v, want %v", params.HasIDRequirementscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Parameters#HasIDRequirement().(), (test.variant != aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantNoPrefix.)) |
| 280 | } |
| 281 | if params.KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Parameters#KeySizeInBytes().() != test.keySize { |
| 282 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("params.KeySizeInBytes()() = %v, want %v", params.KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Parameters#KeySizeInBytes().(), test.keySize) |
| 283 | } |
| 284 | if params.TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Parameters#TagSizeInBytes().() != 16 { |
| 285 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("params.TagSizeInBytes() = %v, want 16", params.TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Parameters#TagSizeInBytes().()) |
| 286 | } |
| 287 | if params.IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Parameters#IVSizeInBytes().() != 12 { |
| 288 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("params.IVSizeInBytes() = %v, want 12", params.IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Parameters#IVSizeInBytes().()) |
| 289 | } |
| 290 | if params.Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Parameters#Variant().() != test.variant { |
| 291 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("params.Variant() = %v, want %v", params.Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Parameters#Variant().(), test.variant) |
| 292 | } |
| 293 | otherParams, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewParameters().(opts) |
| 294 | if err != nil { |
| 295 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewParameters(%v) err = %v, want nil", opts, err) |
| 296 | } |
| 297 | if !params.Equalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Parameters#Equal().(otherParams) { |
| 298 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("params.Equal(otherParams) = %v, want true", params.Equalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Parameters#Equal().(otherParams)) |
| 299 | } |
| 300 | }) |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | func TestParametersEqualFalseIfDifferentscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestParametersEqualFalseIfDifferent().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 305 | for _, test := range []struct { |
| 306 | name string |
| 307 | key1Size int |
| 308 | key1Variant aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Variant# |
| 309 | key2Size int |
| 310 | key2Variant aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Variant# |
| 311 | }{ |
| 312 | { |
| 313 | name: "different key size", |
| 314 | key1Size: 16, |
| 315 | key1Variant: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 316 | key2Size: 32, |
| 317 | key2Variant: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 318 | }, |
| 319 | { |
| 320 | name: "different prefix variant", |
| 321 | key1Size: 16, |
| 322 | key1Variant: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantCrunchyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantCrunchy., |
| 323 | key2Size: 16, |
| 324 | key2Variant: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 325 | }, |
| 326 | } { |
| 327 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(test.name, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 328 | opts1 := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#{ |
| 329 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: test.key1Size, |
| 330 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 331 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 332 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#Variant.: test.key1Variant, |
| 333 | } |
| 334 | params1, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewParameters().(opts1) |
| 335 | if err != nil { |
| 336 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewParameters(%v) err = %v, want nil", opts1, err) |
| 337 | } |
| 338 | opts2 := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#{ |
| 339 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: test.key2Size, |
| 340 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 341 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 342 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#Variant.: test.key2Variant, |
| 343 | } |
| 344 | params2, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewParameters().(opts2) |
| 345 | if err != nil { |
| 346 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("aesgcm.NewParameters(%v) err = %v, want nil", opts2, err) |
| 347 | } |
| 348 | if params1.Equalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Parameters#Equal().(params2) { |
| 349 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("params.Equal(params2) = %v, want false", params1.Equalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Parameters#Equal().(params2)) |
| 350 | } |
| 351 | }) |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | type TestKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey# struct { |
| 356 | namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#name. string |
| 357 | keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize. int |
| 358 | idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id. uint32 |
| 359 | keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key. []byte |
| 360 | variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant. aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Variant# |
| 361 | } |
| 362 | |
| 363 | func TestNewKeyWorksscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestNewKeyWorks().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 364 | for _, test := range []TestKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#{ |
| 365 | { |
| 366 | namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#name.: "128-bit key with Tink prefix", |
| 367 | keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize.: 16, |
| 368 | idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id.: 1, |
| 369 | keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key.: key128Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key128Bits., |
| 370 | variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 371 | }, |
| 372 | { |
| 373 | namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#name.: "128-bit key with Crunchy prefix", |
| 374 | keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize.: 16, |
| 375 | idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id.: 1, |
| 376 | keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key.: key128Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key128Bits., |
| 377 | variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantCrunchyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantCrunchy., |
| 378 | }, |
| 379 | { |
| 380 | namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#name.: "128-bit key with NoPrefix prefix", |
| 381 | keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize.: 16, |
| 382 | idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id.: 0, |
| 383 | keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key.: key128Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key128Bits., |
| 384 | variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantNoPrefix., |
| 385 | }, |
| 386 | { |
| 387 | namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#name.: "256-bit key with Tink prefix", |
| 388 | keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize.: 32, |
| 389 | idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id.: 1, |
| 390 | keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key.: key256Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key256Bits., |
| 391 | variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 392 | }, |
| 393 | { |
| 394 | namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#name.: "256-bit key with Crunchy prefix", |
| 395 | keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize.: 32, |
| 396 | idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id.: 1, |
| 397 | keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key.: key256Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key256Bits., |
| 398 | variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantCrunchyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantCrunchy., |
| 399 | }, |
| 400 | { |
| 401 | namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#name.: "256-bit key with NoPrefix prefix", |
| 402 | keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize.: 32, |
| 403 | idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id.: 0, |
| 404 | keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key.: key256Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key256Bits., |
| 405 | variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantNoPrefix., |
| 406 | }, |
| 407 | } { |
| 408 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(test.namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#name., func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 409 | opts := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#{ |
| 410 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: test.keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize., |
| 411 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 412 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 413 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#Variant.: test.variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant., |
| 414 | } |
| 415 | params, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewParameters().(opts) |
| 416 | if err != nil { |
| 417 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewParameters(%v) err = %v, want nil", opts, err) |
| 418 | } |
| 419 | keyBytes := secretdatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/.NewBytesFromDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/NewBytesFromData().(test.keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key., insecuresecretdataaccessscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/.Tokenscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/Token#{}) |
| 420 | |
| 421 | // Create two keys with the same parameters and key bytes. |
| 422 | key1, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewKey().(keyBytes, test.idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id., params) |
| 423 | if err != nil { |
| 424 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewKey(keyBytes, %v, %v) err = %v, want nil", test.idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id., params, err) |
| 425 | } |
| 426 | if !key1.Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Key#Parameters().().Equalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/key`/Parameters#Equal.(params) { |
| 427 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("key1.Parameters() = %v, want %v", key1.Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Key#Parameters().(), params) |
| 428 | } |
| 429 | key1Bytes := key1.KeyBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Key#KeyBytes().() |
| 430 | if !keyBytes.Equalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/Bytes#Equal().(key1Bytes) { |
| 431 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("keyBytes.Equal(key1Bytes) = false, want true") |
| 432 | } |
| 433 | keyID1, required := key1.IDRequirementscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Key#IDRequirement().() |
| 434 | if wantRequired := test.variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant. != aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantNoPrefix.; required != wantRequired { |
| 435 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("required = %v, want %v", required, wantRequired) |
| 436 | } |
| 437 | wantID := test.idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id. |
| 438 | if !required { |
| 439 | wantID = 0 |
| 440 | } |
| 441 | if keyID1 != wantID { |
| 442 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("keyID1 = %v, want %v", keyID1, wantID) |
| 443 | } |
| 444 | key2, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewKey().(keyBytes, keyID1, params) |
| 445 | if err != nil { |
| 446 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewKey(keyBytes, %v, %v) err = %v, want nil", keyID1, params, err) |
| 447 | } |
| 448 | // Test Equal. |
| 449 | if !key1.Equalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Key#Equal().(key2) { |
| 450 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("key1.Equal(key2) = %v, want true", key1.Equalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Key#Equal().(key2)) |
| 451 | } |
| 452 | }) |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | type stubKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/stubKey# struct{} |
| 457 | |
| 458 | var _ keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/key`/.Keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/key`/Key# = (*stubKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/stubKey#)(nil) |
| 459 | |
| 460 | func (k *stubKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/stubKey#) Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/stubKey#Parameters().() keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/key`/.Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/key`/Parameters# { return nil } |
| 461 | func (k *stubKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/stubKey#) Equalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/stubKey#Equal().(other keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/key`/.Keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/key`/Key#) bool { return true } |
| 462 | func (k *stubKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/stubKey#) IDRequirementscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/stubKey#IDRequirement().() (uint32, bool) { return 123, true } |
| 463 | |
| 464 | func TestKeyEqual_FalseIfDifferentTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKeyEqual_FalseIfDifferentType().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 465 | params, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewParameters().(aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#{ |
| 466 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: 32, |
| 467 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 468 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 469 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#Variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 470 | }) |
| 471 | if err != nil { |
| 472 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewParameters() err = %v, want nil", err) |
| 473 | } |
| 474 | keyBytes := secretdatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/.NewBytesFromDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/NewBytesFromData().([]byte("01234567890123450123456789012345"), insecuresecretdataaccessscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/.Tokenscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/Token#{}) |
| 475 | key, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewKey().(keyBytes, 1234, params) |
| 476 | if err != nil { |
| 477 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewKey() err = %v, want nil", err) |
| 478 | } |
| 479 | if key.Equalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Key#Equal().(&stubKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/stubKey#{}) { |
| 480 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("key.Equal(&stubKey{}) = true, want false") |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | func TestKeyEqualReturnsFalseIfDifferentscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKeyEqualReturnsFalseIfDifferent().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 485 | for _, test := range []struct { |
| 486 | name string |
| 487 | first TestKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey# |
| 488 | second TestKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey# |
| 489 | }{ |
| 490 | { |
| 491 | name: "different key size", |
| 492 | first: TestKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#{ |
| 493 | keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize.: 16, |
| 494 | variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 495 | keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key.: key128Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key128Bits., |
| 496 | idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id.: 0x01, |
| 497 | }, |
| 498 | second: TestKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#{ |
| 499 | keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize.: 32, |
| 500 | variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 501 | keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key.: key256Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key256Bits., |
| 502 | idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id.: 0x01, |
| 503 | }, |
| 504 | }, |
| 505 | { |
| 506 | name: "different prefix variant", |
| 507 | first: TestKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#{ |
| 508 | keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize.: 16, |
| 509 | variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 510 | keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key.: key128Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key128Bits., |
| 511 | idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id.: 0x01, |
| 512 | }, |
| 513 | second: TestKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#{ |
| 514 | keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize.: 16, |
| 515 | variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantCrunchyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantCrunchy., |
| 516 | keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key.: key128Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key128Bits., |
| 517 | idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id.: 0x01, |
| 518 | }, |
| 519 | }, |
| 520 | { |
| 521 | name: "different key IDs", |
| 522 | first: TestKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#{ |
| 523 | keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize.: 16, |
| 524 | variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 525 | keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key.: key128Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key128Bits., |
| 526 | idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id.: 0x01, |
| 527 | }, |
| 528 | second: TestKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#{ |
| 529 | keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize.: 16, |
| 530 | variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 531 | keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key.: key128Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key128Bits., |
| 532 | idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id.: 0x02, |
| 533 | }, |
| 534 | }, |
| 535 | { |
| 536 | name: "different key bytes", |
| 537 | first: TestKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#{ |
| 538 | keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize.: 16, |
| 539 | variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantCrunchyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantCrunchy., |
| 540 | keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key.: key128Bitsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/key128Bits., |
| 541 | idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id.: 0x01, |
| 542 | }, |
| 543 | second: TestKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#{ |
| 544 | keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize.: 16, |
| 545 | variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantCrunchyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantCrunchy., |
| 546 | keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key.: []byte{ |
| 547 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x09, |
| 548 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| 549 | }, |
| 550 | idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id.: 0x01, |
| 551 | }, |
| 552 | }, |
| 553 | } { |
| 554 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(test.name, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 555 | firstOpts := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#{ |
| 556 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: test.first.keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize., |
| 557 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 558 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 559 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#Variant.: test.first.variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant., |
| 560 | } |
| 561 | firstParams, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewParameters().(firstOpts) |
| 562 | if err != nil { |
| 563 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewParameters(%v) err = %v, want nil", firstOpts, err) |
| 564 | } |
| 565 | firstKeyBytes := secretdatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/.NewBytesFromDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/NewBytesFromData().(test.first.keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key., insecuresecretdataaccessscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/.Tokenscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/Token#{}) |
| 566 | firstKey, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewKey().(firstKeyBytes, test.first.idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id., firstParams) |
| 567 | if err != nil { |
| 568 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewKey(firstKeyBytes, %v, %v) err = %v, want nil", test.first.idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id., firstParams, err) |
| 569 | } |
| 570 | |
| 571 | secondOpts := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#{ |
| 572 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: test.second.keySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#keySize., |
| 573 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 574 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 575 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#Variant.: test.second.variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#variant., |
| 576 | } |
| 577 | secondParams, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewParameters().(secondOpts) |
| 578 | if err != nil { |
| 579 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewParameters(%v) err = %v, want nil", secondOpts, err) |
| 580 | } |
| 581 | secondKeyBytes := secretdatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/.NewBytesFromDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/NewBytesFromData().(test.second.keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#key., insecuresecretdataaccessscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/.Tokenscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/Token#{}) |
| 582 | secondKey, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewKey().(secondKeyBytes, test.second.idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id., secondParams) |
| 583 | if err != nil { |
| 584 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewKey(secondKeyBytes, %v, %v) err = %v, want nil", test.second.idscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKey#id., secondParams, err) |
| 585 | } |
| 586 | if firstKey.Equalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Key#Equal().(secondKey) { |
| 587 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("firstKey.Equal(secondKey) = true, want false") |
| 588 | } |
| 589 | }) |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | func TestKeyCreatorscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKeyCreator().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 594 | params, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewParameters().(aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#{ |
| 595 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: 16, |
| 596 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 597 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 598 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#Variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 599 | }) |
| 600 | if err != nil { |
| 601 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewParameters() err = %v, want nil", err) |
| 602 | } |
| 603 | |
| 604 | key, err := keygenregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/keygenregistry`/.CreateKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/keygenregistry`/CreateKey().(params, 123) |
| 605 | if err != nil { |
| 606 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("keygenregistry.CreateKey(%v, 123) err = %v, want nil", params, err) |
| 607 | } |
| 608 | aesGCMKey, ok := key.(*aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.Keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Key#) |
| 609 | if !ok { |
| 610 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("keygenregistry.CreateKey(%v, 123) returned key of type %T, want %T", params, key, (*aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.Keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Key#)(nil)) |
| 611 | } |
| 612 | |
| 613 | idRequirement, hasIDRequirement := aesGCMKey.IDRequirementscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Key#IDRequirement().() |
| 614 | if !hasIDRequirement || idRequirement != 123 { |
| 615 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("aesGCMKey.IDRequirement() (%v, %v), want (%v, %v)", idRequirement, hasIDRequirement, 123, true) |
| 616 | } |
| 617 | if got := aesGCMKey.KeyBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Key#KeyBytes().().Lenscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/Bytes#Len().(); got != params.KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Parameters#KeySizeInBytes().() { |
| 618 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("aesGCMKey.KeyBytes().Len() = %d, want 32", aesGCMKey.KeyBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Key#KeyBytes().().Lenscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/Bytes#Len().()) |
| 619 | } |
| 620 | if diff := cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/.Diffscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/Diff().(aesGCMKey.Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/Key#Parameters().(), params); diff != "" { |
| 621 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("aesGCMKey.Parameters() diff (-want +got):\n%s", diff) |
| 622 | } |
| 623 | } |
| 624 | |
| 625 | func TestKeyCreator_FailsIfInvalidKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestKeyCreator_FailsIfInvalidKeySize().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 626 | params, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewParameters().(aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#{ |
| 627 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: 24, |
| 628 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 629 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 630 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#Variant.: aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/VariantTink., |
| 631 | }) |
| 632 | if err != nil { |
| 633 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewParameters() err = %v, want nil", err) |
| 634 | } |
| 635 | if _, err := keygenregistryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/keygenregistry`/.CreateKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/keygenregistry`/CreateKey().(params, 123); err == nil { |
| 636 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("keygenregistry.CreateKey(%v, 123) err = nil, want error", params) |
| 637 | } |
| 638 | } |