1#![allow(clippy::doc_markdown)]
8
9#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
18#[non_exhaustive]
19pub enum JsonWebSignatureAlg {
20 Hs256,
22
23 Hs384,
25
26 Hs512,
28
29 Rs256,
31
32 Rs384,
34
35 Rs512,
37
38 Es256,
40
41 Es384,
43
44 Es512,
46
47 Ps256,
49
50 Ps384,
52
53 Ps512,
55
56 None,
58
59 EdDsa,
61
62 Es256K,
64
65 Ed25519,
67
68 Ed448,
70
71 Unknown(String),
73}
74
75impl core::fmt::Display for JsonWebSignatureAlg {
76 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
77 match self {
78 Self::Hs256 => write!(f, "HS256"),
79 Self::Hs384 => write!(f, "HS384"),
80 Self::Hs512 => write!(f, "HS512"),
81 Self::Rs256 => write!(f, "RS256"),
82 Self::Rs384 => write!(f, "RS384"),
83 Self::Rs512 => write!(f, "RS512"),
84 Self::Es256 => write!(f, "ES256"),
85 Self::Es384 => write!(f, "ES384"),
86 Self::Es512 => write!(f, "ES512"),
87 Self::Ps256 => write!(f, "PS256"),
88 Self::Ps384 => write!(f, "PS384"),
89 Self::Ps512 => write!(f, "PS512"),
90 Self::None => write!(f, "none"),
91 Self::EdDsa => write!(f, "EdDSA"),
92 Self::Es256K => write!(f, "ES256K"),
93 Self::Ed25519 => write!(f, "Ed25519"),
94 Self::Ed448 => write!(f, "Ed448"),
95 Self::Unknown(value) => write!(f, "{value}"),
96 }
97 }
98}
99
100impl core::str::FromStr for JsonWebSignatureAlg {
101 type Err = core::convert::Infallible;
102
103 fn from_str(s: &str) -> Result<Self, Self::Err> {
104 match s {
105 "HS256" => Ok(Self::Hs256),
106 "HS384" => Ok(Self::Hs384),
107 "HS512" => Ok(Self::Hs512),
108 "RS256" => Ok(Self::Rs256),
109 "RS384" => Ok(Self::Rs384),
110 "RS512" => Ok(Self::Rs512),
111 "ES256" => Ok(Self::Es256),
112 "ES384" => Ok(Self::Es384),
113 "ES512" => Ok(Self::Es512),
114 "PS256" => Ok(Self::Ps256),
115 "PS384" => Ok(Self::Ps384),
116 "PS512" => Ok(Self::Ps512),
117 "none" => Ok(Self::None),
118 "EdDSA" => Ok(Self::EdDsa),
119 "ES256K" => Ok(Self::Es256K),
120 "Ed25519" => Ok(Self::Ed25519),
121 "Ed448" => Ok(Self::Ed448),
122 value => Ok(Self::Unknown(value.to_owned())),
123 }
124 }
125}
126
127impl<'de> serde::Deserialize<'de> for JsonWebSignatureAlg {
128 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
129 where
130 D: serde::de::Deserializer<'de>,
131 {
132 let s = String::deserialize(deserializer)?;
133 core::str::FromStr::from_str(&s).map_err(serde::de::Error::custom)
134 }
135}
136
137impl serde::Serialize for JsonWebSignatureAlg {
138 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
139 where
140 S: serde::ser::Serializer,
141 {
142 serializer.serialize_str(&self.to_string())
143 }
144}
145
146impl schemars::JsonSchema for JsonWebSignatureAlg {
147 fn schema_name() -> String {
148 "JsonWebSignatureAlg".to_owned()
149 }
150
151 fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
152 let enums = vec![
153 schemars::schema::SchemaObject {
155 metadata: Some(Box::new(schemars::schema::Metadata {
156 description: Some(
157 r"HMAC using SHA-256".to_owned(),
159 ),
160 ..Default::default()
161 })),
162 const_value: Some("HS256".into()),
163 ..Default::default()
164 }
165 .into(),
166 schemars::schema::SchemaObject {
168 metadata: Some(Box::new(schemars::schema::Metadata {
169 description: Some(
170 r"HMAC using SHA-384".to_owned(),
172 ),
173 ..Default::default()
174 })),
175 const_value: Some("HS384".into()),
176 ..Default::default()
177 }
178 .into(),
179 schemars::schema::SchemaObject {
181 metadata: Some(Box::new(schemars::schema::Metadata {
182 description: Some(
183 r"HMAC using SHA-512".to_owned(),
185 ),
186 ..Default::default()
187 })),
188 const_value: Some("HS512".into()),
189 ..Default::default()
190 }
191 .into(),
192 schemars::schema::SchemaObject {
194 metadata: Some(Box::new(schemars::schema::Metadata {
195 description: Some(
196 r"RSASSA-PKCS1-v1_5 using SHA-256".to_owned(),
198 ),
199 ..Default::default()
200 })),
201 const_value: Some("RS256".into()),
202 ..Default::default()
203 }
204 .into(),
205 schemars::schema::SchemaObject {
207 metadata: Some(Box::new(schemars::schema::Metadata {
208 description: Some(
209 r"RSASSA-PKCS1-v1_5 using SHA-384".to_owned(),
211 ),
212 ..Default::default()
213 })),
214 const_value: Some("RS384".into()),
215 ..Default::default()
216 }
217 .into(),
218 schemars::schema::SchemaObject {
220 metadata: Some(Box::new(schemars::schema::Metadata {
221 description: Some(
222 r"RSASSA-PKCS1-v1_5 using SHA-512".to_owned(),
224 ),
225 ..Default::default()
226 })),
227 const_value: Some("RS512".into()),
228 ..Default::default()
229 }
230 .into(),
231 schemars::schema::SchemaObject {
233 metadata: Some(Box::new(schemars::schema::Metadata {
234 description: Some(
235 r"ECDSA using P-256 and SHA-256".to_owned(),
237 ),
238 ..Default::default()
239 })),
240 const_value: Some("ES256".into()),
241 ..Default::default()
242 }
243 .into(),
244 schemars::schema::SchemaObject {
246 metadata: Some(Box::new(schemars::schema::Metadata {
247 description: Some(
248 r"ECDSA using P-384 and SHA-384".to_owned(),
250 ),
251 ..Default::default()
252 })),
253 const_value: Some("ES384".into()),
254 ..Default::default()
255 }
256 .into(),
257 schemars::schema::SchemaObject {
259 metadata: Some(Box::new(schemars::schema::Metadata {
260 description: Some(
261 r"ECDSA using P-521 and SHA-512".to_owned(),
263 ),
264 ..Default::default()
265 })),
266 const_value: Some("ES512".into()),
267 ..Default::default()
268 }
269 .into(),
270 schemars::schema::SchemaObject {
272 metadata: Some(Box::new(schemars::schema::Metadata {
273 description: Some(
274 r"RSASSA-PSS using SHA-256 and MGF1 with SHA-256".to_owned(),
276 ),
277 ..Default::default()
278 })),
279 const_value: Some("PS256".into()),
280 ..Default::default()
281 }
282 .into(),
283 schemars::schema::SchemaObject {
285 metadata: Some(Box::new(schemars::schema::Metadata {
286 description: Some(
287 r"RSASSA-PSS using SHA-384 and MGF1 with SHA-384".to_owned(),
289 ),
290 ..Default::default()
291 })),
292 const_value: Some("PS384".into()),
293 ..Default::default()
294 }
295 .into(),
296 schemars::schema::SchemaObject {
298 metadata: Some(Box::new(schemars::schema::Metadata {
299 description: Some(
300 r"RSASSA-PSS using SHA-512 and MGF1 with SHA-512".to_owned(),
302 ),
303 ..Default::default()
304 })),
305 const_value: Some("PS512".into()),
306 ..Default::default()
307 }
308 .into(),
309 schemars::schema::SchemaObject {
311 metadata: Some(Box::new(schemars::schema::Metadata {
312 description: Some(
313 r"No digital signature or MAC performed".to_owned(),
315 ),
316 ..Default::default()
317 })),
318 const_value: Some("none".into()),
319 ..Default::default()
320 }
321 .into(),
322 schemars::schema::SchemaObject {
324 metadata: Some(Box::new(schemars::schema::Metadata {
325 description: Some(
326 r"EdDSA signature algorithms".to_owned(),
328 ),
329 ..Default::default()
330 })),
331 const_value: Some("EdDSA".into()),
332 ..Default::default()
333 }
334 .into(),
335 schemars::schema::SchemaObject {
337 metadata: Some(Box::new(schemars::schema::Metadata {
338 description: Some(
339 r"ECDSA using secp256k1 curve and SHA-256".to_owned(),
341 ),
342 ..Default::default()
343 })),
344 const_value: Some("ES256K".into()),
345 ..Default::default()
346 }
347 .into(),
348 schemars::schema::SchemaObject {
350 metadata: Some(Box::new(schemars::schema::Metadata {
351 description: Some(
352 r"EdDSA using Ed25519 curve".to_owned(),
354 ),
355 ..Default::default()
356 })),
357 const_value: Some("Ed25519".into()),
358 ..Default::default()
359 }
360 .into(),
361 schemars::schema::SchemaObject {
363 metadata: Some(Box::new(schemars::schema::Metadata {
364 description: Some(
365 r"EdDSA using Ed448 curve".to_owned(),
367 ),
368 ..Default::default()
369 })),
370 const_value: Some("Ed448".into()),
371 ..Default::default()
372 }
373 .into(),
374 ];
375
376 let description = r#"JSON Web Signature "alg" parameter"#;
377 schemars::schema::SchemaObject {
378 metadata: Some(Box::new(schemars::schema::Metadata {
379 description: Some(description.to_owned()),
380 ..Default::default()
381 })),
382 subschemas: Some(Box::new(schemars::schema::SubschemaValidation {
383 any_of: Some(enums),
384 ..Default::default()
385 })),
386 ..Default::default()
387 }
388 .into()
389 }
390}
391
392#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
396#[non_exhaustive]
397pub enum JsonWebEncryptionAlg {
398 Rsa15,
400
401 RsaOaep,
403
404 RsaOaep256,
406
407 A128Kw,
409
410 A192Kw,
412
413 A256Kw,
415
416 Dir,
418
419 EcdhEs,
421
422 EcdhEsA128Kw,
424
425 EcdhEsA192Kw,
427
428 EcdhEsA256Kw,
430
431 A128Gcmkw,
433
434 A192Gcmkw,
436
437 A256Gcmkw,
439
440 Pbes2Hs256A128Kw,
442
443 Pbes2Hs384A192Kw,
445
446 Pbes2Hs512A256Kw,
448
449 RsaOaep384,
451
452 RsaOaep512,
454
455 Unknown(String),
457}
458
459impl core::fmt::Display for JsonWebEncryptionAlg {
460 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
461 match self {
462 Self::Rsa15 => write!(f, "RSA1_5"),
463 Self::RsaOaep => write!(f, "RSA-OAEP"),
464 Self::RsaOaep256 => write!(f, "RSA-OAEP-256"),
465 Self::A128Kw => write!(f, "A128KW"),
466 Self::A192Kw => write!(f, "A192KW"),
467 Self::A256Kw => write!(f, "A256KW"),
468 Self::Dir => write!(f, "dir"),
469 Self::EcdhEs => write!(f, "ECDH-ES"),
470 Self::EcdhEsA128Kw => write!(f, "ECDH-ES+A128KW"),
471 Self::EcdhEsA192Kw => write!(f, "ECDH-ES+A192KW"),
472 Self::EcdhEsA256Kw => write!(f, "ECDH-ES+A256KW"),
473 Self::A128Gcmkw => write!(f, "A128GCMKW"),
474 Self::A192Gcmkw => write!(f, "A192GCMKW"),
475 Self::A256Gcmkw => write!(f, "A256GCMKW"),
476 Self::Pbes2Hs256A128Kw => write!(f, "PBES2-HS256+A128KW"),
477 Self::Pbes2Hs384A192Kw => write!(f, "PBES2-HS384+A192KW"),
478 Self::Pbes2Hs512A256Kw => write!(f, "PBES2-HS512+A256KW"),
479 Self::RsaOaep384 => write!(f, "RSA-OAEP-384"),
480 Self::RsaOaep512 => write!(f, "RSA-OAEP-512"),
481 Self::Unknown(value) => write!(f, "{value}"),
482 }
483 }
484}
485
486impl core::str::FromStr for JsonWebEncryptionAlg {
487 type Err = core::convert::Infallible;
488
489 fn from_str(s: &str) -> Result<Self, Self::Err> {
490 match s {
491 "RSA1_5" => Ok(Self::Rsa15),
492 "RSA-OAEP" => Ok(Self::RsaOaep),
493 "RSA-OAEP-256" => Ok(Self::RsaOaep256),
494 "A128KW" => Ok(Self::A128Kw),
495 "A192KW" => Ok(Self::A192Kw),
496 "A256KW" => Ok(Self::A256Kw),
497 "dir" => Ok(Self::Dir),
498 "ECDH-ES" => Ok(Self::EcdhEs),
499 "ECDH-ES+A128KW" => Ok(Self::EcdhEsA128Kw),
500 "ECDH-ES+A192KW" => Ok(Self::EcdhEsA192Kw),
501 "ECDH-ES+A256KW" => Ok(Self::EcdhEsA256Kw),
502 "A128GCMKW" => Ok(Self::A128Gcmkw),
503 "A192GCMKW" => Ok(Self::A192Gcmkw),
504 "A256GCMKW" => Ok(Self::A256Gcmkw),
505 "PBES2-HS256+A128KW" => Ok(Self::Pbes2Hs256A128Kw),
506 "PBES2-HS384+A192KW" => Ok(Self::Pbes2Hs384A192Kw),
507 "PBES2-HS512+A256KW" => Ok(Self::Pbes2Hs512A256Kw),
508 "RSA-OAEP-384" => Ok(Self::RsaOaep384),
509 "RSA-OAEP-512" => Ok(Self::RsaOaep512),
510 value => Ok(Self::Unknown(value.to_owned())),
511 }
512 }
513}
514
515impl<'de> serde::Deserialize<'de> for JsonWebEncryptionAlg {
516 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
517 where
518 D: serde::de::Deserializer<'de>,
519 {
520 let s = String::deserialize(deserializer)?;
521 core::str::FromStr::from_str(&s).map_err(serde::de::Error::custom)
522 }
523}
524
525impl serde::Serialize for JsonWebEncryptionAlg {
526 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
527 where
528 S: serde::ser::Serializer,
529 {
530 serializer.serialize_str(&self.to_string())
531 }
532}
533
534impl schemars::JsonSchema for JsonWebEncryptionAlg {
535 fn schema_name() -> String {
536 "JsonWebEncryptionAlg".to_owned()
537 }
538
539 fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
540 let enums = vec![
541 schemars::schema::SchemaObject {
543 metadata: Some(Box::new(schemars::schema::Metadata {
544 description: Some(
545 r"RSAES-PKCS1-v1_5".to_owned(),
547 ),
548 ..Default::default()
549 })),
550 const_value: Some("RSA1_5".into()),
551 ..Default::default()
552 }
553 .into(),
554 schemars::schema::SchemaObject {
556 metadata: Some(Box::new(schemars::schema::Metadata {
557 description: Some(
558 r"RSAES OAEP using default parameters".to_owned(),
560 ),
561 ..Default::default()
562 })),
563 const_value: Some("RSA-OAEP".into()),
564 ..Default::default()
565 }
566 .into(),
567 schemars::schema::SchemaObject {
569 metadata: Some(Box::new(schemars::schema::Metadata {
570 description: Some(
571 r"RSAES OAEP using SHA-256 and MGF1 with SHA-256".to_owned(),
573 ),
574 ..Default::default()
575 })),
576 const_value: Some("RSA-OAEP-256".into()),
577 ..Default::default()
578 }
579 .into(),
580 schemars::schema::SchemaObject {
582 metadata: Some(Box::new(schemars::schema::Metadata {
583 description: Some(
584 r"AES Key Wrap using 128-bit key".to_owned(),
586 ),
587 ..Default::default()
588 })),
589 const_value: Some("A128KW".into()),
590 ..Default::default()
591 }
592 .into(),
593 schemars::schema::SchemaObject {
595 metadata: Some(Box::new(schemars::schema::Metadata {
596 description: Some(
597 r"AES Key Wrap using 192-bit key".to_owned(),
599 ),
600 ..Default::default()
601 })),
602 const_value: Some("A192KW".into()),
603 ..Default::default()
604 }
605 .into(),
606 schemars::schema::SchemaObject {
608 metadata: Some(Box::new(schemars::schema::Metadata {
609 description: Some(
610 r"AES Key Wrap using 256-bit key".to_owned(),
612 ),
613 ..Default::default()
614 })),
615 const_value: Some("A256KW".into()),
616 ..Default::default()
617 }
618 .into(),
619 schemars::schema::SchemaObject {
621 metadata: Some(Box::new(schemars::schema::Metadata {
622 description: Some(
623 r"Direct use of a shared symmetric key".to_owned(),
625 ),
626 ..Default::default()
627 })),
628 const_value: Some("dir".into()),
629 ..Default::default()
630 }
631 .into(),
632 schemars::schema::SchemaObject {
634 metadata: Some(Box::new(schemars::schema::Metadata {
635 description: Some(
636 r"ECDH-ES using Concat KDF".to_owned(),
638 ),
639 ..Default::default()
640 })),
641 const_value: Some("ECDH-ES".into()),
642 ..Default::default()
643 }
644 .into(),
645 schemars::schema::SchemaObject {
647 metadata: Some(Box::new(schemars::schema::Metadata {
648 description: Some(
649 r#"ECDH-ES using Concat KDF and "A128KW" wrapping"#.to_owned(),
651 ),
652 ..Default::default()
653 })),
654 const_value: Some("ECDH-ES+A128KW".into()),
655 ..Default::default()
656 }
657 .into(),
658 schemars::schema::SchemaObject {
660 metadata: Some(Box::new(schemars::schema::Metadata {
661 description: Some(
662 r#"ECDH-ES using Concat KDF and "A192KW" wrapping"#.to_owned(),
664 ),
665 ..Default::default()
666 })),
667 const_value: Some("ECDH-ES+A192KW".into()),
668 ..Default::default()
669 }
670 .into(),
671 schemars::schema::SchemaObject {
673 metadata: Some(Box::new(schemars::schema::Metadata {
674 description: Some(
675 r#"ECDH-ES using Concat KDF and "A256KW" wrapping"#.to_owned(),
677 ),
678 ..Default::default()
679 })),
680 const_value: Some("ECDH-ES+A256KW".into()),
681 ..Default::default()
682 }
683 .into(),
684 schemars::schema::SchemaObject {
686 metadata: Some(Box::new(schemars::schema::Metadata {
687 description: Some(
688 r"Key wrapping with AES GCM using 128-bit key".to_owned(),
690 ),
691 ..Default::default()
692 })),
693 const_value: Some("A128GCMKW".into()),
694 ..Default::default()
695 }
696 .into(),
697 schemars::schema::SchemaObject {
699 metadata: Some(Box::new(schemars::schema::Metadata {
700 description: Some(
701 r"Key wrapping with AES GCM using 192-bit key".to_owned(),
703 ),
704 ..Default::default()
705 })),
706 const_value: Some("A192GCMKW".into()),
707 ..Default::default()
708 }
709 .into(),
710 schemars::schema::SchemaObject {
712 metadata: Some(Box::new(schemars::schema::Metadata {
713 description: Some(
714 r"Key wrapping with AES GCM using 256-bit key".to_owned(),
716 ),
717 ..Default::default()
718 })),
719 const_value: Some("A256GCMKW".into()),
720 ..Default::default()
721 }
722 .into(),
723 schemars::schema::SchemaObject {
725 metadata: Some(Box::new(schemars::schema::Metadata {
726 description: Some(
727 r#"PBES2 with HMAC SHA-256 and "A128KW" wrapping"#.to_owned(),
729 ),
730 ..Default::default()
731 })),
732 const_value: Some("PBES2-HS256+A128KW".into()),
733 ..Default::default()
734 }
735 .into(),
736 schemars::schema::SchemaObject {
738 metadata: Some(Box::new(schemars::schema::Metadata {
739 description: Some(
740 r#"PBES2 with HMAC SHA-384 and "A192KW" wrapping"#.to_owned(),
742 ),
743 ..Default::default()
744 })),
745 const_value: Some("PBES2-HS384+A192KW".into()),
746 ..Default::default()
747 }
748 .into(),
749 schemars::schema::SchemaObject {
751 metadata: Some(Box::new(schemars::schema::Metadata {
752 description: Some(
753 r#"PBES2 with HMAC SHA-512 and "A256KW" wrapping"#.to_owned(),
755 ),
756 ..Default::default()
757 })),
758 const_value: Some("PBES2-HS512+A256KW".into()),
759 ..Default::default()
760 }
761 .into(),
762 schemars::schema::SchemaObject {
764 metadata: Some(Box::new(schemars::schema::Metadata {
765 description: Some(
766 r"RSA-OAEP using SHA-384 and MGF1 with SHA-384".to_owned(),
768 ),
769 ..Default::default()
770 })),
771 const_value: Some("RSA-OAEP-384".into()),
772 ..Default::default()
773 }
774 .into(),
775 schemars::schema::SchemaObject {
777 metadata: Some(Box::new(schemars::schema::Metadata {
778 description: Some(
779 r"RSA-OAEP using SHA-512 and MGF1 with SHA-512".to_owned(),
781 ),
782 ..Default::default()
783 })),
784 const_value: Some("RSA-OAEP-512".into()),
785 ..Default::default()
786 }
787 .into(),
788 ];
789
790 let description = r#"JSON Web Encryption "alg" parameter"#;
791 schemars::schema::SchemaObject {
792 metadata: Some(Box::new(schemars::schema::Metadata {
793 description: Some(description.to_owned()),
794 ..Default::default()
795 })),
796 subschemas: Some(Box::new(schemars::schema::SubschemaValidation {
797 any_of: Some(enums),
798 ..Default::default()
799 })),
800 ..Default::default()
801 }
802 .into()
803 }
804}
805
806#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
810#[non_exhaustive]
811pub enum JsonWebEncryptionEnc {
812 A128CbcHs256,
814
815 A192CbcHs384,
817
818 A256CbcHs512,
820
821 A128Gcm,
823
824 A192Gcm,
826
827 A256Gcm,
829
830 Unknown(String),
832}
833
834impl core::fmt::Display for JsonWebEncryptionEnc {
835 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
836 match self {
837 Self::A128CbcHs256 => write!(f, "A128CBC-HS256"),
838 Self::A192CbcHs384 => write!(f, "A192CBC-HS384"),
839 Self::A256CbcHs512 => write!(f, "A256CBC-HS512"),
840 Self::A128Gcm => write!(f, "A128GCM"),
841 Self::A192Gcm => write!(f, "A192GCM"),
842 Self::A256Gcm => write!(f, "A256GCM"),
843 Self::Unknown(value) => write!(f, "{value}"),
844 }
845 }
846}
847
848impl core::str::FromStr for JsonWebEncryptionEnc {
849 type Err = core::convert::Infallible;
850
851 fn from_str(s: &str) -> Result<Self, Self::Err> {
852 match s {
853 "A128CBC-HS256" => Ok(Self::A128CbcHs256),
854 "A192CBC-HS384" => Ok(Self::A192CbcHs384),
855 "A256CBC-HS512" => Ok(Self::A256CbcHs512),
856 "A128GCM" => Ok(Self::A128Gcm),
857 "A192GCM" => Ok(Self::A192Gcm),
858 "A256GCM" => Ok(Self::A256Gcm),
859 value => Ok(Self::Unknown(value.to_owned())),
860 }
861 }
862}
863
864impl<'de> serde::Deserialize<'de> for JsonWebEncryptionEnc {
865 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
866 where
867 D: serde::de::Deserializer<'de>,
868 {
869 let s = String::deserialize(deserializer)?;
870 core::str::FromStr::from_str(&s).map_err(serde::de::Error::custom)
871 }
872}
873
874impl serde::Serialize for JsonWebEncryptionEnc {
875 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
876 where
877 S: serde::ser::Serializer,
878 {
879 serializer.serialize_str(&self.to_string())
880 }
881}
882
883impl schemars::JsonSchema for JsonWebEncryptionEnc {
884 fn schema_name() -> String {
885 "JsonWebEncryptionEnc".to_owned()
886 }
887
888 fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
889 let enums = vec![
890 schemars::schema::SchemaObject {
892 metadata: Some(Box::new(schemars::schema::Metadata {
893 description: Some(
894 r"AES_128_CBC_HMAC_SHA_256 authenticated encryption algorithm".to_owned(),
896 ),
897 ..Default::default()
898 })),
899 const_value: Some("A128CBC-HS256".into()),
900 ..Default::default()
901 }
902 .into(),
903 schemars::schema::SchemaObject {
905 metadata: Some(Box::new(schemars::schema::Metadata {
906 description: Some(
907 r"AES_192_CBC_HMAC_SHA_384 authenticated encryption algorithm".to_owned(),
909 ),
910 ..Default::default()
911 })),
912 const_value: Some("A192CBC-HS384".into()),
913 ..Default::default()
914 }
915 .into(),
916 schemars::schema::SchemaObject {
918 metadata: Some(Box::new(schemars::schema::Metadata {
919 description: Some(
920 r"AES_256_CBC_HMAC_SHA_512 authenticated encryption algorithm".to_owned(),
922 ),
923 ..Default::default()
924 })),
925 const_value: Some("A256CBC-HS512".into()),
926 ..Default::default()
927 }
928 .into(),
929 schemars::schema::SchemaObject {
931 metadata: Some(Box::new(schemars::schema::Metadata {
932 description: Some(
933 r"AES GCM using 128-bit key".to_owned(),
935 ),
936 ..Default::default()
937 })),
938 const_value: Some("A128GCM".into()),
939 ..Default::default()
940 }
941 .into(),
942 schemars::schema::SchemaObject {
944 metadata: Some(Box::new(schemars::schema::Metadata {
945 description: Some(
946 r"AES GCM using 192-bit key".to_owned(),
948 ),
949 ..Default::default()
950 })),
951 const_value: Some("A192GCM".into()),
952 ..Default::default()
953 }
954 .into(),
955 schemars::schema::SchemaObject {
957 metadata: Some(Box::new(schemars::schema::Metadata {
958 description: Some(
959 r"AES GCM using 256-bit key".to_owned(),
961 ),
962 ..Default::default()
963 })),
964 const_value: Some("A256GCM".into()),
965 ..Default::default()
966 }
967 .into(),
968 ];
969
970 let description = r#"JSON Web Encryption "enc" parameter"#;
971 schemars::schema::SchemaObject {
972 metadata: Some(Box::new(schemars::schema::Metadata {
973 description: Some(description.to_owned()),
974 ..Default::default()
975 })),
976 subschemas: Some(Box::new(schemars::schema::SubschemaValidation {
977 any_of: Some(enums),
978 ..Default::default()
979 })),
980 ..Default::default()
981 }
982 .into()
983 }
984}
985
986#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
990#[non_exhaustive]
991pub enum JsonWebEncryptionCompressionAlgorithm {
992 Def,
994
995 Unknown(String),
997}
998
999impl core::fmt::Display for JsonWebEncryptionCompressionAlgorithm {
1000 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1001 match self {
1002 Self::Def => write!(f, "DEF"),
1003 Self::Unknown(value) => write!(f, "{value}"),
1004 }
1005 }
1006}
1007
1008impl core::str::FromStr for JsonWebEncryptionCompressionAlgorithm {
1009 type Err = core::convert::Infallible;
1010
1011 fn from_str(s: &str) -> Result<Self, Self::Err> {
1012 match s {
1013 "DEF" => Ok(Self::Def),
1014 value => Ok(Self::Unknown(value.to_owned())),
1015 }
1016 }
1017}
1018
1019impl<'de> serde::Deserialize<'de> for JsonWebEncryptionCompressionAlgorithm {
1020 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1021 where
1022 D: serde::de::Deserializer<'de>,
1023 {
1024 let s = String::deserialize(deserializer)?;
1025 core::str::FromStr::from_str(&s).map_err(serde::de::Error::custom)
1026 }
1027}
1028
1029impl serde::Serialize for JsonWebEncryptionCompressionAlgorithm {
1030 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1031 where
1032 S: serde::ser::Serializer,
1033 {
1034 serializer.serialize_str(&self.to_string())
1035 }
1036}
1037
1038impl schemars::JsonSchema for JsonWebEncryptionCompressionAlgorithm {
1039 fn schema_name() -> String {
1040 "JsonWebEncryptionCompressionAlgorithm".to_owned()
1041 }
1042
1043 fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
1044 let enums = vec![
1045 schemars::schema::SchemaObject {
1047 metadata: Some(Box::new(schemars::schema::Metadata {
1048 description: Some(
1049 r"DEFLATE".to_owned(),
1051 ),
1052 ..Default::default()
1053 })),
1054 const_value: Some("DEF".into()),
1055 ..Default::default()
1056 }
1057 .into(),
1058 ];
1059
1060 let description = r"JSON Web Encryption Compression Algorithm";
1061 schemars::schema::SchemaObject {
1062 metadata: Some(Box::new(schemars::schema::Metadata {
1063 description: Some(description.to_owned()),
1064 ..Default::default()
1065 })),
1066 subschemas: Some(Box::new(schemars::schema::SubschemaValidation {
1067 any_of: Some(enums),
1068 ..Default::default()
1069 })),
1070 ..Default::default()
1071 }
1072 .into()
1073 }
1074}
1075
1076#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
1080#[non_exhaustive]
1081pub enum JsonWebKeyType {
1082 Ec,
1084
1085 Rsa,
1087
1088 Oct,
1090
1091 Okp,
1093
1094 Unknown(String),
1096}
1097
1098impl core::fmt::Display for JsonWebKeyType {
1099 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1100 match self {
1101 Self::Ec => write!(f, "EC"),
1102 Self::Rsa => write!(f, "RSA"),
1103 Self::Oct => write!(f, "oct"),
1104 Self::Okp => write!(f, "OKP"),
1105 Self::Unknown(value) => write!(f, "{value}"),
1106 }
1107 }
1108}
1109
1110impl core::str::FromStr for JsonWebKeyType {
1111 type Err = core::convert::Infallible;
1112
1113 fn from_str(s: &str) -> Result<Self, Self::Err> {
1114 match s {
1115 "EC" => Ok(Self::Ec),
1116 "RSA" => Ok(Self::Rsa),
1117 "oct" => Ok(Self::Oct),
1118 "OKP" => Ok(Self::Okp),
1119 value => Ok(Self::Unknown(value.to_owned())),
1120 }
1121 }
1122}
1123
1124impl<'de> serde::Deserialize<'de> for JsonWebKeyType {
1125 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1126 where
1127 D: serde::de::Deserializer<'de>,
1128 {
1129 let s = String::deserialize(deserializer)?;
1130 core::str::FromStr::from_str(&s).map_err(serde::de::Error::custom)
1131 }
1132}
1133
1134impl serde::Serialize for JsonWebKeyType {
1135 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1136 where
1137 S: serde::ser::Serializer,
1138 {
1139 serializer.serialize_str(&self.to_string())
1140 }
1141}
1142
1143impl schemars::JsonSchema for JsonWebKeyType {
1144 fn schema_name() -> String {
1145 "JsonWebKeyType".to_owned()
1146 }
1147
1148 fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
1149 let enums = vec![
1150 schemars::schema::SchemaObject {
1152 metadata: Some(Box::new(schemars::schema::Metadata {
1153 description: Some(
1154 r"Elliptic Curve".to_owned(),
1156 ),
1157 ..Default::default()
1158 })),
1159 const_value: Some("EC".into()),
1160 ..Default::default()
1161 }
1162 .into(),
1163 schemars::schema::SchemaObject {
1165 metadata: Some(Box::new(schemars::schema::Metadata {
1166 description: Some(
1167 r"RSA".to_owned(),
1169 ),
1170 ..Default::default()
1171 })),
1172 const_value: Some("RSA".into()),
1173 ..Default::default()
1174 }
1175 .into(),
1176 schemars::schema::SchemaObject {
1178 metadata: Some(Box::new(schemars::schema::Metadata {
1179 description: Some(
1180 r"Octet sequence".to_owned(),
1182 ),
1183 ..Default::default()
1184 })),
1185 const_value: Some("oct".into()),
1186 ..Default::default()
1187 }
1188 .into(),
1189 schemars::schema::SchemaObject {
1191 metadata: Some(Box::new(schemars::schema::Metadata {
1192 description: Some(
1193 r"Octet string key pairs".to_owned(),
1195 ),
1196 ..Default::default()
1197 })),
1198 const_value: Some("OKP".into()),
1199 ..Default::default()
1200 }
1201 .into(),
1202 ];
1203
1204 let description = r"JSON Web Key Type";
1205 schemars::schema::SchemaObject {
1206 metadata: Some(Box::new(schemars::schema::Metadata {
1207 description: Some(description.to_owned()),
1208 ..Default::default()
1209 })),
1210 subschemas: Some(Box::new(schemars::schema::SubschemaValidation {
1211 any_of: Some(enums),
1212 ..Default::default()
1213 })),
1214 ..Default::default()
1215 }
1216 .into()
1217 }
1218}
1219
1220#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
1224#[non_exhaustive]
1225pub enum JsonWebKeyEcEllipticCurve {
1226 P256,
1228
1229 P384,
1231
1232 P521,
1234
1235 Secp256K1,
1237
1238 Unknown(String),
1240}
1241
1242impl core::fmt::Display for JsonWebKeyEcEllipticCurve {
1243 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1244 match self {
1245 Self::P256 => write!(f, "P-256"),
1246 Self::P384 => write!(f, "P-384"),
1247 Self::P521 => write!(f, "P-521"),
1248 Self::Secp256K1 => write!(f, "secp256k1"),
1249 Self::Unknown(value) => write!(f, "{value}"),
1250 }
1251 }
1252}
1253
1254impl core::str::FromStr for JsonWebKeyEcEllipticCurve {
1255 type Err = core::convert::Infallible;
1256
1257 fn from_str(s: &str) -> Result<Self, Self::Err> {
1258 match s {
1259 "P-256" => Ok(Self::P256),
1260 "P-384" => Ok(Self::P384),
1261 "P-521" => Ok(Self::P521),
1262 "secp256k1" => Ok(Self::Secp256K1),
1263 value => Ok(Self::Unknown(value.to_owned())),
1264 }
1265 }
1266}
1267
1268impl<'de> serde::Deserialize<'de> for JsonWebKeyEcEllipticCurve {
1269 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1270 where
1271 D: serde::de::Deserializer<'de>,
1272 {
1273 let s = String::deserialize(deserializer)?;
1274 core::str::FromStr::from_str(&s).map_err(serde::de::Error::custom)
1275 }
1276}
1277
1278impl serde::Serialize for JsonWebKeyEcEllipticCurve {
1279 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1280 where
1281 S: serde::ser::Serializer,
1282 {
1283 serializer.serialize_str(&self.to_string())
1284 }
1285}
1286
1287impl schemars::JsonSchema for JsonWebKeyEcEllipticCurve {
1288 fn schema_name() -> String {
1289 "JsonWebKeyEcEllipticCurve".to_owned()
1290 }
1291
1292 fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
1293 let enums = vec![
1294 schemars::schema::SchemaObject {
1296 metadata: Some(Box::new(schemars::schema::Metadata {
1297 description: Some(
1298 r"P-256 Curve".to_owned(),
1300 ),
1301 ..Default::default()
1302 })),
1303 const_value: Some("P-256".into()),
1304 ..Default::default()
1305 }
1306 .into(),
1307 schemars::schema::SchemaObject {
1309 metadata: Some(Box::new(schemars::schema::Metadata {
1310 description: Some(
1311 r"P-384 Curve".to_owned(),
1313 ),
1314 ..Default::default()
1315 })),
1316 const_value: Some("P-384".into()),
1317 ..Default::default()
1318 }
1319 .into(),
1320 schemars::schema::SchemaObject {
1322 metadata: Some(Box::new(schemars::schema::Metadata {
1323 description: Some(
1324 r"P-521 Curve".to_owned(),
1326 ),
1327 ..Default::default()
1328 })),
1329 const_value: Some("P-521".into()),
1330 ..Default::default()
1331 }
1332 .into(),
1333 schemars::schema::SchemaObject {
1335 metadata: Some(Box::new(schemars::schema::Metadata {
1336 description: Some(
1337 r"SECG secp256k1 curve".to_owned(),
1339 ),
1340 ..Default::default()
1341 })),
1342 const_value: Some("secp256k1".into()),
1343 ..Default::default()
1344 }
1345 .into(),
1346 ];
1347
1348 let description = r"JSON Web Key EC Elliptic Curve";
1349 schemars::schema::SchemaObject {
1350 metadata: Some(Box::new(schemars::schema::Metadata {
1351 description: Some(description.to_owned()),
1352 ..Default::default()
1353 })),
1354 subschemas: Some(Box::new(schemars::schema::SubschemaValidation {
1355 any_of: Some(enums),
1356 ..Default::default()
1357 })),
1358 ..Default::default()
1359 }
1360 .into()
1361 }
1362}
1363
1364#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
1368#[non_exhaustive]
1369pub enum JsonWebKeyOkpEllipticCurve {
1370 Ed25519,
1372
1373 Ed448,
1375
1376 X25519,
1378
1379 X448,
1381
1382 Unknown(String),
1384}
1385
1386impl core::fmt::Display for JsonWebKeyOkpEllipticCurve {
1387 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1388 match self {
1389 Self::Ed25519 => write!(f, "Ed25519"),
1390 Self::Ed448 => write!(f, "Ed448"),
1391 Self::X25519 => write!(f, "X25519"),
1392 Self::X448 => write!(f, "X448"),
1393 Self::Unknown(value) => write!(f, "{value}"),
1394 }
1395 }
1396}
1397
1398impl core::str::FromStr for JsonWebKeyOkpEllipticCurve {
1399 type Err = core::convert::Infallible;
1400
1401 fn from_str(s: &str) -> Result<Self, Self::Err> {
1402 match s {
1403 "Ed25519" => Ok(Self::Ed25519),
1404 "Ed448" => Ok(Self::Ed448),
1405 "X25519" => Ok(Self::X25519),
1406 "X448" => Ok(Self::X448),
1407 value => Ok(Self::Unknown(value.to_owned())),
1408 }
1409 }
1410}
1411
1412impl<'de> serde::Deserialize<'de> for JsonWebKeyOkpEllipticCurve {
1413 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1414 where
1415 D: serde::de::Deserializer<'de>,
1416 {
1417 let s = String::deserialize(deserializer)?;
1418 core::str::FromStr::from_str(&s).map_err(serde::de::Error::custom)
1419 }
1420}
1421
1422impl serde::Serialize for JsonWebKeyOkpEllipticCurve {
1423 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1424 where
1425 S: serde::ser::Serializer,
1426 {
1427 serializer.serialize_str(&self.to_string())
1428 }
1429}
1430
1431impl schemars::JsonSchema for JsonWebKeyOkpEllipticCurve {
1432 fn schema_name() -> String {
1433 "JsonWebKeyOkpEllipticCurve".to_owned()
1434 }
1435
1436 fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
1437 let enums = vec![
1438 schemars::schema::SchemaObject {
1440 metadata: Some(Box::new(schemars::schema::Metadata {
1441 description: Some(
1442 r"Ed25519 signature algorithm key pairs".to_owned(),
1444 ),
1445 ..Default::default()
1446 })),
1447 const_value: Some("Ed25519".into()),
1448 ..Default::default()
1449 }
1450 .into(),
1451 schemars::schema::SchemaObject {
1453 metadata: Some(Box::new(schemars::schema::Metadata {
1454 description: Some(
1455 r"Ed448 signature algorithm key pairs".to_owned(),
1457 ),
1458 ..Default::default()
1459 })),
1460 const_value: Some("Ed448".into()),
1461 ..Default::default()
1462 }
1463 .into(),
1464 schemars::schema::SchemaObject {
1466 metadata: Some(Box::new(schemars::schema::Metadata {
1467 description: Some(
1468 r"X25519 function key pairs".to_owned(),
1470 ),
1471 ..Default::default()
1472 })),
1473 const_value: Some("X25519".into()),
1474 ..Default::default()
1475 }
1476 .into(),
1477 schemars::schema::SchemaObject {
1479 metadata: Some(Box::new(schemars::schema::Metadata {
1480 description: Some(
1481 r"X448 function key pairs".to_owned(),
1483 ),
1484 ..Default::default()
1485 })),
1486 const_value: Some("X448".into()),
1487 ..Default::default()
1488 }
1489 .into(),
1490 ];
1491
1492 let description = r"JSON Web Key OKP Elliptic Curve";
1493 schemars::schema::SchemaObject {
1494 metadata: Some(Box::new(schemars::schema::Metadata {
1495 description: Some(description.to_owned()),
1496 ..Default::default()
1497 })),
1498 subschemas: Some(Box::new(schemars::schema::SubschemaValidation {
1499 any_of: Some(enums),
1500 ..Default::default()
1501 })),
1502 ..Default::default()
1503 }
1504 .into()
1505 }
1506}
1507
1508#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
1512#[non_exhaustive]
1513pub enum JsonWebKeyUse {
1514 Sig,
1516
1517 Enc,
1519
1520 Unknown(String),
1522}
1523
1524impl core::fmt::Display for JsonWebKeyUse {
1525 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1526 match self {
1527 Self::Sig => write!(f, "sig"),
1528 Self::Enc => write!(f, "enc"),
1529 Self::Unknown(value) => write!(f, "{value}"),
1530 }
1531 }
1532}
1533
1534impl core::str::FromStr for JsonWebKeyUse {
1535 type Err = core::convert::Infallible;
1536
1537 fn from_str(s: &str) -> Result<Self, Self::Err> {
1538 match s {
1539 "sig" => Ok(Self::Sig),
1540 "enc" => Ok(Self::Enc),
1541 value => Ok(Self::Unknown(value.to_owned())),
1542 }
1543 }
1544}
1545
1546impl<'de> serde::Deserialize<'de> for JsonWebKeyUse {
1547 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1548 where
1549 D: serde::de::Deserializer<'de>,
1550 {
1551 let s = String::deserialize(deserializer)?;
1552 core::str::FromStr::from_str(&s).map_err(serde::de::Error::custom)
1553 }
1554}
1555
1556impl serde::Serialize for JsonWebKeyUse {
1557 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1558 where
1559 S: serde::ser::Serializer,
1560 {
1561 serializer.serialize_str(&self.to_string())
1562 }
1563}
1564
1565impl schemars::JsonSchema for JsonWebKeyUse {
1566 fn schema_name() -> String {
1567 "JsonWebKeyUse".to_owned()
1568 }
1569
1570 fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
1571 let enums = vec![
1572 schemars::schema::SchemaObject {
1574 metadata: Some(Box::new(schemars::schema::Metadata {
1575 description: Some(
1576 r"Digital Signature or MAC".to_owned(),
1578 ),
1579 ..Default::default()
1580 })),
1581 const_value: Some("sig".into()),
1582 ..Default::default()
1583 }
1584 .into(),
1585 schemars::schema::SchemaObject {
1587 metadata: Some(Box::new(schemars::schema::Metadata {
1588 description: Some(
1589 r"Encryption".to_owned(),
1591 ),
1592 ..Default::default()
1593 })),
1594 const_value: Some("enc".into()),
1595 ..Default::default()
1596 }
1597 .into(),
1598 ];
1599
1600 let description = r"JSON Web Key Use";
1601 schemars::schema::SchemaObject {
1602 metadata: Some(Box::new(schemars::schema::Metadata {
1603 description: Some(description.to_owned()),
1604 ..Default::default()
1605 })),
1606 subschemas: Some(Box::new(schemars::schema::SubschemaValidation {
1607 any_of: Some(enums),
1608 ..Default::default()
1609 })),
1610 ..Default::default()
1611 }
1612 .into()
1613 }
1614}
1615
1616#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
1620#[non_exhaustive]
1621pub enum JsonWebKeyOperation {
1622 Sign,
1624
1625 Verify,
1627
1628 Encrypt,
1630
1631 Decrypt,
1633
1634 WrapKey,
1636
1637 UnwrapKey,
1639
1640 DeriveKey,
1642
1643 DeriveBits,
1645
1646 Unknown(String),
1648}
1649
1650impl core::fmt::Display for JsonWebKeyOperation {
1651 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1652 match self {
1653 Self::Sign => write!(f, "sign"),
1654 Self::Verify => write!(f, "verify"),
1655 Self::Encrypt => write!(f, "encrypt"),
1656 Self::Decrypt => write!(f, "decrypt"),
1657 Self::WrapKey => write!(f, "wrapKey"),
1658 Self::UnwrapKey => write!(f, "unwrapKey"),
1659 Self::DeriveKey => write!(f, "deriveKey"),
1660 Self::DeriveBits => write!(f, "deriveBits"),
1661 Self::Unknown(value) => write!(f, "{value}"),
1662 }
1663 }
1664}
1665
1666impl core::str::FromStr for JsonWebKeyOperation {
1667 type Err = core::convert::Infallible;
1668
1669 fn from_str(s: &str) -> Result<Self, Self::Err> {
1670 match s {
1671 "sign" => Ok(Self::Sign),
1672 "verify" => Ok(Self::Verify),
1673 "encrypt" => Ok(Self::Encrypt),
1674 "decrypt" => Ok(Self::Decrypt),
1675 "wrapKey" => Ok(Self::WrapKey),
1676 "unwrapKey" => Ok(Self::UnwrapKey),
1677 "deriveKey" => Ok(Self::DeriveKey),
1678 "deriveBits" => Ok(Self::DeriveBits),
1679 value => Ok(Self::Unknown(value.to_owned())),
1680 }
1681 }
1682}
1683
1684impl<'de> serde::Deserialize<'de> for JsonWebKeyOperation {
1685 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1686 where
1687 D: serde::de::Deserializer<'de>,
1688 {
1689 let s = String::deserialize(deserializer)?;
1690 core::str::FromStr::from_str(&s).map_err(serde::de::Error::custom)
1691 }
1692}
1693
1694impl serde::Serialize for JsonWebKeyOperation {
1695 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1696 where
1697 S: serde::ser::Serializer,
1698 {
1699 serializer.serialize_str(&self.to_string())
1700 }
1701}
1702
1703impl schemars::JsonSchema for JsonWebKeyOperation {
1704 fn schema_name() -> String {
1705 "JsonWebKeyOperation".to_owned()
1706 }
1707
1708 fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
1709 let enums = vec![
1710 schemars::schema::SchemaObject {
1712 metadata: Some(Box::new(schemars::schema::Metadata {
1713 description: Some(
1714 r"Compute digital signature or MAC".to_owned(),
1716 ),
1717 ..Default::default()
1718 })),
1719 const_value: Some("sign".into()),
1720 ..Default::default()
1721 }
1722 .into(),
1723 schemars::schema::SchemaObject {
1725 metadata: Some(Box::new(schemars::schema::Metadata {
1726 description: Some(
1727 r"Verify digital signature or MAC".to_owned(),
1729 ),
1730 ..Default::default()
1731 })),
1732 const_value: Some("verify".into()),
1733 ..Default::default()
1734 }
1735 .into(),
1736 schemars::schema::SchemaObject {
1738 metadata: Some(Box::new(schemars::schema::Metadata {
1739 description: Some(
1740 r"Encrypt content".to_owned(),
1742 ),
1743 ..Default::default()
1744 })),
1745 const_value: Some("encrypt".into()),
1746 ..Default::default()
1747 }
1748 .into(),
1749 schemars::schema::SchemaObject {
1751 metadata: Some(Box::new(schemars::schema::Metadata {
1752 description: Some(
1753 r"Decrypt content and validate decryption, if applicable".to_owned(),
1755 ),
1756 ..Default::default()
1757 })),
1758 const_value: Some("decrypt".into()),
1759 ..Default::default()
1760 }
1761 .into(),
1762 schemars::schema::SchemaObject {
1764 metadata: Some(Box::new(schemars::schema::Metadata {
1765 description: Some(
1766 r"Encrypt key".to_owned(),
1768 ),
1769 ..Default::default()
1770 })),
1771 const_value: Some("wrapKey".into()),
1772 ..Default::default()
1773 }
1774 .into(),
1775 schemars::schema::SchemaObject {
1777 metadata: Some(Box::new(schemars::schema::Metadata {
1778 description: Some(
1779 r"Decrypt key and validate decryption, if applicable".to_owned(),
1781 ),
1782 ..Default::default()
1783 })),
1784 const_value: Some("unwrapKey".into()),
1785 ..Default::default()
1786 }
1787 .into(),
1788 schemars::schema::SchemaObject {
1790 metadata: Some(Box::new(schemars::schema::Metadata {
1791 description: Some(
1792 r"Derive key".to_owned(),
1794 ),
1795 ..Default::default()
1796 })),
1797 const_value: Some("deriveKey".into()),
1798 ..Default::default()
1799 }
1800 .into(),
1801 schemars::schema::SchemaObject {
1803 metadata: Some(Box::new(schemars::schema::Metadata {
1804 description: Some(
1805 r"Derive bits not to be used as a key".to_owned(),
1807 ),
1808 ..Default::default()
1809 })),
1810 const_value: Some("deriveBits".into()),
1811 ..Default::default()
1812 }
1813 .into(),
1814 ];
1815
1816 let description = r"JSON Web Key Operation";
1817 schemars::schema::SchemaObject {
1818 metadata: Some(Box::new(schemars::schema::Metadata {
1819 description: Some(description.to_owned()),
1820 ..Default::default()
1821 })),
1822 subschemas: Some(Box::new(schemars::schema::SubschemaValidation {
1823 any_of: Some(enums),
1824 ..Default::default()
1825 })),
1826 ..Default::default()
1827 }
1828 .into()
1829 }
1830}