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
@@ -8,12 +8,12 @@
8
8
  typedef int32_t fe[10];
9
9
 
10
10
  /*
11
- fe means field element.
12
- Here the field is \Z/(2^255-19).
13
- An element t, entries t[0]...t[9], represents the integer
14
- t[0]+2^26 t[1]+2^51 t[2]+2^77 t[3]+2^102 t[4]+...+2^230 t[9].
15
- Bounds on each t[i] vary depending on context.
16
- */
11
+ fe means field element.
12
+ Here the field is \Z/(2^255-19).
13
+ An element t, entries t[0]...t[9], represents the integer
14
+ t[0]+2^26 t[1]+2^51 t[2]+2^77 t[3]+2^102 t[4]+...+2^230 t[9].
15
+ Bounds on each t[i] vary depending on context.
16
+ */
17
17
 
18
18
  #define fe_frombytes crypto_core_curve25519_ref10_fe_frombytes
19
19
  #define fe_tobytes crypto_core_curve25519_ref10_fe_tobytes
@@ -51,55 +51,55 @@ extern void fe_invert(fe,const fe);
51
51
  extern void fe_pow22523(fe,const fe);
52
52
 
53
53
  /*
54
- ge means group element.
55
-
56
- Here the group is the set of pairs (x,y) of field elements (see fe.h)
57
- satisfying -x^2 + y^2 = 1 + d x^2y^2
58
- where d = -121665/121666.
59
-
60
- Representations:
61
- ge_p2 (projective): (X:Y:Z) satisfying x=X/Z, y=Y/Z
62
- ge_p3 (extended): (X:Y:Z:T) satisfying x=X/Z, y=Y/Z, XY=ZT
63
- ge_p1p1 (completed): ((X:Z),(Y:T)) satisfying x=X/Z, y=Y/T
64
- ge_precomp (Duif): (y+x,y-x,2dxy)
65
- */
54
+ ge means group element.
55
+ *
56
+ Here the group is the set of pairs (x,y) of field elements (see fe.h)
57
+ satisfying -x^2 + y^2 = 1 + d x^2y^2
58
+ where d = -121665/121666.
59
+ *
60
+ Representations:
61
+ ge_p2 (projective): (X:Y:Z) satisfying x=X/Z, y=Y/Z
62
+ ge_p3 (extended): (X:Y:Z:T) satisfying x=X/Z, y=Y/Z, XY=ZT
63
+ ge_p1p1 (completed): ((X:Z),(Y:T)) satisfying x=X/Z, y=Y/T
64
+ ge_precomp (Duif): (y+x,y-x,2dxy)
65
+ */
66
66
 
67
67
  #define ge_p2 crypto_core_curve25519_ref10_ge_p2
68
68
  typedef struct {
69
- fe X;
70
- fe Y;
71
- fe Z;
69
+ fe X;
70
+ fe Y;
71
+ fe Z;
72
72
  } ge_p2;
73
73
 
74
74
  #define ge_p3 crypto_core_curve25519_ref10_ge_p3
75
75
  typedef struct {
76
- fe X;
77
- fe Y;
78
- fe Z;
79
- fe T;
76
+ fe X;
77
+ fe Y;
78
+ fe Z;
79
+ fe T;
80
80
  } ge_p3;
81
81
 
82
82
  #define ge_p1p1 crypto_core_curve25519_ref10_ge_p1p1
83
83
  typedef struct {
84
- fe X;
85
- fe Y;
86
- fe Z;
87
- fe T;
84
+ fe X;
85
+ fe Y;
86
+ fe Z;
87
+ fe T;
88
88
  } ge_p1p1;
89
89
 
90
90
  #define ge_precomp crypto_core_curve25519_ref10_ge_precomp
91
91
  typedef struct {
92
- fe yplusx;
93
- fe yminusx;
94
- fe xy2d;
92
+ fe yplusx;
93
+ fe yminusx;
94
+ fe xy2d;
95
95
  } ge_precomp;
96
96
 
97
97
  #define ge_cached crypto_core_curve25519_ref10_ge_cached
98
98
  typedef struct {
99
- fe YplusX;
100
- fe YminusX;
101
- fe Z;
102
- fe T2d;
99
+ fe YplusX;
100
+ fe YminusX;
101
+ fe Z;
102
+ fe T2d;
103
103
  } ge_cached;
