| 1 |
[//]: # (SPDX-License-Identifier: CC-BY-4.0) |
| 2 |
|
| 3 |
# Low RAM build |
| 4 |
|
| 5 |
This directory contains a minimal example for how to build mldsa-native with reduced RAM usage. |
| 6 |
|
| 7 |
## Use Case |
| 8 |
|
| 9 |
Use this approach when: |
| 10 |
- You are building for an embedded system with tight RAM constraints |
| 11 |
- You need to minimize stack usage |
| 12 |
- Performance is less critical than memory footprint |
| 13 |
|
| 14 |
## Configuration |
| 15 |
|
| 16 |
The `MLD_CONFIG_REDUCE_RAM` option enables optimizations that reduce RAM usage: |
| 17 |
- Uses unions for major allocations to reduce stack usage |
| 18 |
- Trades some performance for lower memory footprint |
| 19 |
|
| 20 |
## Components |
| 21 |
|
| 22 |
1. mldsa-native source tree: [`mldsa/src/`](../../mldsa/src) and [`mldsa/src/fips202/`](../../mldsa/src/fips202) |
| 23 |
2. A secure random number generator implementing [`randombytes.h`](../../mldsa/src/randombytes.h) |
| 24 |
3. Your application source code |
| 25 |
|
| 26 |
## Configuration |
| 27 |
|
| 28 |
The configuration file [mldsa_native_config.h](mldsa_native/mldsa_native_config.h) sets: |
| 29 |
- `MLD_CONFIG_PARAMETER_SET`: Security level (44, 65, or 87). Default is 65. |
| 30 |
- `MLD_CONFIG_NAMESPACE_PREFIX`: Symbol prefix for the API. Set to `mldsa` in this example. |
| 31 |
- `MLD_CONFIG_REDUCE_RAM`: Enables reduced RAM usage optimizations. |
| 32 |
|
| 33 |
To change the security level, modify `MLD_CONFIG_PARAMETER_SET` in the config file or pass it via CFLAGS. |
| 34 |
|
| 35 |
## Usage |
| 36 |
|
| 37 |
```bash |
| 38 |
make build # Build the example |
| 39 |
make run # Run the example |
| 40 |
``` |
| 41 |
|
| 42 |
## Warning |
| 43 |
|
| 44 |
The `randombytes()` implementation in `test_only_rng/` is for TESTING ONLY. |
| 45 |
You MUST provide a cryptographically secure RNG for production use. |