-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkey.go
204 lines (195 loc) · 5.2 KB
/
key.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
// (c) 2022-present, LDC Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package iana
// IANA-registered COSE common key parameters.
//
// From IANA registry <https://www.iana.org/assignments/cose/cose.xhtml#key-common-parameters>
// as of 2022-12-19.
const (
// Reserved value.
KeyParameterReserved = 0
// Identification of the key type
//
// Associated value of type tstr / int
KeyParameterKty = 1
// Key identification value - match to kid in message
//
// Associated value of type bstr
KeyParameterKid = 2
// Key usage restriction to this algorithm
//
// Associated value of type tstr / int
KeyParameterAlg = 3
// Restrict set of permissible operations
//
// Associated value of type [+ (tstr / int)]
KeyParameterKeyOps = 4
// Base IV to be XORed with Partial IVs
//
// Associated value of type bstr
KeyParameterBaseIV = 5
)
// IANA-registered COSE key types.
//
// From IANA registry https://www.iana.org/assignments/cose/cose.xhtml#key-type
// as of 2022-12-19.
const (
// This value is reserved
KeyTypeReserved = 0
// Octet Key Pair
KeyTypeOKP = 1
// Elliptic Curve Keys w/ x- and y-coordinate pair
KeyTypeEC2 = 2
// RSA Key
KeyTypeRSA = 3
// Symmetric Keys
KeyTypeSymmetric = 4
// Public key for HSS/LMS hash-based digital signature
KeyTypeHSS_LMS = 5
// WalnutDSA public key
KeyTypeWalnutDSA = 6
)
// IANA-registered COSE key parameters for keys of type [KeyType::OKP].
//
// From IANA registry https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters
// as of 2022-12-19.
const (
// EC identifier - Taken from the "COSE Elliptic Curves" registry
//
// Associated value of type tstr / int
OKPKeyParameterCrv = -1
// x-coordinate
//
// Associated value of type bstr
OKPKeyParameterX = -2
// Private key
//
// Associated value of type bstr
OKPKeyParameterD = -4
)
// IANA-registered COSE key parameters for keys of type [KeyType::EC2].
//
// From IANA registry https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters
// as of 2022-12-19.
const (
// EC identifier - Taken from the "COSE Elliptic Curves" registry
//
// Associated value of type tstr / int
EC2KeyParameterCrv = -1
// Public Key
//
// Associated value of type bstr
EC2KeyParameterX = -2
// y-coordinate
//
// Associated value of type bstr / bool
EC2KeyParameterY = -3
// Private key
//
// Associated value of type bstr
EC2KeyParameterD = -4
)
// IANA-registered COSE key parameters for keys of type [KeyType::RSA].
//
// From IANA registry <https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters>
// as of 2022-12-19.
const (
// The RSA modulus n
//
// Associated value of type bstr
RSAKeyParameterN = -1
// The RSA public exponent e
//
// Associated value of type bstr
RSAKeyParameterE = -2
// The RSA private exponent d
//
// Associated value of type bstr
RSAKeyParameterD = -3
// The prime factor p of n
//
// Associated value of type bstr
RSAKeyParameterP = -4
// The prime factor q of n
//
// Associated value of type bstr
RSAKeyParameterQ = -5
// dP is d mod (p - 1)
//
// Associated value of type bstr
RSAKeyParameterDP = -6
// dQ is d mod (q - 1)
//
// Associated value of type bstr
RSAKeyParameterDQ = -7
// qInv is the CRT coefficient q^(-1) mod p
//
// Associated value of type bstr
RSAKeyParameterQInv = -8
// Other prime infos, an array
//
// Associated value of type array
RSAKeyParameterOther = -9
// a prime factor r_i of n, where i >= 3
//
// Associated value of type bstr
RSAKeyParameterRI = -10
// d_i = d mod (r_i - 1)
//
// Associated value of type bstr
RSAKeyParameterDI = -11
// The CRT coefficient t_i = (r_1 * r_2 * ... * r_(i-1))^(-1) mod r_i
//
// Associated value of type bstr
RSAKeyParameterTI = -12
)
// IANA-registered COSE key parameters for keys of type [KeyType::Symmetric].
//
// From IANA registry https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters
// as of 2022-12-19.
const (
// Key Value
//
// Associated value of type bstr
SymmetricKeyParameterK = -1
)
// IANA-registered COSE key parameters for keys of type [KeyType::HSS_LMS].
//
// From IANA registry https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters
// as of 2022-12-19.
const (
// Public key for HSS/LMS hash-based digital signature
//
// Associated value of type bstr
HSS_LMSKeyParameterPub = -1
)
// IANA-registered COSE key parameters for keys of type [KeyType::WalnutDSA].
//
// From IANA registry https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters
// as of 2022-12-19.
const (
// Group and Matrix (NxN) size
//
// Associated value of type uint
WalnutDSAKeyParameterN = -1
// Finite field F_q
//
// Associated value of type uint
WalnutDSAKeyParameterQ = -2
// List of T-values, enties in F_q
//
// Associated value of type array of uint
WalnutDSAKeyParameterTValues = -3
// NxN Matrix of enties in F_q in column-major form
//
// Associated value of type array of array of uint
WalnutDSAKeyParameterMatrix1 = -4
// Permutation associated with matrix 1
//
// Associated value of type array of uint
WalnutDSAKeyParameterPermutation1 = -5
// NxN Matrix of enties in F_q in column-major form
//
// Associated value of type array of array of uint
WalnutDSAKeyParameterMatrix2 = -6
)