Skip to main content

decode_mldsa_pkcs8_der

Function decode_mldsa_pkcs8_der 

Source
pub fn decode_mldsa_pkcs8_der(der: &[u8]) -> Result<MlDsaPrivateKey, Pkcs8Error>
Expand description

Decodes a PKCS#8 PrivateKeyInfo DER containing an ML-DSA private key.

Supports ML-DSA-44, ML-DSA-65 and ML-DSA-87 in the seed and both forms defined by RFC 9881. If the optional [1] public key is present it is checked against the key derived from the seed. When the both form is used, the seed is retained and the embedded expanded key is not compared against it (RFC 9881’s seed-consistency check is optional).

Returns Pkcs8Error::MlDsaExpandedKeyNotSupported when the key is stored purely in expanded form (the seed cannot be recovered), and other Pkcs8Error variants when the structure is malformed or the algorithm is not ML-DSA.