pq_crypto 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/SECURITY.md +7 -0
  4. data/ext/pqcrypto/pqcrypto_version.h +1 -1
  5. data/ext/pqcrypto/vendor/.vendored +4 -4
  6. data/ext/pqcrypto/vendor/mldsa-native/README.md +23 -10
  7. data/ext/pqcrypto/vendor/mldsa-native/mldsa/README.md +23 -0
  8. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.c +114 -58
  9. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native.h +498 -461
  10. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_asm.S +145 -85
  11. data/ext/pqcrypto/vendor/mldsa-native/mldsa/mldsa_native_config.h +456 -422
  12. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/cbmc.h +47 -25
  13. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/common.h +26 -14
  14. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/ct.h +56 -81
  15. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/debug.h +17 -24
  16. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.c +33 -40
  17. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202.h +67 -87
  18. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.c +19 -14
  19. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/fips202x4.h +13 -5
  20. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.c +84 -10
  21. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/keccakf1600.h +10 -5
  22. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/auto.h +6 -0
  23. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/fips202_native_aarch64.h +22 -15
  24. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_aarch64_asm.S +376 -0
  25. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_aarch64_asm.S +204 -0
  26. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_aarch64_asm.S +259 -0
  27. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm.S +1077 -0
  28. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm.S +987 -0
  29. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccakf1600_round_constants.c +16 -10
  30. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_scalar.h +2 -1
  31. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x1_v84a.h +1 -1
  32. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x2_v84a.h +4 -2
  33. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_scalar.h +2 -2
  34. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/x4_v8a_v84a_scalar.h +1 -1
  35. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/api.h +60 -0
  36. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/mve.h +48 -0
  37. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/fips202_native_armv81m.h +18 -1
  38. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.S +658 -582
  39. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccak_f1600_x4_mve.c +5 -100
  40. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/keccakf1600_round_constants.c +26 -25
  41. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/state_extract_bytes_x4_mve.S +334 -0
  42. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/armv81m/src/state_xor_bytes_x4_mve.S +355 -0
  43. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/auto.h +8 -3
  44. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/{xkcp.h → keccak_f1600_x4_avx2.h} +11 -8
  45. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/fips202_native_x86_64.h +44 -0
  46. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccak_f1600_x4_avx2_asm.S +454 -0
  47. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/keccakf1600_constants.c +52 -0
  48. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/meta.h +37 -28
  49. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/aarch64_zetas.c +213 -196
  50. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/arith_native_aarch64.h +248 -64
  51. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/intt_aarch64_asm.S +753 -0
  52. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l4_aarch64_asm.S +129 -0
  53. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l5_aarch64_asm.S +145 -0
  54. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l7_aarch64_asm.S +177 -0
  55. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/ntt_aarch64_asm.S +653 -0
  56. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/pointwise_montgomery_aarch64_asm.S +84 -0
  57. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_caddq_aarch64_asm.S +53 -0
  58. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_chknorm_aarch64_asm.S +55 -0
  59. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_32_aarch64_asm.S +86 -0
  60. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_88_aarch64_asm.S +86 -0
  61. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_32_aarch64_asm.S +103 -0
  62. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_88_aarch64_asm.S +111 -0
  63. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_17_aarch64_asm.S +75 -0
  64. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_19_aarch64_asm.S +72 -0
  65. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_table.c +23 -11
  66. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_aarch64_asm.S +189 -0
  67. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta2_aarch64_asm.S +137 -0
  68. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta4_aarch64_asm.S +130 -0
  69. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta_table.c +520 -516
  70. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_table.c +34 -33
  71. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/api.h +202 -242
  72. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/meta.h +25 -17
  73. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/arith_native_x86_64.h +112 -28
  74. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.c +1 -1
  75. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/consts.h +1 -1
  76. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/intt_avx2_asm.S +2311 -0
  77. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/ntt_avx2_asm.S +2383 -0
  78. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/nttunpack_avx2_asm.S +238 -0
  79. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l4_avx2_asm.S +139 -0
  80. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l5_avx2_asm.S +155 -0
  81. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l7_avx2_asm.S +187 -0
  82. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_avx2_asm.S +130 -0
  83. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_caddq_avx2_asm.S +190 -0
  84. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_32_avx2.c +6 -4
  85. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_decompose_88_avx2.c +6 -4
  86. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_32_avx2.c +9 -8
  87. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_use_hint_88_avx2.c +10 -9
  88. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_17_avx2.c +8 -5
  89. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/polyz_unpack_19_avx2.c +8 -5
  90. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta2_avx2.c +6 -4
  91. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_eta4_avx2.c +6 -4
  92. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/rej_uniform_table.c +130 -129
  93. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.c +109 -180
  94. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/packing.h +169 -150
  95. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.c +56 -40
  96. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly.h +149 -164
  97. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.c +52 -57
  98. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/poly_kl.h +132 -167
  99. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.c +57 -424
  100. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec.h +167 -474
  101. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.c +308 -0
  102. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/polyvec_lazy.h +653 -0
  103. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/reduce.h +22 -29
  104. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/rounding.h +37 -43
  105. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.c +511 -367
  106. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/sign.h +456 -417
  107. data/lib/pq_crypto/version.rb +1 -1
  108. data/script/vendor_libs.rb +3 -3
  109. metadata +41 -35
  110. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_scalar_asm.S +0 -376
  111. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x1_v84a_asm.S +0 -204
  112. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x2_v84a_asm.S +0 -259
  113. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_scalar_hybrid_asm.S +0 -1077
  114. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/aarch64/src/keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm.S +0 -987
  115. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.c +0 -488
  116. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/fips202/native/x86_64/src/KeccakP_1600_times4_SIMD256.h +0 -16
  117. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/intt.S +0 -753
  118. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l4.S +0 -129
  119. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l5.S +0 -145
  120. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/mld_polyvecl_pointwise_acc_montgomery_l7.S +0 -177
  121. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/ntt.S +0 -653
  122. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/pointwise_montgomery.S +0 -79
  123. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_caddq_asm.S +0 -53
  124. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_chknorm_asm.S +0 -55
  125. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_32_asm.S +0 -85
  126. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_decompose_88_asm.S +0 -85
  127. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_32_asm.S +0 -102
  128. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/poly_use_hint_88_asm.S +0 -110
  129. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_17_asm.S +0 -72
  130. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/polyz_unpack_19_asm.S +0 -69
  131. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_asm.S +0 -189
  132. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta2_asm.S +0 -135
  133. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/aarch64/src/rej_uniform_eta4_asm.S +0 -128
  134. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/intt.S +0 -2311
  135. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/ntt.S +0 -2383
  136. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/nttunpack.S +0 -239
  137. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise.S +0 -131
  138. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l4.S +0 -139
  139. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l5.S +0 -155
  140. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/pointwise_acc_l7.S +0 -187
  141. data/ext/pqcrypto/vendor/mldsa-native/mldsa/src/native/x86_64/src/poly_caddq_avx2.c +0 -61
