rbnacl-libsodium 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +23 -0
  3. data/CHANGES.md +5 -0
  4. data/Gemfile +5 -2
  5. data/Rakefile +5 -0
  6. data/ext/rbnacl/extconf.rb +2 -1
  7. data/lib/rbnacl/libsodium.rb +8 -2
  8. data/lib/rbnacl/libsodium/version.rb +1 -1
  9. data/vendor/libsodium/AUTHORS +14 -0
  10. data/vendor/libsodium/ChangeLog +26 -0
  11. data/vendor/libsodium/LICENSE +1 -1
  12. data/vendor/libsodium/Makefile.am +1 -0
  13. data/vendor/libsodium/Makefile.in +9 -0
  14. data/vendor/libsodium/README.markdown +7 -0
  15. data/vendor/libsodium/aclocal.m4 +1 -0
  16. data/vendor/libsodium/appveyor.yml +25 -0
  17. data/vendor/libsodium/autom4te.cache/output.1 +640 -126
  18. data/vendor/libsodium/autom4te.cache/output.6 +19049 -0
  19. data/vendor/libsodium/autom4te.cache/requests +1151 -914
  20. data/vendor/libsodium/autom4te.cache/traces.1 +472 -426
  21. data/vendor/libsodium/autom4te.cache/traces.6 +3193 -0
  22. data/vendor/libsodium/builds/msvc/version.h +2 -2
  23. data/vendor/libsodium/builds/msvc/vs2010/libsodium.sln +50 -79
  24. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +20 -8
  25. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +208 -166
  26. data/vendor/libsodium/builds/msvc/vs2012/libsodium.sln +50 -79
  27. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +20 -8
  28. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +206 -164
  29. data/vendor/libsodium/builds/msvc/vs2013/libsodium.sln +52 -81
  30. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +20 -8
  31. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +206 -164
  32. data/vendor/libsodium/builds/msvc/vs2015/libsodium.sln +52 -81
  33. data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +20 -8
  34. data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +206 -164
  35. data/vendor/libsodium/configure +639 -125
  36. data/vendor/libsodium/configure.ac +94 -16
  37. data/vendor/libsodium/dist-build/Makefile.in +9 -0
  38. data/vendor/libsodium/dist-build/emscripten-symbols.def +370 -0
  39. data/vendor/libsodium/dist-build/emscripten.sh +9 -3
  40. data/vendor/libsodium/dist-build/generate-emscripten-symbols.sh +43 -0
  41. data/vendor/libsodium/libsodium-uninstalled.pc.in +1 -1
  42. data/vendor/libsodium/libsodium.pc.in +1 -1
  43. data/vendor/libsodium/libsodium.vcxproj +70 -66
  44. data/vendor/libsodium/libsodium.vcxproj.filters +204 -192
  45. data/vendor/libsodium/m4/ax_valgrind_check.m4 +190 -0
  46. data/vendor/libsodium/msvc-scripts/Makefile.in +9 -0
  47. data/vendor/libsodium/msvc-scripts/process.bat +2 -2
  48. data/vendor/libsodium/src/Makefile.in +9 -0
  49. data/vendor/libsodium/src/libsodium/Makefile.am +31 -6
  50. data/vendor/libsodium/src/libsodium/Makefile.in +238 -42
  51. data/vendor/libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +234 -38
  52. data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +208 -118
  53. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_seal.c +2 -2
  54. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c +1 -4
  55. data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.c +1799 -1790
  56. data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.h +39 -39
  57. data/vendor/libsodium/src/libsodium/crypto_core/hchacha20/core_hchacha20.c +86 -0
  58. data/vendor/libsodium/src/libsodium/crypto_core/hchacha20/core_hchacha20.h +28 -0
  59. data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20.c +38 -46
  60. data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/core_salsa20.c +47 -55
  61. data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/core_salsa2012.c +47 -55
  62. data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/core_salsa208.c +47 -55
  63. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c +7 -0
  64. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2-impl.h +0 -89
  65. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h +50 -141
  66. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-avx2.c +45 -0
  67. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-avx2.h +123 -0
  68. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ref.c +3 -2
  69. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-sse41.c +2 -2
  70. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/{blake2b-round.h → blake2b-compress-sse41.h} +2 -28
  71. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ssse3.c +2 -4
  72. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ssse3.h +97 -0
  73. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-avx2.h +339 -0
  74. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-sse2.h +0 -2
  75. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-sse41.h +0 -2
  76. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +29 -18
  77. data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +4 -43
  78. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +3 -32
  79. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +1 -20
  80. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +22 -41
  81. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +12 -39
  82. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c +2 -4
  83. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.h +1 -20
  84. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.c +570 -0
  85. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.h +198 -0
  86. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c +444 -0
  87. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-encoding.h +32 -0
  88. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ref.c +229 -0
  89. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ssse3.c +222 -0
  90. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-impl.h +40 -0
  91. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.c +238 -0
  92. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.h +251 -0
  93. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blake2b-long.c +80 -0
  94. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blake2b-long.h +8 -0
  95. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blamka-round-ref.h +38 -0
  96. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blamka-round-ssse3.h +117 -0
  97. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/pwhash_argon2i.c +164 -0
  98. data/vendor/libsodium/src/libsodium/crypto_pwhash/crypto_pwhash.c +106 -0
  99. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +1 -1
  100. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +4 -4
  101. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c +186 -186
  102. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.c +2 -2
  103. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +3 -2
  104. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/scrypt_platform.c +33 -33
  105. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +253 -254
  106. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.c +16 -17
  107. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.h +1 -0
  108. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.c +11 -11
  109. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.h +1 -0
  110. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/consts_namespace.h +1 -1
  111. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe.h +3 -2
  112. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51.h +5 -3
  113. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_invert.c +41 -41
  114. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_mul.S +10 -2
  115. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_namespace.h +1 -1
  116. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_nsquare.S +4 -0
  117. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_pack.S +4 -0
  118. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe_frombytes_sandy2x.c +31 -32
  119. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder.S +4 -0
  120. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder.h +1 -1
  121. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base.S +4 -0
  122. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base.h +1 -1
  123. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base_namespace.h +1 -1
  124. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_namespace.h +1 -1
  125. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +2 -6
  126. data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash24.c +8 -28
  127. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +75 -0
  128. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/afternm_aes128ctr.c +6 -6
  129. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/common.h +1 -18
  130. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128_aes128ctr.c +20 -20
  131. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/types.h +4 -4
  132. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/xor_afternm_aes128ctr.c +6 -6
  133. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c +56 -77
  134. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.h +1 -0
  135. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/vec/stream_chacha20_vec.h +1 -0
  136. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20_ref.c +2 -8
  137. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c +2 -8
  138. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c +2 -8
  139. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c +2 -8
  140. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c +2 -8
  141. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c +2 -8
  142. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c +1 -5
  143. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c +1 -5
  144. data/vendor/libsodium/src/libsodium/include/Makefile.am +3 -0
  145. data/vendor/libsodium/src/libsodium/include/Makefile.in +19 -8
  146. data/vendor/libsodium/src/libsodium/include/sodium.h +3 -0
  147. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_aes256gcm.h +50 -0
  148. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h +94 -22
  149. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +6 -6
  150. data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_hchacha20.h +35 -0
  151. data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h +3 -0
  152. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash.h +89 -0
  153. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_argon2i.h +86 -0
  154. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h +6 -6
  155. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h +0 -11
  156. data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +3 -0
  157. data/vendor/libsodium/src/libsodium/randombytes/randombytes.c +3 -0
  158. data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +5 -1
  159. data/vendor/libsodium/src/libsodium/sodium/common.h +150 -0
  160. data/vendor/libsodium/src/libsodium/sodium/core.c +3 -1
  161. data/vendor/libsodium/src/libsodium/sodium/runtime.c +37 -19
  162. data/vendor/libsodium/src/libsodium/sodium/utils.c +18 -9
  163. data/vendor/libsodium/test/Makefile.in +9 -0
  164. data/vendor/libsodium/test/default/Makefile.am +10 -0
  165. data/vendor/libsodium/test/default/Makefile.in +53 -20
  166. data/vendor/libsodium/test/default/aead_aes256gcm.c +43 -17
  167. data/vendor/libsodium/test/default/aead_chacha20poly1305.c +179 -86
  168. data/vendor/libsodium/test/default/auth7.c +5 -5
  169. data/vendor/libsodium/test/default/box.c +4 -4
  170. data/vendor/libsodium/test/default/box2.c +1 -1
  171. data/vendor/libsodium/test/default/core6.c +1 -1
  172. data/vendor/libsodium/test/default/generichash.c +12 -1
  173. data/vendor/libsodium/test/default/generichash2.c +2 -2
  174. data/vendor/libsodium/test/default/generichash3.c +21 -0
  175. data/vendor/libsodium/test/default/pwhash.c +186 -168
  176. data/vendor/libsodium/test/default/pwhash.exp +11 -30
  177. data/vendor/libsodium/test/default/pwhash_scrypt.c +349 -0
  178. data/vendor/libsodium/test/default/pwhash_scrypt.exp +31 -0
  179. data/vendor/libsodium/test/default/secretbox.c +1 -1
  180. data/vendor/libsodium/test/default/secretbox2.c +1 -1
  181. data/vendor/libsodium/test/default/sign.c +15 -0
  182. data/vendor/libsodium/test/default/sodium_utils2.c +8 -3
  183. data/vendor/libsodium/test/default/sodium_utils3.c +4 -2
  184. data/vendor/libsodium/test/default/verify1.c +0 -4
  185. data/vendor/libsodium/test/quirks/quirks.h +3 -0
  186. metadata +37 -22
  187. data/vendor/libsodium/builds/msvc/vs2010/test/test.props +0 -43
  188. data/vendor/libsodium/builds/msvc/vs2010/test/test.runner.bat +0 -78
  189. data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj +0 -244
  190. data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj.filters +0 -192
  191. data/vendor/libsodium/builds/msvc/vs2012/test/test.props +0 -43
  192. data/vendor/libsodium/builds/msvc/vs2012/test/test.runner.bat +0 -78
  193. data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj +0 -244
  194. data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj.filters +0 -192
  195. data/vendor/libsodium/builds/msvc/vs2013/test/test.props +0 -43
  196. data/vendor/libsodium/builds/msvc/vs2013/test/test.runner.bat +0 -78
  197. data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj +0 -244
  198. data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj.filters +0 -192
  199. data/vendor/libsodium/builds/msvc/vs2015/test/test.props +0 -43
  200. data/vendor/libsodium/builds/msvc/vs2015/test/test.runner.bat +0 -78
  201. data/vendor/libsodium/builds/msvc/vs2015/test/test.vcxproj +0 -244
  202. data/vendor/libsodium/builds/msvc/vs2015/test/test.vcxproj.filters +0 -192
  203. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sysendian.h +0 -146
  204. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/common_aes128ctr.c +0 -64
