oa::crypto::pqc::device
Module published by the oa::crypto::pqc module.
MdRust public API
Public Types
Public Functions
pub fn mldsa_import_key( engine: &Engine, parameters: MlDsaParameters, secret_key: &mut [u8], public_key: &Matrix, ) -> Result<DeviceMlDsaKey>pub fn mldsa_sign( key: &DeviceMlDsaKey, message: &Matrix, context: &Matrix, mode: SigningMode, ) -> Result<DeviceSignature>pub fn mldsa_sign_hash_message( key: &DeviceMlDsaKey, message: &Matrix, context: &Matrix, algorithm: MlDsaPrehash, mode: SigningMode, ) -> Result<DeviceSignature>pub fn mldsa_sign_prehashed( key: &DeviceMlDsaKey, digest: &Matrix, context: &Matrix, algorithm: MlDsaPrehash, mode: SigningMode, ) -> Result<DeviceSignature>pub fn mldsa_verify_hash_message( parameters: MlDsaParameters, algorithm: MlDsaPrehash, messages: &Matrix, offsets: &Matrix, lengths: &Matrix, signatures: &Matrix, public_keys: &Matrix, context: Range<usize>, ) -> Result<Matrix>pub fn mldsa_verify_prehashed( parameters: MlDsaParameters, algorithm: MlDsaPrehash, digests: &Matrix, offsets: &Matrix, lengths: &Matrix, signatures: &Matrix, public_keys: &Matrix, context: Range<usize>, ) -> Result<Matrix>pub fn mlkem_decapsulate( key: &DeviceMlKemKey, ciphertext: &Matrix, ) -> Result<DeviceDecapsulation>pub fn mlkem_encapsulate( public_key: &Matrix, parameters: MlKemParameters, ) -> Result<DeviceEncapsulation>Function Documentation
Begin a deferred secret-execution batch on engine. Errors Rejects an active capture or a second concurrent scope.
Import FIPS 204 signing-key bytes with their encoded public U8 key. The secret input range is locked best-effort and erased before return; its upload becomes the retained device secret. Importing does not prove that the secret and public halves form a consistent key pair. Errors Rejects extent/ownership mismatches, capture, or submission errors.
Generate a retained ML-DSA-44/65/87 key from fresh OS entropy. Errors Rejects unsupported kernels, capture, allocation, entropy, or submission errors.
Sign public U8 message bytes with the FIPS 204 context (at most 255 bytes). Inputs retain the key’s Engine; neither input is copied to host. Errors Rejects dtype/ownership/alias/context errors, capture, or execution failure.
Hash and sign original public U8 message bytes on device (HashML-DSA). Errors Rejects dtype/ownership/alias/context errors, capture, or execution failure.
Sign an exact-length public digest with FIPS HashML-DSA OID framing. Errors Rejects digest/context metadata, owner/alias mismatch, capture, or execution errors.
Verify HashML-DSA original-message batches with a typed hash identity. Errors Rejects incompatible metadata; malformed signature rows produce zero status.
Verify precomputed-digest batches with exact typed FIPS hash extents. Errors Rejects incompatible metadata; invalid digest/signature rows produce zero.
Decapsulate a correct-size public ciphertext using a retained device key. Errors Rejects dtype/owner/extent, capture, or execution errors. Ciphertext content rejection produces an opaque replacement secret, never an error or flag.
Encapsulate to a public U8 key. Canonicality is checked on device. Errors Rejects key dtype/owner/extent, capture, entropy, or execution errors.
Import FIPS 203 decapsulation-key bytes. The embedded encapsulation key supplies the retained public value; the secret input range is locked best-effort and erased before return. Importing does not prove that the decapsulation key is well-formed. Errors Rejects extent mismatches, capture, or submission errors.
Generate a retained ML-KEM-512/768/1024 key from fresh OS entropy. Errors Rejects unsupported kernels, capture, allocation, entropy, or submission errors.
Declassify public bytes derived from a device shared secret. The secret never leaves private storage; keyed SHAKE-256 output is the only result. info is public customization data absorbed after the secret; length must be a nonzero multiple of four within 4096 bytes. Errors Rejects dtype/owner/extent errors, capture, or execution failure.