| 1 | // Copyright 2018 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 | "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/" |
| 19 | "testingscip-go gomod github.com/golang/go/src go1.24.0 testing/" |
| 20 | |
| 21 | "google.golang.org/protobuf/protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/" |
| 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 | aeadtestutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/internal/testutil`/ "github.com/tink-crypto/tink-go/v2/aead/internal/testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/internal/testutil`/" |
| 24 | "github.com/tink-crypto/tink-go/v2/aead/subtlescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/subtle`/" |
| 25 | "github.com/tink-crypto/tink-go/v2/core/registryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/" |
| 26 | "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`/" |
| 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 | "github.com/tink-crypto/tink-go/v2/testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/" |
| 29 | "github.com/tink-crypto/tink-go/v2/tinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/tink`/" |
| 30 | gcmpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_go_proto`/ "github.com/tink-crypto/tink-go/v2/proto/aes_gcm_go_protoscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_go_proto`/" |
| 31 | tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/ "github.com/tink-crypto/tink-go/v2/proto/tink_go_protoscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/" |
| 32 | ) |
| 33 | |
| 34 | var keySizesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/keySizes. = []uint32{16, 32} |
| 35 | |
| 36 | func TestAESGCMGetPrimitiveBasicscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestAESGCMGetPrimitiveBasic().(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#) { |
| 37 | keyManager, err := registryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/.GetKeyManagerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/GetKeyManager().(testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMTypeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMTypeURL.) |
| 38 | if err != nil { |
| 39 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("cannot obtain AES-GCM key manager: %s", err) |
| 40 | } |
| 41 | for _, keySize := range keySizesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/keySizes. { |
| 42 | key := testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.NewAESGCMKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/NewAESGCMKey().(testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMKeyVersionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMKeyVersion., keySize) |
| 43 | serializedKey, err := protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/.Marshalscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/Marshal().(key) |
| 44 | if err != nil { |
| 45 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("proto.Marshal() err = %q, want nil", err) |
| 46 | } |
| 47 | p, err := keyManager.Primitivescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/KeyManager#Primitive.(serializedKey) |
| 48 | if err != nil { |
| 49 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("unexpected error: %s", err) |
| 50 | } |
| 51 | aesGCM, ok := p.(tinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/tink`/.AEADscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/tink`/AEAD#) |
| 52 | if !ok { |
| 53 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("Primitive() = %T, want tink.AEAD", p) |
| 54 | } |
| 55 | subtleAESGCM, err := subtlescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/subtle`/.NewAESGCMscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/subtle`/NewAESGCM().(key.GetKeyValuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_go_proto`/AesGcmKey#GetKeyValue().()) |
| 56 | if err != nil { |
| 57 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("subtle.NewAESGCM(key.GetKeyValue()) err = %v, want nil", err) |
| 58 | } |
| 59 | if err := aeadtestutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/internal/testutil`/.EncryptDecryptscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/internal/testutil`/EncryptDecrypt().(aesGCM, subtleAESGCM); err != nil { |
| 60 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("aeadtestutil.EncryptDecrypt(aesGCM, subtleAESGCM) err = %v, want nil", err) |
| 61 | } |
| 62 | if err := aeadtestutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/internal/testutil`/.EncryptDecryptscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/internal/testutil`/EncryptDecrypt().(subtleAESGCM, aesGCM); err != nil { |
| 63 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("aeadtestutil.EncryptDecrypt(subtleAESGCM, aesGCM) err = %v, want nil", err) |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | func TestAESGCMGetPrimitiveWithInvalidInputscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestAESGCMGetPrimitiveWithInvalidInput().(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#) { |
| 69 | keyManager, err := registryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/.GetKeyManagerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/GetKeyManager().(testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMTypeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMTypeURL.) |
| 70 | if err != nil { |
| 71 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("cannot obtain AES-GCM key manager: %s", err) |
| 72 | } |
| 73 | // invalid AESGCMKey |
| 74 | testKeys := genInvalidAESGCMKeysscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/genInvalidAESGCMKeys().() |
| 75 | for i := 0; i < len(testKeys); i++ { |
| 76 | serializedKey, err := protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/.Marshalscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/Marshal().(testKeys[i]) |
| 77 | if err != nil { |
| 78 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("proto.Marshal() err = %q, want nil", err) |
| 79 | } |
| 80 | if _, err := keyManager.Primitivescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/KeyManager#Primitive.(serializedKey); err == nil { |
| 81 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("expect an error in test case %d", i) |
| 82 | } |
| 83 | } |
| 84 | // nil |
| 85 | if _, err := keyManager.Primitivescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/KeyManager#Primitive.(nil); err == nil { |
| 86 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("expect an error when input is nil") |
| 87 | } |
| 88 | // empty array |
| 89 | if _, err := keyManager.Primitivescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/KeyManager#Primitive.([]byte{}); err == nil { |
| 90 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("expect an error when input is empty") |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | func TestAESGCMNewKeyMultipleTimesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestAESGCMNewKeyMultipleTimes().(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#) { |
| 95 | keyManager, err := registryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/.GetKeyManagerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/GetKeyManager().(testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMTypeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMTypeURL.) |
| 96 | if err != nil { |
| 97 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("cannot obtain AES-GCM key manager: %s", err) |
| 98 | } |
| 99 | format := testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.NewAESGCMKeyFormatscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/NewAESGCMKeyFormat().(32) |
| 100 | serializedFormat, err := protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/.Marshalscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/Marshal().(format) |
| 101 | if err != nil { |
| 102 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("proto.Marshal() err = %q, want nil", err) |
| 103 | } |
| 104 | keys := make(map[string]bool) |
| 105 | nTest := 26 |
| 106 | for i := 0; i < nTest; i++ { |
| 107 | key, err := keyManager.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/KeyManager#NewKey.(serializedFormat) |
| 108 | if err != nil { |
| 109 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("keyManager.NewKey() err = %q, want nil", err) |
| 110 | } |
| 111 | serializedKey, err := protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/.Marshalscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/Marshal().(key) |
| 112 | if err != nil { |
| 113 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("proto.Marshal() err = %q, want nil", err) |
| 114 | } |
| 115 | keys[string(serializedKey)] = true |
| 116 | |
| 117 | keyData, err := keyManager.NewKeyDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/KeyManager#NewKeyData.(serializedFormat) |
| 118 | if err != nil { |
| 119 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("keyManager.NewKeyData() err = %q, want nil", err) |
| 120 | } |
| 121 | serializedKey = keyData.Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#Value. |
| 122 | keys[string(serializedKey)] = true |
| 123 | } |
| 124 | if len(keys) != nTest*2 { |
| 125 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("key is repeated") |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | func TestAESGCMNewKeyBasicscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestAESGCMNewKeyBasic().(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#) { |
| 130 | keyManager, err := registryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/.GetKeyManagerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/GetKeyManager().(testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMTypeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMTypeURL.) |
| 131 | if err != nil { |
| 132 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("cannot obtain AES-GCM key manager: %s", err) |
| 133 | } |
| 134 | for _, keySize := range keySizesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/keySizes. { |
| 135 | format := testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.NewAESGCMKeyFormatscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/NewAESGCMKeyFormat().(keySize) |
| 136 | serializedFormat, err := protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/.Marshalscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/Marshal().(format) |
| 137 | if err != nil { |
| 138 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("proto.Marshal() err = %q, want nil", err) |
| 139 | } |
| 140 | m, err := keyManager.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/KeyManager#NewKey.(serializedFormat) |
| 141 | if err != nil { |
| 142 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("unexpected error: %s", err) |
| 143 | } |
| 144 | key := m.(*gcmpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_go_proto`/.AesGcmKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_go_proto`/AesGcmKey#) |
| 145 | if err := validateAESGCMKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/validateAESGCMKey().(key, format); err != nil { |
| 146 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("%s", err) |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | func TestAESGCMNewKeyWithInvalidInputscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestAESGCMNewKeyWithInvalidInput().(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#) { |
| 152 | keyManager, err := registryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/.GetKeyManagerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/GetKeyManager().(testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMTypeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMTypeURL.) |
| 153 | if err != nil { |
| 154 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("cannot obtain AES-GCM key manager: %s", err) |
| 155 | } |
| 156 | // bad format |
| 157 | badFormats := genInvalidAESGCMKeyFormatsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/genInvalidAESGCMKeyFormats().() |
| 158 | for i := 0; i < len(badFormats); i++ { |
| 159 | serializedFormat, err := protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/.Marshalscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/Marshal().(badFormats[i]) |
| 160 | if err != nil { |
| 161 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("proto.Marshal() err = %q, want nil", err) |
| 162 | } |
| 163 | if _, err := keyManager.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/KeyManager#NewKey.(serializedFormat); err == nil { |
| 164 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("expect an error in test case %d", i) |
| 165 | } |
| 166 | } |
| 167 | // nil |
| 168 | if _, err := keyManager.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/KeyManager#NewKey.(nil); err == nil { |
| 169 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("expect an error when input is nil") |
| 170 | } |
| 171 | // empty array |
| 172 | if _, err := keyManager.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/KeyManager#NewKey.([]byte{}); err == nil { |
| 173 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("expect an error when input is empty") |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | func TestAESGCMNewKeyDataBasicscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestAESGCMNewKeyDataBasic().(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#) { |
| 178 | keyManager, err := registryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/.GetKeyManagerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/GetKeyManager().(testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMTypeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMTypeURL.) |
| 179 | if err != nil { |
| 180 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("cannot obtain AES-GCM key manager: %s", err) |
| 181 | } |
| 182 | for _, keySize := range keySizesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/keySizes. { |
| 183 | format := testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.NewAESGCMKeyFormatscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/NewAESGCMKeyFormat().(keySize) |
| 184 | serializedFormat, err := protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/.Marshalscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/Marshal().(format) |
| 185 | if err != nil { |
| 186 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("proto.Marshal() err = %q, want nil", err) |
| 187 | } |
| 188 | keyData, err := keyManager.NewKeyDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/KeyManager#NewKeyData.(serializedFormat) |
| 189 | if err != nil { |
| 190 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("unexpected error: %s", err) |
| 191 | } |
| 192 | if keyData.TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#TypeUrl. != testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMTypeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMTypeURL. { |
| 193 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("incorrect type url") |
| 194 | } |
| 195 | if keyData.KeyMaterialTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#KeyMaterialType. != tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyData_SYMMETRICscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData_SYMMETRIC. { |
| 196 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("incorrect key material type") |
| 197 | } |
| 198 | key := new(gcmpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_go_proto`/.AesGcmKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_go_proto`/AesGcmKey#) |
| 199 | if err := protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/.Unmarshalscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/Unmarshal().(keyData.Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#Value., key); err != nil { |
| 200 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("incorrect key value") |
| 201 | } |
| 202 | if err := validateAESGCMKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/validateAESGCMKey().(key, format); err != nil { |
| 203 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("%s", err) |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | func TestAESGCMNewKeyDataWithInvalidInputscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestAESGCMNewKeyDataWithInvalidInput().(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#) { |
| 209 | keyManager, err := registryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/.GetKeyManagerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/GetKeyManager().(testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMTypeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMTypeURL.) |
| 210 | if err != nil { |
| 211 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("cannot obtain AES-GCM key manager: %s", err) |
| 212 | } |
| 213 | badFormats := genInvalidAESGCMKeyFormatsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/genInvalidAESGCMKeyFormats().() |
| 214 | for i := 0; i < len(badFormats); i++ { |
| 215 | serializedFormat, err := protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/.Marshalscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/Marshal().(badFormats[i]) |
| 216 | if err != nil { |
| 217 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("proto.Marshal() err = %q, want nil", err) |
| 218 | } |
| 219 | if _, err := keyManager.NewKeyDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/KeyManager#NewKeyData.(serializedFormat); err == nil { |
| 220 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("expect an error in test case %d", i) |
| 221 | } |
| 222 | } |
| 223 | // nil input |
| 224 | if _, err := keyManager.NewKeyDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/KeyManager#NewKeyData.(nil); err == nil { |
| 225 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("expect an error when input is nil") |
| 226 | } |
| 227 | // empty input |
| 228 | if _, err := keyManager.NewKeyDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/KeyManager#NewKeyData.([]byte{}); err == nil { |
| 229 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("expect an error when input is empty") |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | func TestAESGCMDoesSupportscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestAESGCMDoesSupport().(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#) { |
| 234 | keyManager, err := registryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/.GetKeyManagerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/GetKeyManager().(testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMTypeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMTypeURL.) |
| 235 | if err != nil { |
| 236 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("cannot obtain AES-GCM key manager: %s", err) |
| 237 | } |
| 238 | if !keyManager.DoesSupportscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/KeyManager#DoesSupport.(testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMTypeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMTypeURL.) { |
| 239 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("AESGCMKeyManager must support %s", testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMTypeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMTypeURL.) |
| 240 | } |
| 241 | if keyManager.DoesSupportscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/KeyManager#DoesSupport.("some bad type") { |
| 242 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("AESGCMKeyManager must support only %s", testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMTypeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMTypeURL.) |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | func TestAESGCMTypeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/TestAESGCMTypeURL().(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#) { |
| 247 | keyManager, err := registryscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/.GetKeyManagerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/GetKeyManager().(testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMTypeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMTypeURL.) |
| 248 | if err != nil { |
| 249 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("cannot obtain AES-GCM key manager: %s", err) |
| 250 | } |
| 251 | if keyManager.TypeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/core/registry`/KeyManager#TypeURL.() != testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMTypeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMTypeURL. { |
| 252 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("incorrect key type") |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | func genInvalidAESGCMKeysscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/genInvalidAESGCMKeys().() []protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/.Messagescip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/Message# { |
| 257 | return []protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/.Messagescip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/Message#{ |
| 258 | // not a AESGCMKey |
| 259 | testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.NewAESGCMKeyFormatscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/NewAESGCMKeyFormat().(32), |
| 260 | // bad key size |
| 261 | testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.NewAESGCMKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/NewAESGCMKey().(testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMKeyVersionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMKeyVersion., 17), |
| 262 | testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.NewAESGCMKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/NewAESGCMKey().(testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMKeyVersionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMKeyVersion., 25), |
| 263 | testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.NewAESGCMKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/NewAESGCMKey().(testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMKeyVersionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMKeyVersion., 33), |
| 264 | // bad version |
| 265 | testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.NewAESGCMKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/NewAESGCMKey().(testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMKeyVersionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMKeyVersion.+1, 16), |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | func genInvalidAESGCMKeyFormatsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/genInvalidAESGCMKeyFormats().() []protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/.Messagescip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/Message# { |
| 270 | return []protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/.Messagescip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/Message#{ |
| 271 | // not AESGCMKeyFormat |
| 272 | testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.NewAESGCMKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/NewAESGCMKey().(testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMKeyVersionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMKeyVersion., 16), |
| 273 | // invalid key size |
| 274 | testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.NewAESGCMKeyFormatscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/NewAESGCMKeyFormat().(uint32(15)), |
| 275 | testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.NewAESGCMKeyFormatscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/NewAESGCMKeyFormat().(uint32(23)), |
| 276 | testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.NewAESGCMKeyFormatscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/NewAESGCMKeyFormat().(uint32(31)), |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | func validateAESGCMKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm_test`/validateAESGCMKey().(key *gcmpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_go_proto`/.AesGcmKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_go_proto`/AesGcmKey#, format *gcmpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_go_proto`/.AesGcmKeyFormatscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_go_proto`/AesGcmKeyFormat#) error { |
| 281 | if uint32(len(key.KeyValuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_go_proto`/AesGcmKey#KeyValue.)) != format.KeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_go_proto`/AesGcmKeyFormat#KeySize. { |
| 282 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("incorrect key size") |
| 283 | } |
| 284 | if key.Versionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_go_proto`/AesGcmKey#Version. != testutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/.AESGCMKeyVersionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/testutil`/AESGCMKeyVersion. { |
| 285 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("incorrect key version") |
| 286 | } |
| 287 | keyValue := 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().(key.GetKeyValuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_go_proto`/AesGcmKey#GetKeyValue().(), 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#{}) |
| 288 | 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#{ |
| 289 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: keyValue.Lenscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/Bytes#Len().(), |
| 290 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 291 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 292 | 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., |
| 293 | } |
| 294 | 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) |
| 295 | if err != nil { |
| 296 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("aesgcm.NewParameters(%v) err = %v, want nil", opts, err) |
| 297 | } |
| 298 | k, 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().(keyValue, 0, params) |
| 299 | if err != nil { |
| 300 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("aesgcm.NewKey() err = %v, want nil", err) |
| 301 | } |
| 302 | p, err := aesgcmscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/.NewAEADscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/NewAEAD().(k) |
| 303 | if err != nil { |
| 304 | return fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("aesgcm.NewAEAD() err = %v, want nil", err) |
| 305 | } |
| 306 | return aeadtestutilscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/internal/testutil`/.EncryptDecryptscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/internal/testutil`/EncryptDecrypt().(p, p) |
| 307 | } |