mldsa-native-rs 0.0.1-alpha.6

FFI bindings and optional wrapper for the mldsa-native ML-DSA implementation
Documentation
#![doc = include_str!("../README.md")]
//!
//! # About `randombytes`
//!
//! Consumers of this crate must provide a `randombytes`
//! function whose exported symbol matches the value of
//! [`crate::randombytes::RANDOMBYTES_INTERNAL_NAME`].
//! The [`crate::randombytes`] module provides helpers and further
//! details.
//!
//! **This function is at the FFI boundary with the backend C
//! implementation, and must adhere to the expected C ABI and
//! semantics.**
//!
//! Consumers who do not wish to provide their own implementation may
//! enable **both** the `rand` and `extern-C-randombytes` Cargo
//! features.
//! This makes the crate self-contained by exporting a default
//! implementation backed by [`rand::fill`].
//!
//! ### Security
//!
//! The `randombytes` function is a critical cryptographic dependency.
//! It must produce fresh, unpredictable bytes from a cryptographically
//! secure random number generator (CSPRNG).
//!
//! Any weakness in the provided randomness source directly compromises
//! the security of all non-deterministic operations performed by
//! `mldsa-native`.

/// Bindings to the underlying functions and constants from mldsa-native.
///
/// This module also re-exports the C types from [`core::ffi`] for convenience.
pub mod ffi {
    #![allow(non_upper_case_globals)]
    #![allow(non_camel_case_types)]
    #![allow(non_snake_case)]

    include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

    // C types (c_int etc.)
    pub use core::ffi::*;

    /// The return code that indicates a successful operation.
    pub const SUCCESS: c_int = 0;

    /// The return code that indicates a failed operation.
    pub const FAILURE: c_int = -1;
}

pub mod randombytes;

#[cfg(feature = "wrapper")]
mod wrapper;
#[cfg(feature = "wrapper")]
pub use wrapper::*;

#[cfg(feature = "native")]
mod cpufeatures;

#[cfg(feature = "built_info")]
pub mod built_info;