Debian Codegraph @

streamingaead/aesgcmhkdf/protoserialization.go

raw symbols SCIP
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 aesgcmhkdfscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/
16
17 import (
18 "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/"
19
20 "google.golang.org/protobuf/protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/"
21 "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`/"
22 "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`/"
23 "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`/"
24 "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`/"
25 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`/"
26 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`/"
27 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`/"
28 )
29
30 const typeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/typeURL. = "type.googleapis.com/google.crypto.tink.AesGcmHkdfStreamingKey"
31
32 type keySerializerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/keySerializer# struct{}
33
34 var _ protoserializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/.KeySerializerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/KeySerializer# = (*keySerializerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/keySerializer#)(nil)
35
36 func hashTypeToProtoscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/hashTypeToProto().(ht HashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/HashType#) (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#, error) {
37 switch ht {
38 case SHA1scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/SHA1.:
39 return 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., nil
40 case SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/SHA256.:
41 return 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., nil
42 case SHA512scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/SHA512.:
43 return 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., nil
44 default:
45 return 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., fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("unknown hash type: %v", ht)
46 }
47 }
48
49 func (s *keySerializerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/keySerializer#) SerializeKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/keySerializer#SerializeKey().(k 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#) (*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#, error) {
50 actualKey, ok := k.(*Keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Key#)
51 if !ok {
52 return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("invalid key type: got %T, want %T", k, (*Keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Key#)(nil))
53 }
54 // Case where the key is empty.
55 if actualKey.KeyBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Key#KeyBytes().().Lenscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/Bytes#Len().() == 0 {
56 return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("invalid key")
57 }
58 actualParameters, ok := actualKey.Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Key#Parameters().().(*Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Parameters#)
59 if !ok {
60 return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("key parameters is not a aesgcmhkdf.Parameters")
61 }
62 hkdfHashType, err := hashTypeToProtoscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/hashTypeToProto().(actualParameters.HKDFHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Parameters#HKDFHashType().())
63 if err != nil {
64 return nil, err
65 }
66 protoKey := &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#{
67 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,
68 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.: actualKey.KeyBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Key#KeyBytes().().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#{}),
69 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#{
70 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.: hkdfHashType,
71 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(actualParameters.DerivedKeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Parameters#DerivedKeySizeInBytes().()),
72 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(actualParameters.SegmentSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Parameters#SegmentSizeInBytes().()),
73 },
74 }
75 serializedKey, err := protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/.Marshalscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/Marshal().(protoKey)
76 if err != nil {
77 return nil, err
78 }
79 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#{
80 TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#TypeUrl.: typeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/typeURL.,
81 Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#Value.: serializedKey,
82 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.,
83 }
84 return 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)
85 }
86
87 type keyParserscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/keyParser# struct{}
88
89 var _ protoserializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/.KeyParserscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/KeyParser# = (*keyParserscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/keyParser#)(nil)
90
91 func hashTypeFromProtoscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/hashTypeFromProto().(ht 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#) (HashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/HashType#, error) {
92 switch ht {
93 case 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.:
94 return SHA1scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/SHA1., nil
95 case 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.:
96 return SHA256scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/SHA256., nil
97 case 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.:
98 return SHA512scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/SHA512., nil
99 default:
100 return HashTypeUnknownscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/HashTypeUnknown., fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("unknown hash type: %v", ht)
101 }
102 }
103
104 func (s *keyParserscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/keyParser#) ParseKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/keyParser#ParseKey().(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#) (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#, error) {
105 if keySerialization == nil {
106 return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("key serialization is nil")
107 }
108 keyData := keySerialization.KeyDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/KeySerialization#KeyData().()
109 if keyData.GetTypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#GetTypeUrl().() != typeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/typeURL. {
110 return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("invalid type URL: got %q, want %q", keyData.GetTypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#GetTypeUrl().(), typeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/typeURL.)
111 }
112 if keyData.GetKeyMaterialTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#GetKeyMaterialType().() != 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. {
113 return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("key is not a SYMMETRIC key")
114 }
115 protoKey := new(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#)
116 if err := protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/.Unmarshalscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/Unmarshal().(keyData.GetValuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#GetValue().(), protoKey); err != nil {
117 return nil, err
118 }
119 if protoKey.GetVersionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#GetVersion().() != 0 {
120 return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("unsupported key version: got %q, want %q", protoKey.GetVersionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#GetVersion().(), 0)
121 }
122 paramsProto := protoKey.GetParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#GetParams().()
123 hkdfHashType, err := hashTypeFromProtoscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/hashTypeFromProto().(paramsProto.GetHkdfHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#GetHkdfHashType().())
124 if err != nil {
125 return nil, err
126 }
127 params, err := NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/NewParameters().(ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#{
128 KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#KeySizeInBytes.: len(protoKey.GetKeyValuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#GetKeyValue().()),
129 DerivedKeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#DerivedKeySizeInBytes.: int(paramsProto.GetDerivedKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#GetDerivedKeySize().()),
130 HKDFHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#HKDFHashType.: hkdfHashType,
131 SegmentSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#SegmentSizeInBytes.: int32(paramsProto.GetCiphertextSegmentSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#GetCiphertextSegmentSize().()),
132 })
133 if err != nil {
134 return nil, err
135 }
136 keyBytes := secretdatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/.NewBytesFromDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/secretdata`/NewBytesFromData().(protoKey.GetKeyValuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKey#GetKeyValue().(), insecuresecretdataaccessscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/.Tokenscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/insecuresecretdataaccess`/Token#{})
137 return NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/NewKey().(params, keyBytes)
138 }
139
140 type parametersSerializerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/parametersSerializer# struct{}
141
142 var _ protoserializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/.ParametersSerializerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/ParametersSerializer# = (*parametersSerializerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/parametersSerializer#)(nil)
143
144 func (s *parametersSerializerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/parametersSerializer#) Serializescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/parametersSerializer#Serialize().(params keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/key`/.Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/key`/Parameters#) (*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#, error) {
145 actualParams, ok := params.(*Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Parameters#)
146 if !ok {
147 return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("parameters is not a %T", (*Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Parameters#)(nil))
148 }
149 hkdfHashType, err := hashTypeToProtoscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/hashTypeToProto().(actualParams.HKDFHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Parameters#HKDFHashType().())
150 if err != nil {
151 return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("invalid HKDF hash type: %v", err)
152 }
153 keyFormat := &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#{
154 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,
155 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#{
156 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.: hkdfHashType,
157 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(actualParams.DerivedKeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Parameters#DerivedKeySizeInBytes().()),
158 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(actualParams.SegmentSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Parameters#SegmentSizeInBytes().()),
159 },
160 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(actualParams.KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/Parameters#KeySizeInBytes().()),
161 }
162 serializedParams, 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().(keyFormat)
163 if err != nil {
164 return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("failed to marshal key format: %v", err)
165 }
166 return &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#{
167 TypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#TypeUrl.: typeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/typeURL.,
168 Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#Value.: serializedParams,
169 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.,
170 }, nil
171 }
172
173 type parametersParserscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/parametersParser# struct{}
174
175 var _ protoserializationscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/.ParametersParserscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/ParametersParser# = (*parametersParserscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/parametersParser#)(nil)
176
177 func (s *parametersParserscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/parametersParser#) Parsescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/parametersParser#Parse().(kt *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#) (keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/key`/.Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/key`/Parameters#, error) {
178 if kt == nil {
179 return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("parameters serialization is nil")
180 }
181 if kt.GetTypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#GetTypeUrl().() != typeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/typeURL. {
182 return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("invalid type URL: got %q, want %q", kt.GetTypeUrlscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#GetTypeUrl().(), typeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/typeURL.)
183 }
184 if kt.GetOutputPrefixTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#GetOutputPrefixType().() != 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. {
185 return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("output prefix type is not RAW")
186 }
187 keyFormat := new(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#)
188 if err := protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/.Unmarshalscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/Unmarshal().(kt.GetValuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#GetValue().(), keyFormat); err != nil {
189 return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("failed to unmarshal key format: %v", err)
190 }
191 if keyFormat.GetVersionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#GetVersion().() != 0 {
192 return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("unsupported key version: got %d, want %d", keyFormat.GetVersionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#GetVersion().(), 0)
193 }
194 protoParams := keyFormat.GetParamsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#GetParams().()
195 hkdfHashType, err := hashTypeFromProtoscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/hashTypeFromProto().(protoParams.GetHkdfHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#GetHkdfHashType().())
196 if err != nil {
197 return nil, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Errorf().("invalid HKDF hash type: %v", err)
198 }
199 return NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/NewParameters().(ParametersOptsscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#{
200 KeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#KeySizeInBytes.: int(keyFormat.GetKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingKeyFormat#GetKeySize().()),
201 DerivedKeySizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#DerivedKeySizeInBytes.: int(protoParams.GetDerivedKeySizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#GetDerivedKeySize().()),
202 HKDFHashTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#HKDFHashType.: hkdfHashType,
203 SegmentSizeInBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/streamingaead/aesgcmhkdf`/ParametersOpts#SegmentSizeInBytes.: int32(protoParams.GetCiphertextSegmentSizescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/aes_gcm_hkdf_streaming_go_proto`/AesGcmHkdfStreamingParams#GetCiphertextSegmentSize().()),
204 })
205 }