| 1 | // Copyright 2025 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 keyderivers_testscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers_test`/ |
| 16 | |
| 17 | import ( |
| 18 | "bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/" |
| 19 | "reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/" |
| 20 | "testingscip-go gomod github.com/golang/go/src go1.24.0 testing/" |
| 21 | |
| 22 | "github.com/google/go-cmp/cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/" |
| 23 | "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`/" |
| 24 | "github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/" |
| 25 | "github.com/tink-crypto/tink-go/v2/daead/aessivscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/" |
| 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/keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/key`/" |
| 28 | "github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderiversscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers`/" |
| 29 | "github.com/tink-crypto/tink-go/v2/mac/hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/" |
| 30 | "github.com/tink-crypto/tink-go/v2/prf/hkdfprfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hkdfprf`/" |
| 31 | "github.com/tink-crypto/tink-go/v2/prf/hmacprfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/" |
| 32 | "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`/" |
| 33 | "github.com/tink-crypto/tink-go/v2/signature/ed25519scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/" |
| 34 | "github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/" |
| 35 | ) |
| 36 | |
| 37 | func TestDeriveKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers_test`/TestDeriveKey().(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#) { |
| 38 | // AES-GCM keys. |
| 39 | aes128GCMParams, 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#{ |
| 40 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: 16, |
| 41 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 42 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 43 | 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., |
| 44 | }) |
| 45 | if err != nil { |
| 46 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewParameters() err = %v, want nil", err) |
| 47 | } |
| 48 | aes128GCMKey, 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().(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("0123456789012345"), 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#{}), 123, aes128GCMParams) |
| 49 | if err != nil { |
| 50 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewKey() err = %v, want nil", err) |
| 51 | } |
| 52 | aes128GCMNoPrefixParams, 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#{ |
| 53 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: 16, |
| 54 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 55 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 56 | 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., |
| 57 | }) |
| 58 | if err != nil { |
| 59 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewParameters() err = %v, want nil", err) |
| 60 | } |
| 61 | aes128GCMNoPrefixKey, 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().(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("0123456789012345"), 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#{}), 0, aes128GCMNoPrefixParams) |
| 62 | if err != nil { |
| 63 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewKey() err = %v, want nil", err) |
| 64 | } |
| 65 | |
| 66 | // XChaCha20-Poly1305 keys. |
| 67 | xChaCha20Poly1305Params, err := xchacha20poly1305scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/NewParameters().(xchacha20poly1305scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/VariantTink.) |
| 68 | if err != nil { |
| 69 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("xchacha20poly1305.NewParameters() err = %v, want nil", err) |
| 70 | } |
| 71 | xChaCha20Poly1305Key, err := xchacha20poly1305scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/NewKey().(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#{}), 123, xChaCha20Poly1305Params) |
| 72 | if err != nil { |
| 73 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("xchacha20poly1305.NewKey() err = %v, want nil", err) |
| 74 | } |
| 75 | xChaCha20Poly1305NoPrefixParams, err := xchacha20poly1305scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/NewParameters().(xchacha20poly1305scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/VariantNoPrefix.) |
| 76 | if err != nil { |
| 77 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("xchacha20poly1305.NewParameters() err = %v, want nil", err) |
| 78 | } |
| 79 | xChaCha20Poly1305NoPrefixKey, err := xchacha20poly1305scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/NewKey().(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#{}), 0, xChaCha20Poly1305NoPrefixParams) |
| 80 | if err != nil { |
| 81 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("xchacha20poly1305.NewKey() err = %v, want nil", err) |
| 82 | } |
| 83 | |
| 84 | // AES-SIV keys. |
| 85 | aes256SIVParams, err := aessivscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/NewParameters().(32, aessivscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/VariantTink.) |
| 86 | if err != nil { |
| 87 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aessiv.NewParameters() err = %v, want nil", err) |
| 88 | } |
| 89 | aes256SIVKey, err := aessivscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/NewKey().(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#{}), 123, aes256SIVParams) |
| 90 | if err != nil { |
| 91 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aessiv.NewKey() err = %v, want nil", err) |
| 92 | } |
| 93 | aes256SIVNoPrefixParams, err := aessivscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/NewParameters().(32, aessivscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/VariantNoPrefix.) |
| 94 | if err != nil { |
| 95 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aessiv.NewParameters() err = %v, want nil", err) |
| 96 | } |
| 97 | aes256SIVNoPrefixKey, err := aessivscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/NewKey().(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#{}), 0, aes256SIVNoPrefixParams) |
| 98 | if err != nil { |
| 99 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aessiv.NewKey() err = %v, want nil", err) |
| 100 | } |
| 101 | |
| 102 | // HMAC keys. |
| 103 | hmacSHA256Tag128Params, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewParameters().(hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#{ |
| 104 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#KeySizeInBytes.: 32, |
| 105 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#TagSizeInBytes.: 16, |
| 106 | HashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#HashType.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/SHA256., |
| 107 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#Variant.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/VariantTink., |
| 108 | }) |
| 109 | if err != nil { |
| 110 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewParameters() err = %v, want nil", err) |
| 111 | } |
| 112 | hmacSHA256Tag128Key, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewKey().(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#{}), hmacSHA256Tag128Params, 123) |
| 113 | if err != nil { |
| 114 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewKey() err = %v, want nil", err) |
| 115 | } |
| 116 | hmacSHA256Tag128NoPrefixParams, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewParameters().(hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#{ |
| 117 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#KeySizeInBytes.: 32, |
| 118 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#TagSizeInBytes.: 16, |
| 119 | HashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#HashType.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/SHA256., |
| 120 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#Variant.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/VariantNoPrefix., |
| 121 | }) |
| 122 | if err != nil { |
| 123 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewParameters() err = %v, want nil", err) |
| 124 | } |
| 125 | hmacSHA256Tag128NoPrefixKey, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewKey().(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#{}), hmacSHA256Tag128NoPrefixParams, 0) |
| 126 | if err != nil { |
| 127 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewKey() err = %v, want nil", err) |
| 128 | } |
| 129 | hmacSHA256Tag256Params, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewParameters().(hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#{ |
| 130 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#KeySizeInBytes.: 32, |
| 131 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#TagSizeInBytes.: 32, |
| 132 | HashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#HashType.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/SHA256., |
| 133 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#Variant.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/VariantTink., |
| 134 | }) |
| 135 | if err != nil { |
| 136 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewParameters() err = %v, want nil", err) |
| 137 | } |
| 138 | hmacSHA256Tag256Key, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewKey().(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#{}), hmacSHA256Tag256Params, 123) |
| 139 | if err != nil { |
| 140 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewKey() err = %v, want nil", err) |
| 141 | } |
| 142 | hmacSHA256Tag256NoPrefixParams, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewParameters().(hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#{ |
| 143 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#KeySizeInBytes.: 32, |
| 144 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#TagSizeInBytes.: 32, |
| 145 | HashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#HashType.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/SHA256., |
| 146 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#Variant.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/VariantNoPrefix., |
| 147 | }) |
| 148 | if err != nil { |
| 149 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewParameters() err = %v, want nil", err) |
| 150 | } |
| 151 | hmacSHA256Tag256NoPrefixKey, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewKey().(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#{}), hmacSHA256Tag256NoPrefixParams, 0) |
| 152 | if err != nil { |
| 153 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewKey() err = %v, want nil", err) |
| 154 | } |
| 155 | hmacSHA512Tag256Params, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewParameters().(hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#{ |
| 156 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#KeySizeInBytes.: 64, |
| 157 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#TagSizeInBytes.: 32, |
| 158 | HashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#HashType.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.SHA512scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/SHA512., |
| 159 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#Variant.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/VariantTink., |
| 160 | }) |
| 161 | if err != nil { |
| 162 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewParameters() err = %v, want nil", err) |
| 163 | } |
| 164 | hmacSHA512Tag256Key, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewKey().(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("0123456789012345012345678901234501234567890123450123456789012345"), 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#{}), hmacSHA512Tag256Params, 123) |
| 165 | if err != nil { |
| 166 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewKey() err = %v, want nil", err) |
| 167 | } |
| 168 | hmacSHA512Tag256NoPrefixParams, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewParameters().(hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#{ |
| 169 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#KeySizeInBytes.: 64, |
| 170 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#TagSizeInBytes.: 32, |
| 171 | HashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#HashType.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.SHA512scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/SHA512., |
| 172 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#Variant.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/VariantNoPrefix., |
| 173 | }) |
| 174 | if err != nil { |
| 175 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewParameters() err = %v, want nil", err) |
| 176 | } |
| 177 | hmacSHA512Tag256NoPrefixKey, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewKey().(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("0123456789012345012345678901234501234567890123450123456789012345"), 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#{}), hmacSHA512Tag256NoPrefixParams, 0) |
| 178 | if err != nil { |
| 179 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewKey() err = %v, want nil", err) |
| 180 | } |
| 181 | hmacSHA512Tag512Params, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewParameters().(hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#{ |
| 182 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#KeySizeInBytes.: 64, |
| 183 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#TagSizeInBytes.: 64, |
| 184 | HashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#HashType.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.SHA512scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/SHA512., |
| 185 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#Variant.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/VariantTink., |
| 186 | }) |
| 187 | if err != nil { |
| 188 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewParameters() err = %v, want nil", err) |
| 189 | } |
| 190 | hmacSHA512Tag512Key, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewKey().(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("0123456789012345012345678901234501234567890123450123456789012345"), 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#{}), hmacSHA512Tag512Params, 123) |
| 191 | if err != nil { |
| 192 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewKey() err = %v, want nil", err) |
| 193 | } |
| 194 | hmacSHA512Tag512NoPrefixParams, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewParameters().(hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#{ |
| 195 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#KeySizeInBytes.: 64, |
| 196 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#TagSizeInBytes.: 64, |
| 197 | HashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#HashType.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.SHA512scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/SHA512., |
| 198 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#Variant.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/VariantNoPrefix., |
| 199 | }) |
| 200 | if err != nil { |
| 201 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewParameters() err = %v, want nil", err) |
| 202 | } |
| 203 | hmacSHA512Tag512NoPrefixKey, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewKey().(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("0123456789012345012345678901234501234567890123450123456789012345"), 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#{}), hmacSHA512Tag512NoPrefixParams, 0) |
| 204 | if err != nil { |
| 205 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewKey() err = %v, want nil", err) |
| 206 | } |
| 207 | |
| 208 | // PRF keys. |
| 209 | hkdfPRFSHA256Params, err := hkdfprfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hkdfprf`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hkdfprf`/NewParameters().(32, hkdfprfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hkdfprf`/.SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hkdfprf`/SHA256., []byte("salt")) |
| 210 | if err != nil { |
| 211 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hkdfprf.NewParameters() err = %v, want nil", err) |
| 212 | } |
| 213 | hkdfPRFSHA256Key, err := hkdfprfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hkdfprf`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hkdfprf`/NewKey().(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#{}), hkdfPRFSHA256Params) |
| 214 | if err != nil { |
| 215 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hkdfprf.NewKey() err = %v, want nil", err) |
| 216 | } |
| 217 | hmacSHA256PRFParams, err := hmacprfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/NewParameters().(32, hmacprfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/.SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/SHA256.) |
| 218 | if err != nil { |
| 219 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmacprf.NewParameters() err = %v, want nil", err) |
| 220 | } |
| 221 | hmacSHA256PRFKey, err := hmacprfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/NewKey().(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#{}), hmacSHA256PRFParams) |
| 222 | if err != nil { |
| 223 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmacprf.NewKey() err = %v, want nil", err) |
| 224 | } |
| 225 | hmacSHA512PRFParams, err := hmacprfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/NewParameters().(64, hmacprfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/.SHA512scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/SHA512.) |
| 226 | if err != nil { |
| 227 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmacprf.NewParameters() err = %v, want nil", err) |
| 228 | } |
| 229 | hmacSHA512PRFKey, err := hmacprfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/NewKey().(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("0123456789012345012345678901234501234567890123450123456789012345"), 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#{}), hmacSHA512PRFParams) |
| 230 | if err != nil { |
| 231 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmacprf.NewKey() err = %v, want nil", err) |
| 232 | } |
| 233 | |
| 234 | // Signature keys. |
| 235 | ed25519Params, err := ed25519scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/NewParameters().(ed25519scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/VariantTink.) |
| 236 | if err != nil { |
| 237 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("ed25519.NewParameters() err = %v, want nil", err) |
| 238 | } |
| 239 | ed25519Key, err := ed25519scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/.NewPrivateKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/NewPrivateKey().(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#{}), 123, ed25519Params) |
| 240 | if err != nil { |
| 241 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("ed25519.NewPrivateKey() err = %v, want nil", err) |
| 242 | } |
| 243 | ed25519NoPrefixParams, err := ed25519scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/NewParameters().(ed25519scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/VariantNoPrefix.) |
| 244 | if err != nil { |
| 245 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("ed25519.NewParameters() err = %v, want nil", err) |
| 246 | } |
| 247 | ed25519KeyNoPrefixKey, err := ed25519scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/.NewPrivateKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/NewPrivateKey().(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#{}), 0, ed25519NoPrefixParams) |
| 248 | if err != nil { |
| 249 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("ed25519.NewPrivateKey() err = %v, want nil", err) |
| 250 | } |
| 251 | |
| 252 | // Streaming AEAD keys. |
| 253 | aesGCMHKDFParams, err := aesgcmhkdfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/NewParameters().(aesgcmhkdfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#{ |
| 254 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#KeySizeInBytes.: 16, |
| 255 | DerivedKeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#DerivedKeySizeInBytes.: 16, |
| 256 | HKDFHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#HKDFHashType.: aesgcmhkdfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/.SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/SHA256., |
| 257 | SegmentSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#SegmentSizeInBytes.: 4096, |
| 258 | }) |
| 259 | if err != nil { |
| 260 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcmhkdf.NewParameters() err = %v, want nil", err) |
| 261 | } |
| 262 | aesGCMHKDFKey, err := aesgcmhkdfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/NewKey().(aesGCMHKDFParams, 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("0123456789012345"), 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#{})) |
| 263 | if err != nil { |
| 264 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcmhkdf.NewPrivateKey() err = %v, want nil", err) |
| 265 | } |
| 266 | |
| 267 | for _, tc := range []struct { |
| 268 | name string |
| 269 | params 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# |
| 270 | idRequirement uint32 |
| 271 | randomBytes []byte |
| 272 | wantKey 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# |
| 273 | }{ |
| 274 | { |
| 275 | name: "AES128GCM", |
| 276 | params: aes128GCMParams, |
| 277 | idRequirement: 123, |
| 278 | randomBytes: []byte("0123456789012345"), |
| 279 | wantKey: aes128GCMKey, |
| 280 | }, |
| 281 | { |
| 282 | name: "AES128GCM_longer_key_bytes", |
| 283 | params: aes128GCMParams, |
| 284 | idRequirement: 123, |
| 285 | randomBytes: []byte("0123456789012345ABCDEFGHIJKLMNOPQRSTUVWXYZ"), |
| 286 | wantKey: aes128GCMKey, |
| 287 | }, |
| 288 | { |
| 289 | name: "AES128GCMNoPrefix", |
| 290 | params: aes128GCMNoPrefixParams, |
| 291 | idRequirement: 0, |
| 292 | randomBytes: []byte("0123456789012345"), |
| 293 | wantKey: aes128GCMNoPrefixKey, |
| 294 | }, |
| 295 | { |
| 296 | name: "XChaCha20Poly13035", |
| 297 | params: xChaCha20Poly1305Params, |
| 298 | idRequirement: 123, |
| 299 | randomBytes: []byte("01234567890123450123456789012345"), |
| 300 | wantKey: xChaCha20Poly1305Key, |
| 301 | }, |
| 302 | { |
| 303 | name: "XChaCha20Poly13035_longer_key_bytes", |
| 304 | params: xChaCha20Poly1305Params, |
| 305 | idRequirement: 123, |
| 306 | randomBytes: []byte("01234567890123450123456789012345ABCDEFGHIJKLMNOPQRSTUVWXYZ"), |
| 307 | wantKey: xChaCha20Poly1305Key, |
| 308 | }, |
| 309 | { |
| 310 | name: "XChaCha20Poly13035NoPrefix", |
| 311 | params: xChaCha20Poly1305NoPrefixParams, |
| 312 | idRequirement: 0, |
| 313 | randomBytes: []byte("01234567890123450123456789012345"), |
| 314 | wantKey: xChaCha20Poly1305NoPrefixKey, |
| 315 | }, |
| 316 | { |
| 317 | name: "AES256SIV", |
| 318 | params: aes256SIVParams, |
| 319 | idRequirement: 123, |
| 320 | randomBytes: []byte("01234567890123450123456789012345"), |
| 321 | wantKey: aes256SIVKey, |
| 322 | }, |
| 323 | { |
| 324 | name: "AES256SIV_longer_key_bytes", |
| 325 | params: aes256SIVParams, |
| 326 | idRequirement: 123, |
| 327 | randomBytes: []byte("01234567890123450123456789012345ABCDEFGHIJKLMNOPQRSTUVWXYZ"), |
| 328 | wantKey: aes256SIVKey, |
| 329 | }, |
| 330 | { |
| 331 | name: "AES256SIVNoPrefix", |
| 332 | params: aes256SIVNoPrefixParams, |
| 333 | idRequirement: 0, |
| 334 | randomBytes: []byte("01234567890123450123456789012345"), |
| 335 | wantKey: aes256SIVNoPrefixKey, |
| 336 | }, |
| 337 | { |
| 338 | name: "HMACSHA256Tag128", |
| 339 | params: hmacSHA256Tag128Params, |
| 340 | idRequirement: 123, |
| 341 | randomBytes: []byte("01234567890123450123456789012345"), |
| 342 | wantKey: hmacSHA256Tag128Key, |
| 343 | }, |
| 344 | { |
| 345 | name: "HMACSHA256Tag128_longer_key_bytes", |
| 346 | params: hmacSHA256Tag128Params, |
| 347 | idRequirement: 123, |
| 348 | randomBytes: []byte("01234567890123450123456789012345ABCDEFGHIJKLMNOPQRSTUVWXYZ"), |
| 349 | wantKey: hmacSHA256Tag128Key, |
| 350 | }, |
| 351 | { |
| 352 | name: "HMACSHA256Tag128NoPrefix", |
| 353 | params: hmacSHA256Tag128NoPrefixParams, |
| 354 | idRequirement: 0, |
| 355 | randomBytes: []byte("01234567890123450123456789012345"), |
| 356 | wantKey: hmacSHA256Tag128NoPrefixKey, |
| 357 | }, |
| 358 | { |
| 359 | name: "HMACSHA256Tag256", |
| 360 | params: hmacSHA256Tag256Params, |
| 361 | idRequirement: 123, |
| 362 | randomBytes: []byte("01234567890123450123456789012345"), |
| 363 | wantKey: hmacSHA256Tag256Key, |
| 364 | }, |
| 365 | { |
| 366 | name: "HMACSHA256Tag256_longer_key_bytes", |
| 367 | params: hmacSHA256Tag256Params, |
| 368 | idRequirement: 123, |
| 369 | randomBytes: []byte("01234567890123450123456789012345ABCDEFGHIJKLMNOPQRSTUVWXYZ"), |
| 370 | wantKey: hmacSHA256Tag256Key, |
| 371 | }, |
| 372 | { |
| 373 | name: "HMACSHA256Tag256NoPrefix", |
| 374 | params: hmacSHA256Tag256NoPrefixParams, |
| 375 | idRequirement: 0, |
| 376 | randomBytes: []byte("01234567890123450123456789012345"), |
| 377 | wantKey: hmacSHA256Tag256NoPrefixKey, |
| 378 | }, |
| 379 | { |
| 380 | name: "HMACSHA512Tag256", |
| 381 | params: hmacSHA512Tag256Params, |
| 382 | idRequirement: 123, |
| 383 | randomBytes: []byte("0123456789012345012345678901234501234567890123450123456789012345"), |
| 384 | wantKey: hmacSHA512Tag256Key, |
| 385 | }, |
| 386 | { |
| 387 | name: "HMACSHA512Tag256_longer_key_bytes", |
| 388 | params: hmacSHA512Tag256Params, |
| 389 | idRequirement: 123, |
| 390 | randomBytes: []byte("0123456789012345012345678901234501234567890123450123456789012345ABCDEFGHIJKLMNOPQRSTUVWXYZ"), |
| 391 | wantKey: hmacSHA512Tag256Key, |
| 392 | }, |
| 393 | { |
| 394 | name: "HMACSHA512Tag256NoPrefix", |
| 395 | params: hmacSHA512Tag256NoPrefixParams, |
| 396 | idRequirement: 0, |
| 397 | randomBytes: []byte("0123456789012345012345678901234501234567890123450123456789012345"), |
| 398 | wantKey: hmacSHA512Tag256NoPrefixKey, |
| 399 | }, |
| 400 | { |
| 401 | name: "HMACSHA512Tag512", |
| 402 | params: hmacSHA512Tag512Params, |
| 403 | idRequirement: 123, |
| 404 | randomBytes: []byte("0123456789012345012345678901234501234567890123450123456789012345"), |
| 405 | wantKey: hmacSHA512Tag512Key, |
| 406 | }, |
| 407 | { |
| 408 | name: "HMACSHA512Tag512_longer_key_bytes", |
| 409 | params: hmacSHA512Tag512Params, |
| 410 | idRequirement: 123, |
| 411 | randomBytes: []byte("0123456789012345012345678901234501234567890123450123456789012345ABCDEFGHIJKLMNOPQRSTUVWXYZ"), |
| 412 | wantKey: hmacSHA512Tag512Key, |
| 413 | }, |
| 414 | { |
| 415 | name: "HMACSHA512Tag512NoPrefix", |
| 416 | params: hmacSHA512Tag512NoPrefixParams, |
| 417 | idRequirement: 0, |
| 418 | randomBytes: []byte("0123456789012345012345678901234501234567890123450123456789012345"), |
| 419 | wantKey: hmacSHA512Tag512NoPrefixKey, |
| 420 | }, |
| 421 | { |
| 422 | name: "HKDF_SHA256", |
| 423 | params: hkdfPRFSHA256Params, |
| 424 | idRequirement: 123, |
| 425 | randomBytes: []byte("01234567890123450123456789012345"), |
| 426 | wantKey: hkdfPRFSHA256Key, |
| 427 | }, |
| 428 | { |
| 429 | name: "HKDF_SHA256_longer_key_bytes", |
| 430 | params: hkdfPRFSHA256Params, |
| 431 | idRequirement: 123, |
| 432 | randomBytes: []byte("01234567890123450123456789012345ABCDEFGHIJKLMNOPQRSTUVWXYZ"), |
| 433 | wantKey: hkdfPRFSHA256Key, |
| 434 | }, |
| 435 | { |
| 436 | name: "HMAC_SHA256_PRF", |
| 437 | params: hmacSHA256PRFParams, |
| 438 | idRequirement: 123, |
| 439 | randomBytes: []byte("01234567890123450123456789012345"), |
| 440 | wantKey: hmacSHA256PRFKey, |
| 441 | }, |
| 442 | { |
| 443 | name: "HMAC_SHA256_longer_key_bytes_PRF", |
| 444 | params: hmacSHA256PRFParams, |
| 445 | idRequirement: 123, |
| 446 | randomBytes: []byte("01234567890123450123456789012345ABCDEFGHIJKLMNOPQRSTUVWXYZ"), |
| 447 | wantKey: hmacSHA256PRFKey, |
| 448 | }, |
| 449 | { |
| 450 | name: "HMAC_SHA512_PRF", |
| 451 | params: hmacSHA512PRFParams, |
| 452 | idRequirement: 123, |
| 453 | randomBytes: []byte("0123456789012345012345678901234501234567890123450123456789012345"), |
| 454 | wantKey: hmacSHA512PRFKey, |
| 455 | }, |
| 456 | { |
| 457 | name: "HMAC_SHA512_longer_key_bytes_PRF", |
| 458 | params: hmacSHA512PRFParams, |
| 459 | idRequirement: 123, |
| 460 | randomBytes: []byte("0123456789012345012345678901234501234567890123450123456789012345ABCDEFGHIJKLMNOPQRSTUVWXYZ"), |
| 461 | wantKey: hmacSHA512PRFKey, |
| 462 | }, |
| 463 | { |
| 464 | name: "ED25519", |
| 465 | params: &ed25519Params, |
| 466 | idRequirement: 123, |
| 467 | randomBytes: []byte("01234567890123450123456789012345"), |
| 468 | wantKey: ed25519Key, |
| 469 | }, |
| 470 | { |
| 471 | name: "ED25519_longer_key_bytes", |
| 472 | params: &ed25519Params, |
| 473 | idRequirement: 123, |
| 474 | randomBytes: []byte("01234567890123450123456789012345ABCDEFGHIJKLMNOPQRSTUVWXYZ"), |
| 475 | wantKey: ed25519Key, |
| 476 | }, |
| 477 | { |
| 478 | name: "ED25519NoPrefix", |
| 479 | params: &ed25519NoPrefixParams, |
| 480 | idRequirement: 0, |
| 481 | randomBytes: []byte("01234567890123450123456789012345"), |
| 482 | wantKey: ed25519KeyNoPrefixKey, |
| 483 | }, |
| 484 | { |
| 485 | name: "AESGCMHKDF", |
| 486 | params: aesGCMHKDFParams, |
| 487 | idRequirement: 0, |
| 488 | randomBytes: []byte("0123456789012345"), |
| 489 | wantKey: aesGCMHKDFKey, |
| 490 | }, |
| 491 | { |
| 492 | name: "AESGCMHKDF_longer_key_bytes", |
| 493 | params: aesGCMHKDFParams, |
| 494 | idRequirement: 0, |
| 495 | randomBytes: []byte("0123456789012345ABCDEFGHIJKLMNOPQRSTUVWXYZ"), |
| 496 | wantKey: aesGCMHKDFKey, |
| 497 | }, |
| 498 | } { |
| 499 | 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#) { |
| 500 | derivedKey, err := keyderiversscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers`/.DeriveKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers`/DeriveKey().(tc.params, tc.idRequirement, bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.24.0 bytes/NewBuffer().(tc.randomBytes), 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#{}) |
| 501 | if err != nil { |
| 502 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("keyderivation.DeriveKey() err = %v, want nil", err) |
| 503 | } |
| 504 | 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().(tc.wantKey, derivedKey); diff != "" { |
| 505 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("keyderivation.DeriveKey() returned diff (-want +got):\n%s", diff) |
| 506 | } |
| 507 | }) |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | func TestDeriveKey_Failuresscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers_test`/TestDeriveKey_Failures().(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#) { |
| 512 | aes128GCMParams, 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#{ |
| 513 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: 16, |
| 514 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 515 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 516 | 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., |
| 517 | }) |
| 518 | if err != nil { |
| 519 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewParameters() err = %v, want nil", err) |
| 520 | } |
| 521 | |
| 522 | aes128GCMNoPrefixParams, 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#{ |
| 523 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: 16, |
| 524 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 525 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 526 | 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., |
| 527 | }) |
| 528 | if err != nil { |
| 529 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcm.NewParameters() err = %v, want nil", err) |
| 530 | } |
| 531 | |
| 532 | xChaCha20Poly1305Params, err := xchacha20poly1305scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/NewParameters().(xchacha20poly1305scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/VariantTink.) |
| 533 | if err != nil { |
| 534 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("xchacha20poly1305.NewParameters() err = %v, want nil", err) |
| 535 | } |
| 536 | xChaCha20Poly1305NoPrefixParams, err := xchacha20poly1305scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/NewParameters().(xchacha20poly1305scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/VariantNoPrefix.) |
| 537 | if err != nil { |
| 538 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("xchacha20poly1305.NewParameters() err = %v, want nil", err) |
| 539 | } |
| 540 | |
| 541 | aes256SIVParams, err := aessivscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/NewParameters().(32, aessivscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/VariantTink.) |
| 542 | if err != nil { |
| 543 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aessiv.NewParameters() err = %v, want nil", err) |
| 544 | } |
| 545 | aes256SIVNoPrefixParams, err := aessivscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/NewParameters().(32, aessivscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/VariantNoPrefix.) |
| 546 | if err != nil { |
| 547 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aessiv.NewParameters() err = %v, want nil", err) |
| 548 | } |
| 549 | |
| 550 | hmacSHA256Tag128Params, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewParameters().(hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#{ |
| 551 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#KeySizeInBytes.: 32, |
| 552 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#TagSizeInBytes.: 16, |
| 553 | HashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#HashType.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/SHA256., |
| 554 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#Variant.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/VariantTink., |
| 555 | }) |
| 556 | if err != nil { |
| 557 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewParameters() err = %v, want nil", err) |
| 558 | } |
| 559 | hmacSHA256Tag128NoPrefixParams, err := hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/NewParameters().(hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#{ |
| 560 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#KeySizeInBytes.: 32, |
| 561 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#TagSizeInBytes.: 16, |
| 562 | HashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#HashType.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/SHA256., |
| 563 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#Variant.: hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/VariantNoPrefix., |
| 564 | }) |
| 565 | if err != nil { |
| 566 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewParameters() err = %v, want nil", err) |
| 567 | } |
| 568 | |
| 569 | hkdfPRFSHA256Params, err := hkdfprfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hkdfprf`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hkdfprf`/NewParameters().(32, hkdfprfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hkdfprf`/.SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hkdfprf`/SHA256., []byte("salt")) |
| 570 | if err != nil { |
| 571 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hkdfprf.NewParameters() err = %v, want nil", err) |
| 572 | } |
| 573 | hmacSHA256PRFParams, err := hmacprfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/NewParameters().(32, hmacprfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/.SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/SHA256.) |
| 574 | if err != nil { |
| 575 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmacprf.NewParameters() err = %v, want nil", err) |
| 576 | } |
| 577 | |
| 578 | ed25519Params, err := ed25519scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/NewParameters().(ed25519scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/.VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/VariantTink.) |
| 579 | if err != nil { |
| 580 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("ed25519.NewParameters() err = %v, want nil", err) |
| 581 | } |
| 582 | ed25519NoPrefixParams, err := ed25519scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/NewParameters().(ed25519scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/VariantNoPrefix.) |
| 583 | if err != nil { |
| 584 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("ed25519.NewParameters() err = %v, want nil", err) |
| 585 | } |
| 586 | |
| 587 | for _, tc := range []struct { |
| 588 | name string |
| 589 | params 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# |
| 590 | idRequirement uint32 |
| 591 | randomnessBytes []byte |
| 592 | }{ |
| 593 | { |
| 594 | name: "invalid parameters type", |
| 595 | params: &stubParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers_test`/stubParams#{}, |
| 596 | idRequirement: 123, |
| 597 | randomnessBytes: []byte("0123456789012345"), |
| 598 | }, |
| 599 | { |
| 600 | name: "AES128GCM insufficient random bytes", |
| 601 | params: aes128GCMParams, |
| 602 | idRequirement: 123, |
| 603 | randomnessBytes: []byte("012345678901234"), // 1 byte short |
| 604 | }, |
| 605 | { |
| 606 | name: "AES128GCM invalid ID requirement", |
| 607 | params: aes128GCMNoPrefixParams, |
| 608 | idRequirement: 123, |
| 609 | randomnessBytes: []byte("0123456789012345"), |
| 610 | }, |
| 611 | { |
| 612 | name: "XChaCha20Poly1305 insufficient random bytes", |
| 613 | params: xChaCha20Poly1305Params, |
| 614 | idRequirement: 123, |
| 615 | randomnessBytes: []byte("0123456789012345012345678901234"), // 1 byte short |
| 616 | }, |
| 617 | { |
| 618 | name: "XChaCha20Poly1305 invalid ID requirement", |
| 619 | params: xChaCha20Poly1305NoPrefixParams, |
| 620 | idRequirement: 123, |
| 621 | randomnessBytes: []byte("01234567890123450123456789012345"), |
| 622 | }, |
| 623 | { |
| 624 | name: "AES-SIV insufficient random bytes", |
| 625 | params: aes256SIVParams, |
| 626 | idRequirement: 123, |
| 627 | randomnessBytes: []byte("0123456789012345012345678901234"), // 1 byte short |
| 628 | }, |
| 629 | { |
| 630 | name: "AES-SIV invalid ID requirement", |
| 631 | params: aes256SIVNoPrefixParams, |
| 632 | idRequirement: 123, |
| 633 | randomnessBytes: []byte("01234567890123450123456789012345"), |
| 634 | }, |
| 635 | { |
| 636 | name: "HMAC insufficient random bytes", |
| 637 | params: hmacSHA256Tag128Params, |
| 638 | idRequirement: 123, |
| 639 | randomnessBytes: []byte("0123456789012345012345678901234"), // 1 byte short |
| 640 | }, |
| 641 | { |
| 642 | name: "HMAC invalid ID requirement", |
| 643 | params: hmacSHA256Tag128NoPrefixParams, |
| 644 | idRequirement: 123, |
| 645 | randomnessBytes: []byte("01234567890123450123456789012345"), |
| 646 | }, |
| 647 | { |
| 648 | name: "HKDF PRF insufficient random bytes", |
| 649 | params: hkdfPRFSHA256Params, |
| 650 | idRequirement: 123, |
| 651 | randomnessBytes: []byte("0123456789012345012345678901234"), // 1 byte short |
| 652 | }, |
| 653 | { |
| 654 | name: "HMAC PRF insufficient random bytes", |
| 655 | params: hmacSHA256PRFParams, |
| 656 | idRequirement: 123, |
| 657 | randomnessBytes: []byte("0123456789012345012345678901234"), // 1 byte short |
| 658 | }, |
| 659 | { |
| 660 | name: "ED25519 insufficient random bytes", |
| 661 | params: &ed25519Params, |
| 662 | idRequirement: 123, |
| 663 | randomnessBytes: []byte("0123456789012345012345678901234"), // 1 byte short |
| 664 | }, |
| 665 | { |
| 666 | name: "ED25519 invalid ID requirement", |
| 667 | params: &ed25519NoPrefixParams, |
| 668 | idRequirement: 123, |
| 669 | randomnessBytes: []byte("01234567890123450123456789012345"), |
| 670 | }, |
| 671 | } { |
| 672 | 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#) { |
| 673 | if _, err := keyderiversscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers`/.DeriveKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers`/DeriveKey().(tc.params, tc.idRequirement, bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.24.0 bytes/NewBuffer().(tc.randomnessBytes), 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#{}); err == nil { |
| 674 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("keyderivers.DeriveKey() err = nil, want error") |
| 675 | } |
| 676 | }) |
| 677 | } |
| 678 | } |
| 679 | |
| 680 | func TestCanDeriveKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers_test`/TestCanDeriveKey().(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#) { |
| 681 | for _, tc := range []struct { |
| 682 | name string |
| 683 | paramsType reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/.Typescip-go gomod github.com/golang/go/src go1.24.0 reflect/Type# |
| 684 | want bool |
| 685 | }{ |
| 686 | { |
| 687 | name: "AESGCM", |
| 688 | paramsType: reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/.TypeForscip-go gomod github.com/golang/go/src go1.24.0 reflect/TypeFor().[*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#](), |
| 689 | want: true, |
| 690 | }, |
| 691 | { |
| 692 | name: "XCHACHA20POLY1305", |
| 693 | paramsType: reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/.TypeForscip-go gomod github.com/golang/go/src go1.24.0 reflect/TypeFor().[*xchacha20poly1305scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/.Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/xchacha20poly1305`/Parameters#](), |
| 694 | want: true, |
| 695 | }, |
| 696 | { |
| 697 | name: "AESSIV", |
| 698 | paramsType: reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/.TypeForscip-go gomod github.com/golang/go/src go1.24.0 reflect/TypeFor().[*aessivscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/.Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/daead/aessiv`/Parameters#](), |
| 699 | want: true, |
| 700 | }, |
| 701 | { |
| 702 | name: "HMAC", |
| 703 | paramsType: reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/.TypeForscip-go gomod github.com/golang/go/src go1.24.0 reflect/TypeFor().[*hmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/.Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/Parameters#](), |
| 704 | want: true, |
| 705 | }, |
| 706 | { |
| 707 | name: "HKDF-PRF", |
| 708 | paramsType: reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/.TypeForscip-go gomod github.com/golang/go/src go1.24.0 reflect/TypeFor().[*hkdfprfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hkdfprf`/.Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hkdfprf`/Parameters#](), |
| 709 | want: true, |
| 710 | }, |
| 711 | { |
| 712 | name: "HMAC-PRF", |
| 713 | paramsType: reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/.TypeForscip-go gomod github.com/golang/go/src go1.24.0 reflect/TypeFor().[*hmacprfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/.Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/prf/hmacprf`/Parameters#](), |
| 714 | want: true, |
| 715 | }, |
| 716 | { |
| 717 | name: "ED25519", |
| 718 | paramsType: reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/.TypeForscip-go gomod github.com/golang/go/src go1.24.0 reflect/TypeFor().[*ed25519scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/.Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/signature/ed25519`/Parameters#](), |
| 719 | want: true, |
| 720 | }, |
| 721 | { |
| 722 | name: "AESGCMHKDF", |
| 723 | paramsType: reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/.TypeForscip-go gomod github.com/golang/go/src go1.24.0 reflect/TypeFor().[*aesgcmhkdfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/.Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Parameters#](), |
| 724 | want: true, |
| 725 | }, |
| 726 | { |
| 727 | name: "invalid parameters type", |
| 728 | paramsType: reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/.TypeForscip-go gomod github.com/golang/go/src go1.24.0 reflect/TypeFor().[*stubParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers_test`/stubParams#](), |
| 729 | want: false, |
| 730 | }, |
| 731 | } { |
| 732 | 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#) { |
| 733 | if got := keyderiversscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers`/.CanDeriveKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers`/CanDeriveKey().(tc.paramsType); got != tc.want { |
| 734 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("keyderivers.CanDeriveKey() = %v, want %v", got, tc.want) |
| 735 | } |
| 736 | }) |
| 737 | } |
| 738 | } |
| 739 | |
| 740 | type stubParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers_test`/stubParams# struct { |
| 741 | hasIDRequirementscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers_test`/stubParams#hasIDRequirement. bool |
| 742 | } |
| 743 | |
| 744 | var _ 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# = (*stubParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers_test`/stubParams#)(nil) |
| 745 | |
| 746 | func (p *stubParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers_test`/stubParams#) HasIDRequirementscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers_test`/stubParams#HasIDRequirement().() bool { return p.hasIDRequirementscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers_test`/stubParams#hasIDRequirement. } |
| 747 | |
| 748 | func (p *stubParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers_test`/stubParams#) Equalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers_test`/stubParams#Equal().(other 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#) bool { |
| 749 | _, ok := other.(*stubParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/keyderivation/internal/keyderivers_test`/stubParams#) |
| 750 | return ok |
| 751 | } |