| 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 aesgcmhkdf_testscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/ |
| 16 | |
| 17 | import ( |
| 18 | "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/" |
| 19 | "testingscip-go gomod github.com/golang/go/src go1.24.0 testing/" |
| 20 | |
| 21 | "github.com/google/go-cmp/cmpscip-go gomod github.com/google/go-cmp v0.7.0 `github.com/google/go-cmp/cmp`/" |
| 22 | |
| 23 | "google.golang.org/protobuf/protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/" |
| 24 | "google.golang.org/protobuf/testing/protocmpscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/testing/protocmp`/" |
| 25 | "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`/" |
| 26 | "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`/" |
| 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/secretdatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/" |
| 29 | "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`/" |
| 30 | streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/ "github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_protoscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/" |
| 31 | commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/ "github.com/tink-crypto/tink-go/v2/proto/common_go_protoscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/" |
| 32 | 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`/" |
| 33 | ) |
| 34 | |
| 35 | func mustMarshalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_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#, p 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 { |
| 36 | t.Helperscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Helper().() |
| 37 | data, 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().(p) |
| 38 | if err != nil { |
| 39 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("proto.Marshal() err = %v, want nil", err) |
| 40 | } |
| 41 | return data |
| 42 | } |
| 43 | |
| 44 | type keyParsingTestCasescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/keyParsingTestCase# struct { |
| 45 | namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/keyParsingTestCase#name. string |
| 46 | keySerializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/keyParsingTestCase#keySerialization. *protoserializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/.KeySerializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/KeySerialization# |
| 47 | keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/keyParsingTestCase#key. *aesgcmhkdfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/.Keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Key# |
| 48 | } |
| 49 | |
| 50 | func testCasesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/testCases().(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#) []*keyParsingTestCasescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/keyParsingTestCase# { |
| 51 | t.Helperscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Helper().() |
| 52 | |
| 53 | keyBytes := []byte("01234567890123456789012345678901") |
| 54 | |
| 55 | var testCases []*keyParsingTestCasescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/keyParsingTestCase# |
| 56 | keySizes := []int{16, 32} |
| 57 | segmentSizes := []int32{4096, 8192} |
| 58 | |
| 59 | for _, keySize := range keySizes { |
| 60 | for _, hashType := range []struct { |
| 61 | hashType aesgcmhkdfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/.HashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/HashType# |
| 62 | protoHashType commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType# |
| 63 | }{ |
| 64 | {aesgcmhkdfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/.SHA1scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/SHA1., commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_SHA1scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_SHA1.}, |
| 65 | {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., commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_SHA256.}, |
| 66 | {aesgcmhkdfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/.SHA512scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/SHA512., commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_SHA512scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_SHA512.}, |
| 67 | } { |
| 68 | for _, segmentSize := range segmentSizes { |
| 69 | params, 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#{ |
| 70 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#KeySizeInBytes.: keySize, |
| 71 | DerivedKeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#DerivedKeySizeInBytes.: keySize, |
| 72 | HKDFHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#HKDFHashType.: hashType.hashType, |
| 73 | SegmentSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#SegmentSizeInBytes.: segmentSize, |
| 74 | }) |
| 75 | if err != nil { |
| 76 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcmhkdf.NewParameters() err = %v, want nil", err) |
| 77 | } |
| 78 | keySecretDataBytes := 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().(keyBytes[:keySize], 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#{}) |
| 79 | k, 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().(params, keySecretDataBytes) |
| 80 | if err != nil { |
| 81 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcmhkdf.NewKey() err = %v, want nil", err) |
| 82 | } |
| 83 | |
| 84 | serializedKey := mustMarshalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/mustMarshal().(t, &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#{ |
| 85 | Versionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#Version.: 0, |
| 86 | KeyValuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#KeyValue.: keySecretDataBytes.Datascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/Bytes#Data().(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#{}), |
| 87 | Paramsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#Params.: &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#{ |
| 88 | HkdfHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#HkdfHashType.: hashType.protoHashType, |
| 89 | DerivedKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#DerivedKeySize.: uint32(keySize), |
| 90 | CiphertextSegmentSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#CiphertextSegmentSize.: uint32(segmentSize), |
| 91 | }, |
| 92 | }) |
| 93 | 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#{ |
| 94 | TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#TypeUrl.: "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey", |
| 95 | Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#Value.: serializedKey, |
| 96 | KeyMaterialTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#KeyMaterialType.: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyData_SYMMETRICscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData_SYMMETRIC., |
| 97 | } |
| 98 | ks, err := protoserializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/.NewKeySerializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/NewKeySerialization().(keyData, tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_RAWscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_RAW., 0) |
| 99 | if err != nil { |
| 100 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("protoserialization.NewKeySerialization() err = %v, want nil", err) |
| 101 | } |
| 102 | testCases = append(testCases, &keyParsingTestCasescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/keyParsingTestCase#{ |
| 103 | namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/keyParsingTestCase#name.: fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("keySize:%d,derivedKeySize:%d,hkdfHashType:%s,segmentSize:%d", keySize, keySize, hashType.hashType, segmentSize), |
| 104 | keySerializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/keyParsingTestCase#keySerialization.: ks, |
| 105 | keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/keyParsingTestCase#key.: k, |
| 106 | }) |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | return testCases |
| 111 | } |
| 112 | |
| 113 | func TestParseKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/TestParseKey().(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#) { |
| 114 | for _, tc := range testCasesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/testCases().(t) { |
| 115 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(tc.namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/keyParsingTestCase#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#) { |
| 116 | gotKey, err := protoserializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/.ParseKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/ParseKey().(tc.keySerializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/keyParsingTestCase#keySerialization.) |
| 117 | if err != nil { |
| 118 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("protoserialization.ParseKey() err = %v, want nil", err) |
| 119 | } |
| 120 | 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.keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/keyParsingTestCase#key., gotKey); diff != "" { |
| 121 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("parsed key is not equal to original key. diff (-want +got):\n%s", diff) |
| 122 | } |
| 123 | }) |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | func mustCreateProtoSerializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/mustCreateProtoSerialization().(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#, 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#, outputPrefixType tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType#, idRequirement uint32) *protoserializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/.KeySerializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/KeySerialization# { |
| 128 | t.Helperscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Helper().() |
| 129 | ks, err := protoserializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/.NewKeySerializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/NewKeySerialization().(keyData, outputPrefixType, idRequirement) |
| 130 | if err != nil { |
| 131 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("protoserialization.NewKeySerialization() err = %v, want nil", err) |
| 132 | } |
| 133 | return ks |
| 134 | } |
| 135 | |
| 136 | func TestParseKey_Failsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/TestParseKey_Fails().(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#) { |
| 137 | for _, tc := range []struct { |
| 138 | name string |
| 139 | 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# |
| 140 | outputPrefixType tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType# |
| 141 | keyID uint32 |
| 142 | }{ |
| 143 | { |
| 144 | name: "invalid key data value", |
| 145 | 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#{ |
| 146 | TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#TypeUrl.: "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey", |
| 147 | Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#Value.: []byte("invalid proto"), |
| 148 | KeyMaterialTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#KeyMaterialType.: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyData_SYMMETRICscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData_SYMMETRIC., |
| 149 | }, |
| 150 | outputPrefixType: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_RAWscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_RAW., |
| 151 | keyID: 0, |
| 152 | }, |
| 153 | { |
| 154 | name: "wrong key material type", |
| 155 | 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#{ |
| 156 | TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#TypeUrl.: "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey", |
| 157 | Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#Value.: mustMarshalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/mustMarshal().(t, &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#{ |
| 158 | Versionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#Version.: 0, |
| 159 | KeyValuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#KeyValue.: []byte("0123456789012345"), |
| 160 | Paramsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#Params.: &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#{ |
| 161 | HkdfHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#HkdfHashType.: commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_SHA256., |
| 162 | DerivedKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#DerivedKeySize.: 16, |
| 163 | CiphertextSegmentSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#CiphertextSegmentSize.: 4096, |
| 164 | }, |
| 165 | }), |
| 166 | KeyMaterialTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#KeyMaterialType.: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyData_ASYMMETRIC_PUBLICscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData_ASYMMETRIC_PUBLIC., |
| 167 | }, |
| 168 | outputPrefixType: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_RAWscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_RAW., |
| 169 | keyID: 0, |
| 170 | }, |
| 171 | { |
| 172 | name: "invalid version", |
| 173 | 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#{ |
| 174 | TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#TypeUrl.: "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey", |
| 175 | Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#Value.: mustMarshalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/mustMarshal().(t, &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#{ |
| 176 | Versionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#Version.: 1, |
| 177 | KeyValuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#KeyValue.: []byte("0123456789012345"), |
| 178 | Paramsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#Params.: &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#{ |
| 179 | HkdfHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#HkdfHashType.: commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_SHA256., |
| 180 | DerivedKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#DerivedKeySize.: 16, |
| 181 | CiphertextSegmentSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#CiphertextSegmentSize.: 4096, |
| 182 | }, |
| 183 | }), |
| 184 | KeyMaterialTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#KeyMaterialType.: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyData_SYMMETRICscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData_SYMMETRIC., |
| 185 | }, |
| 186 | outputPrefixType: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_RAWscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_RAW., |
| 187 | keyID: 0, |
| 188 | }, |
| 189 | { |
| 190 | name: "invalid_key_value", |
| 191 | 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#{ |
| 192 | TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#TypeUrl.: "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey", |
| 193 | Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#Value.: mustMarshalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/mustMarshal().(t, &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#{ |
| 194 | Versionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#Version.: 0, |
| 195 | KeyValuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#KeyValue.: []byte("01234567890123"), // Key size should be >= DerivedKeySize. |
| 196 | Paramsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#Params.: &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#{ |
| 197 | HkdfHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#HkdfHashType.: commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_SHA256., |
| 198 | DerivedKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#DerivedKeySize.: 16, |
| 199 | CiphertextSegmentSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#CiphertextSegmentSize.: 4096, |
| 200 | }, |
| 201 | }), |
| 202 | KeyMaterialTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#KeyMaterialType.: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyData_SYMMETRICscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData_SYMMETRIC., |
| 203 | }, |
| 204 | outputPrefixType: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_RAWscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_RAW., |
| 205 | keyID: 0, |
| 206 | }, |
| 207 | { |
| 208 | name: "invalid_derived_key_size", |
| 209 | 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#{ |
| 210 | TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#TypeUrl.: "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey", |
| 211 | Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#Value.: mustMarshalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/mustMarshal().(t, &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#{ |
| 212 | Versionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#Version.: 0, |
| 213 | KeyValuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#KeyValue.: []byte("0123456789012345"), |
| 214 | Paramsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#Params.: &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#{ |
| 215 | HkdfHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#HkdfHashType.: commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_SHA256., |
| 216 | DerivedKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#DerivedKeySize.: 12, // Derived key size should be 16 or 32 |
| 217 | CiphertextSegmentSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#CiphertextSegmentSize.: 4096, |
| 218 | }, |
| 219 | }), |
| 220 | KeyMaterialTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#KeyMaterialType.: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyData_SYMMETRICscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData_SYMMETRIC., |
| 221 | }, |
| 222 | outputPrefixType: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_RAWscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_RAW., |
| 223 | keyID: 0, |
| 224 | }, |
| 225 | { |
| 226 | name: "invalid_segment_size", |
| 227 | 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#{ |
| 228 | TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#TypeUrl.: "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey", |
| 229 | Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#Value.: mustMarshalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/mustMarshal().(t, &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#{ |
| 230 | Versionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#Version.: 0, |
| 231 | KeyValuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#KeyValue.: []byte("0123456789012345"), |
| 232 | Paramsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#Params.: &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#{ |
| 233 | HkdfHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#HkdfHashType.: commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_SHA256., |
| 234 | DerivedKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#DerivedKeySize.: 16, |
| 235 | CiphertextSegmentSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#CiphertextSegmentSize.: 10, |
| 236 | }, |
| 237 | }), |
| 238 | KeyMaterialTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#KeyMaterialType.: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyData_SYMMETRICscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData_SYMMETRIC., |
| 239 | }, |
| 240 | outputPrefixType: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_RAWscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_RAW., |
| 241 | keyID: 0, |
| 242 | }, |
| 243 | { |
| 244 | name: "invalid_hkdf_hash_type", |
| 245 | 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#{ |
| 246 | TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#TypeUrl.: "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey", |
| 247 | Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#Value.: mustMarshalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/mustMarshal().(t, &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#{ |
| 248 | Versionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#Version.: 0, |
| 249 | KeyValuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#KeyValue.: []byte("0123456789012345"), |
| 250 | Paramsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#Params.: &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#{ |
| 251 | HkdfHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#HkdfHashType.: commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_UNKNOWN_HASHscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_UNKNOWN_HASH., |
| 252 | DerivedKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#DerivedKeySize.: 16, |
| 253 | CiphertextSegmentSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#CiphertextSegmentSize.: 4096, |
| 254 | }, |
| 255 | }), |
| 256 | KeyMaterialTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#KeyMaterialType.: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyData_SYMMETRICscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData_SYMMETRIC., |
| 257 | }, |
| 258 | outputPrefixType: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_RAWscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_RAW., |
| 259 | keyID: 0, |
| 260 | }, |
| 261 | } { |
| 262 | 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#) { |
| 263 | keySerialization, err := protoserializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/.NewKeySerializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/NewKeySerialization().(tc.keyData, tc.outputPrefixType, tc.keyID) |
| 264 | if err != nil { |
| 265 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("protoserialization.NewKeySerialization(%v, %v, %v) err = %v, want nil", tc.keyData, tc.outputPrefixType, tc.keyID, err) |
| 266 | } |
| 267 | if _, err := protoserializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/.ParseKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/ParseKey().(keySerialization); err == nil { |
| 268 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("protoserialization.ParseKey(%v) err = nil, want non-nil", keySerialization) |
| 269 | } |
| 270 | }) |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | func TestSerializeKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/TestSerializeKey().(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#) { |
| 275 | for _, tc := range testCasesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/testCases().(t) { |
| 276 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(tc.namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/keyParsingTestCase#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#) { |
| 277 | gotSerialization, 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().(tc.keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/keyParsingTestCase#key.) |
| 278 | if err != nil { |
| 279 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("protoserialization.SerializeKey() err = %v, want nil", err) |
| 280 | } |
| 281 | 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.keySerializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/keyParsingTestCase#keySerialization., gotSerialization, protocmpscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/testing/protocmp`/.Transformscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/testing/protocmp`/Transform().()); diff != "" { |
| 282 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("serialized key is not equal to original. diff: %s", diff) |
| 283 | } |
| 284 | }) |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | func TestSerializeKey_Failsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/TestSerializeKey_Fails().(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#) { |
| 289 | for _, tc := range []struct { |
| 290 | name string |
| 291 | 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# |
| 292 | }{ |
| 293 | { |
| 294 | name: "nil key", |
| 295 | key: nil, |
| 296 | }, |
| 297 | { |
| 298 | name: "empty key", |
| 299 | key: &aesgcmhkdfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/.Keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Key#{}, |
| 300 | }, |
| 301 | { |
| 302 | name: "key with wrong key type", |
| 303 | key: &stubKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/stubKey#{}, |
| 304 | }, |
| 305 | } { |
| 306 | 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#) { |
| 307 | if _, 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().(tc.key); err == nil { |
| 308 | t.Errorscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Error().("SerializeKey() err = nil, want non-nil") |
| 309 | } |
| 310 | }) |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | type parametersTestCasescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parametersTestCase# struct { |
| 315 | namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parametersTestCase#name. string |
| 316 | parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parametersTestCase#parameters. *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# |
| 317 | keyTemplatescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parametersTestCase#keyTemplate. *tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyTemplatescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate# |
| 318 | } |
| 319 | |
| 320 | func parameterTestCasesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parameterTestCases().(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#) []*parametersTestCasescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parametersTestCase# { |
| 321 | t.Helperscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Helper().() |
| 322 | var testCases []*parametersTestCasescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parametersTestCase# |
| 323 | keySizes := []int{16, 32} |
| 324 | segmentSizes := []int32{4096, 8192} |
| 325 | |
| 326 | for _, keySize := range keySizes { |
| 327 | for _, hashType := range []struct { |
| 328 | hashType aesgcmhkdfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/.HashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/HashType# |
| 329 | protoHashType commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType# |
| 330 | }{ |
| 331 | {aesgcmhkdfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/.SHA1scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/SHA1., commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_SHA1scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_SHA1.}, |
| 332 | {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., commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_SHA256.}, |
| 333 | {aesgcmhkdfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/.SHA512scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/SHA512., commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_SHA512scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_SHA512.}, |
| 334 | } { |
| 335 | for _, segmentSize := range segmentSizes { |
| 336 | params, 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#{ |
| 337 | KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#KeySizeInBytes.: keySize, |
| 338 | DerivedKeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#DerivedKeySizeInBytes.: keySize, |
| 339 | HKDFHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#HKDFHashType.: hashType.hashType, |
| 340 | SegmentSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#SegmentSizeInBytes.: segmentSize, |
| 341 | }) |
| 342 | if err != nil { |
| 343 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("aesgcmhkdf.NewParameters() err = %v, want nil", err) |
| 344 | } |
| 345 | keyTemplate := &tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyTemplatescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#{ |
| 346 | TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#TypeUrl.: "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey", |
| 347 | Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#Value.: mustMarshalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/mustMarshal().(t, &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingKeyFormatscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#{ |
| 348 | Versionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#Version.: 0, |
| 349 | Paramsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#Params.: &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#{ |
| 350 | HkdfHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#HkdfHashType.: hashType.protoHashType, |
| 351 | DerivedKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#DerivedKeySize.: uint32(keySize), |
| 352 | CiphertextSegmentSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#CiphertextSegmentSize.: uint32(segmentSize), |
| 353 | }, |
| 354 | KeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#KeySize.: uint32(keySize), |
| 355 | }), |
| 356 | OutputPrefixTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#OutputPrefixType.: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_RAWscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_RAW., |
| 357 | } |
| 358 | |
| 359 | testCases = append(testCases, ¶metersTestCasescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parametersTestCase#{ |
| 360 | namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parametersTestCase#name.: fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("keySize:%d,derivedKeySize:%d,hkdfHashType:%s,segmentSize:%d", keySize, keySize, hashType.hashType, segmentSize), |
| 361 | parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parametersTestCase#parameters.: params, |
| 362 | keyTemplatescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parametersTestCase#keyTemplate.: keyTemplate, |
| 363 | }) |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | return testCases |
| 368 | } |
| 369 | |
| 370 | func TestParseParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/TestParseParameters().(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#) { |
| 371 | for _, tc := range parameterTestCasesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parameterTestCases().(t) { |
| 372 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(tc.namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parametersTestCase#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#) { |
| 373 | gotParams, err := protoserializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/.ParseParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/ParseParameters().(tc.keyTemplatescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parametersTestCase#keyTemplate.) |
| 374 | if err != nil { |
| 375 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("protoserialization.ParseParameters() err = %v, want nil", err) |
| 376 | } |
| 377 | 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.parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parametersTestCase#parameters., gotParams); diff != "" { |
| 378 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("parsed parameters are not equal to original parameters. diff (-want +got):\n%s", diff) |
| 379 | } |
| 380 | }) |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | func TestParseParameters_Failsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/TestParseParameters_Fails().(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#) { |
| 385 | for _, tc := range []struct { |
| 386 | name string |
| 387 | keyTemplate *tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyTemplatescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate# |
| 388 | keyFormat 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# |
| 389 | }{ |
| 390 | { |
| 391 | name: "invalid_derived_key_size", |
| 392 | keyTemplate: &tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyTemplatescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#{ |
| 393 | TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#TypeUrl.: "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey", |
| 394 | Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#Value.: mustMarshalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/mustMarshal().(t, &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingKeyFormatscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#{ |
| 395 | Paramsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#Params.: &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#{ |
| 396 | HkdfHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#HkdfHashType.: commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_SHA256., |
| 397 | DerivedKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#DerivedKeySize.: 12, // Derived key size should be 16 or 32 |
| 398 | CiphertextSegmentSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#CiphertextSegmentSize.: 4096, |
| 399 | }, |
| 400 | KeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#KeySize.: 16, |
| 401 | }), |
| 402 | OutputPrefixTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#OutputPrefixType.: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_RAWscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_RAW., |
| 403 | }, |
| 404 | }, |
| 405 | { |
| 406 | name: "invalid_key_size", |
| 407 | keyTemplate: &tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyTemplatescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#{ |
| 408 | TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#TypeUrl.: "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey", |
| 409 | Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#Value.: mustMarshalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/mustMarshal().(t, &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingKeyFormatscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#{ |
| 410 | Paramsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#Params.: &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#{ |
| 411 | HkdfHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#HkdfHashType.: commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_SHA256., |
| 412 | DerivedKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#DerivedKeySize.: 16, |
| 413 | CiphertextSegmentSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#CiphertextSegmentSize.: 4096, |
| 414 | }, |
| 415 | KeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#KeySize.: 12, // Key size should be >= DerivedKeySize. |
| 416 | }), |
| 417 | OutputPrefixTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#OutputPrefixType.: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_RAWscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_RAW., |
| 418 | }, |
| 419 | }, |
| 420 | { |
| 421 | name: "invalid_segment_size", |
| 422 | keyTemplate: &tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyTemplatescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#{ |
| 423 | TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#TypeUrl.: "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey", |
| 424 | Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#Value.: mustMarshalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/mustMarshal().(t, &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingKeyFormatscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#{ |
| 425 | Paramsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#Params.: &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#{ |
| 426 | HkdfHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#HkdfHashType.: commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_SHA256., |
| 427 | DerivedKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#DerivedKeySize.: 16, |
| 428 | CiphertextSegmentSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#CiphertextSegmentSize.: 10, |
| 429 | }, |
| 430 | KeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#KeySize.: 16, |
| 431 | }), |
| 432 | OutputPrefixTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#OutputPrefixType.: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_RAWscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_RAW., |
| 433 | }, |
| 434 | }, |
| 435 | { |
| 436 | name: "invalid_hkdf_hash_type", |
| 437 | keyTemplate: &tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyTemplatescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#{ |
| 438 | TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#TypeUrl.: "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey", |
| 439 | Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#Value.: mustMarshalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/mustMarshal().(t, &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingKeyFormatscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#{ |
| 440 | Paramsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#Params.: &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#{ |
| 441 | HkdfHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#HkdfHashType.: commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_UNKNOWN_HASHscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_UNKNOWN_HASH., |
| 442 | DerivedKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#DerivedKeySize.: 16, |
| 443 | CiphertextSegmentSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#CiphertextSegmentSize.: 4096, |
| 444 | }, |
| 445 | KeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#KeySize.: 16, |
| 446 | }), |
| 447 | OutputPrefixTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#OutputPrefixType.: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_RAWscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_RAW., |
| 448 | }, |
| 449 | }, |
| 450 | { |
| 451 | name: "invalid_version", |
| 452 | keyTemplate: &tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyTemplatescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#{ |
| 453 | TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#TypeUrl.: "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey", |
| 454 | Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#Value.: mustMarshalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/mustMarshal().(t, &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingKeyFormatscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#{ |
| 455 | Versionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#Version.: 1, |
| 456 | Paramsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#Params.: &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#{ |
| 457 | HkdfHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#HkdfHashType.: commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_SHA256., |
| 458 | DerivedKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#DerivedKeySize.: 16, |
| 459 | CiphertextSegmentSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#CiphertextSegmentSize.: 4096, |
| 460 | }, |
| 461 | KeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#KeySize.: 16, |
| 462 | }), |
| 463 | OutputPrefixTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#OutputPrefixType.: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_RAWscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_RAW., |
| 464 | }, |
| 465 | }, |
| 466 | { |
| 467 | name: "invalid_output_prefix_type", |
| 468 | keyTemplate: &tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.KeyTemplatescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#{ |
| 469 | TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#TypeUrl.: "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey", |
| 470 | Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#Value.: mustMarshalscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/mustMarshal().(t, &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingKeyFormatscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#{ |
| 471 | Paramsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#Params.: &streamaeadpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/.AesGcmHkdfStreamingParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#{ |
| 472 | HkdfHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#HkdfHashType.: commonpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/.HashType_SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/common_go_proto`/HashType_SHA256., |
| 473 | DerivedKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#DerivedKeySize.: 16, |
| 474 | CiphertextSegmentSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#CiphertextSegmentSize.: 4096, |
| 475 | }, |
| 476 | KeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#KeySize.: 16, |
| 477 | }), |
| 478 | OutputPrefixTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#OutputPrefixType.: tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_TINKscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_TINK., // Output prefix type should be RAW. |
| 479 | }, |
| 480 | }, |
| 481 | } { |
| 482 | 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#) { |
| 483 | if _, err := protoserializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/.ParseParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/ParseParameters().(tc.keyTemplate); err == nil { |
| 484 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("protoserialization.ParseParameters(%v) err = nil, want non-nil", tc.keyTemplate) |
| 485 | } |
| 486 | }) |
| 487 | } |
| 488 | } |
| 489 | |
| 490 | func TestSerializeParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/TestSerializeParameters().(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#) { |
| 491 | for _, tc := range parameterTestCasesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parameterTestCases().(t) { |
| 492 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(tc.namescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parametersTestCase#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#) { |
| 493 | got, err := protoserializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/.SerializeParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/SerializeParameters().(tc.parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parametersTestCase#parameters.) |
| 494 | if err != nil { |
| 495 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("protoserialization.SerializeParameters() err = %v, want nil", err) |
| 496 | } |
| 497 | 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.keyTemplatescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf_test`/parametersTestCase#keyTemplate., got, protocmpscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/testing/protocmp`/.Transformscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/testing/protocmp`/Transform().()); diff != "" { |
| 498 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("serialized parameters are not equal to original. diff: %s", diff) |
| 499 | } |
| 500 | }) |
| 501 | } |
| 502 | } |