@@ -18,26 +18,26 @@
18
18
  #define SHA3_512_HASHBYTES 64
19
19
 
20
20
 
21
+ /** Context for the incremental SHAKE128 XOF. */
21
22
  typedef struct
22
23
  {
23
- uint64_t s[MLD_KECCAK_LANES];
24
- unsigned int pos;
24
+ uint64_t s[MLD_KECCAK_LANES]; /**< Keccak state. */
25
+ unsigned int pos; /**< Byte position within the current Keccak block. */
25
26
  } mld_shake128ctx;
26
27
 
28
+ /** Context for the incremental SHAKE256 XOF. */
27
29
  typedef struct
28
30
  {
29
- uint64_t s[MLD_KECCAK_LANES];
30
- unsigned int pos;
31
+ uint64_t s[MLD_KECCAK_LANES]; /**< Keccak state. */
32
+ unsigned int pos; /**< Byte position within the current Keccak block. */
31
33
  } mld_shake256ctx;
32
34
 
33
35
  #define mld_shake128_init MLD_NAMESPACE(shake128_init)
34
- /*************************************************
35
- * Name: mld_shake128_init
36
+ /**
37
+ * Initializes state for use as SHAKE128 XOF.
36
38
  *
37
- * Description: Initializes state for use as SHAKE128 XOF
38
- *
39
- * Arguments: - mld_shake128ctx *state: pointer to (uninitialized) state
40
- **************************************************/
39
+ * @param[out] state Pointer to (uninitialized) state.
40
+ */
41
41
  MLD_INTERNAL_API
42
42
  void mld_shake128_init(mld_shake128ctx *state)
