pub struct PqdsaKeyPair {
algorithm: &'static PqdsaSigningAlgorithm,
evp_pkey: ManagedPointer<*mut EVP_PKEY>,
pubkey: PublicKey,
}Expand description
A PQDSA (Post-Quantum Digital Signature Algorithm) key pair, used for signing and verification.
Fields§
§algorithm: &'static PqdsaSigningAlgorithm§evp_pkey: ManagedPointer<*mut EVP_PKEY>§pubkey: PublicKeyImplementations§
Source§impl PqdsaKeyPair
impl PqdsaKeyPair
Sourcepub fn generate(
algorithm: &'static PqdsaSigningAlgorithm,
) -> Result<Self, Unspecified>
pub fn generate( algorithm: &'static PqdsaSigningAlgorithm, ) -> Result<Self, Unspecified>
Generates a new PQDSA key pair for the specified algorithm.
§Errors
Returns Unspecified if the key generation fails.
Sourcepub fn from_pkcs8(
algorithm: &'static PqdsaSigningAlgorithm,
pkcs8: &[u8],
) -> Result<Self, KeyRejected>
pub fn from_pkcs8( algorithm: &'static PqdsaSigningAlgorithm, pkcs8: &[u8], ) -> Result<Self, KeyRejected>
Constructs a key pair from the parsing of PKCS#8.
This accepts either the seed or expanded private key encodings. If both are present in the input, they are validated to agree with each other.
§Errors
Returns Unspecified if the key is not valid for the specified signing algorithm.
Sourcepub fn from_raw_private_key(
algorithm: &'static PqdsaSigningAlgorithm,
raw_private_key: &[u8],
) -> Result<Self, KeyRejected>
pub fn from_raw_private_key( algorithm: &'static PqdsaSigningAlgorithm, raw_private_key: &[u8], ) -> Result<Self, KeyRejected>
Constructs a key pair from raw private key bytes.
This expects the expanded form of the raw private key bytes.
§Errors
Returns Unspecified if the key is not valid for the specified signing algorithm.
Sourcepub fn from_seed(
algorithm: &'static PqdsaSigningAlgorithm,
seed: &[u8],
) -> Result<Self, KeyRejected>
pub fn from_seed( algorithm: &'static PqdsaSigningAlgorithm, seed: &[u8], ) -> Result<Self, KeyRejected>
Constructs a key pair deterministically from a 32-byte seed.
Per FIPS 204, the same seed always produces the same key pair. This enables reproducible key generation for testing, ACVP validation, and interoperability with implementations that store seeds rather than expanded private keys.
algorithm is the PqdsaSigningAlgorithm to be associated with the key pair.
seed is the 32-byte seed from which the key pair is deterministically derived.
All ML-DSA variants (ML-DSA-44, ML-DSA-65, ML-DSA-87) use 32-byte seeds.
§Security Considerations
The seed is the root secret. Compromise of the seed is equivalent to compromise of the private key. Callers are responsible for generating seeds from a cryptographically secure random source and protecting them accordingly.
The seed should be produced from random entropy such as through crate::rand::fill.
However, for users requiring FIPS, the seed must be produced from
Self::generate. The Self::to_pkcs8v1 method serializes the private key in seed form.
AWS-LC keeps the seed in the internal representation when possible, but if PqdsaKeyPair
is constructed from the expanded form (via Self::from_raw_private_key) the seed cannot
be obtained and Self::to_pkcs8v1 will fail.
This method expands the seed into the full private key internally. The expanded private key
can be retrieved via Self::private_key and serialized via
PqdsaPrivateKey::as_raw_bytes.
§Errors
Returns KeyRejected::too_small() if seed.len() < 32.
Returns KeyRejected::too_large() if seed.len() > 32.
Returns KeyRejected::unspecified() if the underlying cryptographic operation fails.
Sourcepub fn to_pkcs8v1(&self) -> Result<Document, Unspecified>
pub fn to_pkcs8v1(&self) -> Result<Document, Unspecified>
Serializes the private key to PKCS#8 v1 DER.
This currently serializes the seed. If the seed is not available (for example when this
PqdsaKeyPair was constructed from the expanded private key via
Self::from_raw_private_key), serialization fails and this currently returns an error. A
future implementation may encode the expanded form of the key instead.
§Errors
Returns Unspecified if serialization fails.
Sourcepub fn sign(
&self,
msg: &[u8],
signature: &mut [u8],
) -> Result<usize, Unspecified>
pub fn sign( &self, msg: &[u8], signature: &mut [u8], ) -> Result<usize, Unspecified>
Uses this key to sign the message provided. The signature is written to the signature
slice provided, which must be at least PqdsaSigningAlgorithm::signature_len bytes
long. It returns the length of the signature on success.
§Errors
Returns Unspecified if signature is too small or if signing fails.
Sourcepub fn algorithm(&self) -> &'static PqdsaSigningAlgorithm
pub fn algorithm(&self) -> &'static PqdsaSigningAlgorithm
Returns the signing algorithm associated with this key pair.
Sourcepub fn private_key(&self) -> PqdsaPrivateKey<'_>
pub fn private_key(&self) -> PqdsaPrivateKey<'_>
Returns the private key associated with this key pair.