104
104
 
105
105
  #define ge_frombytes_negate_vartime crypto_core_curve25519_ref10_ge_frombytes_negate_vartime
@@ -147,9 +147,9 @@ extern void ge_double_scalarmult_vartime(ge_p2 *,const unsigned char *,const ge_
147
147
  extern void ge_scalarmult_vartime(ge_p3 *,const unsigned char *,const ge_p3 *);
148
148
 
149
149
  /*
150
- The set of scalars is \Z/l
151
- where l = 2^252 + 27742317777372353535851937790883648493.
152
- */
150
+ The set of scalars is \Z/l
151
+ where l = 2^252 + 27742317777372353535851937790883648493.
152
+ */
153
153
 
154
154
  #define sc_reduce crypto_core_curve25519_ref10_sc_reduce
155
155
  #define sc_muladd crypto_core_curve25519_ref10_sc_muladd
@@ -0,0 +1,86 @@
1
+
2
+ #include <stdint.h>
3
+ #include <stdlib.h>
4
+
5
+ #include "core_hchacha20.h"
6
+ #include "crypto_core_hchacha20.h"
7
+ #include "../../sodium/common.h"
8
+
9
+ int
10
+ crypto_core_hchacha20(unsigned char *out, const unsigned char *in,
11
+ const unsigned char *k, const unsigned char *c)
12
+ {
13
+ int i;
14
+ uint32_t x0, x1, x2, x3, x4, x5, x6, x7;
15
+ uint32_t x8, x9, x10, x11, x12, x13, x14, x15;
16
+
17
+ if (c == NULL) {
18
+ x0 = U32C(0x61707865);
19
+ x1 = U32C(0x3320646e);
20
+ x2 = U32C(0x79622d32);
21
+ x3 = U32C(0x6b206574);
22
+ } else {
23
+ x0 = LOAD32_LE(c + 0);
24
+ x1 = LOAD32_LE(c + 4);
25
+ x2 = LOAD32_LE(c + 8);
26
+ x3 = LOAD32_LE(c + 12);
27
+ }
28
+ x4 = LOAD32_LE(k + 0);
29
+ x5 = LOAD32_LE(k + 4);
30
+ x6 = LOAD32_LE(k + 8);
31
+ x7 = LOAD32_LE(k + 12);
32
+ x8 = LOAD32_LE(k + 16);
33
+ x9 = LOAD32_LE(k + 20);
34
+ x10 = LOAD32_LE(k + 24);
35
+ x11 = LOAD32_LE(k + 28);
36
+ x12 = LOAD32_LE(in + 0);
37
+ x13 = LOAD32_LE(in + 4);
38
+ x14 = LOAD32_LE(in + 8);
39
+ x15 = LOAD32_LE(in + 12);
40
+
41
+ for (i = 0; i < 10; i++) {
42
+ QUARTERROUND(x0, x4, x8, x12);
43
+ QUARTERROUND(x1, x5, x9, x13);
44
+ QUARTERROUND(x2, x6, x10, x14);
45
+ QUARTERROUND(x3, x7, x11, x15);
46
+ QUARTERROUND(x0, x5, x10, x15);
47
+ QUARTERROUND(x1, x6, x11, x12);
48
+ QUARTERROUND(x2, x7, x8, x13);
49
+ QUARTERROUND(x3, x4, x9, x14);
50
+ }
51
+
52
+ STORE32_LE(out + 0, x0);
53
+ STORE32_LE(out + 4, x1);
54
+ STORE32_LE(out + 8, x2);
55
+ STORE32_LE(out + 12, x3);
56
+ STORE32_LE(out + 16, x12);
57
+ STORE32_LE(out + 20, x13);
58
+ STORE32_LE(out + 24, x14);
59
+ STORE32_LE(out + 28, x15);
60
+
61
+ return 0;
62
+ }
63
+
64
+ size_t
65
+ crypto_core_hchacha20_outputbytes(void)
66
+ {
67
+ return crypto_core_hchacha20_OUTPUTBYTES;
68
+ }
69
+
70
+ size_t
71
+ crypto_core_hchacha20_inputbytes(void)
72
+ {
73
+ return crypto_core_hchacha20_INPUTBYTES;
74
+ }
75
+
76
+ size_t
77
+ crypto_core_hchacha20_keybytes(void)
78
+ {
79
+ return crypto_core_hchacha20_KEYBYTES;
80
+ }
81
+
82
+ size_t
83
+ crypto_core_hchacha20_constbytes(void)
84
+ {
85
+ return crypto_core_hchacha20_CONSTBYTES;
86
+ }
@@ -0,0 +1,28 @@
1
+ #ifndef core_hchacha20_H
2
+ #define core_hchacha20_H
3
+
4
+ #include <stdint.h>
5
+ #include <stdlib.h>
6
+ #include <string.h>
7
+
8
+ #define U8C(v) (v##U)
9
+ #define U32C(v) (v##U)
10
+
11
+ #define U8V(v) ((uint8_t)(v) & U8C(0xFF))
12
+ #define U32V(v) ((uint32_t)(v) & U32C(0xFFFFFFFF))
13
+
14
+ #define ROTL32(v, n) (U32V((v) << (n)) | ((v) >> (32 - (n))))
15
+
16
+ #define ROTATE(v, c) (ROTL32(v, c))
17
+ #define XOR(v, w) ((v) ^ (w))
18
+ #define PLUS(v, w) (U32V((v) + (w)))
19
+
20
+ #define QUARTERROUND(a, b, c, d) \
21
+ do { \
22
+ a = PLUS(a, b); d = ROTATE(XOR(d, a), 16); \
23
+ c = PLUS(c, d); b = ROTATE(XOR(b, c), 12); \
24
+ a = PLUS(a, b); d = ROTATE(XOR(d, a), 8); \
25
+ c = PLUS(c, d); b = ROTATE(XOR(b, c), 7); \
26
+ } while(0)
27
+
28
+ #endif
@@ -4,35 +4,20 @@ D. J. Bernstein
4
4
  Public domain.
5
5
  */
6
6
 
7
+ #include <stdint.h>
8
+ #include <stdlib.h>
9
+
7
10
  #include "crypto_core_hsalsa20.h"
11
+ #include "../../sodium/common.h"
8
12
 
9
13
  #define ROUNDS 20
14
+ #define U32C(v) (v##U)
10
15
 
11
- typedef unsigned int uint32;
12
-
13
- static uint32 rotate(uint32 u,int c)
16
+ static uint32_t rotate(uint32_t u,int c)
14
17
  {
15
18
  return (u << c) | (u >> (32 - c));
16
19
  }
17
20
 
18
- static uint32 load_littleendian(const unsigned char *x)
19
- {
20
- return
21
- (uint32) (x[0]) \
22
- | (((uint32) (x[1])) << 8) \
23
- | (((uint32) (x[2])) << 16) \
24
- | (((uint32) (x[3])) << 24)
25
- ;
26
- }
27
-
28
- static void store_littleendian(unsigned char *x,uint32 u)
29
- {
30
- x[0] = u; u >>= 8;
31
- x[1] = u; u >>= 8;
32
- x[2] = u; u >>= 8;
33
- x[3] = u;
34
- }
35
-
36
21
  int crypto_core_hsalsa20(
37
22
  unsigned char *out,
38
23
  const unsigned char *in,
@@ -40,25 +25,32 @@ int crypto_core_hsalsa20(
40
25
  const unsigned char *c
41
26
  )
42
27
  {
43
- uint32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
28
+ uint32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
44
29
  int i;
45
30
 
46
- x0 = load_littleendian(c + 0);
47
- x1 = load_littleendian(k + 0);
48
- x2 = load_littleendian(k + 4);
49
- x3 = load_littleendian(k + 8);
50
- x4 = load_littleendian(k + 12);
51
- x5 = load_littleendian(c + 4);
52
- x6 = load_littleendian(in + 0);
53
- x7 = load_littleendian(in + 4);
54
- x8 = load_littleendian(in + 8);
55
- x9 = load_littleendian(in + 12);
56
- x10 = load_littleendian(c + 8);
57
- x11 = load_littleendian(k + 16);
58
- x12 = load_littleendian(k + 20);
59
- x13 = load_littleendian(k + 24);
60
- x14 = load_littleendian(k + 28);
61
- x15 = load_littleendian(c + 12);
31
+ if (c == NULL) {
32
+ x0 = U32C(0x61707865);
33
+ x5 = U32C(0x3320646e);
34
+ x10 = U32C(0x79622d32);
35
+ x15 = U32C(0x6b206574);
36
+ } else {
37
+ x0 = LOAD32_LE(c + 0);
38
+ x5 = LOAD32_LE(c + 4);
39
+ x10 = LOAD32_LE(c + 8);
40
+ x15 = LOAD32_LE(c + 12);
41
+ }
42
+ x1 = LOAD32_LE(k + 0);
43
+ x2 = LOAD32_LE(k + 4);
44
+ x3 = LOAD32_LE(k + 8);
45
+ x4 = LOAD32_LE(k + 12);
46
+ x11 = LOAD32_LE(k + 16);
47
+ x12 = LOAD32_LE(k + 20);
48
+ x13 = LOAD32_LE(k + 24);
49
+ x14 = LOAD32_LE(k + 28);
50
+ x6 = LOAD32_LE(in + 0);
51
+ x7 = LOAD32_LE(in + 4);
52
+ x8 = LOAD32_LE(in + 8);
53
+ x9 = LOAD32_LE(in + 12);
62
54
 
63
55
  for (i = ROUNDS;i > 0;i -= 2) {
64
56
  x4 ^= rotate( x0+x12, 7);
@@ -95,14 +87,14 @@ int crypto_core_hsalsa20(
95
87
  x15 ^= rotate(x14+x13,18);
96
88
  }
97
89
 
98
- store_littleendian(out + 0,x0);
99
- store_littleendian(out + 4,x5);
100
- store_littleendian(out + 8,x10);
101
- store_littleendian(out + 12,x15);
102
- store_littleendian(out + 16,x6);
103
- store_littleendian(out + 20,x7);
104
- store_littleendian(out + 24,x8);
105
- store_littleendian(out + 28,x9);
90
+ STORE32_LE(out + 0,x0);
91
+ STORE32_LE(out + 4,x5);
92
+ STORE32_LE(out + 8,x10);
93
+ STORE32_LE(out + 12,x15);
94
+ STORE32_LE(out + 16,x6);
95
+ STORE32_LE(out + 20,x7);
96
+ STORE32_LE(out + 24,x8);
97
+ STORE32_LE(out + 28,x9);
106
98
 
107
99
  return 0;
108
100
  }
@@ -4,35 +4,20 @@ D. J. Bernstein
4
4
  Public domain.
5
5
  */
6
6
 
7
+ #include <stdint.h>
8
+ #include <stdlib.h>
9
+
7
10
  #include "crypto_core_salsa20.h"
11
+ #include "../../sodium/common.h"
8
12
 
9
13
  #define ROUNDS 20
14
+ #define U32C(v) (v##U)
10
15
 
11
- typedef unsigned int uint32;
12
-
13
- static uint32 rotate(uint32 u,int c)
16
+ static uint32_t rotate(uint32_t u,int c)
14
17
  {
15
18
  return (u << c) | (u >> (32 - c));
16
19
  }
17
20
 
18
- static uint32 load_littleendian(const unsigned char *x)
19
- {
20
- return
21
- (uint32) (x[0]) \
22
- | (((uint32) (x[1])) << 8) \
23
- | (((uint32) (x[2])) << 16) \
24
- | (((uint32) (x[3])) << 24)
25
- ;
26
- }
27
-
28
- static void store_littleendian(unsigned char *x,uint32 u)
29
- {
30
- x[0] = u; u >>= 8;
31
- x[1] = u; u >>= 8;
32
- x[2] = u; u >>= 8;
33
- x[3] = u;
34
- }
35
-
36
21
  int crypto_core_salsa20(
37
22
  unsigned char *out,
38
23
  const unsigned char *in,
@@ -40,26 +25,33 @@ int crypto_core_salsa20(
40
25
  const unsigned char *c
41
26
  )
42
27
  {
43
- uint32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
44
- uint32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
28
+ uint32_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
29
+ uint32_t j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
45
30
  int i;
46
31
 
47
- j0 = x0 = load_littleendian(c + 0);
48
- j1 = x1 = load_littleendian(k + 0);
49
- j2 = x2 = load_littleendian(k + 4);
50
- j3 = x3 = load_littleendian(k + 8);
51
- j4 = x4 = load_littleendian(k + 12);
52
- j5 = x5 = load_littleendian(c + 4);
53
- j6 = x6 = load_littleendian(in + 0);
54
- j7 = x7 = load_littleendian(in + 4);
55
- j8 = x8 = load_littleendian(in + 8);
56
- j9 = x9 = load_littleendian(in + 12);
57
- j10 = x10 = load_littleendian(c + 8);
58
- j11 = x11 = load_littleendian(k + 16);
59
- j12 = x12 = load_littleendian(k + 20);
60
- j13 = x13 = load_littleendian(k + 24);
61
- j14 = x14 = load_littleendian(k + 28);
62
- j15 = x15 = load_littleendian(c + 12);
32
+ if (c == NULL) {
33
+ j0 = x0 = U32C(0x61707865);
34
+ j5 = x5 = U32C(0x3320646e);
35
+ j10 = x10 = U32C(0x79622d32);
36
+ j15 = x15 = U32C(0x6b206574);
37
+ } else {
38
+ j0 = x0 = LOAD32_LE(c + 0);
39
+ j5 = x5 = LOAD32_LE(c + 4);
40
+ j10 = x10 = LOAD32_LE(c + 8);
41
+ j15 = x15 = LOAD32_LE(c + 12);
42
+ }
43
+ j1 = x1 = LOAD32_LE(k + 0);
44
+ j2 = x2 = LOAD32_LE(k + 4);
45
+ j3 = x3 = LOAD32_LE(k + 8);
46
+ j4 = x4 = LOAD32_LE(k + 12);
47
+ j6 = x6 = LOAD32_LE(in + 0);
48
+ j7 = x7 = LOAD32_LE(in + 4);
49
+ j8 = x8 = LOAD32_LE(in + 8);
50
+ j9 = x9 = LOAD32_LE(in + 12);
51
+ j11 = x11 = LOAD32_LE(k + 16);
52
+ j12 = x12 = LOAD32_LE(k + 20);
53
+ j13 = x13 = LOAD32_LE(k + 24);
54
+ j14 = x14 = LOAD32_LE(k + 28);
63
55
 
64
56
  for (i = ROUNDS;i > 0;i -= 2) {
65
57
  x4 ^= rotate( x0+x12, 7);
@@ -113,22 +105,22 @@ int crypto_core_salsa20(
113
105
  x14 += j14;
114
106
  x15 += j15;
115
107
 
116
- store_littleendian(out + 0,x0);
117
- store_littleendian(out + 4,x1);
118
- store_littleendian(out + 8,x2);
119
- store_littleendian(out + 12,x3);
120
- store_littleendian(out + 16,x4);
121
- store_littleendian(out + 20,x5);
122
- store_littleendian(out + 24,x6);
123
- store_littleendian(out + 28,x7);
124
- store_littleendian(out + 32,x8);
125
- store_littleendian(out + 36,x9);
126
- store_littleendian(out + 40,x10);
127
- store_littleendian(out + 44,x11);
128
- store_littleendian(out + 48,x12);
129
- store_littleendian(out + 52,x13);
130
- store_littleendian(out + 56,x14);
131
- store_littleendian(out + 60,x15);
108
+ STORE32_LE(out + 0,x0);
109
+ STORE32_LE(out + 4,x1);
110
+ STORE32_LE(out + 8,x2);
111
+ STORE32_LE(out + 12,x3);
112
+ STORE32_LE(out + 16,x4);
113
+ STORE32_LE(out + 20,x5);
114
+ STORE32_LE(out + 24,x6);
115
+ STORE32_LE(out + 28,x7);
116
+ STORE32_LE(out + 32,x8);
117
+ STORE32_LE(out + 36,x9);
118
+ STORE32_LE(out + 40,x10);
119
+ STORE32_LE(out + 44,x11);
120
+ STORE32_LE(out + 48,x12);
121
+ STORE32_LE(out + 52,x13);
122
+ STORE32_LE(out + 56,x14);
123
+ STORE32_LE(out + 60,x15);
132
124
 
133
125
  return 0;
134
126
  }