| 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. |