#[non_exhaustive]pub enum JwsAlgorithm {
EdDSA,
ES256,
ES256K,
ES384,
RS256,
PS256,
}Expand description
A JWS digital signature algorithm (RFC 7518 §3.1, RFC 8037 §3.1, RFC 8812 §3.2).
Only asymmetric algorithms are listed: a DID controller signs with a private key and anyone
resolves the public key, so HMAC and none have no place here. Conversions to and from
jsonwebtoken::Algorithm are fallible in both directions because jsonwebtoken has HMAC
variants this type lacks and lacks ES256K.
The Display and FromStr forms are the IANA “JSON Web Signature and Encryption Algorithms”
names, and the type serializes as that string.
§Examples
use identity_kit::jose::JwsAlgorithm;
let alg: JwsAlgorithm = "ES256".parse()?;
assert_eq!(alg, JwsAlgorithm::ES256);
assert_eq!(alg.to_string(), "ES256");
assert_eq!(serde_json::to_string(&alg)?, "\"ES256\"");
assert!("HS256".parse::<JwsAlgorithm>().is_err());
assert!("none".parse::<JwsAlgorithm>().is_err());Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
EdDSA
EdDSA with Ed25519 (RFC 8037).
ES256
ECDSA with P-256 and SHA-256 (RFC 7518 §3.4). Verification accepts s and n - s
alike, as JOSE allows, so a JWS’s bytes do not identify it; see
DefaultVerifier.
ES256K
ECDSA with secp256k1 and SHA-256 (RFC 8812 §3.2). Verification accepts only the lower of
s and n - s.
ES384
ECDSA with P-384 and SHA-384 (RFC 7518 §3.4).
RS256
RSASSA-PKCS1-v1_5 with SHA-256 (RFC 7518 §3.3), with a key of at least 2048 bits.
PS256
RSASSA-PSS with SHA-256 and MGF1 with SHA-256 (RFC 7518 §3.5), with a key of at least 2048 bits.
Implementations§
Source§impl JwsAlgorithm
impl JwsAlgorithm
Sourcepub const ALL: &'static [JwsAlgorithm]
pub const ALL: &'static [JwsAlgorithm]
Every algorithm this type knows, in declaration order.
Trait Implementations§
Source§impl Clone for JwsAlgorithm
impl Clone for JwsAlgorithm
impl Copy for JwsAlgorithm
Source§impl Debug for JwsAlgorithm
impl Debug for JwsAlgorithm
Source§impl<'de> Deserialize<'de> for JwsAlgorithm
impl<'de> Deserialize<'de> for JwsAlgorithm
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for JwsAlgorithm
impl Display for JwsAlgorithm
impl Eq for JwsAlgorithm
Source§impl FromStr for JwsAlgorithm
impl FromStr for JwsAlgorithm
Source§impl Hash for JwsAlgorithm
impl Hash for JwsAlgorithm
Source§impl Ord for JwsAlgorithm
impl Ord for JwsAlgorithm
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for JwsAlgorithm
impl PartialEq for JwsAlgorithm
Source§impl PartialOrd for JwsAlgorithm
impl PartialOrd for JwsAlgorithm
Source§impl PartialSchema for JwsAlgorithm
Available on crate feature utoipa only.
impl PartialSchema for JwsAlgorithm
utoipa only.Source§impl Serialize for JwsAlgorithm
impl Serialize for JwsAlgorithm
impl StructuralPartialEq for JwsAlgorithm
Source§impl ToSchema for JwsAlgorithm
Available on crate feature utoipa only.
impl ToSchema for JwsAlgorithm
utoipa only.Source§impl TryFrom<Algorithm> for JwsAlgorithm
impl TryFrom<Algorithm> for JwsAlgorithm
Source§impl TryFrom<JwsAlgorithm> for Algorithm
impl TryFrom<JwsAlgorithm> for Algorithm
Source§fn try_from(alg: JwsAlgorithm) -> Result<Self, Self::Error>
fn try_from(alg: JwsAlgorithm) -> Result<Self, Self::Error>
Fails for JwsAlgorithm::ES256K, which jsonwebtoken does not implement.
Source§type Error = UnknownAlgorithm
type Error = UnknownAlgorithm
Auto Trait Implementations§
impl Freeze for JwsAlgorithm
impl RefUnwindSafe for JwsAlgorithm
impl Send for JwsAlgorithm
impl Sync for JwsAlgorithm
impl Unpin for JwsAlgorithm
impl UnsafeUnpin for JwsAlgorithm
impl UnwindSafe for JwsAlgorithm
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.