43
43
  __contract__(
@@ -47,16 +47,14 @@ __contract__(
47
47
  );
48
48
 
49
49
  #define mld_shake128_absorb MLD_NAMESPACE(shake128_absorb)
50
- /*************************************************
51
- * Name: mld_shake128_absorb
52
- *
53
- * Description: Absorb step of the SHAKE128 XOF. Absorbs arbitrarily many bytes.
54
- * Can be called multiple times to absorb multiple chunks of data.
50
+ /**
51
+ * Absorb step of the SHAKE128 XOF. Absorbs arbitrarily many bytes. Can be
52
+ * called multiple times to absorb multiple chunks of data.
55
53
  *
56
- * Arguments: - mld_shake128ctx *state: pointer to (initialized) output state
57
- * - const uint8_t *in: pointer to input to be absorbed into s
58
- * - size_t inlen: length of input in bytes
59
- **************************************************/
54
+ * @param[in,out] state Pointer to (initialized) output state.
55
+ * @param[in] in Pointer to input to be absorbed into s.
56
+ * @param inlen Length of input in bytes.
57
+ */
60
58
  MLD_INTERNAL_API
61
59
  void mld_shake128_absorb(mld_shake128ctx *state, const uint8_t *in,
62
60
  size_t inlen)
@@ -70,13 +68,11 @@ __contract__(
70
68
  );
71
69
 
72
70
  #define mld_shake128_finalize MLD_NAMESPACE(shake128_finalize)
73
- /*************************************************
74
- * Name: mld_shake128_finalize
75
- *
76
- * Description: Concludes the absorb phase of the SHAKE128 XOF.
71
+ /**
72
+ * Concludes the absorb phase of the SHAKE128 XOF.
77
73
  *
78
- * Arguments: - mld_shake128ctx *state: pointer to state
79
- **************************************************/
74
+ * @param[in,out] state Pointer to state.
75
+ */
80
76
  MLD_INTERNAL_API
81
77
  void mld_shake128_finalize(mld_shake128ctx *state)
82
78
  __contract__(
@@ -87,17 +83,14 @@ __contract__(
87
83
  );
88
84
 
89
85
  #define mld_shake128_squeeze MLD_NAMESPACE(shake128_squeeze)
90
- /*************************************************
91
- * Name: mld_shake128_squeeze
86
+ /**
87
+ * Squeeze step of SHAKE128 XOF. Squeezes arbitrarily many bytes. Can be
88
+ * called multiple times to keep squeezing.
92
89
  *
93
- * Description: Squeeze step of SHAKE128 XOF. Squeezes arbitrarily many
94
- * bytes. Can be called multiple times to keep squeezing.
95
- *
96
- * Arguments: - uint8_t *out: pointer to output blocks
97
- * - size_t outlen : number of bytes to be squeezed (written to
98
- *output)
99
- * - mld_shake128ctx *s: pointer to input/output state
100
- **************************************************/
90
+ * @param[out] out Pointer to output blocks.
91
+ * @param outlen Number of bytes to be squeezed (written to output).
92
+ * @param[in,out] state Pointer to input/output state.
93
+ */
101
94
  MLD_INTERNAL_API
102
95
  void mld_shake128_squeeze(uint8_t *out, size_t outlen, mld_shake128ctx *state)
103
96
  __contract__(
@@ -111,13 +104,11 @@ __contract__(
111
104
  );
112
105
 
113
106
  #define mld_shake128_release MLD_NAMESPACE(shake128_release)
114
- /*************************************************
115
- * Name: mld_shake128_release
116
- *
117
- * Description: Release and securely zero the SHAKE128 state.
107
+ /**
108
+ * Release and securely zero the SHAKE128 state.
118
109
  *
119
- * Arguments: - mld_shake128ctx *state: pointer to state
120
- **************************************************/
110
+ * @param[in,out] state Pointer to state.
111
+ */
121
112
  MLD_INTERNAL_API
122
113
  void mld_shake128_release(mld_shake128ctx *state)
123
114
  __contract__(
@@ -126,13 +117,11 @@ __contract__(
126
117
  );
127
118
 
128
119
  #define mld_shake256_init MLD_NAMESPACE(shake256_init)
129
- /*************************************************
130
- * Name: mld_shake256_init
131
- *
132
- * Description: Initializes state for use as SHAKE256 XOF
120
+ /**
121
+ * Initializes state for use as SHAKE256 XOF.
133
122
  *
134
- * Arguments: - mld_shake256ctx *state: pointer to (uninitialized) state
135
- **************************************************/
123
+ * @param[out] state Pointer to (uninitialized) state.
124
+ */
136
125
  MLD_INTERNAL_API
137
126
  void mld_shake256_init(mld_shake256ctx *state)
138
127
  __contract__(
@@ -142,16 +131,14 @@ __contract__(
142
131
  );
143
132
 
144
133
  #define mld_shake256_absorb MLD_NAMESPACE(shake256_absorb)
145
- /*************************************************
146
- * Name: mld_shake256_absorb
147
- *
148
- * Description: Absorb step of the SHAKE256 XOF. Absorbs arbitrarily many bytes.
149
- * Can be called multiple times to absorb multiple chunks of data.
134
+ /**
135
+ * Absorb step of the SHAKE256 XOF. Absorbs arbitrarily many bytes. Can be
136
+ * called multiple times to absorb multiple chunks of data.
150
137
  *
151
- * Arguments: - mld_shake256ctx *state: pointer to (initialized) output state
152
- * - const uint8_t *in: pointer to input to be absorbed into s
153
- * - size_t inlen: length of input in bytes
154
- **************************************************/
138
+ * @param[in,out] state Pointer to (initialized) output state.
139
+ * @param[in] in Pointer to input to be absorbed into s.
140
+ * @param inlen Length of input in bytes.
141
+ */
155
142
  MLD_INTERNAL_API
156
143
  void mld_shake256_absorb(mld_shake256ctx *state, const uint8_t *in,
157
144
  size_t inlen)
@@ -165,13 +152,11 @@ __contract__(
165
152
  );
166
153
 
167
154
  #define mld_shake256_finalize MLD_NAMESPACE(shake256_finalize)
168
- /*************************************************
169
- * Name: mld_shake256_finalize
155
+ /**
156
+ * Concludes the absorb phase of the SHAKE256 XOF.
170
157
  *
171
- * Description: Concludes the absorb phase of the SHAKE256 XOF.
172
- *
173
- * Arguments: - mld_shake256ctx *state: pointer to state
174
- **************************************************/
158
+ * @param[in,out] state Pointer to state.
159
+ */
175
160
  MLD_INTERNAL_API
176
161
  void mld_shake256_finalize(mld_shake256ctx *state)
177
162
  __contract__(
@@ -182,17 +167,14 @@ __contract__(
182
167
  );
183
168
 
184
169
  #define mld_shake256_squeeze MLD_NAMESPACE(shake256_squeeze)
185
- /*************************************************
186
- * Name: mld_shake256_squeeze
187
- *
188
- * Description: Squeeze step of SHAKE256 XOF. Squeezes arbitrarily many
189
- * bytes. Can be called multiple times to keep squeezing.
170
+ /**
171
+ * Squeeze step of SHAKE256 XOF. Squeezes arbitrarily many bytes. Can be
172
+ * called multiple times to keep squeezing.
190
173
  *
191
- * Arguments: - uint8_t *out: pointer to output blocks
192
- * - size_t outlen : number of bytes to be squeezed (written to
193
- *output)
194
- * - mld_shake256ctx *s: pointer to input/output state
195
- **************************************************/
174
+ * @param[out] out Pointer to output blocks.
175
+ * @param outlen Number of bytes to be squeezed (written to output).
176
+ * @param[in,out] state Pointer to input/output state.
177
+ */
196
178
  MLD_INTERNAL_API
197
179
  void mld_shake256_squeeze(uint8_t *out, size_t outlen, mld_shake256ctx *state)
198
180
  __contract__(
@@ -206,13 +188,11 @@ __contract__(
206
188
  );
207
189
 
208
190
  #define mld_shake256_release MLD_NAMESPACE(shake256_release)
209
- /*************************************************
210
- * Name: mld_shake256_release
211
- *
212
- * Description: Release and securely zero the SHAKE256 state.
191
+ /**
192
+ * Release and securely zero the SHAKE256 state.
213
193
  *
214
- * Arguments: - mld_shake256ctx *state: pointer to state
215
- **************************************************/
194
+ * @param[in,out] state Pointer to state.
195
+ */
216
196
  MLD_INTERNAL_API
217
197
  void mld_shake256_release(mld_shake256ctx *state)
218
198
  __contract__(
@@ -220,17 +200,16 @@ __contract__(
220
200
  assigns(memory_slice(state, sizeof(mld_shake256ctx)))
221
201
  );
222
202
 
203
+ #if !defined(MLD_CONFIG_NO_KEYPAIR_API) || !defined(MLD_CONFIG_CORE_API_ONLY)
223
204
  #define mld_shake256 MLD_NAMESPACE(shake256)
224
- /*************************************************
225
- * Name: mld_shake256
205
+ /**
206
+ * SHAKE256 XOF with non-incremental API.
226
207
  *
227
- * Description: SHAKE256 XOF with non-incremental API
228
- *
229
- * Arguments: - uint8_t *out: pointer to output
230
- * - size_t outlen: requested output length in bytes
231
- * - const uint8_t *in: pointer to input
232
- * - size_t inlen: length of input in bytes
233
- **************************************************/
208
+ * @param[out] out Pointer to output.
209
+ * @param outlen Requested output length in bytes.
210
+ * @param[in] in Pointer to input.
211
+ * @param inlen Length of input in bytes.
212
+ */
234
213
  MLD_INTERNAL_API
235
214
  void mld_shake256(uint8_t *out, size_t outlen, const uint8_t *in, size_t inlen)
236
215
  __contract__(
@@ -240,5 +219,6 @@ __contract__(
240
219
  requires(memory_no_alias(out, outlen))
241
220
  assigns(memory_slice(out, outlen))
242
221
  );
222
+ #endif /* !MLD_CONFIG_NO_KEYPAIR_API || !MLD_CONFIG_CORE_API_ONLY */
243
223
 
244
224
  #endif /* !MLD_FIPS202_FIPS202_H */
@@ -22,6 +22,8 @@
22
22
  #include "fips202x4.h"
23
23
  #include "keccakf1600.h"
24
24
 
25
+ #if !defined(MLD_CONFIG_NO_KEYPAIR_API) || !defined(MLD_CONFIG_REDUCE_RAM) || \
26
+ defined(MLD_UNIT_TEST)
25
27
  static void mld_keccak_absorb_once_x4(uint64_t *s, uint32_t r,
26
28
  const uint8_t *in0, const uint8_t *in1,
27
29
  const uint8_t *in2, const uint8_t *in3,
@@ -94,33 +96,31 @@ __contract__(
94
96
  assigns(memory_slice(out2, nblocks * r))
95
97
  assigns(memory_slice(out3, nblocks * r)))
96
98
  {
99
+ size_t current_offset = 0;
97
100
  while (nblocks > 0)
98
101
  __loop__(
99
- assigns(out0, out1, out2, out3, nblocks,
102
+ assigns(nblocks, current_offset,
100
103
  memory_slice(s, sizeof(uint64_t) * MLD_KECCAK_LANES * MLD_KECCAK_WAY),
101
104
  memory_slice(out0, nblocks * r),
102
105
  memory_slice(out1, nblocks * r),
103
106
  memory_slice(out2, nblocks * r),
104
107
  memory_slice(out3, nblocks * r))
105
- invariant(nblocks <= loop_entry(nblocks) &&
106
- out0 == loop_entry(out0) + r * (loop_entry(nblocks) - nblocks) &&
107
- out1 == loop_entry(out1) + r * (loop_entry(nblocks) - nblocks) &&
108
- out2 == loop_entry(out2) + r * (loop_entry(nblocks) - nblocks) &&
109
- out3 == loop_entry(out3) + r * (loop_entry(nblocks) - nblocks))
108
+ invariant(nblocks <= loop_entry(nblocks))
109
+ invariant(current_offset == (loop_entry(nblocks) - nblocks) * r)
110
110
  decreases(nblocks))
111
111
  {
112
112
  mld_keccakf1600x4_permute(s);
113
- mld_keccakf1600x4_extract_bytes(s, out0, out1, out2, out3, 0, r);
114
-
115
- out0 += r;
116
- out1 += r;
117
- out2 += r;
118
- out3 += r;
113
+ mld_keccakf1600x4_extract_bytes(
114
+ s, &out0[current_offset], &out1[current_offset], &out2[current_offset],
115
+ &out3[current_offset], 0, r);
116
+ current_offset += r;
119
117
  nblocks--;
120
118
  }
121
119
  }
120
+ #endif /* !MLD_CONFIG_NO_KEYPAIR_API || !MLD_CONFIG_REDUCE_RAM || \
121
+ MLD_UNIT_TEST */
122
122
 
123
- #if !defined(MLD_CONFIG_REDUCE_RAM)
123
+ #if !defined(MLD_CONFIG_REDUCE_RAM) || defined(MLD_UNIT_TEST)
124
124
  MLD_INTERNAL_API
125
125
  void mld_shake128x4_absorb_once(mld_shake128x4ctx *state, const uint8_t *in0,
126
126
  const uint8_t *in1, const uint8_t *in2,
@@ -148,8 +148,11 @@ void mld_shake128x4_release(mld_shake128x4ctx *state)
148
148
  /* @[FIPS204, Section 3.6.3] Destruction of intermediate values. */
149
149
  mld_zeroize(state, sizeof(mld_shake128x4ctx));
150
150
  }
151
- #endif /* !MLD_CONFIG_REDUCE_RAM */
151
+ #endif /* !MLD_CONFIG_REDUCE_RAM || MLD_UNIT_TEST */
152
152
 
153
+ #if !defined(MLD_CONFIG_NO_KEYPAIR_API) || \
154
+ (!defined(MLD_CONFIG_NO_SIGN_API) && \
155
+ (!defined(MLD_CONFIG_REDUCE_RAM) || defined(MLD_UNIT_TEST)))
153
156
  MLD_INTERNAL_API
154
157
  void mld_shake256x4_absorb_once(mld_shake256x4ctx *state, const uint8_t *in0,
155
158
  const uint8_t *in1, const uint8_t *in2,
@@ -177,6 +180,8 @@ void mld_shake256x4_release(mld_shake256x4ctx *state)
177
180
  /* @[FIPS204, Section 3.6.3] Destruction of intermediate values. */
178
181
  mld_zeroize(state, sizeof(mld_shake256x4ctx));
179
182
  }
183
+ #endif /* !MLD_CONFIG_NO_KEYPAIR_API || (!MLD_CONFIG_NO_SIGN_API && \
184
+ (!MLD_CONFIG_REDUCE_RAM || MLD_UNIT_TEST)) */
180
185
 
181
186
  #endif /* !MLD_CONFIG_MULTILEVEL_NO_SHARED && !MLD_CONFIG_SERIAL_FIPS202_ONLY \
182
187
  */
@@ -16,18 +16,21 @@
16
16
  #include "fips202.h"
17
17
  #include "keccakf1600.h"
18
18
 
19
- /* Context for non-incremental API */
19
+ /** Context for the non-incremental 4-way SHAKE128 API. */
20
20
  typedef struct
21
21
  {
22
- uint64_t ctx[MLD_KECCAK_LANES * MLD_KECCAK_WAY];
22
+ uint64_t ctx[MLD_KECCAK_LANES *
23
+ MLD_KECCAK_WAY]; /**< 4-way Keccak state, stored sequentially. */
23
24
  } mld_shake128x4ctx;
24
25
 
26
+ /** Context for the 4-way batched SHAKE256 XOF. */
25
27
  typedef struct
26
28
  {
27
- uint64_t ctx[MLD_KECCAK_LANES * MLD_KECCAK_WAY];
29
+ uint64_t ctx[MLD_KECCAK_LANES *
30
+ MLD_KECCAK_WAY]; /**< Interleaved 4-way Keccak state. */
28
31
  } mld_shake256x4ctx;
29
32
 
30
- #if !defined(MLD_CONFIG_REDUCE_RAM)
33
+ #if !defined(MLD_CONFIG_REDUCE_RAM) || defined(MLD_UNIT_TEST)
31
34
  #define mld_shake128x4_absorb_once MLD_NAMESPACE(shake128x4_absorb_once)
32
35
  MLD_INTERNAL_API
33
36
  void mld_shake128x4_absorb_once(mld_shake128x4ctx *state, const uint8_t *in0,
@@ -69,8 +72,11 @@ void mld_shake128x4_init(mld_shake128x4ctx *state);
69
72
  #define mld_shake128x4_release MLD_NAMESPACE(shake128x4_release)
70
73
  MLD_INTERNAL_API
71
74
  void mld_shake128x4_release(mld_shake128x4ctx *state);
72
- #endif /* !MLD_CONFIG_REDUCE_RAM */
75
+ #endif /* !MLD_CONFIG_REDUCE_RAM || MLD_UNIT_TEST */
73
76
 
77
+ #if !defined(MLD_CONFIG_NO_KEYPAIR_API) || \
78
+ (!defined(MLD_CONFIG_NO_SIGN_API) && \
79
+ (!defined(MLD_CONFIG_REDUCE_RAM) || defined(MLD_UNIT_TEST)))
74
80
  #define mld_shake256x4_absorb_once MLD_NAMESPACE(shake256x4_absorb_once)
75
81
  MLD_INTERNAL_API
76
82
  void mld_shake256x4_absorb_once(mld_shake256x4ctx *state, const uint8_t *in0,
@@ -112,6 +118,8 @@ void mld_shake256x4_init(mld_shake256x4ctx *state);
112
118
  #define mld_shake256x4_release MLD_NAMESPACE(shake256x4_release)
113
119
  MLD_INTERNAL_API
114
120
  void mld_shake256x4_release(mld_shake256x4ctx *state);
121
+ #endif /* !MLD_CONFIG_NO_KEYPAIR_API || (!MLD_CONFIG_NO_SIGN_API && \
122
+ (!MLD_CONFIG_REDUCE_RAM || MLD_UNIT_TEST)) */
115
123
 
116
124
  #endif /* !MLD_CONFIG_SERIAL_FIPS202_ONLY */
117
125
  #endif /* !MLD_FIPS202_FIPS202X4_H */
@@ -84,11 +84,28 @@ void mld_keccakf1600_xor_bytes(uint64_t *state, const unsigned char *data,
84
84
  #endif /* !MLD_SYS_LITTLE_ENDIAN */
85
85
  }
86
86
 
87
- MLD_INTERNAL_API
88
- void mld_keccakf1600x4_extract_bytes(uint64_t *state, unsigned char *data0,
89
- unsigned char *data1, unsigned char *data2,
90
- unsigned char *data3, unsigned offset,
91
- unsigned length)
87
+ #if (!defined(MLD_CONFIG_NO_KEYPAIR_API) || !defined(MLD_CONFIG_REDUCE_RAM) || \
88
+ defined(MLD_UNIT_TEST)) && \
89
+ !defined(MLD_CONFIG_SERIAL_FIPS202_ONLY)
90
+ static void mld_keccakf1600x4_extract_bytes_c(uint64_t *state,
91
+ unsigned char *data0,
92
+ unsigned char *data1,
93
+ unsigned char *data2,
94
+ unsigned char *data3,
95
+ unsigned offset, unsigned length)
96
+ __contract__(
97
+ requires(0 <= offset && offset <= MLD_KECCAK_LANES * sizeof(uint64_t) &&
98
+ 0 <= length && length <= MLD_KECCAK_LANES * sizeof(uint64_t) - offset)
99
+ requires(memory_no_alias(state, sizeof(uint64_t) * MLD_KECCAK_LANES * MLD_KECCAK_WAY))
100
+ requires(memory_no_alias(data0, length))
101
+ requires(memory_no_alias(data1, length))
102
+ requires(memory_no_alias(data2, length))
103
+ requires(memory_no_alias(data3, length))
104
+ assigns(memory_slice(data0, length))
105
+ assigns(memory_slice(data1, length))
106
+ assigns(memory_slice(data2, length))
107
+ assigns(memory_slice(data3, length))
108
+ )
92
109
  {
93
110
  mld_keccakf1600_extract_bytes(state + MLD_KECCAK_LANES * 0, data0, offset,
94
111
  length);
@@ -101,11 +118,43 @@ void mld_keccakf1600x4_extract_bytes(uint64_t *state, unsigned char *data0,
101
118
  }
102
119
 
103
120
  MLD_INTERNAL_API
104
- void mld_keccakf1600x4_xor_bytes(uint64_t *state, const unsigned char *data0,
105
- const unsigned char *data1,
106
- const unsigned char *data2,
107
- const unsigned char *data3, unsigned offset,
108
- unsigned length)
121
+ void mld_keccakf1600x4_extract_bytes(uint64_t *state, unsigned char *data0,
122
+ unsigned char *data1, unsigned char *data2,
123
+ unsigned char *data3, unsigned offset,
124
+ unsigned length)
125
+ {
126
+ #if defined(MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE)
127
+ if (mld_keccakf1600_extract_bytes_x4_native(state, data0, data1, data2, data3,
128
+ offset, length) ==
129
+ MLD_NATIVE_FUNC_SUCCESS)
130
+ {
131
+ return;
132
+ }
133
+ #endif /* MLD_USE_FIPS202_X4_EXTRACT_BYTES_NATIVE */
134
+ mld_keccakf1600x4_extract_bytes_c(state, data0, data1, data2, data3, offset,
135
+ length);
136
+ }
137
+
138
+ static void mld_keccakf1600x4_xor_bytes_c(uint64_t *state,
139
+ const unsigned char *data0,
140
+ const unsigned char *data1,
141
+ const unsigned char *data2,
142
+ const unsigned char *data3,
143
+ unsigned offset, unsigned length)
144
+ __contract__(
145
+ requires(0 <= offset && offset <= MLD_KECCAK_LANES * sizeof(uint64_t) &&
146
+ 0 <= length && length <= MLD_KECCAK_LANES * sizeof(uint64_t) - offset)
147
+ requires(memory_no_alias(state, sizeof(uint64_t) * MLD_KECCAK_LANES * MLD_KECCAK_WAY))
148
+ requires(memory_no_alias(data0, length))
149
+ /* Case 1: all input buffers are distinct; Case 2: All input buffers are the same */
150
+ requires((data0 == data1 &&
151
+ data0 == data2 &&
152
+ data0 == data3) ||
153
+ (memory_no_alias(data1, length) &&
154
+ memory_no_alias(data2, length) &&
155
+ memory_no_alias(data3, length)))
156
+ assigns(memory_slice(state, sizeof(uint64_t) * MLD_KECCAK_LANES * MLD_KECCAK_WAY))
157
+ )
109
158
  {
110
159
  mld_keccakf1600_xor_bytes(state + MLD_KECCAK_LANES * 0, data0, offset,
111
160
  length);
@@ -117,6 +166,25 @@ void mld_keccakf1600x4_xor_bytes(uint64_t *state, const unsigned char *data0,
117
166
  length);
118
167
  }
119
168
 
169
+ MLD_INTERNAL_API
170
+ void mld_keccakf1600x4_xor_bytes(uint64_t *state, const unsigned char *data0,
171
+ const unsigned char *data1,
172
+ const unsigned char *data2,
173
+ const unsigned char *data3, unsigned offset,
174
+ unsigned length)
175
+ {
176
+ #if defined(MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE)
177
+ if (mld_keccakf1600_xor_bytes_x4_native(state, data0, data1, data2, data3,
178
+ offset,
179
+ length) == MLD_NATIVE_FUNC_SUCCESS)
180
+ {
181
+ return;
182
+ }
183
+ #endif /* MLD_USE_FIPS202_X4_XOR_BYTES_NATIVE */
184
+ mld_keccakf1600x4_xor_bytes_c(state, data0, data1, data2, data3, offset,
185
+ length);
186
+ }
187
+
120
188
  MLD_INTERNAL_API
121
189
  void mld_keccakf1600x4_permute(uint64_t *state)
122
190
  {
@@ -131,6 +199,8 @@ void mld_keccakf1600x4_permute(uint64_t *state)
131
199
  mld_keccakf1600_permute(state + MLD_KECCAK_LANES * 2);
132
200
  mld_keccakf1600_permute(state + MLD_KECCAK_LANES * 3);
133
201
  }
202
+ #endif /* (!MLD_CONFIG_NO_KEYPAIR_API || !MLD_CONFIG_REDUCE_RAM || \
203
+ MLD_UNIT_TEST) && !MLD_CONFIG_SERIAL_FIPS202_ONLY */
134
204
 
135
205
  static const uint64_t mld_KeccakF_RoundConstants[MLD_KECCAK_NROUNDS] = {
136
206
  (uint64_t)0x0000000000000001ULL, (uint64_t)0x0000000000008082ULL,
@@ -148,6 +218,10 @@ static const uint64_t mld_KeccakF_RoundConstants[MLD_KECCAK_NROUNDS] = {
148
218
 
149
219
  MLD_STATIC_TESTABLE
150
220
  void mld_keccakf1600_permute_c(uint64_t *state)
221
+ __contract__(
222
+ requires(memory_no_alias(state, sizeof(uint64_t) * MLD_KECCAK_LANES))
223
+ assigns(memory_slice(state, sizeof(uint64_t) * MLD_KECCAK_LANES))
224
+ )
151
225
  {
152
226
  unsigned round;
153
227
 
@@ -25,7 +25,7 @@ void mld_keccakf1600_extract_bytes(uint64_t *state, unsigned char *data,
25
25
  unsigned offset, unsigned length)
26
26
  __contract__(
27
27
  requires(0 <= offset && offset <= MLD_KECCAK_LANES * sizeof(uint64_t) &&
28
- 0 <= length && length <= MLD_KECCAK_LANES * sizeof(uint64_t) - offset)
28
+ 0 <= length && length <= MLD_KECCAK_LANES * sizeof(uint64_t) - offset)
29
29
  requires(memory_no_alias(state, sizeof(uint64_t) * MLD_KECCAK_LANES))
30
30
  requires(memory_no_alias(data, length))
31
31
  assigns(memory_slice(data, length))
@@ -37,12 +37,15 @@ void mld_keccakf1600_xor_bytes(uint64_t *state, const unsigned char *data,
37
37
  unsigned offset, unsigned length)
38
38
  __contract__(
39
39
  requires(0 <= offset && offset <= MLD_KECCAK_LANES * sizeof(uint64_t) &&
40
- 0 <= length && length <= MLD_KECCAK_LANES * sizeof(uint64_t) - offset)
40
+ 0 <= length && length <= MLD_KECCAK_LANES * sizeof(uint64_t) - offset)
41
41
  requires(memory_no_alias(state, sizeof(uint64_t) * MLD_KECCAK_LANES))
42
42
  requires(memory_no_alias(data, length))
43
43
  assigns(memory_slice(state, sizeof(uint64_t) * MLD_KECCAK_LANES))
44
44
  );
45
45
 
46
+ #if (!defined(MLD_CONFIG_NO_KEYPAIR_API) || !defined(MLD_CONFIG_REDUCE_RAM) || \
47
+ defined(MLD_UNIT_TEST)) && \
48
+ !defined(MLD_CONFIG_SERIAL_FIPS202_ONLY)
46
49
  #define mld_keccakf1600x4_extract_bytes \
47
50
  MLD_NAMESPACE(keccakf1600x4_extract_bytes)
48
51
  MLD_INTERNAL_API
@@ -52,7 +55,7 @@ void mld_keccakf1600x4_extract_bytes(uint64_t *state, unsigned char *data0,
52
55
  unsigned length)
53
56
  __contract__(
54
57
  requires(0 <= offset && offset <= MLD_KECCAK_LANES * sizeof(uint64_t) &&
55
- 0 <= length && length <= MLD_KECCAK_LANES * sizeof(uint64_t) - offset)
58
+ 0 <= length && length <= MLD_KECCAK_LANES * sizeof(uint64_t) - offset)
56
59
  requires(memory_no_alias(state, sizeof(uint64_t) * MLD_KECCAK_LANES * MLD_KECCAK_WAY))
57
60
  requires(memory_no_alias(data0, length))
58
61
  requires(memory_no_alias(data1, length))
@@ -73,14 +76,14 @@ void mld_keccakf1600x4_xor_bytes(uint64_t *state, const unsigned char *data0,
73
76
  unsigned length)
74
77
  __contract__(
75
78
  requires(0 <= offset && offset <= MLD_KECCAK_LANES * sizeof(uint64_t) &&
76
- 0 <= length && length <= MLD_KECCAK_LANES * sizeof(uint64_t) - offset)
79
+ 0 <= length && length <= MLD_KECCAK_LANES * sizeof(uint64_t) - offset)
77
80
  requires(memory_no_alias(state, sizeof(uint64_t) * MLD_KECCAK_LANES * MLD_KECCAK_WAY))
78
81
  requires(memory_no_alias(data0, length))
79
82
  /* Case 1: all input buffers are distinct; Case 2: All input buffers are the same */
80
83
  requires((data0 == data1 &&
81
84
  data0 == data2 &&
82
85
  data0 == data3) ||
83
- (memory_no_alias(data1, length) &&
86
+ (memory_no_alias(data1, length) &&
84
87
  memory_no_alias(data2, length) &&
85
88
  memory_no_alias(data3, length)))
86
89
  assigns(memory_slice(state, sizeof(uint64_t) * MLD_KECCAK_LANES * MLD_KECCAK_WAY))
@@ -93,6 +96,8 @@ __contract__(
93
96
  requires(memory_no_alias(state, sizeof(uint64_t) * MLD_KECCAK_LANES * MLD_KECCAK_WAY))
94
97
  assigns(memory_slice(state, sizeof(uint64_t) * MLD_KECCAK_LANES * MLD_KECCAK_WAY))
95
98
  );
99
+ #endif /* (!MLD_CONFIG_NO_KEYPAIR_API || !MLD_CONFIG_REDUCE_RAM || \
100
+ MLD_UNIT_TEST) && !MLD_CONFIG_SERIAL_FIPS202_ONLY */
96
101
 
97
102
  #define mld_keccakf1600_permute MLD_NAMESPACE(keccakf1600_permute)
98
103
  MLD_INTERNAL_API
@@ -37,6 +37,9 @@
37
37
  #include "x1_scalar.h"
38
38
  #endif
39
39
 
40
+ #if (!defined(MLD_CONFIG_NO_KEYPAIR_API) || \
41
+ !defined(MLD_CONFIG_NO_SIGN_API) || !defined(MLD_CONFIG_REDUCE_RAM)) && \
42
+ !defined(MLD_CONFIG_SERIAL_FIPS202_ONLY)
40
43
  /*
41
44
  * Keccak-f1600x2/x4
42
45
  *
@@ -68,4 +71,7 @@
68
71
 
69
72
  #endif /* !__ARM_FEATURE_SHA3 */
70
73
 
74
+ #endif /* (!MLD_CONFIG_NO_KEYPAIR_API || !MLD_CONFIG_NO_SIGN_API || \
75
+ !MLD_CONFIG_REDUCE_RAM) && !MLD_CONFIG_SERIAL_FIPS202_ONLY */
76
+
71
77
  #endif /* !MLD_FIPS202_NATIVE_AARCH64_AUTO_H */
@@ -13,46 +13,53 @@
13
13
 
14
14
  #define mld_keccakf1600_round_constants \
15
15
  MLD_NAMESPACE(keccakf1600_round_constants)
16
- extern const uint64_t mld_keccakf1600_round_constants[];
16
+ MLD_INTERNAL_DATA_DECLARATION const uint64_t
17
+ mld_keccakf1600_round_constants[24];
17
18
 
18
- #define mld_keccak_f1600_x1_scalar_asm MLD_NAMESPACE(keccak_f1600_x1_scalar_asm)
19
- void mld_keccak_f1600_x1_scalar_asm(uint64_t state[25], const uint64_t rc[24])
19
+ #define mld_keccak_f1600_x1_scalar_aarch64_asm \
20
+ MLD_NAMESPACE(keccak_f1600_x1_scalar_aarch64_asm)
21
+ void mld_keccak_f1600_x1_scalar_aarch64_asm(uint64_t state[25],
22
+ const uint64_t rc[24])
20
23
  __contract__(
21
24
  requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 1))
22
25
  requires(rc == mld_keccakf1600_round_constants)
23
26
  assigns(memory_slice(state, sizeof(uint64_t) * 25 * 1))
24
27
  );
25
28
 
26
- #define mld_keccak_f1600_x1_v84a_asm MLD_NAMESPACE(keccak_f1600_x1_v84a_asm)
27
- void mld_keccak_f1600_x1_v84a_asm(uint64_t state[25], const uint64_t rc[24])
29
+ #define mld_keccak_f1600_x1_v84a_aarch64_asm \
30
+ MLD_NAMESPACE(keccak_f1600_x1_v84a_aarch64_asm)
31
+ void mld_keccak_f1600_x1_v84a_aarch64_asm(uint64_t state[25],
32
+ const uint64_t rc[24])
28
33
  __contract__(
29
34
  requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 1))
30
35
  requires(rc == mld_keccakf1600_round_constants)
31
36
  assigns(memory_slice(state, sizeof(uint64_t) * 25 * 1))
32
37
  );
33
38
 
34
- #define mld_keccak_f1600_x2_v84a_asm MLD_NAMESPACE(keccak_f1600_x2_v84a_asm)
35
- void mld_keccak_f1600_x2_v84a_asm(uint64_t state[50], const uint64_t rc[24])
39
+ #define mld_keccak_f1600_x2_v84a_aarch64_asm \
40
+ MLD_NAMESPACE(keccak_f1600_x2_v84a_aarch64_asm)
41
+ void mld_keccak_f1600_x2_v84a_aarch64_asm(uint64_t state[50],
42
+ const uint64_t rc[24])
36
43
  __contract__(
37
44
  requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 2))
38
45
  requires(rc == mld_keccakf1600_round_constants)
39
46
  assigns(memory_slice(state, sizeof(uint64_t) * 25 * 2))
40
47
  );
41
48
 
42
- #define mld_keccak_f1600_x4_v8a_scalar_hybrid_asm \
43
- MLD_NAMESPACE(keccak_f1600_x4_v8a_scalar_hybrid_asm)
44
- void mld_keccak_f1600_x4_v8a_scalar_hybrid_asm(uint64_t state[100],
45
- const uint64_t rc[24])
49
+ #define mld_keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm \
50
+ MLD_NAMESPACE(keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm)
51
+ void mld_keccak_f1600_x4_v8a_scalar_hybrid_aarch64_asm(uint64_t state[100],
52
+ const uint64_t rc[24])
46
53
  __contract__(
47
54
  requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 4))
48
55
  requires(rc == mld_keccakf1600_round_constants)
49
56
  assigns(memory_slice(state, sizeof(uint64_t) * 25 * 4))
50
57
  );
51
58
 
52
- #define mld_keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm \
53
- MLD_NAMESPACE(keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm)
54
- void mld_keccak_f1600_x4_v8a_v84a_scalar_hybrid_asm(uint64_t state[100],
55
- const uint64_t rc[24])
59
+ #define mld_keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm \
60
+ MLD_NAMESPACE(keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm)
61
+ void mld_keccak_f1600_x4_v8a_v84a_scalar_hybrid_aarch64_asm(
62
+ uint64_t state[100], const uint64_t rc[24])
56
63
  __contract__(
57
64
  requires(memory_no_alias(state, sizeof(uint64_t) * 25 * 4))
58
65
  requires(rc == mld_keccakf1600_round_constants)