Debian Codegraph @

others/mbedtls/tf-psa-crypto/drivers/pqcp/mldsa-native/examples/multilevel_build/README.md

raw
1 [//]: # (SPDX-License-Identifier: CC-BY-4.0)
2
3 # Multi-Level Build (C Backend)
4
5 This directory contains a minimal example for building mldsa-native with support for all three security levels
6 (ML-DSA-44, ML-DSA-65, ML-DSA-87), with level-independent code shared to reduce binary size.
7
8 ## Use Case
9
10 Use this approach when:
11 - You need multiple ML-DSA security levels in the same application
12 - You want to minimize code duplication across levels
13 - You want to build the mldsa-native C files separately, not as a single compilation unit.
14 - You're only using C (no native backends)
15
16 ## Components
17
18 1. mldsa-native source tree: [`mldsa/src/`](../../mldsa/src) and [`mldsa/src/fips202/`](../../mldsa/src/fips202)
19 2. A secure random number generator implementing [`randombytes.h`](../../mldsa/src/randombytes.h)
20 3. Your application source code
21
22 ## Configuration
23
24 The library is built 3 times into separate directories (`build/mldsa44`, `build/mldsa65`, `build/mldsa87`).
25
26 The configuration file [mldsa_native_config.h](mldsa_native/mldsa_native_config.h) sets:
27 - `MLD_CONFIG_MULTILEVEL_BUILD`: Enables multi-level build mode
28 - `MLD_CONFIG_NAMESPACE_PREFIX=mldsa`: Base prefix; level suffix added automatically
29 - `MLD_CONFIG_NO_SUPERCOP`: Disables the SUPERCOP API (crypto_sign*)
30
31 Build-time flags passed via CFLAGS:
32 - `MLD_CONFIG_PARAMETER_SET=44/65/87`: Selects the security level
33 - `MLD_CONFIG_MULTILEVEL_WITH_SHARED`: Set for ONE build (e.g., 44) to include shared code
34 - `MLD_CONFIG_MULTILEVEL_NO_SHARED`: Set for OTHER builds to exclude shared code
35
36 The resulting API functions are namespaced as:
37 - `mldsa44_keypair()`, `mldsa44_signature()`, `mldsa44_verify()`, ...
38 - `mldsa65_keypair()`, `mldsa65_signature()`, `mldsa65_verify()`, ...
39 - `mldsa87_keypair()`, `mldsa87_signature()`, `mldsa87_verify()`, ...
40
41 ## Usage
42
43 ```bash
44 make build # Build all three security levels
45 make run # Run the example
46 ```
47
48 ## Warning
49
50 The `randombytes()` implementation in `test_only_rng/` is for TESTING ONLY.
51 You MUST provide a cryptographically secure RNG for production use.