@@ -1,32 +1,12 @@
1
1
  #include "crypto_shorthash_siphash24.h"
2
- #include "crypto_uint64.h"
3
- #include "crypto_uint32.h"
4
- #include "crypto_uint8.h"
2
+ #include "../../sodium/common.h"
5
3
 
6
- typedef crypto_uint64 u64;
7
- typedef crypto_uint32 u32;
8
- typedef crypto_uint8 u8;
4
+ typedef uint64_t u64;
5
+ typedef uint32_t u32;
6
+ typedef uint8_t u8;
9
7
 
10
8
  #define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) )
11
9
 
12
- #define U32TO8_LE(p, v) \
13
- (p)[0] = (u8)((v) ); (p)[1] = (u8)((v) >> 8); \
14
- (p)[2] = (u8)((v) >> 16); (p)[3] = (u8)((v) >> 24);
15
-
16
- #define U64TO8_LE(p, v) \
17
- U32TO8_LE((p), (u32)((v) )); \
18
- U32TO8_LE((p) + 4, (u32)((v) >> 32));
19
-
20
- #define U8TO64_LE(p) \
21
- (((u64)((p)[0]) ) | \
22
- ((u64)((p)[1]) << 8) | \
23
- ((u64)((p)[2]) << 16) | \
24
- ((u64)((p)[3]) << 24) | \
25
- ((u64)((p)[4]) << 32) | \
26
- ((u64)((p)[5]) << 40) | \
27
- ((u64)((p)[6]) << 48) | \
28
- ((u64)((p)[7]) << 56))
29
-
30
10
  #define SIPROUND \
