1use core::fmt;
4
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
9#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
10#[non_exhaustive]
11#[allow(missing_docs)]
12pub enum Algorithm {
13 RS256,
14 RS384,
15 RS512,
16 PS256,
18 PS384,
19 PS512,
20 ES256,
22 ES384,
23 ES512,
24 Ed25519,
26 Ed448,
27 EdDSA,
28}
29
30impl fmt::Display for Algorithm {
31 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32 match &self {
33 Self::RS256 => f.write_str("RS256"),
34 Self::RS384 => f.write_str("RS384"),
35 Self::RS512 => f.write_str("RS512"),
36 Self::PS256 => f.write_str("PS256"),
37 Self::PS384 => f.write_str("PS384"),
38 Self::PS512 => f.write_str("PS512"),
39 Self::ES256 => f.write_str("ES256"),
40 Self::ES384 => f.write_str("ES384"),
41 Self::ES512 => f.write_str("ES512"),
42 Self::Ed25519 => f.write_str("Ed25519"),
43 Self::Ed448 => f.write_str("Ed448"),
44 Self::EdDSA => f.write_str("EdDSA"),
45 }
46 }
47}
48
49#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
51#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
52#[non_exhaustive]
53#[allow(missing_docs)]
54pub enum Curve {
55 #[serde(rename = "P-256")]
56 P256,
57 #[serde(rename = "P-384")]
58 P384,
59 #[serde(rename = "P-521")]
60 P521,
61 Ed25519,
62 Ed448,
63}
64
65impl fmt::Display for Curve {
66 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
67 match &self {
68 Self::P256 => f.write_str("P-256"),
69 Self::P384 => f.write_str("P-384"),
70 Self::P521 => f.write_str("P-521"),
71 Self::Ed25519 => f.write_str("Ed25519"),
72 Self::Ed448 => f.write_str("Ed448"),
73 }
74 }
75}