|
52 | 52 | 44 /* Change this for different security strengths */ |
53 | 53 | #endif |
54 | 54 |
|
| 55 | +/****************************************************************************** |
| 56 | + * Name: MLD_CONFIG_FILE |
| 57 | + * |
| 58 | + * Description: If defined, this is a header that will be included instead |
| 59 | + * of the default configuration file mldsa/src/config.h. |
| 60 | + * |
| 61 | + * When you need to build mldsa-native in multiple configurations, |
| 62 | + * using varying MLD_CONFIG_FILE can be more convenient |
| 63 | + * then configuring everything through CFLAGS. |
| 64 | + * |
| 65 | + * To use, MLD_CONFIG_FILE _must_ be defined prior |
| 66 | + * to the inclusion of any mldsa-native headers. For example, |
| 67 | + * it can be set by passing `-DMLD_CONFIG_FILE="..."` |
| 68 | + * on the command line. |
| 69 | + * |
| 70 | + *****************************************************************************/ |
| 71 | +/* No need to set this -- we _are_ already in a custom config */ |
| 72 | +/* #define MLD_CONFIG_FILE "config.h" */ |
| 73 | + |
55 | 74 | /****************************************************************************** |
56 | 75 | * Name: MLD_CONFIG_NAMESPACE_PREFIX |
57 | 76 | * |
|
115 | 134 | *****************************************************************************/ |
116 | 135 | /* #define MLD_CONFIG_MULTILEVEL_NO_SHARED */ |
117 | 136 |
|
118 | | -/****************************************************************************** |
119 | | - * Name: MLD_CONFIG_FILE |
120 | | - * |
121 | | - * Description: If defined, this is a header that will be included instead |
122 | | - * of the default configuration file mldsa/src/config.h. |
123 | | - * |
124 | | - * When you need to build mldsa-native in multiple configurations, |
125 | | - * using varying MLD_CONFIG_FILE can be more convenient |
126 | | - * then configuring everything through CFLAGS. |
127 | | - * |
128 | | - * To use, MLD_CONFIG_FILE _must_ be defined prior |
129 | | - * to the inclusion of any mldsa-native headers. For example, |
130 | | - * it can be set by passing `-DMLD_CONFIG_FILE="..."` |
131 | | - * on the command line. |
132 | | - * |
133 | | - *****************************************************************************/ |
134 | | -/* No need to set this -- we _are_ already in a custom config */ |
135 | | -/* #define MLD_CONFIG_FILE "config.h" */ |
136 | 137 |
|
137 | 138 | /****************************************************************************** |
138 | 139 | * Name: MLD_CONFIG_USE_NATIVE_BACKEND_ARITH |
|
216 | 217 | !defined(MLD_CONFIG_FIPS202_BACKEND_FILE) |
217 | 218 | #define MLD_CONFIG_FIPS202_BACKEND_FILE "fips202/native/auto.h" |
218 | 219 | #endif |
| 220 | + |
219 | 221 | /****************************************************************************** |
220 | 222 | * Name: MLD_CONFIG_FIPS202_CUSTOM_HEADER |
221 | 223 | * |
|
289 | 291 | #endif |
290 | 292 | */ |
291 | 293 |
|
292 | | -/****************************************************************************** |
293 | | - * Name: MLD_CONFIG_CUSTOM_MEMCPY |
294 | | - * |
295 | | - * Description: Set this option and define `mld_memcpy` if you want to |
296 | | - * use a custom method to copy memory instead of the standard |
297 | | - * library memcpy function. |
298 | | - * |
299 | | - * The custom implementation must have the same signature and |
300 | | - * behavior as the standard memcpy function: |
301 | | - * void *mld_memcpy(void *dest, const void *src, size_t n) |
302 | | - * |
303 | | - *****************************************************************************/ |
304 | | -/* #define MLD_CONFIG_CUSTOM_MEMCPY |
305 | | - #if !defined(__ASSEMBLER__) |
306 | | - #include <stdint.h> |
307 | | - #include "sys.h" |
308 | | - static MLD_INLINE void *mld_memcpy(void *dest, const void *src, size_t n) |
309 | | - { |
310 | | - ... your implementation ... |
311 | | - } |
312 | | - #endif |
313 | | -*/ |
314 | | - |
315 | | -/****************************************************************************** |
316 | | - * Name: MLD_CONFIG_CUSTOM_MEMSET |
317 | | - * |
318 | | - * Description: Set this option and define `mld_memset` if you want to |
319 | | - * use a custom method to set memory instead of the standard |
320 | | - * library memset function. |
321 | | - * |
322 | | - * The custom implementation must have the same signature and |
323 | | - * behavior as the standard memset function: |
324 | | - * void *mld_memset(void *s, int c, size_t n) |
325 | | - * |
326 | | - *****************************************************************************/ |
327 | | -/* #define MLD_CONFIG_CUSTOM_MEMSET |
328 | | - #if !defined(__ASSEMBLER__) |
329 | | - #include <stdint.h> |
330 | | - #include "sys.h" |
331 | | - static MLD_INLINE void *mld_memset(void *s, int c, size_t n) |
332 | | - { |
333 | | - ... your implementation ... |
334 | | - } |
335 | | - #endif |
336 | | -*/ |
337 | | - |
338 | 294 | /****************************************************************************** |
339 | 295 | * Name: MLD_CONFIG_CUSTOM_RANDOMBYTES |
340 | 296 | * |
|
361 | 317 | #endif |
362 | 318 | */ |
363 | 319 |
|
364 | | - |
365 | 320 | /****************************************************************************** |
366 | 321 | * Name: MLD_CONFIG_CUSTOM_CAPABILITY_FUNC |
367 | 322 | * |
|
392 | 347 | */ |
393 | 348 |
|
394 | 349 | /****************************************************************************** |
395 | | - * Name: MLD_CONFIG_NO_RANDOMIZED_API |
396 | | - * |
397 | | - * Description: If this option is set, mldsa-native will be built without the |
398 | | - * randomized API functions (crypto_sign_keypair, |
399 | | - * crypto_sign, crypto_sign_signature, and |
400 | | - * crypto_sign_signature_extmu). |
401 | | - * This allows users to build mldsa-native without providing a |
402 | | - * randombytes() implementation if they only need the |
403 | | - * internal deterministic API |
404 | | - * (crypto_sign_keypair_internal, crypto_sign_signature_internal). |
405 | | - * |
406 | | - * NOTE: This option is incompatible with MLD_CONFIG_KEYGEN_PCT |
407 | | - * as the current PCT implementation requires |
408 | | - * crypto_sign_signature(). |
409 | | - * |
410 | | - *****************************************************************************/ |
411 | | -#define MLD_CONFIG_NO_RANDOMIZED_API |
412 | | - |
413 | | -/****************************************************************************** |
414 | | - * Name: MLD_CONFIG_KEYGEN_PCT |
415 | | - * |
416 | | - * Description: Compliance with @[FIPS140_3_IG, p.87] requires a |
417 | | - * Pairwise Consistency Test (PCT) to be carried out on a freshly |
418 | | - * generated keypair before it can be exported. |
| 350 | + * Name: MLD_CONFIG_CUSTOM_MEMCPY |
419 | 351 | * |
420 | | - * Set this option if such a check should be implemented. |
421 | | - * In this case, crypto_sign_keypair_internal and |
422 | | - * crypto_sign_keypair will return a non-zero error code if the |
423 | | - * PCT failed. |
| 352 | + * Description: Set this option and define `mld_memcpy` if you want to |
| 353 | + * use a custom method to copy memory instead of the standard |
| 354 | + * library memcpy function. |
424 | 355 | * |
425 | | - * NOTE: This feature will drastically lower the performance of |
426 | | - * key generation. |
| 356 | + * The custom implementation must have the same signature and |
| 357 | + * behavior as the standard memcpy function: |
| 358 | + * void *mld_memcpy(void *dest, const void *src, size_t n) |
427 | 359 | * |
428 | 360 | *****************************************************************************/ |
429 | | -/* #define MLD_CONFIG_KEYGEN_PCT */ |
| 361 | +/* #define MLD_CONFIG_CUSTOM_MEMCPY |
| 362 | + #if !defined(__ASSEMBLER__) |
| 363 | + #include <stdint.h> |
| 364 | + #include "sys.h" |
| 365 | + static MLD_INLINE void *mld_memcpy(void *dest, const void *src, size_t n) |
| 366 | + { |
| 367 | + ... your implementation ... |
| 368 | + } |
| 369 | + #endif |
| 370 | +*/ |
430 | 371 |
|
431 | 372 | /****************************************************************************** |
432 | | - * Name: MLD_CONFIG_KEYGEN_PCT_BREAKAGE_TEST |
| 373 | + * Name: MLD_CONFIG_CUSTOM_MEMSET |
433 | 374 | * |
434 | | - * Description: If this option is set, the user must provide a runtime |
435 | | - * function `static inline int mld_break_pct() { ... }` to |
436 | | - * indicate whether the PCT should be made fail. |
| 375 | + * Description: Set this option and define `mld_memset` if you want to |
| 376 | + * use a custom method to set memory instead of the standard |
| 377 | + * library memset function. |
437 | 378 | * |
438 | | - * This option only has an effect if MLD_CONFIG_KEYGEN_PCT is set. |
| 379 | + * The custom implementation must have the same signature and |
| 380 | + * behavior as the standard memset function: |
| 381 | + * void *mld_memset(void *s, int c, size_t n) |
439 | 382 | * |
440 | 383 | *****************************************************************************/ |
441 | | -/* #define MLD_CONFIG_KEYGEN_PCT_BREAKAGE_TEST |
| 384 | +/* #define MLD_CONFIG_CUSTOM_MEMSET |
442 | 385 | #if !defined(__ASSEMBLER__) |
| 386 | + #include <stdint.h> |
443 | 387 | #include "sys.h" |
444 | | - static MLD_INLINE int mld_break_pct(void) |
| 388 | + static MLD_INLINE void *mld_memset(void *s, int c, size_t n) |
445 | 389 | { |
446 | | - ... return 0/1 depending on whether PCT should be broken ... |
| 390 | + ... your implementation ... |
447 | 391 | } |
448 | 392 | #endif |
449 | 393 | */ |
|
524 | 468 | *****************************************************************************/ |
525 | 469 | /* #define MLD_CONFIG_NO_ASM_VALUE_BARRIER */ |
526 | 470 |
|
| 471 | +/****************************************************************************** |
| 472 | + * Name: MLD_CONFIG_NO_RANDOMIZED_API |
| 473 | + * |
| 474 | + * Description: If this option is set, mldsa-native will be built without the |
| 475 | + * randomized API functions (crypto_sign_keypair, |
| 476 | + * crypto_sign, crypto_sign_signature, and |
| 477 | + * crypto_sign_signature_extmu). |
| 478 | + * This allows users to build mldsa-native without providing a |
| 479 | + * randombytes() implementation if they only need the |
| 480 | + * internal deterministic API |
| 481 | + * (crypto_sign_keypair_internal, crypto_sign_signature_internal). |
| 482 | + * |
| 483 | + * NOTE: This option is incompatible with MLD_CONFIG_KEYGEN_PCT |
| 484 | + * as the current PCT implementation requires |
| 485 | + * crypto_sign_signature(). |
| 486 | + * |
| 487 | + *****************************************************************************/ |
| 488 | +#define MLD_CONFIG_NO_RANDOMIZED_API |
| 489 | + |
| 490 | +/****************************************************************************** |
| 491 | + * Name: MLD_CONFIG_KEYGEN_PCT |
| 492 | + * |
| 493 | + * Description: Compliance with @[FIPS140_3_IG, p.87] requires a |
| 494 | + * Pairwise Consistency Test (PCT) to be carried out on a freshly |
| 495 | + * generated keypair before it can be exported. |
| 496 | + * |
| 497 | + * Set this option if such a check should be implemented. |
| 498 | + * In this case, crypto_sign_keypair_internal and |
| 499 | + * crypto_sign_keypair will return a non-zero error code if the |
| 500 | + * PCT failed. |
| 501 | + * |
| 502 | + * NOTE: This feature will drastically lower the performance of |
| 503 | + * key generation. |
| 504 | + * |
| 505 | + *****************************************************************************/ |
| 506 | +/* #define MLD_CONFIG_KEYGEN_PCT */ |
| 507 | + |
| 508 | +/****************************************************************************** |
| 509 | + * Name: MLD_CONFIG_KEYGEN_PCT_BREAKAGE_TEST |
| 510 | + * |
| 511 | + * Description: If this option is set, the user must provide a runtime |
| 512 | + * function `static inline int mld_break_pct() { ... }` to |
| 513 | + * indicate whether the PCT should be made fail. |
| 514 | + * |
| 515 | + * This option only has an effect if MLD_CONFIG_KEYGEN_PCT is set. |
| 516 | + * |
| 517 | + *****************************************************************************/ |
| 518 | +/* #define MLD_CONFIG_KEYGEN_PCT_BREAKAGE_TEST |
| 519 | + #if !defined(__ASSEMBLER__) |
| 520 | + #include "sys.h" |
| 521 | + static MLD_INLINE int mld_break_pct(void) |
| 522 | + { |
| 523 | + ... return 0/1 depending on whether PCT should be broken ... |
| 524 | + } |
| 525 | + #endif |
| 526 | +*/ |
| 527 | + |
527 | 528 | /****************************************************************************** |
528 | 529 | * Name: MLD_CONFIG_SERIAL_FIPS202_ONLY |
529 | 530 | * |
|
0 commit comments