| 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 macconfig_testscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/ |
| 16 | |
| 17 | import ( |
| 18 | "encoding/hexscip-go gomod github.com/golang/go/src go1.24.0 `encoding/hex`/" |
| 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 | "google.golang.org/protobuf/protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/" |
| 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/insecuresecretdataaccessscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/" |
| 25 | "github.com/tink-crypto/tink-go/v2/internal/config/macconfigscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig`/" |
| 26 | "github.com/tink-crypto/tink-go/v2/internal/internalapiscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalapi`/" |
| 27 | "github.com/tink-crypto/tink-go/v2/internal/protoserializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/" |
| 28 | "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`/" |
| 29 | "github.com/tink-crypto/tink-go/v2/mac/aescmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/aescmac`/" |
| 30 | "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`/" |
| 31 | "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`/" |
| 32 | "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`/" |
| 33 | 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`/" |
| 34 | ) |
| 35 | |
| 36 | func mustMarshalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/mustMarshal().(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#, m 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#) []byte { |
| 37 | t.Helperscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Helper().() |
| 38 | b, 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().(m) |
| 39 | if err != nil { |
| 40 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("proto.Marshal(%v) err=%v, want nil", m, err) |
| 41 | } |
| 42 | return b |
| 43 | } |
| 44 | |
| 45 | func mustHexDecodescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/mustHexDecode().(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#, s string) []byte { |
| 46 | t.Helperscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Helper().() |
| 47 | b, err := hexscip-go gomod github.com/golang/go/src go1.24.0 `encoding/hex`/.DecodeStringscip-go gomod github.com/golang/go/src go1.24.0 `encoding/hex`/DecodeString().(s) |
| 48 | if err != nil { |
| 49 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hex.DecodeString(%q) err=%v, want nil", s, err) |
| 50 | } |
| 51 | return b |
| 52 | } |
| 53 | |
| 54 | const ( |
| 55 | // https://github.com/C2SP/wycheproof/blob/cd27d6419bedd83cbd24611ec54b6d4bfdb0cdca/testvectors/hmac_sha256_test.json#L37. |
| 56 | hmacKeyHexscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/hmacKeyHex. = "85a7cbaae825bb82c9b6f6c5c2af5ac03d1f6daa63d2a93c189948ec41b9ded9" |
| 57 | hmacMsgHexscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/hmacMsgHex. = "a59b" |
| 58 | hmacTagHexscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/hmacTagHex. = "0fe2f13bba2198f6dda1a084be928e304e9cb16a56bc0b7b939a073280244373" |
| 59 | // https://github.com/C2SP/wycheproof/blob/cd27d6419bedd83cbd24611ec54b6d4bfdb0cdca/testvectors/aes_cmac_test.json#L1869 |
| 60 | aesCMACKeyHexscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/aesCMACKeyHex. = "ea3b016bdd387dd64d837c71683808f335dbdc53598a4ea8c5f952473fafaf5f" |
| 61 | aesCMACMsgHexscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/aesCMACMsgHex. = "6601" |
| 62 | aesCMACTagHexscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/aesCMACTagHex. = "c7c44e31c466334992d6f9de3c771634" |
| 63 | ) |
| 64 | |
| 65 | func TestConfigV0MACFailsIfKeyNotMACscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/TestConfigV0MACFailsIfKeyNotMAC().(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#) { |
| 66 | configV0 := macconfigscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig`/.V0scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig`/V0().() |
| 67 | aesGCMParams, 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#{ |
| 68 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#KeySizeInBytes.: 32, |
| 69 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#TagSizeInBytes.: 16, |
| 70 | 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., |
| 71 | IVSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/aesgcm`/ParametersOpts#IVSizeInBytes.: 12, |
| 72 | }) |
| 73 | if err != nil { |
| 74 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aescmac.NewParameters() err=%v, want nil", err) |
| 75 | } |
| 76 | aesGCMKey, 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().(mustHexDecodescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/mustHexDecode().(t, "ea3b016bdd387dd64d837c71683808f335dbdc53598a4ea8c5f952473fafaf5f"), 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, aesGCMParams) |
| 77 | if err != nil { |
| 78 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().(" aescmac.NewKey() err=%v, want nil", err) |
| 79 | } |
| 80 | if _, err := configV0.PrimitiveFromKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config`/Config#PrimitiveFromKey().(aesGCMKey, internalapiscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalapi`/.Tokenscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalapi`/Token#{}); err == nil { |
| 81 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("configV0.PrimitiveFromKey() err=nil, want error") |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | func TestConfigV0MACscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/TestConfigV0MAC().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 86 | configV0 := macconfigscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig`/.V0scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig`/V0().() |
| 87 | |
| 88 | // HMAC. |
| 89 | hmacParams, 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#{ |
| 90 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#KeySizeInBytes.: 32, |
| 91 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/hmac`/ParametersOpts#TagSizeInBytes.: 32, |
| 92 | 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., |
| 93 | 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., |
| 94 | }) |
| 95 | if err != nil { |
| 96 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("hmac.NewParameters() err=%v, want nil", err) |
| 97 | } |
| 98 | hmacKey, 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().(mustHexDecodescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/mustHexDecode().(t, hmacKeyHexscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/hmacKeyHex.), 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#{}), hmacParams, 0) |
| 99 | if err != nil { |
| 100 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().(" hmac.NewKey() err=%v, want nil", err) |
| 101 | } |
| 102 | hmacKeyPS, err := protoserializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/.SerializeKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/SerializeKey().(hmacKey) |
| 103 | if err != nil { |
| 104 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("protoserialization.SerializeKey() err=%v, want nil", err) |
| 105 | } |
| 106 | |
| 107 | // AES-CMAC. |
| 108 | aesCMACParams, err := aescmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/aescmac`/.NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/aescmac`/NewParameters().(aescmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/aescmac`/.ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/aescmac`/ParametersOpts#{ |
| 109 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/aescmac`/ParametersOpts#KeySizeInBytes.: 32, |
| 110 | TagSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/aescmac`/ParametersOpts#TagSizeInBytes.: 16, |
| 111 | Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/aescmac`/ParametersOpts#Variant.: aescmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/aescmac`/.VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/aescmac`/VariantNoPrefix., |
| 112 | }) |
| 113 | if err != nil { |
| 114 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aescmac.NewParameters() err=%v, want nil", err) |
| 115 | } |
| 116 | aesCMACKey, err := aescmacscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/aescmac`/.NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/mac/aescmac`/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().(mustHexDecodescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/mustHexDecode().(t, "ea3b016bdd387dd64d837c71683808f335dbdc53598a4ea8c5f952473fafaf5f"), 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#{}), aesCMACParams, 0) |
| 117 | if err != nil { |
| 118 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().(" aescmac.NewKey() err=%v, want nil", err) |
| 119 | } |
| 120 | aesCMACKeyPS, err := protoserializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/.SerializeKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/SerializeKey().(aesCMACKey) |
| 121 | if err != nil { |
| 122 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("protoserialization.SerializeKey() err=%v, want nil", err) |
| 123 | } |
| 124 | |
| 125 | for _, test := range []struct { |
| 126 | name string |
| 127 | key 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# |
| 128 | keyData *tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData# |
| 129 | msg []byte |
| 130 | tag []byte |
| 131 | }{ |
| 132 | { |
| 133 | name: "HMAC", |
| 134 | key: hmacKey, |
| 135 | keyData: hmacKeyPS.KeyDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/KeySerialization#KeyData().(), |
| 136 | msg: mustHexDecodescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/mustHexDecode().(t, hmacMsgHexscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/hmacMsgHex.), |
| 137 | tag: mustHexDecodescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/mustHexDecode().(t, hmacTagHexscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/hmacTagHex.), |
| 138 | }, |
| 139 | { |
| 140 | name: "AES-CMAC", |
| 141 | key: aesCMACKey, |
| 142 | keyData: aesCMACKeyPS.KeyDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/KeySerialization#KeyData().(), |
| 143 | msg: mustHexDecodescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/mustHexDecode().(t, aesCMACMsgHexscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/aesCMACMsgHex.), |
| 144 | tag: mustHexDecodescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/mustHexDecode().(t, aesCMACTagHexscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config/macconfig_test`/aesCMACTagHex.), |
| 145 | }, |
| 146 | } { |
| 147 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(test.name, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 148 | mac, err := configV0.PrimitiveFromKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/config`/Config#PrimitiveFromKey().(test.key, internalapiscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalapi`/.Tokenscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/internalapi`/Token#{}) |
| 149 | if err != nil { |
| 150 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("configV0.PrimitiveFromKey() err=%v, want nil", err) |
| 151 | } |
| 152 | m, ok := mac.(tinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/tink`/.MACscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/tink`/MAC#) |
| 153 | if !ok { |
| 154 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("mac was of type %v, want tink.MAC", reflectscip-go gomod github.com/golang/go/src go1.24.0 reflect/.TypeOfscip-go gomod github.com/golang/go/src go1.24.0 reflect/TypeOf().(mac)) |
| 155 | } |
| 156 | if err := m.VerifyMACscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/tink`/MAC#VerifyMAC.(test.tag, test.msg); err != nil { |
| 157 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("mac.VerifyMAC() err=%v, want nil", err) |
| 158 | } |
| 159 | }) |
| 160 | } |
| 161 | } |