31
11
  do { \
32
12
  v0 += v1; v1=ROTL(v1,13); v1 ^= v0; v0=ROTL(v0,32); \
@@ -44,8 +24,8 @@ int crypto_shorthash_siphash24(unsigned char *out, const unsigned char *in,
44
24
  u64 v2 = 0x6c7967656e657261ULL;
45
25
  u64 v3 = 0x7465646279746573ULL;
46
26
  u64 b;
47
- u64 k0 = U8TO64_LE( k );
48
- u64 k1 = U8TO64_LE( k + 8 );
27
+ u64 k0 = LOAD64_LE( k );
28
+ u64 k1 = LOAD64_LE( k + 8 );
49
29
  u64 m;
50
30
  const u8 *end = in + inlen - ( inlen % sizeof( u64 ) );
51
31
  const int left = inlen & 7;
@@ -57,7 +37,7 @@ int crypto_shorthash_siphash24(unsigned char *out, const unsigned char *in,
57
37
 
58
38
  for ( ; in != end; in += 8 )
59
39
  {
60
- m = U8TO64_LE( in );
40
+ m = LOAD64_LE( in );
61
41
  v3 ^= m;
62
42
  SIPROUND;
63
43
  SIPROUND;
@@ -86,7 +66,7 @@ int crypto_shorthash_siphash24(unsigned char *out, const unsigned char *in,
86
66
  SIPROUND;
87
67
  SIPROUND;
88
68
  b = v0 ^ v1 ^ v2 ^ v3;
89
- U64TO8_LE( out, b );
69
+ STORE64_LE( out, b );
90
70
  return 0;
91
71
  }
92
72
 
@@ -9,6 +9,74 @@
9
9
  #include "utils.h"
10
10
  #include "../../../crypto_core/curve25519/ref10/curve25519_ref10.h"
11
11
 
12
+ #ifndef ED25519_COMPAT
13
+ static int
14
+ crypto_sign_check_S_lt_L(const unsigned char *S)
15
+ {
16
+ /* 2^252+27742317777372353535851937790883648493 */
17
+ static const unsigned char L[32] =
18
+ { 0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58,
19
+ 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14,
20
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10 };
22
+ unsigned char c = 0;
23
+ unsigned char n = 1;
24
+ unsigned int i = 32;
25
+
26
+ do {
27
+ i--;
28
+ c |= ((S[i] - L[i]) >> 8) & n;
29
+ n &= ((S[i] ^ L[i]) - 1) >> 8;
30
+ } while (i != 0);
31
+
32
+ return -(c == 0);
33
+ }
34
+
35
+ static int
36
+ small_order(const unsigned char R[32])
37
+ {
38
+ CRYPTO_ALIGN(16) static const unsigned char blacklist[][32] = {
39
+ /* 0 (order 4) */
40
+ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
41
+ /* 1 (order 1) */
42
+ { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
43
+ /* 2707385501144840649318225287225658788936804267575313519463743609750303402022 (order 8) */
44
+ { 0x26, 0xe8, 0x95, 0x8f, 0xc2, 0xb2, 0x27, 0xb0, 0x45, 0xc3, 0xf4, 0x89, 0xf2, 0xef, 0x98, 0xf0, 0xd5, 0xdf, 0xac, 0x05, 0xd3, 0xc6, 0x33, 0x39, 0xb1, 0x38, 0x02, 0x88, 0x6d, 0x53, 0xfc, 0x05 },
45
+ /* 55188659117513257062467267217118295137698188065244968500265048394206261417927 (order 8) */
46
+ { 0xc7, 0x17, 0x6a, 0x70, 0x3d, 0x4d, 0xd8, 0x4f, 0xba, 0x3c, 0x0b, 0x76, 0x0d, 0x10, 0x67, 0x0f, 0x2a, 0x20, 0x53, 0xfa, 0x2c, 0x39, 0xcc, 0xc6, 0x4e, 0xc7, 0xfd, 0x77, 0x92, 0xac, 0x03, 0x7a },
47
+ /* p-1 (order 2) */
48
+ { 0x13, 0xe8, 0x95, 0x8f, 0xc2, 0xb2, 0x27, 0xb0, 0x45, 0xc3, 0xf4, 0x89, 0xf2, 0xef, 0x98, 0xf0, 0xd5, 0xdf, 0xac, 0x05, 0xd3, 0xc6, 0x33, 0x39, 0xb1, 0x38, 0x02, 0x88, 0x6d, 0x53, 0xfc, 0x85 },
49
+ /* p (order 4) */
50
+ { 0xb4, 0x17, 0x6a, 0x70, 0x3d, 0x4d, 0xd8, 0x4f, 0xba, 0x3c, 0x0b, 0x76, 0x0d, 0x10, 0x67, 0x0f, 0x2a, 0x20, 0x53, 0xfa, 0x2c, 0x39, 0xcc, 0xc6, 0x4e, 0xc7, 0xfd, 0x77, 0x92, 0xac, 0x03, 0xfa },
51
+ /* p+1 (order 1) */
52
+ { 0xec, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f },
53
+ /* p+2707385501144840649318225287225658788936804267575313519463743609750303402022 (order 8) */
54
+ { 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f },
55
+ /* p+55188659117513257062467267217118295137698188065244968500265048394206261417927 (order 8) */
56
+ { 0xee, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f },
57
+ /* 2p-1 (order 2) */
58
+ { 0xd9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
59
+ /* 2p (order 4) */
60
+ { 0xda, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
61
+ /* 2p+1 (order 1) */
62
+ { 0xdb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }
63
+ };
64
+ size_t i, j;
65
+ unsigned char c;
66
+
67
+ for (i = 0; i < sizeof blacklist / sizeof blacklist[0]; i++) {
68
+ c = 0;
69
+ for (j = 0; j < 32; j++) {
70
+ c |= R[j] ^ blacklist[i][j];
71
+ }
72
+ if (c == 0) {
73
+ return 1;
74
+ }
75
+ }
76
+ return 0;
77
+ }
78
+ #endif
79
+
12
80
  int
13
81
  crypto_sign_ed25519_verify_detached(const unsigned char *sig,
14
82
  const unsigned char *m,
@@ -23,9 +91,16 @@ crypto_sign_ed25519_verify_detached(const unsigned char *sig,
23
91
  ge_p3 A;
24
92
  ge_p2 R;
25
93
 
94
+ #ifndef ED25519_COMPAT
95
+ if (crypto_sign_check_S_lt_L(sig + 32) != 0 ||
96
+ small_order(sig) != 0) {
97
+ return -1;
98
+ }
99
+ #else
26
100
  if (sig[63] & 224) {
27
101
  return -1;
28
102
  }
103
+ #endif
29
104
  if (ge_frombytes_negate_vartime(&A, pk) != 0) {
30
105
  return -1;
31
106
  }
@@ -88,9 +88,9 @@ int crypto_stream_aes128ctr_afternm(unsigned char *out, unsigned long long len,
88
88
  if(len < 128) goto partial;
89
89
  if(len == 128) goto full;
90
90
 
91
- tmp = load32_bigendian(np + 12);
91
+ tmp = LOAD32_BE(np + 12);
92
92
  tmp += 8;
93
- store32_bigendian(np + 12, tmp);
93
+ STORE32_BE(np + 12, tmp);
94
94
 
95
95
  *(int128 *) (out + 0) = xmm8;
96
96
  *(int128 *) (out + 16) = xmm9;
@@ -111,9 +111,9 @@ int crypto_stream_aes128ctr_afternm(unsigned char *out, unsigned long long len,
111
111
  lensav = len;
112
112
  len >>= 4;
113
113
 
114
- tmp = load32_bigendian(np + 12);
114
+ tmp = LOAD32_BE(np + 12);
115
115
  tmp += len;
116
- store32_bigendian(np + 12, tmp);
116
+ STORE32_BE(np + 12, tmp);
117
117
 
118
118
  blp = bl;
119
119
  *(int128 *)(blp + 0) = xmm8;
@@ -140,9 +140,9 @@ int crypto_stream_aes128ctr_afternm(unsigned char *out, unsigned long long len,
140
140
 
141
141
  full:
142
142
 
143
- tmp = load32_bigendian(np + 12);
143
+ tmp = LOAD32_BE(np + 12);
144
144
  tmp += 8;
145
- store32_bigendian(np + 12, tmp);
145
+ STORE32_BE(np + 12, tmp);
146
146
 
147
147
  *(int128 *) (out + 0) = xmm8;
148
148
  *(int128 *) (out + 16) = xmm9;
@@ -5,24 +5,7 @@
5
5
  #define COMMON_H
6
6
 
7
7
  #include "types.h"
8
-
9
- #define load32_bigendian crypto_stream_aes128ctr_portable_load32_bigendian
10
- uint32 load32_bigendian(const unsigned char *x);
11
-
12
- #define store32_bigendian crypto_stream_aes128ctr_portable_store32_bigendian
13
- void store32_bigendian(unsigned char *x,uint32 u);
14
-
15
- #define load32_littleendian crypto_stream_aes128ctr_portable_load32_littleendian
16
- uint32 load32_littleendian(const unsigned char *x);
17
-
18
- #define store32_littleendian crypto_stream_aes128ctr_portable_store32_littleendian
19
- void store32_littleendian(unsigned char *x,uint32 u);
20
-
21
- #define load64_littleendian crypto_stream_aes128ctr_portable_load64_littleendian
22
- uint64 load64_littleendian(const unsigned char *x);
23
-
24
- #define store64_littleendian crypto_stream_aes128ctr_portable_store64_littleendian
25
- void store64_littleendian(unsigned char *x,uint64 u);
8
+ #include "../../sodium/common.h"
26
9
 
27
10
  /* Macros required only for key expansion */
28
11
 
@@ -68,42 +68,42 @@ void rshift32_littleendian(int128 *r, const unsigned int n)
68
68
  {
69
69
  unsigned char *rp = (unsigned char *)r;
70
70
  uint32 t;
71
- t = load32_littleendian(rp);
71
+ t = LOAD32_LE(rp);
72
72
  t >>= n;
73
- store32_littleendian(rp, t);
74
- t = load32_littleendian(rp+4);
73
+ STORE32_LE(rp, t);
74
+ t = LOAD32_LE(rp+4);
75
75
  t >>= n;
76
- store32_littleendian(rp+4, t);
77
- t = load32_littleendian(rp+8);
76
+ STORE32_LE(rp+4, t);
77
+ t = LOAD32_LE(rp+8);
78
78
  t >>= n;
79
- store32_littleendian(rp+8, t);
80
- t = load32_littleendian(rp+12);
79
+ STORE32_LE(rp+8, t);
80
+ t = LOAD32_LE(rp+12);
81
81
  t >>= n;
82
- store32_littleendian(rp+12, t);
82
+ STORE32_LE(rp+12, t);
83
83
  }
84
84
 
85
85
  void rshift64_littleendian(int128 *r, const unsigned int n)
86
86
  {
87
87
  unsigned char *rp = (unsigned char *)r;
88
88
  uint64 t;
89
- t = load64_littleendian(rp);
89
+ t = LOAD64_LE(rp);
90
90
  t >>= n;
91
- store64_littleendian(rp, t);
92
- t = load64_littleendian(rp+8);
91
+ STORE64_LE(rp, t);
92
+ t = LOAD64_LE(rp+8);
93
93
  t >>= n;
94
- store64_littleendian(rp+8, t);
94
+ STORE64_LE(rp+8, t);
95
95
  }
96
96
 
97
97
  void lshift64_littleendian(int128 *r, const unsigned int n)
98
98
  {
99
99
  unsigned char *rp = (unsigned char *)r;
100
100
  uint64 t;
101
- t = load64_littleendian(rp);
101
+ t = LOAD64_LE(rp);
102
102
  t <<= n;
103
- store64_littleendian(rp, t);
104
- t = load64_littleendian(rp+8);
103
+ STORE64_LE(rp, t);
104
+ t = LOAD64_LE(rp+8);
105
105
  t <<= n;
106
- store64_littleendian(rp+8, t);
106
+ STORE64_LE(rp+8, t);
107
107
  }
108
108
 
109
109
  void toggle(int128 *r)
@@ -116,16 +116,16 @@ void xor_rcon(int128 *r)
116
116
  {
117
117
  unsigned char *rp = (unsigned char *)r;
118
118
  uint32 t;
119
- t = load32_littleendian(rp+12);
119
+ t = LOAD32_LE(rp+12);
120
120
  t ^= 0xffffffff;
121
- store32_littleendian(rp+12, t);
121
+ STORE32_LE(rp+12, t);
122
122
  }
123
123
 
124
124
  void add_uint32_big(int128 *r, uint32 x)
125
125
  {
126
126
  unsigned char *rp = (unsigned char *)r;
127
127
  uint32 t;
128
- t = load32_littleendian(rp+12);
128
+ t = LOAD32_LE(rp+12);
129
129
  t += x;
130
- store32_littleendian(rp+12, t);
130
+ STORE32_LE(rp+12, t);
131
131
  }
@@ -1,10 +1,10 @@
1
1
  #ifndef TYPES_H
2
2
  #define TYPES_H
3
3
 
4
- #include "crypto_uint32.h"
5
- typedef crypto_uint32 uint32;
4
+ #include <stdint.h>
5
+ #include <stdlib.h>
6
6
 
7
- #include "crypto_uint64.h"
8
- typedef crypto_uint64 uint64;
7
+ typedef uint32_t uint32;
8
+ typedef uint64_t uint64;
9
9
 
10
10
  #endif
@@ -88,9 +88,9 @@ int crypto_stream_aes128ctr_xor_afternm(unsigned char *out, const unsigned char
88
88
  if(len < 128) goto partial;
89
89
  if(len == 128) goto full;
90
90
 
91
- tmp = load32_bigendian(np + 12);
91
+ tmp = LOAD32_BE(np + 12);
92
92
  tmp += 8;
93
- store32_bigendian(np + 12, tmp);
93
+ STORE32_BE(np + 12, tmp);
94
94
 
95
95
  xor2(&xmm8, (const int128 *)(in + 0));
96
96
  xor2(&xmm9, (const int128 *)(in + 16));
@@ -121,9 +121,9 @@ int crypto_stream_aes128ctr_xor_afternm(unsigned char *out, const unsigned char
121
121
  lensav = len;
122
122
  len >>= 4;
123
123
 
124
- tmp = load32_bigendian(np + 12);
124
+ tmp = LOAD32_BE(np + 12);
125
125
  tmp += len;
126
- store32_bigendian(np + 12, tmp);
126
+ STORE32_BE(np + 12, tmp);
127
127
 
128
128
  blp = bl;
129
129
  *(int128 *)(blp + 0) = xmm8;
@@ -152,9 +152,9 @@ int crypto_stream_aes128ctr_xor_afternm(unsigned char *out, const unsigned char
152
152
 
153
153
  full:
154
154
 
155
- tmp = load32_bigendian(np + 12);
155
+ tmp = LOAD32_BE(np + 12);
156
156
  tmp += 8;
157
- store32_bigendian(np + 12, tmp);
157
+ STORE32_BE(np + 12, tmp);
158
158
 
159
159
  xor2(&xmm8, (const int128 *)(in + 0));
160
160
  xor2(&xmm9, (const int128 *)(in + 16));
@@ -13,6 +13,7 @@
13
13
  #include "crypto_stream_chacha20.h"
14
14
  #include "stream_chacha20_ref.h"
15
15
  #include "../stream_chacha20.h"
16
+ #include "../../sodium/common.h"
16
17
 
17
18
  struct chacha_ctx {
18
19
  uint32_t input[16];
@@ -32,20 +33,6 @@ typedef struct chacha_ctx chacha_ctx;
32
33
  #define ROTL32(v, n) \
33
34
  (U32V((v) << (n)) | ((v) >> (32 - (n))))
34
35
 
35
- #define U8TO32_LITTLE(p) \
36
- (((u32)((p)[0]) ) | \
37
- ((u32)((p)[1]) << 8) | \
38
- ((u32)((p)[2]) << 16) | \
39
- ((u32)((p)[3]) << 24))
40
-
41
- #define U32TO8_LITTLE(p, v) \
42
- do { \
43
- (p)[0] = U8V((v) ); \
44
- (p)[1] = U8V((v) >> 8); \
45
- (p)[2] = U8V((v) >> 16); \
46
- (p)[3] = U8V((v) >> 24); \
47
- } while (0)
48
-
49
36
  #define ROTATE(v,c) (ROTL32(v,c))
50
37
  #define XOR(v,w) ((v) ^ (w))
51
38
  #define PLUS(v,w) (U32V((v) + (w)))
@@ -57,47 +44,39 @@ typedef struct chacha_ctx chacha_ctx;
57
44
  a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
58
45
  c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
59
46
 
60
- static const unsigned char sigma[16] = {
61
- 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k'
62
- };
63
-
64
47
  static void
65
48
  chacha_keysetup(chacha_ctx *ctx, const u8 *k)
66
49
  {
67
- const unsigned char *constants;
68
-
69
- ctx->input[4] = U8TO32_LITTLE(k + 0);
70
- ctx->input[5] = U8TO32_LITTLE(k + 4);
71
- ctx->input[6] = U8TO32_LITTLE(k + 8);
72
- ctx->input[7] = U8TO32_LITTLE(k + 12);
73
- k += 16;
74
- constants = sigma;
75
- ctx->input[8] = U8TO32_LITTLE(k + 0);
76
- ctx->input[9] = U8TO32_LITTLE(k + 4);
77
- ctx->input[10] = U8TO32_LITTLE(k + 8);
78
- ctx->input[11] = U8TO32_LITTLE(k + 12);
79
- ctx->input[0] = U8TO32_LITTLE(constants + 0);
80
- ctx->input[1] = U8TO32_LITTLE(constants + 4);
81
- ctx->input[2] = U8TO32_LITTLE(constants + 8);
82
- ctx->input[3] = U8TO32_LITTLE(constants + 12);
50
+ ctx->input[0] = U32C(0x61707865);
51
+ ctx->input[1] = U32C(0x3320646e);
52
+ ctx->input[2] = U32C(0x79622d32);
53
+ ctx->input[3] = U32C(0x6b206574);
54
+ ctx->input[4] = LOAD32_LE(k + 0);
55
+ ctx->input[5] = LOAD32_LE(k + 4);
56
+ ctx->input[6] = LOAD32_LE(k + 8);
57
+ ctx->input[7] = LOAD32_LE(k + 12);
58
+ ctx->input[8] = LOAD32_LE(k + 16);
59
+ ctx->input[9] = LOAD32_LE(k + 20);
60
+ ctx->input[10] = LOAD32_LE(k + 24);
61
+ ctx->input[11] = LOAD32_LE(k + 28);
83
62
  }
84
63
 
85
64
  static void
86
65
  chacha_ivsetup(chacha_ctx *ctx, const u8 *iv, const u8 *counter)
87
66
  {
88
- ctx->input[12] = counter == NULL ? 0 : U8TO32_LITTLE(counter + 0);
89
- ctx->input[13] = counter == NULL ? 0 : U8TO32_LITTLE(counter + 4);
90
- ctx->input[14] = U8TO32_LITTLE(iv + 0);
91
- ctx->input[15] = U8TO32_LITTLE(iv + 4);
67
+ ctx->input[12] = counter == NULL ? 0 : LOAD32_LE(counter + 0);
68
+ ctx->input[13] = counter == NULL ? 0 : LOAD32_LE(counter + 4);
69
+ ctx->input[14] = LOAD32_LE(iv + 0);
70
+ ctx->input[15] = LOAD32_LE(iv + 4);
92
71
  }
93
72
 
94
73
  static void
95
74
  chacha_ietf_ivsetup(chacha_ctx *ctx, const u8 *iv, const u8 *counter)
96
75
  {
97
- ctx->input[12] = counter == NULL ? 0 : U8TO32_LITTLE(counter);
98
- ctx->input[13] = U8TO32_LITTLE(iv + 0);
99
- ctx->input[14] = U8TO32_LITTLE(iv + 4);
100
- ctx->input[15] = U8TO32_LITTLE(iv + 8);
76
+ ctx->input[12] = counter == NULL ? 0 : LOAD32_LE(counter);
77
+ ctx->input[13] = LOAD32_LE(iv + 0);
78
+ ctx->input[14] = LOAD32_LE(iv + 4);
79
+ ctx->input[15] = LOAD32_LE(iv + 8);
101
80
  }
102
81
 
103
82
  static void
@@ -185,22 +164,22 @@ chacha_encrypt_bytes(chacha_ctx *ctx, const u8 *m, u8 *c, unsigned long long byt
185
164
  x14 = PLUS(x14, j14);
186
165
  x15 = PLUS(x15, j15);
187
166
 
188
- x0 = XOR(x0, U8TO32_LITTLE(m + 0));
189
- x1 = XOR(x1, U8TO32_LITTLE(m + 4));
190
- x2 = XOR(x2, U8TO32_LITTLE(m + 8));
191
- x3 = XOR(x3, U8TO32_LITTLE(m + 12));
192
- x4 = XOR(x4, U8TO32_LITTLE(m + 16));
193
- x5 = XOR(x5, U8TO32_LITTLE(m + 20));
194
- x6 = XOR(x6, U8TO32_LITTLE(m + 24));
195
- x7 = XOR(x7, U8TO32_LITTLE(m + 28));
196
- x8 = XOR(x8, U8TO32_LITTLE(m + 32));
197
- x9 = XOR(x9, U8TO32_LITTLE(m + 36));
198
- x10 = XOR(x10, U8TO32_LITTLE(m + 40));
199
- x11 = XOR(x11, U8TO32_LITTLE(m + 44));
200
- x12 = XOR(x12, U8TO32_LITTLE(m + 48));
201
- x13 = XOR(x13, U8TO32_LITTLE(m + 52));
202
- x14 = XOR(x14, U8TO32_LITTLE(m + 56));
203
- x15 = XOR(x15, U8TO32_LITTLE(m + 60));
167
+ x0 = XOR(x0, LOAD32_LE(m + 0));
168
+ x1 = XOR(x1, LOAD32_LE(m + 4));
169
+ x2 = XOR(x2, LOAD32_LE(m + 8));
170
+ x3 = XOR(x3, LOAD32_LE(m + 12));
171
+ x4 = XOR(x4, LOAD32_LE(m + 16));
172
+ x5 = XOR(x5, LOAD32_LE(m + 20));
173
+ x6 = XOR(x6, LOAD32_LE(m + 24));
174
+ x7 = XOR(x7, LOAD32_LE(m + 28));
175
+ x8 = XOR(x8, LOAD32_LE(m + 32));
176
+ x9 = XOR(x9, LOAD32_LE(m + 36));
177
+ x10 = XOR(x10, LOAD32_LE(m + 40));
178
+ x11 = XOR(x11, LOAD32_LE(m + 44));
179
+ x12 = XOR(x12, LOAD32_LE(m + 48));
180
+ x13 = XOR(x13, LOAD32_LE(m + 52));
181
+ x14 = XOR(x14, LOAD32_LE(m + 56));
182
+ x15 = XOR(x15, LOAD32_LE(m + 60));
204
183
 
205
184
  j12 = PLUSONE(j12);
206
185
  /* LCOV_EXCL_START */
@@ -209,22 +188,22 @@ chacha_encrypt_bytes(chacha_ctx *ctx, const u8 *m, u8 *c, unsigned long long byt
209
188
  }
210
189
  /* LCOV_EXCL_STOP */
211
190
 
212
- U32TO8_LITTLE(c + 0, x0);
213
- U32TO8_LITTLE(c + 4, x1);
214
- U32TO8_LITTLE(c + 8, x2);
215
- U32TO8_LITTLE(c + 12, x3);
216
- U32TO8_LITTLE(c + 16, x4);
217
- U32TO8_LITTLE(c + 20, x5);
218
- U32TO8_LITTLE(c + 24, x6);
219
- U32TO8_LITTLE(c + 28, x7);
220
- U32TO8_LITTLE(c + 32, x8);
221
- U32TO8_LITTLE(c + 36, x9);
222
- U32TO8_LITTLE(c + 40, x10);
223
- U32TO8_LITTLE(c + 44, x11);
224
- U32TO8_LITTLE(c + 48, x12);
225
- U32TO8_LITTLE(c + 52, x13);
226
- U32TO8_LITTLE(c + 56, x14);
227
- U32TO8_LITTLE(c + 60, x15);
191
+ STORE32_LE(c + 0, x0);
192
+ STORE32_LE(c + 4, x1);
193
+ STORE32_LE(c + 8, x2);
194
+ STORE32_LE(c + 12, x3);
195
+ STORE32_LE(c + 16, x4);
196
+ STORE32_LE(c + 20, x5);
197
+ STORE32_LE(c + 24, x6);
198
+ STORE32_LE(c + 28, x7);
199
+ STORE32_LE(c + 32, x8);
200
+ STORE32_LE(c + 36, x9);
201
+ STORE32_LE(c + 40, x10);
202
+ STORE32_LE(c + 44, x11);
203
+ STORE32_LE(c + 48, x12);
204
+ STORE32_LE(c + 52, x13);
205
+ STORE32_LE(c + 56, x14);
206
+ STORE32_LE(c + 60, x15);
228
207
 
229
208
  if (bytes <= 64) {
230
209
  if (bytes < 64) {
@@ -296,8 +275,8 @@ stream_ref_xor_ic(unsigned char *c, const unsigned char *m,
296
275
  }
297
276
  ic_high = U32V(ic >> 32);
298
277
  ic_low = U32V(ic);
299
- U32TO8_LITTLE(&ic_bytes[0], ic_low);
300
- U32TO8_LITTLE(&ic_bytes[4], ic_high);
278
+ STORE32_LE(&ic_bytes[0], ic_low);
279
+ STORE32_LE(&ic_bytes[4], ic_high);
301
280
  chacha_keysetup(&ctx, k);
302
281
  chacha_ivsetup(&ctx, n, ic_bytes);
303
282
  chacha_encrypt_bytes(&ctx, m, c, mlen);
@@ -318,7 +297,7 @@ stream_ietf_ref_xor_ic(unsigned char *c, const unsigned char *m,
318
297
  if (!mlen) {
319
298
  return 0;
320
299
  }
321
- U32TO8_LITTLE(ic_bytes, ic);
300
+ STORE32_LE(ic_bytes, ic);
322
301
  chacha_keysetup(&ctx, k);
323
302
  chacha_ietf_ivsetup(&ctx, n, ic_bytes);
324
303
  chacha_encrypt_bytes(&ctx, m, c, mlen);