Skip to content

Commit 64235d0

Browse files
committed
Add STDLIB.md
Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
1 parent 557f421 commit 64235d0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

STDLIB.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[//]: # (SPDX-License-Identifier: CC-BY-4.0)
2+
3+
# Standard Library Dependencies
4+
5+
mldsa-native has minimal dependencies on the C standard library. This document lists all stdlib functions used and configuration options for custom replacements.
6+
7+
## Dependencies
8+
9+
### Memory Functions
10+
- **memcpy**: Used extensively for copying data structures, keys, and intermediate values (40+ occurrences)
11+
- **memset**: Used for zeroing state structures and buffers (3 occurrences). **Note**: This is NOT used for security-critical zeroing - that is handled by `mld_zeroize` which has its own custom replacement mechanism
12+
13+
### Debug Functions (MLDSA_DEBUG builds only)
14+
- **fprintf**: Used in debug.c for error reporting to stderr
15+
- **exit**: Used in debug.c to terminate on assertion failures
16+
17+
## Custom Replacements
18+
19+
Custom replacements can be provided for memory functions using the configuration options in `mldsa/src/config.h`:
20+
21+
### MLD_CONFIG_CUSTOM_MEMCPY
22+
Replaces all `memcpy` calls with a custom implementation. When enabled, you must define a `mld_memcpy` function with the same signature as the standard `memcpy`.
23+
24+
### MLD_CONFIG_CUSTOM_MEMSET
25+
Replaces all `memset` calls with a custom implementation. When enabled, you must define a `mld_memset` function with the same signature as the standard `memset`.
26+
27+
See the configuration examples in `mldsa/src/config.h` and test configurations in `test/custom_*_config.h` for usage examples and implementation requirements.

0 commit comments

Comments
 (0)