|
6 | 6 | #ifndef MLD_COMMON_H |
7 | 7 | #define MLD_COMMON_H |
8 | 8 |
|
| 9 | +#ifndef __ASSEMBLER__ |
| 10 | +#include <stdint.h> |
| 11 | +#endif |
| 12 | + |
| 13 | + |
9 | 14 | #define MLD_BUILD_INTERNAL |
10 | 15 |
|
11 | 16 | #if defined(MLD_CONFIG_FILE) |
|
21 | 26 | * this can be overwritten by the user, e.g. for single-CU builds. */ |
22 | 27 | #if !defined(MLD_CONFIG_INTERNAL_API_QUALIFIER) |
23 | 28 | #define MLD_INTERNAL_API |
| 29 | +#define MLD_INTERNAL_DATA_DECLARATION extern |
| 30 | +#define MLD_INTERNAL_DATA_DEFINITION |
24 | 31 | #else |
25 | 32 | #define MLD_INTERNAL_API MLD_CONFIG_INTERNAL_API_QUALIFIER |
| 33 | +#define MLD_INTERNAL_DATA_DECLARATION MLD_CONFIG_INTERNAL_API_QUALIFIER |
| 34 | +#define MLD_INTERNAL_DATA_DEFINITION MLD_CONFIG_INTERNAL_API_QUALIFIER |
26 | 35 | #endif |
27 | 36 |
|
28 | 37 | #if !defined(MLD_CONFIG_EXTERNAL_API_QUALIFIER) |
|
77 | 86 | */ |
78 | 87 | #if defined(MLD_SYS_X86_64) |
79 | 88 | #define MLD_ASM_FN_SYMBOL(sym) MLD_ASM_NAMESPACE(sym) : MLD_CET_ENDBR |
80 | | -#else |
| 89 | +#elif defined(MLD_SYS_ARMV81M_MVE) |
| 90 | +/* clang-format off */ |
| 91 | +#define MLD_ASM_FN_SYMBOL(sym) \ |
| 92 | + .type MLD_ASM_NAMESPACE(sym), %function; \ |
| 93 | + MLD_ASM_NAMESPACE(sym) : |
| 94 | +/* clang-format on */ |
| 95 | +#else /* !MLD_SYS_X86_64 && MLD_SYS_ARMV81M_MVE */ |
81 | 96 | #define MLD_ASM_FN_SYMBOL(sym) MLD_ASM_NAMESPACE(sym) : |
| 97 | +#endif /* !MLD_SYS_X86_64 && !MLD_SYS_ARMV81M_MVE */ |
| 98 | + |
| 99 | +/* |
| 100 | + * Output the size of an assembly function. |
| 101 | + */ |
| 102 | +#if defined(__ELF__) |
| 103 | +#define MLD_ASM_FN_SIZE(sym) \ |
| 104 | + .size MLD_ASM_NAMESPACE(sym), .- MLD_ASM_NAMESPACE(sym) |
| 105 | +#else |
| 106 | +#define MLD_ASM_FN_SIZE(sym) |
82 | 107 | #endif |
83 | 108 |
|
84 | 109 | /* We aim to simplify the user's life by supporting builds where |
|
107 | 132 | #error Bad configuration: MLD_CONFIG_NO_RANDOMIZED_API is incompatible with MLD_CONFIG_KEYGEN_PCT as the current PCT implementation requires crypto_sign_signature() |
108 | 133 | #endif |
109 | 134 |
|
| 135 | +#if defined(MLD_CONFIG_NO_SIGN_API) && defined(MLD_CONFIG_KEYGEN_PCT) |
| 136 | +#error Bad configuration: MLD_CONFIG_NO_SIGN_API is incompatible with MLD_CONFIG_KEYGEN_PCT as the current PCT implementation requires crypto_sign_signature() |
| 137 | +#endif |
| 138 | + |
| 139 | +#if defined(MLD_CONFIG_NO_VERIFY_API) && defined(MLD_CONFIG_KEYGEN_PCT) |
| 140 | +#error Bad configuration: MLD_CONFIG_NO_VERIFY_API is incompatible with MLD_CONFIG_KEYGEN_PCT as the current PCT implementation requires crypto_sign_verify() |
| 141 | +#endif |
| 142 | + |
110 | 143 | #if defined(MLD_CONFIG_USE_NATIVE_BACKEND_ARITH) |
111 | 144 | #include MLD_CONFIG_ARITH_BACKEND_FILE |
112 | 145 | /* Include to enforce consistency of API and implementation, |
|
269 | 302 |
|
270 | 303 | #endif /* MLD_CONFIG_CUSTOM_ALLOC_FREE */ |
271 | 304 |
|
272 | | -/* |
273 | | - * We are facing severe CBMC performance issues when using unions. |
274 | | - * As a temporary workaround, we use unions only when MLD_CONFIG_REDUCE_RAM is |
275 | | - * set. |
276 | | - * TODO: Remove the workaround once |
277 | | - * https://github.com/diffblue/cbmc/issues/8813 |
278 | | - * is resolved |
279 | | - */ |
280 | | -#if defined(MLD_CONFIG_REDUCE_RAM) |
281 | | -#define MLK_UNION_OR_STRUCT union |
282 | | -#else |
283 | | -#define MLK_UNION_OR_STRUCT struct |
284 | | -#endif |
285 | | - |
286 | 305 | /****************************** Error codes ***********************************/ |
287 | 306 |
|
288 | 307 | /* Generic failure condition */ |
|
293 | 312 | /* An rng failure occured. Might be due to insufficient entropy or |
294 | 313 | * system misconfiguration. */ |
295 | 314 | #define MLD_ERR_RNG_FAIL -3 |
| 315 | +/* The signing rejection-sampling loop exceeded |
| 316 | + * MLD_CONFIG_MAX_SIGNING_ATTEMPTS iterations without producing a valid |
| 317 | + * signature. With a FIPS 204 Appendix C compliant bound (>= 814) this |
| 318 | + * has probability < 2^-256. */ |
| 319 | +#define MLD_ERR_SIGN_ATTEMPTS_EXHAUSTED -4 |
296 | 320 |
|
297 | 321 |
|
298 | 322 | #endif /* !__ASSEMBLER__ */ |
|
0 commit comments