Skip to main content

MlDsa44Key

Struct MlDsa44Key 

Source
pub struct MlDsa44Key { /* private fields */ }
Expand description

An ML-DSA-44 private key for mldsa44 signing (DKIM2 only, draft-ietf-dkim-dkim2-spec Section 3.4).

Signatures use “pure” ML-DSA-44 (FIPS 204) with the DKIM2 context string. They are hedged (randomized), as the specification recommends, so signing the same input twice gives different signatures.

Implementations§

Source§

impl MlDsa44Key

Source

pub fn generate_pkcs8() -> Result<Vec<u8>>

Generates a new random key and returns it as PKCS #8 DER bytes (the RFC 9881 seed-only private key encoding), ready for from_pkcs8_der.

§Errors

Returns Error::Crypto with CryptoError::Library if the system random number generator fails.

Source

pub fn from_pkcs8_der(pkcs8_der: &[u8]) -> Result<Self>

Loads a key from PKCS #8 DER bytes holding an ML-DSA-44 private key in the RFC 9881 seed-only or both (seed and expanded key) form. The key is derived from the seed.

§Errors

Returns Error::Crypto with CryptoError::Library if the key cannot be decoded or has no seed.

Source

pub fn from_raw_private_key(raw: &[u8]) -> Result<Self>

Loads a key from its 32-byte seed.

§Errors

Returns Error::Crypto with CryptoError::Library if the seed has the wrong length or cannot be expanded.

Source

pub fn public_key(&self) -> Result<Vec<u8>>

Returns the 1312-byte ML-DSA-44 public key, as published in the p= tag of a k=mldsa44 key record.

§Errors

Returns Error::Crypto with CryptoError::Library if the backend cannot export the public key.

Trait Implementations§

Source§

impl From<MlDsa44Key> for DkimKey

Available on crate features aws-lc-rs or rust-crypto only.
Source§

fn from(key: MlDsa44Key) -> Self

Converts to this type from the input type.
Source§

impl SigningKey for MlDsa44Key

Source§

type Hasher = Sha256

The hash function used by the signature algorithm.
Source§

fn sign(&self, input: impl Writable) -> Result<Vec<u8>>

Signs the bytes written by input and returns the raw signature. Read more
Source§

fn algorithm(&self) -> Algorithm

Returns the signature algorithm written to the a= tag.
Source§

fn heap_size(&self) -> usize

Approximate heap memory owned by the key, in bytes, for weighing cache entries that hold it.
Source§

fn hash(&self, data: impl Writable) -> HashOutput

Hashes the bytes written by data with Self::Hasher.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more