1
1
#![ allow( missing_docs) ]
2
- ///! This crate contains types only for working JWK and JWK Sets
3
- ///! This is only meant to be used to deal with public JWK, not generate ones.
4
- ///! Most of the code in this file is taken from https://github.com/lawliet89/biscuit but
5
- /// tweaked to remove the private bits as it's not the goal for this crate currently.
6
- ///!
2
+ //! This crate contains types only for working JWK and JWK Sets
3
+ //! This is only meant to be used to deal with public JWK, not generate ones.
4
+ //! Most of the code in this file is taken from https://github.com/lawliet89/biscuit but
5
+ //! tweaked to remove the private bits as it's not the goal for this crate currently.
7
6
use crate :: Algorithm ;
8
7
use serde:: { de, Deserialize , Deserializer , Serialize , Serializer } ;
9
8
use std:: fmt;
@@ -194,24 +193,20 @@ pub struct CommonParameters {
194
193
195
194
/// Key type value for an Elliptic Curve Key.
196
195
/// This single value enum is a workaround for Rust not supporting associated constants.
197
- #[ derive( Clone , Copy , Debug , Eq , PartialEq , Serialize , Deserialize , Hash ) ]
196
+ #[ derive( Clone , Copy , Debug , Default , Eq , PartialEq , Serialize , Deserialize , Hash ) ]
198
197
pub enum EllipticCurveKeyType {
199
198
/// Key type value for an Elliptic Curve Key.
199
+ #[ default]
200
200
EC ,
201
201
}
202
202
203
- impl Default for EllipticCurveKeyType {
204
- fn default ( ) -> Self {
205
- EllipticCurveKeyType :: EC
206
- }
207
- }
208
-
209
203
/// Type of cryptographic curve used by a key. This is defined in
210
204
/// [RFC 7518 #7.6](https://tools.ietf.org/html/rfc7518#section-7.6)
211
- #[ derive( Clone , Debug , Eq , PartialEq , Serialize , Deserialize , Hash ) ]
205
+ #[ derive( Clone , Debug , Default , Eq , PartialEq , Serialize , Deserialize , Hash ) ]
212
206
pub enum EllipticCurve {
213
207
/// P-256 curve
214
208
#[ serde( rename = "P-256" ) ]
209
+ #[ default]
215
210
P256 ,
216
211
/// P-384 curve
217
212
#[ serde( rename = "P-384" ) ]
@@ -224,12 +219,6 @@ pub enum EllipticCurve {
224
219
Ed25519 ,
225
220
}
226
221
227
- impl Default for EllipticCurve {
228
- fn default ( ) -> Self {
229
- EllipticCurve :: P256
230
- }
231
- }
232
-
233
222
/// Parameters for an Elliptic Curve Key
234
223
#[ derive( Clone , Debug , Eq , PartialEq , Serialize , Deserialize , Default , Hash ) ]
235
224
pub struct EllipticCurveKeyParameters {
@@ -250,18 +239,13 @@ pub struct EllipticCurveKeyParameters {
250
239
251
240
/// Key type value for an RSA Key.
252
241
/// This single value enum is a workaround for Rust not supporting associated constants.
253
- #[ derive( Clone , Copy , Debug , Eq , PartialEq , Serialize , Deserialize , Hash ) ]
242
+ #[ derive( Clone , Copy , Debug , Default , Eq , PartialEq , Serialize , Deserialize , Hash ) ]
254
243
pub enum RSAKeyType {
255
244
/// Key type value for an RSA Key.
245
+ #[ default]
256
246
RSA ,
257
247
}
258
248
259
- impl Default for RSAKeyType {
260
- fn default ( ) -> Self {
261
- RSAKeyType :: RSA
262
- }
263
- }
264
-
265
249
/// Parameters for a RSA Key
266
250
#[ derive( Clone , Debug , Eq , PartialEq , Serialize , Deserialize , Default , Hash ) ]
267
251
pub struct RSAKeyParameters {
@@ -280,19 +264,14 @@ pub struct RSAKeyParameters {
280
264
281
265
/// Key type value for an Octet symmetric key.
282
266
/// This single value enum is a workaround for Rust not supporting associated constants.
283
- #[ derive( Clone , Copy , Debug , Eq , PartialEq , Serialize , Deserialize , Hash ) ]
267
+ #[ derive( Clone , Copy , Debug , Default , Eq , PartialEq , Serialize , Deserialize , Hash ) ]
284
268
pub enum OctetKeyType {
285
269
/// Key type value for an Octet symmetric key.
286
270
#[ serde( rename = "oct" ) ]
271
+ #[ default]
287
272
Octet ,
288
273
}
289
274
290
- impl Default for OctetKeyType {
291
- fn default ( ) -> Self {
292
- OctetKeyType :: Octet
293
- }
294
- }
295
-
296
275
/// Parameters for an Octet Key
297
276
#[ derive( Clone , Debug , Eq , PartialEq , Serialize , Deserialize , Default , Hash ) ]
298
277
pub struct OctetKeyParameters {
@@ -306,19 +285,14 @@ pub struct OctetKeyParameters {
306
285
307
286
/// Key type value for an Octet Key Pair.
308
287
/// This single value enum is a workaround for Rust not supporting associated constants.
309
- #[ derive( Clone , Copy , Debug , Eq , PartialEq , Serialize , Deserialize , Hash ) ]
288
+ #[ derive( Clone , Copy , Debug , Default , Eq , PartialEq , Serialize , Deserialize , Hash ) ]
310
289
pub enum OctetKeyPairType {
311
290
/// Key type value for an Octet Key Pair.
312
291
#[ serde( rename = "OKP" ) ]
292
+ #[ default]
313
293
OctetKeyPair ,
314
294
}
315
295
316
- impl Default for OctetKeyPairType {
317
- fn default ( ) -> Self {
318
- OctetKeyPairType :: OctetKeyPair
319
- }
320
- }
321
-
322
296
/// Parameters for an Octet Key Pair
323
297
#[ derive( Clone , Debug , Eq , PartialEq , Serialize , Deserialize , Default , Hash ) ]
324
298
pub struct OctetKeyPairParameters {
0 commit comments