You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit extends the config to allow customization of
mlkem-native's dependencies on the stdlib: memset and memcpy.
It follows the same mechanism used for zeroize and randombytes.
Custom test configs are added illustrating how the new options work,
and they are exercised in CI.
Further, STDLIB.md is added, documenting the dependencies on the stdlib
and pointing to the customization mechanism.
Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
mlkem-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 `mlk_zeroize` which has its own custom replacement mechanism
12
+
13
+
### Debug Functions (MLKEM_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 `mlkem/src/config.h`:
20
+
21
+
### MLK_CONFIG_CUSTOM_MEMCPY
22
+
Replaces all `memcpy` calls with a custom implementation. When enabled, you must define a `mlk_memcpy` function with the same signature as the standard `memcpy`.
23
+
24
+
### MLK_CONFIG_CUSTOM_MEMSET
25
+
Replaces all `memset` calls with a custom implementation. When enabled, you must define a `mlk_memset` function with the same signature as the standard `memset`.
26
+
27
+
See the configuration examples in `mlkem/src/config.h` and test configurations in `test/custom_*_config.h` for usage examples and implementation requirements.
0 commit comments