Debian Codegraph @

aead/chacha20poly1305/protoserialization.go

raw symbols SCIP
1 // Copyright 2024 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 chacha20poly1305scip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/
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 cppbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/chacha20_poly1305_go_proto`/ "github.com/tink-crypto/tink-go/v2/proto/chacha20_poly1305_go_protoscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/chacha20_poly1305_go_proto`/"
26 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`/"
27 )
28
29 const (
30 // protoVersion is the accepted [gcmpb.AesGcmKey] proto version.
31 //
32 // Currently, only version 0 is supported; other versions are rejected.
33 protoVersionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/protoVersion. = 0
34 typeURLscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/typeURL. = "type.googleapis.com/google.crypto.tink.ChaCha20Poly1305Key"
35 )
36
37 type keySerializerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/keySerializer# struct{}
38
39 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/aead/chacha20poly1305`/keySerializer#)(nil)
40
41 func protoOutputPrefixTypeFromVariantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/protoOutputPrefixTypeFromVariant().(variant Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/Variant#) (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#, error) {
42 switch variant {
43 case VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/VariantTink.:
44 return 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., nil
45 case VariantCrunchyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/VariantCrunchy.:
46 return tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_CRUNCHYscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_CRUNCHY., nil
47 case VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/VariantNoPrefix.:
48 return 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., nil
49 default:
50 return tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_UNKNOWN_PREFIXscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_UNKNOWN_PREFIX., 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 output prefix variant: %v", variant)
51 }
52 }
53
54 func (s *keySerializerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/keySerializer#) SerializeKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/keySerializer#SerializeKey().(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#) (*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) {
55 that, ok := key.(*Keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/Key#)
56 if !ok {
57 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 Key")
58 }
59 actualParameters, ok := that.Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/Key#Parameters().().(*Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/Parameters#)
60 if !ok {
61 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 Parameters")
62 }
63 outputPrefixType, err := protoOutputPrefixTypeFromVariantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/protoOutputPrefixTypeFromVariant().(actualParameters.Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/Parameters#Variant().())
64 if err != nil {
65 return nil, err
66 }
67 keyBytes := that.KeyBytesscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/Key#KeyBytes().()
68 protoKey := &cppbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/chacha20_poly1305_go_proto`/.ChaCha20Poly1305Keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/chacha20_poly1305_go_proto`/ChaCha20Poly1305Key#{
69 KeyValuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/chacha20_poly1305_go_proto`/ChaCha20Poly1305Key#KeyValue.: 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#{}),
70 Versionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/chacha20_poly1305_go_proto`/ChaCha20Poly1305Key#Version.: protoVersionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/protoVersion.,
71 }
72 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)
73 if err != nil {
74 return nil, err
75 }
76 // idRequirement is zero if the key doesn't have a key requirement.
77 idRequirement, _ := that.IDRequirementscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/Key#IDRequirement().()
78 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#{
79 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/aead/chacha20poly1305`/typeURL.,
80 Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyData#Value.: serializedKey,
81 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.,
82 }
83 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, outputPrefixType, idRequirement)
84 }
85
86 type keyParserscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/keyParser# struct{}
87
88 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/aead/chacha20poly1305`/keyParser#)(nil)
89
90 func variantFromProtoscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/variantFromProto().(prefixType 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#) (Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/Variant#, error) {
91 switch prefixType {
92 case 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.:
93 return VariantTinkscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/VariantTink., nil
94 case tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_CRUNCHYscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_CRUNCHY., tinkpbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/.OutputPrefixType_LEGACYscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/OutputPrefixType_LEGACY.:
95 return VariantCrunchyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/VariantCrunchy., nil
96 case 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.:
97 return VariantNoPrefixscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/VariantNoPrefix., nil
98 default:
99 return VariantUnknownscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/VariantUnknown., 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 output prefix type: %v", prefixType)
100 }
101 }
102
103 func (s *keyParserscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/keyParser#) ParseKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/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) {
104 if keySerialization == nil {
105 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")
106 }
107 keyData := keySerialization.KeyDatascip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/KeySerialization#KeyData().()
108 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/aead/chacha20poly1305`/typeURL. {
109 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 ChaCha20Poly1305 key")
110 }
111 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. {
112 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")
113 }
114 protoKey := new(cppbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/chacha20_poly1305_go_proto`/.ChaCha20Poly1305Keyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/chacha20_poly1305_go_proto`/ChaCha20Poly1305Key#)
115 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 {
116 return nil, err
117 }
118 if protoKey.GetVersionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/chacha20_poly1305_go_proto`/ChaCha20Poly1305Key#GetVersion().() != protoVersionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/protoVersion. {
119 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 has unsupported version: %v", protoKey.GetVersionscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/chacha20_poly1305_go_proto`/ChaCha20Poly1305Key#GetVersion().())
120 }
121 variant, err := variantFromProtoscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/variantFromProto().(keySerialization.OutputPrefixTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/KeySerialization#OutputPrefixType().())
122 if err != nil {
123 return nil, err
124 }
125 params, err := NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/NewParameters().(variant)
126 if err != nil {
127 return nil, err
128 }
129 keyMaterial := 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/chacha20_poly1305_go_proto`/ChaCha20Poly1305Key#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#{})
130 // keySerialization.IDRequirement() returns zero if the key doesn't have a
131 // key requirement.
132 keyID, _ := keySerialization.IDRequirementscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/internal/protoserialization`/KeySerialization#IDRequirement().()
133 return NewKeyscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/NewKey().(keyMaterial, keyID, params)
134 }
135
136 type parametersSerializerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/parametersSerializer# struct{}
137
138 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/aead/chacha20poly1305`/parametersSerializer#)(nil)
139
140 func (s *parametersSerializerscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/parametersSerializer#) Serializescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/parametersSerializer#Serialize().(parameters 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) {
141 actualParameters, ok := parameters.(*Parametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/Parameters#)
142 if !ok {
143 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 parameters type: got %T, want *chacha20poly1305.Parameters", parameters)
144 }
145 outputPrefixType, err := protoOutputPrefixTypeFromVariantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/protoOutputPrefixTypeFromVariant().(actualParameters.Variantscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/Parameters#Variant().())
146 if err != nil {
147 return nil, err
148 }
149 format := &cppbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/chacha20_poly1305_go_proto`/.ChaCha20Poly1305KeyFormatscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/chacha20_poly1305_go_proto`/ChaCha20Poly1305KeyFormat#{}
150 serializedFormat, err := protoscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/.Marshalscip-go gomod google.golang.org/protobuf v1.36.8 `google.golang.org/protobuf/proto`/Marshal().(format)
151 if err != nil {
152 return nil, err
153 }
154 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#{
155 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/aead/chacha20poly1305`/typeURL.,
156 OutputPrefixTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#OutputPrefixType.: outputPrefixType,
157 Valuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#Value.: serializedFormat,
158 }, nil
159 }
160
161 type parametersParserscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/parametersParser# struct{}
162
163 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/aead/chacha20poly1305`/parametersParser#)(nil)
164
165 func (s *parametersParserscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/parametersParser#) Parsescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/parametersParser#Parse().(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#) (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) {
166 if keyTemplate.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/aead/chacha20poly1305`/typeURL. {
167 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", keyTemplate.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/aead/chacha20poly1305`/typeURL.)
168 }
169 format := new(cppbscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/chacha20_poly1305_go_proto`/.ChaCha20Poly1305KeyFormatscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/chacha20_poly1305_go_proto`/ChaCha20Poly1305KeyFormat#)
170 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().(keyTemplate.GetValuescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#GetValue().(), format); err != nil {
171 return nil, err
172 }
173 variant, err := variantFromProtoscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/variantFromProto().(keyTemplate.GetOutputPrefixTypescip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/proto/tink_go_proto`/KeyTemplate#GetOutputPrefixType().())
174 if err != nil {
175 return nil, err
176 }
177 return NewParametersscip-go gomod github.com/tink-crypto/tink-go/v2 . `github.com/tink-crypto/tink-go/v2/aead/chacha20poly1305`/NewParameters().(variant)
178 }