|
37 | 37 | 44 /* Change this for different security strengths */ |
38 | 38 | #endif |
39 | 39 |
|
| 40 | +/****************************************************************************** |
| 41 | + * Name: MLD_CONFIG_FILE |
| 42 | + * |
| 43 | + * Description: If defined, this is a header that will be included instead |
| 44 | + * of the default configuration file mldsa/src/config.h. |
| 45 | + * |
| 46 | + * When you need to build mldsa-native in multiple configurations, |
| 47 | + * using varying MLD_CONFIG_FILE can be more convenient |
| 48 | + * then configuring everything through CFLAGS. |
| 49 | + * |
| 50 | + * To use, MLD_CONFIG_FILE _must_ be defined prior |
| 51 | + * to the inclusion of any mldsa-native headers. For example, |
| 52 | + * it can be set by passing `-DMLD_CONFIG_FILE="..."` |
| 53 | + * on the command line. |
| 54 | + * |
| 55 | + *****************************************************************************/ |
| 56 | +/* #define MLD_CONFIG_FILE "config.h" */ |
| 57 | + |
40 | 58 | /****************************************************************************** |
41 | 59 | * Name: MLD_CONFIG_NAMESPACE_PREFIX |
42 | 60 | * |
|
100 | 118 | *****************************************************************************/ |
101 | 119 | /* #define MLD_CONFIG_MULTILEVEL_NO_SHARED */ |
102 | 120 |
|
103 | | -/****************************************************************************** |
104 | | - * Name: MLD_CONFIG_FILE |
105 | | - * |
106 | | - * Description: If defined, this is a header that will be included instead |
107 | | - * of the default configuration file mldsa/src/config.h. |
108 | | - * |
109 | | - * When you need to build mldsa-native in multiple configurations, |
110 | | - * using varying MLD_CONFIG_FILE can be more convenient |
111 | | - * then configuring everything through CFLAGS. |
112 | | - * |
113 | | - * To use, MLD_CONFIG_FILE _must_ be defined prior |
114 | | - * to the inclusion of any mldsa-native headers. For example, |
115 | | - * it can be set by passing `-DMLD_CONFIG_FILE="..."` |
116 | | - * on the command line. |
117 | | - * |
118 | | - *****************************************************************************/ |
119 | | -/* #define MLD_CONFIG_FILE "config.h" */ |
120 | 121 |
|
121 | 122 | /****************************************************************************** |
122 | 123 | * Name: MLD_CONFIG_USE_NATIVE_BACKEND_ARITH |
|
200 | 201 | !defined(MLD_CONFIG_FIPS202_BACKEND_FILE) |
201 | 202 | #define MLD_CONFIG_FIPS202_BACKEND_FILE "fips202/native/auto.h" |
202 | 203 | #endif |
| 204 | + |
203 | 205 | /****************************************************************************** |
204 | 206 | * Name: MLD_CONFIG_FIPS202_CUSTOM_HEADER |
205 | 207 | * |
|
273 | 275 | #endif |
274 | 276 | */ |
275 | 277 |
|
276 | | -/****************************************************************************** |
277 | | - * Name: MLD_CONFIG_CUSTOM_MEMCPY |
278 | | - * |
279 | | - * Description: Set this option and define `mld_memcpy` if you want to |
280 | | - * use a custom method to copy memory instead of the standard |
281 | | - * library memcpy function. |
282 | | - * |
283 | | - * The custom implementation must have the same signature and |
284 | | - * behavior as the standard memcpy function: |
285 | | - * void *mld_memcpy(void *dest, const void *src, size_t n) |
286 | | - * |
287 | | - *****************************************************************************/ |
288 | | -/* #define MLD_CONFIG_CUSTOM_MEMCPY |
289 | | - #if !defined(__ASSEMBLER__) |
290 | | - #include <stdint.h> |
291 | | - #include "sys.h" |
292 | | - static MLD_INLINE void *mld_memcpy(void *dest, const void *src, size_t n) |
293 | | - { |
294 | | - ... your implementation ... |
295 | | - } |
296 | | - #endif |
297 | | -*/ |
298 | | - |
299 | | -/****************************************************************************** |
300 | | - * Name: MLD_CONFIG_CUSTOM_MEMSET |
301 | | - * |
302 | | - * Description: Set this option and define `mld_memset` if you want to |
303 | | - * use a custom method to set memory instead of the standard |
304 | | - * library memset function. |
305 | | - * |
306 | | - * The custom implementation must have the same signature and |
307 | | - * behavior as the standard memset function: |
308 | | - * void *mld_memset(void *s, int c, size_t n) |
309 | | - * |
310 | | - *****************************************************************************/ |
311 | | -/* #define MLD_CONFIG_CUSTOM_MEMSET |
312 | | - #if !defined(__ASSEMBLER__) |
313 | | - #include <stdint.h> |
314 | | - #include "sys.h" |
315 | | - static MLD_INLINE void *mld_memset(void *s, int c, size_t n) |
316 | | - { |
317 | | - ... your implementation ... |
318 | | - } |
319 | | - #endif |
320 | | -*/ |
321 | | - |
322 | 278 | /****************************************************************************** |
323 | 279 | * Name: MLD_CONFIG_CUSTOM_RANDOMBYTES |
324 | 280 | * |
|
345 | 301 | #endif |
346 | 302 | */ |
347 | 303 |
|
348 | | - |
349 | 304 | /****************************************************************************** |
350 | 305 | * Name: MLD_CONFIG_CUSTOM_CAPABILITY_FUNC |
351 | 306 | * |
|
376 | 331 | */ |
377 | 332 |
|
378 | 333 | /****************************************************************************** |
379 | | - * Name: MLD_CONFIG_NO_RANDOMIZED_API |
380 | | - * |
381 | | - * Description: If this option is set, mldsa-native will be built without the |
382 | | - * randomized API functions (crypto_sign_keypair, |
383 | | - * crypto_sign, crypto_sign_signature, and |
384 | | - * crypto_sign_signature_extmu). |
385 | | - * This allows users to build mldsa-native without providing a |
386 | | - * randombytes() implementation if they only need the |
387 | | - * internal deterministic API |
388 | | - * (crypto_sign_keypair_internal, crypto_sign_signature_internal). |
389 | | - * |
390 | | - * NOTE: This option is incompatible with MLD_CONFIG_KEYGEN_PCT |
391 | | - * as the current PCT implementation requires |
392 | | - * crypto_sign_signature(). |
393 | | - * |
394 | | - *****************************************************************************/ |
395 | | -/* #define MLD_CONFIG_NO_RANDOMIZED_API */ |
396 | | - |
397 | | -/****************************************************************************** |
398 | | - * Name: MLD_CONFIG_KEYGEN_PCT |
399 | | - * |
400 | | - * Description: Compliance with @[FIPS140_3_IG, p.87] requires a |
401 | | - * Pairwise Consistency Test (PCT) to be carried out on a freshly |
402 | | - * generated keypair before it can be exported. |
| 334 | + * Name: MLD_CONFIG_CUSTOM_MEMCPY |
403 | 335 | * |
404 | | - * Set this option if such a check should be implemented. |
405 | | - * In this case, crypto_sign_keypair_internal and |
406 | | - * crypto_sign_keypair will return a non-zero error code if the |
407 | | - * PCT failed. |
| 336 | + * Description: Set this option and define `mld_memcpy` if you want to |
| 337 | + * use a custom method to copy memory instead of the standard |
| 338 | + * library memcpy function. |
408 | 339 | * |
409 | | - * NOTE: This feature will drastically lower the performance of |
410 | | - * key generation. |
| 340 | + * The custom implementation must have the same signature and |
| 341 | + * behavior as the standard memcpy function: |
| 342 | + * void *mld_memcpy(void *dest, const void *src, size_t n) |
411 | 343 | * |
412 | 344 | *****************************************************************************/ |
413 | | -/* #define MLD_CONFIG_KEYGEN_PCT */ |
| 345 | +/* #define MLD_CONFIG_CUSTOM_MEMCPY |
| 346 | + #if !defined(__ASSEMBLER__) |
| 347 | + #include <stdint.h> |
| 348 | + #include "sys.h" |
| 349 | + static MLD_INLINE void *mld_memcpy(void *dest, const void *src, size_t n) |
| 350 | + { |
| 351 | + ... your implementation ... |
| 352 | + } |
| 353 | + #endif |
| 354 | +*/ |
414 | 355 |
|
415 | 356 | /****************************************************************************** |
416 | | - * Name: MLD_CONFIG_KEYGEN_PCT_BREAKAGE_TEST |
| 357 | + * Name: MLD_CONFIG_CUSTOM_MEMSET |
417 | 358 | * |
418 | | - * Description: If this option is set, the user must provide a runtime |
419 | | - * function `static inline int mld_break_pct() { ... }` to |
420 | | - * indicate whether the PCT should be made fail. |
| 359 | + * Description: Set this option and define `mld_memset` if you want to |
| 360 | + * use a custom method to set memory instead of the standard |
| 361 | + * library memset function. |
421 | 362 | * |
422 | | - * This option only has an effect if MLD_CONFIG_KEYGEN_PCT is set. |
| 363 | + * The custom implementation must have the same signature and |
| 364 | + * behavior as the standard memset function: |
| 365 | + * void *mld_memset(void *s, int c, size_t n) |
423 | 366 | * |
424 | 367 | *****************************************************************************/ |
425 | | -/* #define MLD_CONFIG_KEYGEN_PCT_BREAKAGE_TEST |
| 368 | +/* #define MLD_CONFIG_CUSTOM_MEMSET |
426 | 369 | #if !defined(__ASSEMBLER__) |
| 370 | + #include <stdint.h> |
427 | 371 | #include "sys.h" |
428 | | - static MLD_INLINE int mld_break_pct(void) |
| 372 | + static MLD_INLINE void *mld_memset(void *s, int c, size_t n) |
429 | 373 | { |
430 | | - ... return 0/1 depending on whether PCT should be broken ... |
| 374 | + ... your implementation ... |
431 | 375 | } |
432 | 376 | #endif |
433 | 377 | */ |
|
508 | 452 | *****************************************************************************/ |
509 | 453 | /* #define MLD_CONFIG_NO_ASM_VALUE_BARRIER */ |
510 | 454 |
|
| 455 | +/****************************************************************************** |
| 456 | + * Name: MLD_CONFIG_NO_RANDOMIZED_API |
| 457 | + * |
| 458 | + * Description: If this option is set, mldsa-native will be built without the |
| 459 | + * randomized API functions (crypto_sign_keypair, |
| 460 | + * crypto_sign, crypto_sign_signature, and |
| 461 | + * crypto_sign_signature_extmu). |
| 462 | + * This allows users to build mldsa-native without providing a |
| 463 | + * randombytes() implementation if they only need the |
| 464 | + * internal deterministic API |
| 465 | + * (crypto_sign_keypair_internal, crypto_sign_signature_internal). |
| 466 | + * |
| 467 | + * NOTE: This option is incompatible with MLD_CONFIG_KEYGEN_PCT |
| 468 | + * as the current PCT implementation requires |
| 469 | + * crypto_sign_signature(). |
| 470 | + * |
| 471 | + *****************************************************************************/ |
| 472 | +/* #define MLD_CONFIG_NO_RANDOMIZED_API */ |
| 473 | + |
| 474 | +/****************************************************************************** |
| 475 | + * Name: MLD_CONFIG_KEYGEN_PCT |
| 476 | + * |
| 477 | + * Description: Compliance with @[FIPS140_3_IG, p.87] requires a |
| 478 | + * Pairwise Consistency Test (PCT) to be carried out on a freshly |
| 479 | + * generated keypair before it can be exported. |
| 480 | + * |
| 481 | + * Set this option if such a check should be implemented. |
| 482 | + * In this case, crypto_sign_keypair_internal and |
| 483 | + * crypto_sign_keypair will return a non-zero error code if the |
| 484 | + * PCT failed. |
| 485 | + * |
| 486 | + * NOTE: This feature will drastically lower the performance of |
| 487 | + * key generation. |
| 488 | + * |
| 489 | + *****************************************************************************/ |
| 490 | +/* #define MLD_CONFIG_KEYGEN_PCT */ |
| 491 | + |
| 492 | +/****************************************************************************** |
| 493 | + * Name: MLD_CONFIG_KEYGEN_PCT_BREAKAGE_TEST |
| 494 | + * |
| 495 | + * Description: If this option is set, the user must provide a runtime |
| 496 | + * function `static inline int mld_break_pct() { ... }` to |
| 497 | + * indicate whether the PCT should be made fail. |
| 498 | + * |
| 499 | + * This option only has an effect if MLD_CONFIG_KEYGEN_PCT is set. |
| 500 | + * |
| 501 | + *****************************************************************************/ |
| 502 | +/* #define MLD_CONFIG_KEYGEN_PCT_BREAKAGE_TEST |
| 503 | + #if !defined(__ASSEMBLER__) |
| 504 | + #include "sys.h" |
| 505 | + static MLD_INLINE int mld_break_pct(void) |
| 506 | + { |
| 507 | + ... return 0/1 depending on whether PCT should be broken ... |
| 508 | + } |
| 509 | + #endif |
| 510 | +*/ |
| 511 | + |
511 | 512 | /****************************************************************************** |
512 | 513 | * Name: MLD_CONFIG_SERIAL_FIPS202_ONLY |
513 | 514 | * |
|
0 commit comments