#[non_exhaustive]pub enum HashAlgorithm {
Sha256,
Sha384,
Sha512,
}Available on crate feature
sd-jwt only.Expand description
The hash algorithm an SD-JWT uses for its disclosure digests and its sd_hash, named as
in the IANA “Named Information Hash Algorithm” registry (sha-256, the default and the
one every implementation must support, sha-384 or sha-512).
§Examples
use identity_kit::sd_jwt_vc::HashAlgorithm;
// RFC 9901 §4.2.3: the digest of the `family_name` disclosure.
let disclosure = "WyJfMjZiYzRMVC1hYzZxMktJNmNCVzVlcyIsICJmYW1pbHlfbmFtZSIsICJNw7ZiaXVzIl0";
assert_eq!(
HashAlgorithm::Sha256.digest(disclosure.as_bytes()),
"X9yH0Ajrdm1Oij4tWso9UzzKJvPoDxwmuEcO3XAdRC0"
);
assert_eq!("sha-256".parse::<HashAlgorithm>()?, HashAlgorithm::Sha256);
assert!("md5".parse::<HashAlgorithm>().is_err());Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Implementations§
Source§impl HashAlgorithm
impl HashAlgorithm
Sourcepub fn parse(name: &str) -> Result<Self, SdJwtError>
pub fn parse(name: &str) -> Result<Self, SdJwtError>
The algorithm with the IANA hash name name.
§Errors
SdJwtError::UnsupportedHashAlgorithm for any other name.
Trait Implementations§
Source§impl Clone for HashAlgorithm
impl Clone for HashAlgorithm
impl Copy for HashAlgorithm
Source§impl Debug for HashAlgorithm
impl Debug for HashAlgorithm
Source§impl Default for HashAlgorithm
impl Default for HashAlgorithm
Source§impl<'de> Deserialize<'de> for HashAlgorithm
impl<'de> Deserialize<'de> for HashAlgorithm
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for HashAlgorithm
impl Display for HashAlgorithm
impl Eq for HashAlgorithm
Source§impl FromStr for HashAlgorithm
impl FromStr for HashAlgorithm
Source§impl Hash for HashAlgorithm
impl Hash for HashAlgorithm
Source§impl PartialEq for HashAlgorithm
impl PartialEq for HashAlgorithm
Source§impl Serialize for HashAlgorithm
impl Serialize for HashAlgorithm
impl StructuralPartialEq for HashAlgorithm
Auto Trait Implementations§
impl Freeze for HashAlgorithm
impl RefUnwindSafe for HashAlgorithm
impl Send for HashAlgorithm
impl Sync for HashAlgorithm
impl Unpin for HashAlgorithm
impl UnsafeUnpin for HashAlgorithm
impl UnwindSafe for HashAlgorithm
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
Compare self to
key and return true if they are equal.