rbnacl-libsodium 1.0.11 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (465) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +4 -0
  3. data/lib/rbnacl/libsodium/version.rb +1 -1
  4. data/vendor/libsodium/AUTHORS +45 -33
  5. data/vendor/libsodium/ChangeLog +63 -2
  6. data/vendor/libsodium/LICENSE +1 -1
  7. data/vendor/libsodium/Makefile.am +1 -0
  8. data/vendor/libsodium/Makefile.in +17 -14
  9. data/vendor/libsodium/README.markdown +1 -0
  10. data/vendor/libsodium/THANKS +38 -4
  11. data/vendor/libsodium/aclocal.m4 +25 -24
  12. data/vendor/libsodium/autogen.sh +12 -7
  13. data/vendor/libsodium/autom4te.cache/output.0 +5066 -2281
  14. data/vendor/libsodium/autom4te.cache/output.1 +1013 -600
  15. data/vendor/libsodium/autom4te.cache/output.2 +5066 -2281
  16. data/vendor/libsodium/autom4te.cache/requests +426 -1584
  17. data/vendor/libsodium/autom4te.cache/traces.0 +2044 -876
  18. data/vendor/libsodium/autom4te.cache/traces.1 +996 -523
  19. data/vendor/libsodium/autom4te.cache/traces.2 +1996 -828
  20. data/vendor/libsodium/build-aux/compile +5 -4
  21. data/vendor/libsodium/build-aux/config.guess +120 -68
  22. data/vendor/libsodium/build-aux/config.sub +51 -22
  23. data/vendor/libsodium/build-aux/depcomp +3 -3
  24. data/vendor/libsodium/build-aux/install-sh +2 -2
  25. data/vendor/libsodium/build-aux/missing +3 -3
  26. data/vendor/libsodium/build-aux/test-driver +3 -3
  27. data/vendor/libsodium/builds/msvc/properties/Win32.props +4 -1
  28. data/vendor/libsodium/builds/msvc/properties/x64.props +4 -1
  29. data/vendor/libsodium/builds/msvc/resource.h +14 -0
  30. data/vendor/libsodium/builds/msvc/resource.rc +63 -0
  31. data/vendor/libsodium/builds/msvc/version.h +7 -4
  32. data/vendor/libsodium/builds/msvc/vs2010/libsodium.import.props +1 -1
  33. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.props +10 -5
  34. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +182 -139
  35. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +632 -470
  36. data/vendor/libsodium/builds/msvc/vs2012/libsodium.import.props +1 -1
  37. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.props +10 -5
  38. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +182 -129
  39. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +632 -470
  40. data/vendor/libsodium/builds/msvc/vs2013/libsodium.import.props +1 -1
  41. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.props +10 -5
  42. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +182 -129
  43. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +632 -470
  44. data/vendor/libsodium/builds/msvc/vs2015/libsodium.import.props +1 -1
  45. data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.props +10 -5
  46. data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +181 -118
  47. data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +632 -470
  48. data/vendor/libsodium/builds/msvc/vs2017/libsodium.import.props +52 -0
  49. data/vendor/libsodium/builds/msvc/vs2017/libsodium.import.xml +17 -0
  50. data/vendor/libsodium/builds/msvc/vs2017/libsodium.sln +52 -0
  51. data/vendor/libsodium/builds/msvc/vs2017/libsodium/libsodium.props +48 -0
  52. data/vendor/libsodium/builds/msvc/vs2017/libsodium/libsodium.vcxproj +320 -0
  53. data/vendor/libsodium/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters +962 -0
  54. data/vendor/libsodium/builds/msvc/vs2017/libsodium/libsodium.xml +15 -0
  55. data/vendor/libsodium/configure +1002 -589
  56. data/vendor/libsodium/configure.ac +48 -21
  57. data/vendor/libsodium/contrib/Findsodium.cmake +267 -0
  58. data/vendor/libsodium/contrib/Makefile.am +3 -0
  59. data/vendor/libsodium/contrib/Makefile.in +483 -0
  60. data/vendor/libsodium/dist-build/Makefile.in +11 -7
  61. data/vendor/libsodium/dist-build/android-armv8-a.sh +1 -1
  62. data/vendor/libsodium/dist-build/android-build.sh +25 -17
  63. data/vendor/libsodium/dist-build/android-mips32.sh +1 -1
  64. data/vendor/libsodium/dist-build/android-mips64.sh +1 -1
  65. data/vendor/libsodium/dist-build/android-x86_64.sh +1 -1
  66. data/vendor/libsodium/dist-build/emscripten-symbols.def +150 -2
  67. data/vendor/libsodium/dist-build/emscripten-wasm.sh +132 -0
  68. data/vendor/libsodium/dist-build/emscripten.sh +8 -6
  69. data/vendor/libsodium/dist-build/ios.sh +29 -5
  70. data/vendor/libsodium/libsodium.vcxproj +139 -77
  71. data/vendor/libsodium/libsodium.vcxproj.filters +315 -144
  72. data/vendor/libsodium/m4/ax_check_catchable_segv.m4 +42 -0
  73. data/vendor/libsodium/m4/ax_check_compile_flag.m4 +6 -4
  74. data/vendor/libsodium/m4/ax_check_define.m4 +3 -3
  75. data/vendor/libsodium/m4/ax_check_gnu_make.m4 +31 -25
  76. data/vendor/libsodium/m4/ax_check_link_flag.m4 +8 -6
  77. data/vendor/libsodium/m4/ax_pthread.m4 +275 -275
  78. data/vendor/libsodium/m4/ax_valgrind_check.m4 +92 -41
  79. data/vendor/libsodium/m4/pkg.m4 +1 -1
  80. data/vendor/libsodium/msvc-scripts/Makefile.in +11 -7
  81. data/vendor/libsodium/msvc-scripts/process.bat +4 -3
  82. data/vendor/libsodium/packaging/dotnet-core/README.md +59 -0
  83. data/vendor/libsodium/packaging/dotnet-core/desktop.targets +16 -0
  84. data/vendor/libsodium/packaging/dotnet-core/libsodium.props +33 -0
  85. data/vendor/libsodium/packaging/dotnet-core/prepare.py +262 -0
  86. data/vendor/libsodium/packaging/dotnet-core/recipes/alpine-x64 +3 -0
  87. data/vendor/libsodium/packaging/dotnet-core/recipes/build +9 -0
  88. data/vendor/libsodium/packaging/dotnet-core/recipes/centos-x64 +3 -0
  89. data/vendor/libsodium/packaging/dotnet-core/recipes/debian-x64 +4 -0
  90. data/vendor/libsodium/packaging/dotnet-core/recipes/fedora-x64 +3 -0
  91. data/vendor/libsodium/packaging/dotnet-core/recipes/opensuse-x64 +3 -0
  92. data/vendor/libsodium/packaging/dotnet-core/recipes/pack +5 -0
  93. data/vendor/libsodium/packaging/dotnet-core/recipes/test +27 -0
  94. data/vendor/libsodium/packaging/dotnet-core/recipes/ubuntu-x64 +4 -0
  95. data/vendor/libsodium/packaging/nuget/package.config +1 -1
  96. data/vendor/libsodium/packaging/nuget/package.gsl +3 -3
  97. data/vendor/libsodium/src/Makefile.in +11 -7
  98. data/vendor/libsodium/src/libsodium/Makefile.am +113 -98
  99. data/vendor/libsodium/src/libsodium/Makefile.in +1034 -1236
  100. data/vendor/libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +31 -12
  101. data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +31 -10
  102. data/vendor/libsodium/src/libsodium/crypto_aead/xchacha20poly1305/sodium/aead_xchacha20poly1305.c +153 -0
  103. data/vendor/libsodium/src/libsodium/crypto_auth/crypto_auth.c +7 -0
  104. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/{cp/hmac_hmacsha256.c → auth_hmacsha256.c} +43 -35
  105. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/{cp/hmac_hmacsha512.c → auth_hmacsha512.c} +43 -35
  106. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/{cp/hmac_hmacsha512256.c → auth_hmacsha512256.c} +48 -9
  107. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_easy.c +4 -3
  108. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_seal.c +2 -1
  109. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xchacha20poly1305/box_curve25519xchacha20poly1305.c +197 -0
  110. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xchacha20poly1305/box_seal_curve25519xchacha20poly1305.c +79 -0
  111. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305.c +150 -0
  112. data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.c +1156 -662
  113. data/vendor/libsodium/src/libsodium/crypto_core/hchacha20/core_hchacha20.c +12 -5
  114. data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/{core_hsalsa20_api.c → core_hsalsa20.c} +0 -0
  115. data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20_ref2.c +95 -0
  116. data/vendor/libsodium/src/libsodium/crypto_core/salsa/ref/core_salsa_ref.c +195 -0
  117. data/vendor/libsodium/src/libsodium/crypto_generichash/{blake2/generichash_blake2_api.c → blake2b/generichash_blake2.c} +7 -0
  118. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2.h +109 -0
  119. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-avx2.c +49 -0
  120. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-avx2.h +140 -0
  121. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ref.c +92 -0
  122. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-sse41.c +87 -0
  123. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-sse41.h +103 -0
  124. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ssse3.c +90 -0
  125. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ssse3.h +103 -0
  126. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-load-avx2.h +340 -0
  127. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-load-sse2.h +164 -0
  128. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-load-sse41.h +307 -0
  129. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-ref.c +494 -0
  130. data/vendor/libsodium/src/libsodium/crypto_generichash/{blake2 → blake2b}/ref/generichash_blake2b.c +22 -26
  131. data/vendor/libsodium/src/libsodium/crypto_generichash/crypto_generichash.c +7 -0
  132. data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256_cp.c +254 -0
  133. data/vendor/libsodium/src/libsodium/crypto_hash/sha256/{hash_sha256_api.c → hash_sha256.c} +4 -2
  134. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512_cp.c +280 -0
  135. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/{hash_sha512_api.c → hash_sha512.c} +4 -2
  136. data/vendor/libsodium/src/libsodium/crypto_kdf/blake2b/kdf_blake2b.c +52 -0
  137. data/vendor/libsodium/src/libsodium/crypto_kdf/crypto_kdf.c +49 -0
  138. data/vendor/libsodium/src/libsodium/crypto_kx/crypto_kx.c +136 -0
  139. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/crypto_onetimeauth.c +6 -0
  140. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.c +34 -27
  141. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +1 -1
  142. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +203 -156
  143. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +178 -134
  144. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c +22 -4
  145. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.h +10 -12
  146. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c +564 -315
  147. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.h +1 -1
  148. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.c +131 -84
  149. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.h +23 -18
  150. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c +163 -145
  151. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-encoding.h +2 -1
  152. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-avx2.c +247 -0
  153. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ref.c +42 -29
  154. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ssse3.c +71 -47
  155. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.c +100 -65
  156. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.h +77 -23
  157. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blake2b-long.c +30 -31
  158. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blamka-round-avx2.h +150 -0
  159. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blamka-round-ref.h +28 -26
  160. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blamka-round-ssse3.h +102 -99
  161. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/pwhash_argon2i.c +90 -41
  162. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/pwhash_argon2id.c +213 -0
  163. data/vendor/libsodium/src/libsodium/crypto_pwhash/crypto_pwhash.c +72 -4
  164. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +34 -37
  165. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +27 -32
  166. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c +120 -86
  167. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.c +16 -13
  168. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.h +4 -4
  169. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +98 -50
  170. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/scrypt_platform.c +23 -18
  171. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +105 -105
  172. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.c +395 -330
  173. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.c +225 -198
  174. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox.c +7 -0
  175. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +6 -5
  176. data/vendor/libsodium/src/libsodium/crypto_secretbox/xchacha20poly1305/secretbox_xchacha20poly1305.c +170 -0
  177. data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305.c +83 -0
  178. data/vendor/libsodium/src/libsodium/crypto_shorthash/crypto_shorthash.c +7 -0
  179. data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash24_ref.c +65 -0
  180. data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash_ref.h +24 -0
  181. data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphashx24_ref.c +71 -0
  182. data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/{shorthash_siphash24_api.c → shorthash_siphash24.c} +0 -0
  183. data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/shorthash_siphashx24.c +11 -0
  184. data/vendor/libsodium/src/libsodium/crypto_sign/crypto_sign.c +33 -0
  185. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ed25519_ref10.h +18 -0
  186. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +18 -13
  187. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/obsolete.c +29 -26
  188. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +75 -36
  189. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sign.c +39 -15
  190. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/sign_ed25519.c +91 -0
  191. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/afternm_aes128ctr.c +174 -0
  192. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/beforenm_aes128ctr.c +66 -0
  193. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/common.h +766 -0
  194. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/consts.h +28 -0
  195. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/consts_aes128ctr.c +28 -0
  196. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/int128.h +50 -0
  197. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/int128_aes128ctr.c +149 -0
  198. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/stream_aes128ctr_nacl.c +31 -0
  199. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/xor_afternm_aes128ctr.c +195 -0
  200. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/{stream_aes128ctr_api.c → stream_aes128ctr.c} +6 -3
  201. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/chacha20_dolbeau-avx2.c +179 -0
  202. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/chacha20_dolbeau-avx2.h +8 -0
  203. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/chacha20_dolbeau-ssse3.c +173 -0
  204. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/chacha20_dolbeau-ssse3.h +8 -0
  205. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/u0.h +86 -0
  206. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/u1.h +98 -0
  207. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/u4.h +175 -0
  208. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/u8.h +357 -0
  209. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/{stream_chacha20_ref.c → chacha20_ref.c} +93 -94
  210. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/chacha20_ref.h +8 -0
  211. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/stream_chacha20.c +39 -7
  212. data/vendor/libsodium/src/libsodium/crypto_stream/crypto_stream.c +7 -0
  213. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/salsa20_ref.c +120 -0
  214. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/salsa20_ref.h +8 -0
  215. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20.c +93 -0
  216. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20.h +16 -0
  217. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/{amd64_xmm6/stream_salsa20_amd64_xmm6.S → xmm6/salsa20_xmm6-asm.S} +20 -12
  218. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6/salsa20_xmm6.c +31 -0
  219. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6/salsa20_xmm6.h +8 -0
  220. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/salsa20_xmm6int-avx2.c +131 -0
  221. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/salsa20_xmm6int-avx2.h +8 -0
  222. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/salsa20_xmm6int-sse2.c +122 -0
  223. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/salsa20_xmm6int-sse2.h +8 -0
  224. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/u0.h +195 -0
  225. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/u1.h +207 -0
  226. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/u4.h +547 -0
  227. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/u8.h +476 -0
  228. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012_ref.c +106 -0
  229. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/stream_salsa2012.c +20 -0
  230. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208_ref.c +106 -0
  231. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/stream_salsa208.c +20 -0
  232. data/vendor/libsodium/src/libsodium/crypto_stream/xchacha20/stream_xchacha20.c +63 -0
  233. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/stream_xsalsa20.c +60 -0
  234. data/vendor/libsodium/src/libsodium/crypto_verify/sodium/verify.c +61 -0
  235. data/vendor/libsodium/src/libsodium/include/Makefile.am +8 -6
  236. data/vendor/libsodium/src/libsodium/include/Makefile.in +29 -21
  237. data/vendor/libsodium/src/libsodium/include/sodium.h +15 -4
  238. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_aes256gcm.h +4 -0
  239. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h +6 -0
  240. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_xchacha20poly1305.h +91 -0
  241. data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth.h +3 -0
  242. data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha256.h +5 -0
  243. data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512.h +4 -0
  244. data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512256.h +4 -0
  245. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xchacha20poly1305.h +153 -0
  246. data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash.h +4 -0
  247. data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h +3 -4
  248. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha256.h +4 -3
  249. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha512.h +4 -3
  250. data/vendor/libsodium/src/libsodium/include/sodium/crypto_kdf.h +51 -0
  251. data/vendor/libsodium/src/libsodium/include/sodium/crypto_kdf_blake2b.h +42 -0
  252. data/vendor/libsodium/src/libsodium/include/sodium/crypto_kx.h +64 -0
  253. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth.h +4 -0
  254. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h +11 -9
  255. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash.h +37 -1
  256. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_argon2i.h +40 -10
  257. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_argon2id.h +116 -0
  258. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h +37 -4
  259. data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h +0 -4
  260. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox.h +3 -0
  261. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xchacha20poly1305.h +62 -0
  262. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h +5 -1
  263. data/vendor/libsodium/src/libsodium/include/sodium/crypto_shorthash.h +3 -0
  264. data/vendor/libsodium/src/libsodium/include/sodium/crypto_shorthash_siphash24.h +18 -0
  265. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign.h +22 -0
  266. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_ed25519.h +28 -0
  267. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream.h +3 -0
  268. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes128ctr.h +10 -5
  269. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_chacha20.h +14 -3
  270. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa20.h +4 -0
  271. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa2012.h +3 -0
  272. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa208.h +3 -0
  273. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_xchacha20.h +53 -0
  274. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_xsalsa20.h +4 -0
  275. data/vendor/libsodium/src/libsodium/include/sodium/private/common.h +84 -17
  276. data/vendor/libsodium/src/libsodium/include/sodium/private/implementations.h +11 -0
  277. data/vendor/libsodium/src/libsodium/include/sodium/private/sse2_64_32.h +50 -0
  278. data/vendor/libsodium/src/libsodium/include/sodium/randombytes.h +10 -2
  279. data/vendor/libsodium/src/libsodium/include/sodium/utils.h +4 -5
  280. data/vendor/libsodium/src/libsodium/include/sodium/version.h.in +4 -0
  281. data/vendor/libsodium/src/libsodium/randombytes/randombytes.c +47 -19
  282. data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +30 -50
  283. data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +25 -15
  284. data/vendor/libsodium/src/libsodium/sodium/core.c +25 -23
  285. data/vendor/libsodium/src/libsodium/sodium/runtime.c +66 -57
  286. data/vendor/libsodium/src/libsodium/sodium/utils.c +120 -106
  287. data/vendor/libsodium/src/libsodium/sodium/version.c +10 -0
  288. data/vendor/libsodium/test/Makefile.in +11 -7
  289. data/vendor/libsodium/test/default/Makefile.am +65 -5
  290. data/vendor/libsodium/test/default/Makefile.in +243 -78
  291. data/vendor/libsodium/test/default/aead_aes256gcm.c +2 -2
  292. data/vendor/libsodium/test/default/aead_xchacha20poly1305.c +188 -0
  293. data/vendor/libsodium/test/default/aead_xchacha20poly1305.exp +51 -0
  294. data/vendor/libsodium/test/default/auth.c +11 -7
  295. data/vendor/libsodium/test/default/auth2.c +15 -12
  296. data/vendor/libsodium/test/default/auth3.c +18 -15
  297. data/vendor/libsodium/test/default/auth5.c +3 -2
  298. data/vendor/libsodium/test/default/auth6.c +4 -3
  299. data/vendor/libsodium/test/default/auth7.c +3 -2
  300. data/vendor/libsodium/test/default/box.c +57 -52
  301. data/vendor/libsodium/test/default/box2.c +41 -36
  302. data/vendor/libsodium/test/default/box7.c +4 -3
  303. data/vendor/libsodium/test/default/box8.c +4 -3
  304. data/vendor/libsodium/test/default/box_easy.c +36 -32
  305. data/vendor/libsodium/test/default/box_easy2.c +41 -34
  306. data/vendor/libsodium/test/default/box_seal.c +7 -6
  307. data/vendor/libsodium/test/default/box_seed.c +10 -8
  308. data/vendor/libsodium/test/default/chacha20.c +18 -3
  309. data/vendor/libsodium/test/default/chacha20.exp +45 -0
  310. data/vendor/libsodium/test/default/cmptest.h +1 -0
  311. data/vendor/libsodium/test/default/core1.c +10 -9
  312. data/vendor/libsodium/test/default/core2.c +13 -12
  313. data/vendor/libsodium/test/default/core3.c +13 -12
  314. data/vendor/libsodium/test/default/core4.c +11 -12
  315. data/vendor/libsodium/test/default/core5.c +13 -12
  316. data/vendor/libsodium/test/default/core6.c +15 -13
  317. data/vendor/libsodium/test/default/ed25519_convert.c +12 -9
  318. data/vendor/libsodium/test/default/hash.c +10 -6
  319. data/vendor/libsodium/test/default/hash3.c +3 -2
  320. data/vendor/libsodium/test/default/index-wasm.html.tpl +118 -0
  321. data/vendor/libsodium/test/default/kdf.c +61 -0
  322. data/vendor/libsodium/test/default/kdf.exp +77 -0
  323. data/vendor/libsodium/test/default/keygen.c +64 -0
  324. data/vendor/libsodium/test/default/keygen.exp +1 -0
  325. data/vendor/libsodium/test/default/kx.c +119 -0
  326. data/vendor/libsodium/test/default/kx.exp +7 -0
  327. data/vendor/libsodium/test/default/nacl-test-wrapper.sh +9 -2
  328. data/vendor/libsodium/test/default/onetimeauth.c +26 -23
  329. data/vendor/libsodium/test/default/onetimeauth2.c +22 -20
  330. data/vendor/libsodium/test/default/onetimeauth7.c +3 -2
  331. data/vendor/libsodium/test/default/pwhash.c +209 -157
  332. data/vendor/libsodium/test/default/pwhash_argon2id.c +388 -0
  333. data/vendor/libsodium/test/default/pwhash_argon2id.exp +15 -0
  334. data/vendor/libsodium/test/default/pwhash_scrypt.c +232 -224
  335. data/vendor/libsodium/test/default/pwhash_scrypt.exp +2 -1
  336. data/vendor/libsodium/test/default/pwhash_scrypt_ll.c +39 -41
  337. data/vendor/libsodium/test/default/randombytes.c +34 -13
  338. data/vendor/libsodium/test/default/randombytes.exp +1 -0
  339. data/vendor/libsodium/test/default/scalarmult.c +21 -18
  340. data/vendor/libsodium/test/default/scalarmult2.c +8 -6
  341. data/vendor/libsodium/test/default/scalarmult5.c +13 -10
  342. data/vendor/libsodium/test/default/scalarmult6.c +17 -14
  343. data/vendor/libsodium/test/default/scalarmult7.c +9 -10
  344. data/vendor/libsodium/test/default/secretbox.c +39 -36
  345. data/vendor/libsodium/test/default/secretbox2.c +28 -25
  346. data/vendor/libsodium/test/default/secretbox7.c +3 -2
  347. data/vendor/libsodium/test/default/secretbox8.c +4 -3
  348. data/vendor/libsodium/test/default/secretbox_easy.c +40 -37
  349. data/vendor/libsodium/test/default/secretbox_easy2.c +19 -18
  350. data/vendor/libsodium/test/default/shorthash.c +4 -4
  351. data/vendor/libsodium/test/default/sign.c +70 -13
  352. data/vendor/libsodium/test/default/sign.exp +2 -0
  353. data/vendor/libsodium/test/default/siphashx24.c +33 -0
  354. data/vendor/libsodium/test/default/siphashx24.exp +64 -0
  355. data/vendor/libsodium/test/default/sodium_core.c +9 -8
  356. data/vendor/libsodium/test/default/sodium_utils.c +52 -46
  357. data/vendor/libsodium/test/default/sodium_utils2.c +17 -8
  358. data/vendor/libsodium/test/default/sodium_utils3.c +15 -6
  359. data/vendor/libsodium/test/default/sodium_version.c +7 -1
  360. data/vendor/libsodium/test/default/stream.c +31 -18
  361. data/vendor/libsodium/test/default/stream.exp +65 -0
  362. data/vendor/libsodium/test/default/stream2.c +13 -9
  363. data/vendor/libsodium/test/default/stream3.c +12 -10
  364. data/vendor/libsodium/test/default/stream4.c +30 -27
  365. data/vendor/libsodium/test/default/verify1.c +5 -4
  366. data/vendor/libsodium/test/default/xchacha20.c +376 -0
  367. data/vendor/libsodium/test/default/xchacha20.exp +5 -0
  368. data/vendor/libsodium/test/quirks/quirks.h +4 -3
  369. metadata +140 -111
  370. data/vendor/libsodium/autom4te.cache/output.3 +0 -17240
  371. data/vendor/libsodium/autom4te.cache/output.4 +0 -17517
  372. data/vendor/libsodium/autom4te.cache/output.5 +0 -18535
  373. data/vendor/libsodium/autom4te.cache/output.6 +0 -19077
  374. data/vendor/libsodium/autom4te.cache/output.7 +0 -19837
  375. data/vendor/libsodium/autom4te.cache/traces.3 +0 -2833
  376. data/vendor/libsodium/autom4te.cache/traces.4 +0 -2951
  377. data/vendor/libsodium/autom4te.cache/traces.5 +0 -3042
  378. data/vendor/libsodium/autom4te.cache/traces.6 +0 -3194
  379. data/vendor/libsodium/autom4te.cache/traces.7 +0 -3614
  380. data/vendor/libsodium/builds/msvc/properties/ARM.props +0 -20
  381. data/vendor/libsodium/compile +0 -347
  382. data/vendor/libsodium/config.guess +0 -1568
  383. data/vendor/libsodium/config.sub +0 -1793
  384. data/vendor/libsodium/depcomp +0 -791
  385. data/vendor/libsodium/install-sh +0 -527
  386. data/vendor/libsodium/ltmain.sh +0 -9655
  387. data/vendor/libsodium/missing +0 -215
  388. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/auth_hmacsha256_api.c +0 -16
  389. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/cp/verify_hmacsha256.c +0 -11
  390. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/auth_hmacsha512_api.c +0 -16
  391. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/verify_hmacsha512.c +0 -12
  392. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/auth_hmacsha512256_api.c +0 -16
  393. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/verify_hmacsha512256.c +0 -14
  394. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305_api.c +0 -41
  395. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/after_curve25519xsalsa20poly1305.c +0 -22
  396. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c +0 -18
  397. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/box_curve25519xsalsa20poly1305.c +0 -42
  398. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c +0 -29
  399. data/vendor/libsodium/src/libsodium/crypto_core/hchacha20/core_hchacha20.h +0 -28
  400. data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20.c +0 -100
  401. data/vendor/libsodium/src/libsodium/crypto_core/salsa20/core_salsa20_api.c +0 -21
  402. data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/core_salsa20.c +0 -126
  403. data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/core_salsa2012_api.c +0 -21
  404. data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/core_salsa2012.c +0 -126
  405. data/vendor/libsodium/src/libsodium/crypto_core/salsa208/core_salsa208_api.c +0 -21
  406. data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/core_salsa208.c +0 -126
  407. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2-impl.h +0 -48
  408. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h +0 -97
  409. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-avx2.c +0 -45
  410. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-avx2.h +0 -123
  411. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ref.c +0 -94
  412. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-sse41.c +0 -80
  413. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-sse41.h +0 -97
  414. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ssse3.c +0 -87
  415. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ssse3.h +0 -97
  416. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-avx2.h +0 -339
  417. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-sse2.h +0 -66
  418. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-sse41.h +0 -400
  419. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +0 -456
  420. data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +0 -269
  421. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +0 -298
  422. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-impl.h +0 -40
  423. data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/ref/box_xsalsa20poly1305.c +0 -35
  424. data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305_api.c +0 -26
  425. data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash24.c +0 -72
  426. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/description +0 -1
  427. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/sign_ed25519_api.c +0 -39
  428. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/afternm_aes128ctr.c +0 -159
  429. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/beforenm_aes128ctr.c +0 -59
  430. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/common.h +0 -771
  431. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/consts.h +0 -28
  432. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/consts_aes128ctr.c +0 -14
  433. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128.h +0 -56
  434. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128_aes128ctr.c +0 -131
  435. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/stream_aes128ctr.c +0 -29
  436. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/types.h +0 -10
  437. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/xor_afternm_aes128ctr.c +0 -180
  438. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.h +0 -28
  439. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/vec/stream_chacha20_vec.c +0 -336
  440. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/vec/stream_chacha20_vec.h +0 -28
  441. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20_ref.c +0 -55
  442. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c +0 -63
  443. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20_api.c +0 -19
  444. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c +0 -51
  445. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c +0 -54
  446. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/stream_salsa2012_api.c +0 -11
  447. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c +0 -51
  448. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c +0 -54
  449. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/stream_salsa208_api.c +0 -11
  450. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c +0 -24
  451. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c +0 -35
  452. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/stream_xsalsa20_api.c +0 -11
  453. data/vendor/libsodium/src/libsodium/crypto_verify/16/ref/verify_16.c +0 -17
  454. data/vendor/libsodium/src/libsodium/crypto_verify/16/verify_16_api.c +0 -6
  455. data/vendor/libsodium/src/libsodium/crypto_verify/32/ref/verify_32.c +0 -17
  456. data/vendor/libsodium/src/libsodium/crypto_verify/32/verify_32_api.c +0 -6
  457. data/vendor/libsodium/src/libsodium/crypto_verify/64/ref/verify_64.c +0 -17
  458. data/vendor/libsodium/src/libsodium/crypto_verify/64/verify_64_api.c +0 -6
  459. data/vendor/libsodium/src/libsodium/include/sodium/crypto_int32.h +0 -8
  460. data/vendor/libsodium/src/libsodium/include/sodium/crypto_int64.h +0 -8
  461. data/vendor/libsodium/src/libsodium/include/sodium/crypto_uint16.h +0 -8
  462. data/vendor/libsodium/src/libsodium/include/sodium/crypto_uint32.h +0 -8
  463. data/vendor/libsodium/src/libsodium/include/sodium/crypto_uint64.h +0 -8
  464. data/vendor/libsodium/src/libsodium/include/sodium/crypto_uint8.h +0 -8
  465. data/vendor/libsodium/test-driver +0 -139
@@ -22,29 +22,30 @@
22
22
  * from the sample implementation.
23
23
  */
24
24
 
25
- #include <string.h>
26
25
  #include <stdint.h>
26
+ #include <string.h>
27
27
 
28
28
  #ifdef HAVE_TI_MODE
29
29
 
30
- #include "utils.h"
31
- #include "curve25519_donna_c64.h"
32
30
  #include "../scalarmult_curve25519.h"
31
+ #include "curve25519_donna_c64.h"
32
+ #include "utils.h"
33
33
 
34
34
  typedef uint8_t u8;
35
35
  typedef uint64_t limb;
36
36
  typedef limb felem[5];
37
37
  /* Special gcc mode for 128-bit integers */
38
- typedef unsigned uint128_t __attribute__ ((mode(TI)));
38
+ typedef unsigned uint128_t __attribute__((mode(TI)));
39
39
 
40
40
  /* Sum two numbers: output += in */
41
41
  static inline void
42
- fsum(limb *output, const limb *in) {
43
- output[0] += in[0];
44
- output[1] += in[1];
45
- output[2] += in[2];
46
- output[3] += in[3];
47
- output[4] += in[4];
42
+ fsum(limb *output, const limb *in)
43
+ {
44
+ output[0] += in[0];
45
+ output[1] += in[1];
46
+ output[2] += in[2];
47
+ output[3] += in[3];
48
+ output[4] += in[4];
48
49
  }
49
50
 
50
51
  /* Find the difference of two numbers: output = in - output
@@ -54,39 +55,41 @@ fsum(limb *output, const limb *in) {
54
55
  * On return, out[i] < 2**55
55
56
  */
56
57
  static inline void
57
- fdifference_backwards(felem out, const felem in) {
58
- /* 152 is 19 << 3 */
59
- static const limb two54m152 = (((limb)1) << 54) - 152;
60
- static const limb two54m8 = (((limb)1) << 54) - 8;
61
-
62
- out[0] = in[0] + two54m152 - out[0];
63
- out[1] = in[1] + two54m8 - out[1];
64
- out[2] = in[2] + two54m8 - out[2];
65
- out[3] = in[3] + two54m8 - out[3];
66
- out[4] = in[4] + two54m8 - out[4];
58
+ fdifference_backwards(felem out, const felem in)
59
+ {
60
+ /* 152 is 19 << 3 */
61
+ static const limb two54m152 = (((limb)1) << 54) - 152;
62
+ static const limb two54m8 = (((limb)1) << 54) - 8;
63
+
64
+ out[0] = in[0] + two54m152 - out[0];
65
+ out[1] = in[1] + two54m8 - out[1];
66
+ out[2] = in[2] + two54m8 - out[2];
67
+ out[3] = in[3] + two54m8 - out[3];
68
+ out[4] = in[4] + two54m8 - out[4];
67
69
  }
68
70
 
69
71
  /* Multiply a number by a scalar: output = in * scalar */
70
72
  static inline void
71
- fscalar_product(felem output, const felem in, const limb scalar) {
72
- uint128_t a;
73
+ fscalar_product(felem output, const felem in, const limb scalar)
74
+ {
75
+ uint128_t a;
73
76
 
74
- a = ((uint128_t) in[0]) * scalar;
75
- output[0] = ((limb)a) & 0x7ffffffffffff;
77
+ a = in[0] * (uint128_t)scalar;
78
+ output[0] = ((limb)a) & 0x7ffffffffffff;
76
79
 
77
- a = ((uint128_t) in[1]) * scalar + ((limb) (a >> 51));
78
- output[1] = ((limb)a) & 0x7ffffffffffff;
80
+ a = in[1] * (uint128_t)scalar + ((limb)(a >> 51));
81
+ output[1] = ((limb)a) & 0x7ffffffffffff;
79
82
 
80
- a = ((uint128_t) in[2]) * scalar + ((limb) (a >> 51));
81
- output[2] = ((limb)a) & 0x7ffffffffffff;
83
+ a = in[2] * (uint128_t)scalar + ((limb)(a >> 51));
84
+ output[2] = ((limb)a) & 0x7ffffffffffff;
82
85
 
83
- a = ((uint128_t) in[3]) * scalar + ((limb) (a >> 51));
84
- output[3] = ((limb)a) & 0x7ffffffffffff;
86
+ a = in[3] * (uint128_t)scalar + ((limb)(a >> 51));
87
+ output[3] = ((limb)a) & 0x7ffffffffffff;
85
88
 
86
- a = ((uint128_t) in[4]) * scalar + ((limb) (a >> 51));
87
- output[4] = ((limb)a) & 0x7ffffffffffff;
89
+ a = in[4] * (uint128_t)scalar + ((limb)(a >> 51));
90
+ output[4] = ((limb)a) & 0x7ffffffffffff;
88
91
 
89
- output[0] += (a >> 51) * 19;
92
+ output[0] += (a >> 51) * 19;
90
93
  }
91
94
 
92
95
  /* Multiply two numbers: output = in2 * in
@@ -98,200 +101,257 @@ fscalar_product(felem output, const felem in, const limb scalar) {
98
101
  * On return, output[i] < 2**52
99
102
  */
100
103
  static inline void
101
- fmul(felem output, const felem in2, const felem in) {
102
- uint128_t t[5];
103
- limb r0,r1,r2,r3,r4,s0,s1,s2,s3,s4,c;
104
-
105
- r0 = in[0];
106
- r1 = in[1];
107
- r2 = in[2];
108
- r3 = in[3];
109
- r4 = in[4];
110
-
111
- s0 = in2[0];
112
- s1 = in2[1];
113
- s2 = in2[2];
114
- s3 = in2[3];
115
- s4 = in2[4];
116
-
117
- t[0] = ((uint128_t) r0) * s0;
118
- t[1] = ((uint128_t) r0) * s1 + ((uint128_t) r1) * s0;
119
- t[2] = ((uint128_t) r0) * s2 + ((uint128_t) r2) * s0 + ((uint128_t) r1) * s1;
120
- t[3] = ((uint128_t) r0) * s3 + ((uint128_t) r3) * s0 + ((uint128_t) r1) * s2 + ((uint128_t) r2) * s1;
121
- t[4] = ((uint128_t) r0) * s4 + ((uint128_t) r4) * s0 + ((uint128_t) r3) * s1 + ((uint128_t) r1) * s3 + ((uint128_t) r2) * s2;
122
-
123
- r4 *= 19;
124
- r1 *= 19;
125
- r2 *= 19;
126
- r3 *= 19;
127
-
128
- t[0] += ((uint128_t) r4) * s1 + ((uint128_t) r1) * s4 + ((uint128_t) r2) * s3 + ((uint128_t) r3) * s2;
129
- t[1] += ((uint128_t) r4) * s2 + ((uint128_t) r2) * s4 + ((uint128_t) r3) * s3;
130
- t[2] += ((uint128_t) r4) * s3 + ((uint128_t) r3) * s4;
131
- t[3] += ((uint128_t) r4) * s4;
132
-
133
- r0 = (limb)t[0] & 0x7ffffffffffff; c = (limb)(t[0] >> 51);
134
- t[1] += c; r1 = (limb)t[1] & 0x7ffffffffffff; c = (limb)(t[1] >> 51);
135
- t[2] += c; r2 = (limb)t[2] & 0x7ffffffffffff; c = (limb)(t[2] >> 51);
136
- t[3] += c; r3 = (limb)t[3] & 0x7ffffffffffff; c = (limb)(t[3] >> 51);
137
- t[4] += c; r4 = (limb)t[4] & 0x7ffffffffffff; c = (limb)(t[4] >> 51);
138
- r0 += c * 19; c = r0 >> 51; r0 = r0 & 0x7ffffffffffff;
139
- r1 += c; c = r1 >> 51; r1 = r1 & 0x7ffffffffffff;
140
- r2 += c;
141
-
142
- output[0] = r0;
143
- output[1] = r1;
144
- output[2] = r2;
145
- output[3] = r3;
146
- output[4] = r4;
104
+ fmul(felem output, const felem in2, const felem in)
105
+ {
106
+ uint128_t t[5];
107
+ limb r0, r1, r2, r3, r4, s0, s1, s2, s3, s4, c;
108
+
109
+ r0 = in[0];
110
+ r1 = in[1];
111
+ r2 = in[2];
112
+ r3 = in[3];
113
+ r4 = in[4];
114
+
115
+ s0 = in2[0];
116
+ s1 = in2[1];
117
+ s2 = in2[2];
118
+ s3 = in2[3];
119
+ s4 = in2[4];
120
+
121
+ t[0] = ((uint128_t)r0) * s0;
122
+ t[1] = ((uint128_t)r0) * s1 + ((uint128_t)r1) * s0;
123
+ t[2] = ((uint128_t)r0) * s2 + ((uint128_t)r2) * s0 + ((uint128_t)r1) * s1;
124
+ t[3] = ((uint128_t)r0) * s3 + ((uint128_t)r3) * s0 + ((uint128_t)r1) * s2
125
+ + ((uint128_t)r2) * s1;
126
+ t[4] = ((uint128_t)r0) * s4 + ((uint128_t)r4) * s0 + ((uint128_t)r3) * s1
127
+ + ((uint128_t)r1) * s3 + ((uint128_t)r2) * s2;
128
+
129
+ r4 *= 19;
130
+ r1 *= 19;
131
+ r2 *= 19;
132
+ r3 *= 19;
133
+
134
+ t[0] += ((uint128_t)r4) * s1 + ((uint128_t)r1) * s4 + ((uint128_t)r2) * s3
135
+ + ((uint128_t)r3) * s2;
136
+ t[1] += ((uint128_t)r4) * s2 + ((uint128_t)r2) * s4 + ((uint128_t)r3) * s3;
137
+ t[2] += ((uint128_t)r4) * s3 + ((uint128_t)r3) * s4;
138
+ t[3] += ((uint128_t)r4) * s4;
139
+
140
+ r0 = (limb)t[0] & 0x7ffffffffffff;
141
+ c = (limb)(t[0] >> 51);
142
+ t[1] += c;
143
+ r1 = (limb)t[1] & 0x7ffffffffffff;
144
+ c = (limb)(t[1] >> 51);
145
+ t[2] += c;
146
+ r2 = (limb)t[2] & 0x7ffffffffffff;
147
+ c = (limb)(t[2] >> 51);
148
+ t[3] += c;
149
+ r3 = (limb)t[3] & 0x7ffffffffffff;
150
+ c = (limb)(t[3] >> 51);
151
+ t[4] += c;
152
+ r4 = (limb)t[4] & 0x7ffffffffffff;
153
+ c = (limb)(t[4] >> 51);
154
+ r0 += c * 19;
155
+ c = r0 >> 51;
156
+ r0 = r0 & 0x7ffffffffffff;
157
+ r1 += c;
158
+ c = r1 >> 51;
159
+ r1 = r1 & 0x7ffffffffffff;
160
+ r2 += c;
161
+
162
+ output[0] = r0;
163
+ output[1] = r1;
164
+ output[2] = r2;
165
+ output[3] = r3;
166
+ output[4] = r4;
147
167
  }
148
168
 
149
169
  static inline void
150
- fsquare_times(felem output, const felem in, limb count) {
151
- uint128_t t[5];
152
- limb r0,r1,r2,r3,r4,c;
153
- limb d0,d1,d2,d4,d419;
154
-
155
- r0 = in[0];
156
- r1 = in[1];
157
- r2 = in[2];
158
- r3 = in[3];
159
- r4 = in[4];
160
-
161
- do {
162
- d0 = r0 * 2;
163
- d1 = r1 * 2;
164
- d2 = r2 * 2 * 19;
165
- d419 = r4 * 19;
166
- d4 = d419 * 2;
167
-
168
- t[0] = ((uint128_t) r0) * r0 + ((uint128_t) d4) * r1 + (((uint128_t) d2) * (r3 ));
169
- t[1] = ((uint128_t) d0) * r1 + ((uint128_t) d4) * r2 + (((uint128_t) r3) * (r3 * 19));
170
- t[2] = ((uint128_t) d0) * r2 + ((uint128_t) r1) * r1 + (((uint128_t) d4) * (r3 ));
171
- t[3] = ((uint128_t) d0) * r3 + ((uint128_t) d1) * r2 + (((uint128_t) r4) * (d419 ));
172
- t[4] = ((uint128_t) d0) * r4 + ((uint128_t) d1) * r3 + (((uint128_t) r2) * (r2 ));
173
-
174
- r0 = (limb)t[0] & 0x7ffffffffffff; c = (limb)(t[0] >> 51);
175
- t[1] += c; r1 = (limb)t[1] & 0x7ffffffffffff; c = (limb)(t[1] >> 51);
176
- t[2] += c; r2 = (limb)t[2] & 0x7ffffffffffff; c = (limb)(t[2] >> 51);
177
- t[3] += c; r3 = (limb)t[3] & 0x7ffffffffffff; c = (limb)(t[3] >> 51);
178
- t[4] += c; r4 = (limb)t[4] & 0x7ffffffffffff; c = (limb)(t[4] >> 51);
179
- r0 += c * 19; c = r0 >> 51; r0 = r0 & 0x7ffffffffffff;
180
- r1 += c; c = r1 >> 51; r1 = r1 & 0x7ffffffffffff;
181
- r2 += c;
182
- } while(--count);
183
-
184
- output[0] = r0;
185
- output[1] = r1;
186
- output[2] = r2;
187
- output[3] = r3;
188
- output[4] = r4;
170
+ fsquare_times(felem output, const felem in, limb count)
171
+ {
172
+ uint128_t t[5];
173
+ limb r0, r1, r2, r3, r4, c;
174
+ limb d0, d1, d2, d4, d419;
175
+
176
+ r0 = in[0];
177
+ r1 = in[1];
178
+ r2 = in[2];
179
+ r3 = in[3];
180
+ r4 = in[4];
181
+
182
+ do {
183
+ d0 = r0 * 2;
184
+ d1 = r1 * 2;
185
+ d2 = r2 * 2 * 19;
186
+ d419 = r4 * 19;
187
+ d4 = d419 * 2;
188
+
189
+ t[0] = ((uint128_t)r0) * r0 + ((uint128_t)d4) * r1
190
+ + (((uint128_t)d2) * (r3));
191
+ t[1] = ((uint128_t)d0) * r1 + ((uint128_t)d4) * r2
192
+ + (((uint128_t)r3) * (r3 * 19));
193
+ t[2] = ((uint128_t)d0) * r2 + ((uint128_t)r1) * r1
194
+ + (((uint128_t)d4) * (r3));
195
+ t[3] = ((uint128_t)d0) * r3 + ((uint128_t)d1) * r2
196
+ + (((uint128_t)r4) * (d419));
197
+ t[4] = ((uint128_t)d0) * r4 + ((uint128_t)d1) * r3
198
+ + (((uint128_t)r2) * (r2));
199
+
200
+ r0 = (limb)t[0] & 0x7ffffffffffff;
201
+ c = (limb)(t[0] >> 51);
202
+ t[1] += c;
203
+ r1 = (limb)t[1] & 0x7ffffffffffff;
204
+ c = (limb)(t[1] >> 51);
205
+ t[2] += c;
206
+ r2 = (limb)t[2] & 0x7ffffffffffff;
207
+ c = (limb)(t[2] >> 51);
208
+ t[3] += c;
209
+ r3 = (limb)t[3] & 0x7ffffffffffff;
210
+ c = (limb)(t[3] >> 51);
211
+ t[4] += c;
212
+ r4 = (limb)t[4] & 0x7ffffffffffff;
213
+ c = (limb)(t[4] >> 51);
214
+ r0 += c * 19;
215
+ c = r0 >> 51;
216
+ r0 = r0 & 0x7ffffffffffff;
217
+ r1 += c;
218
+ c = r1 >> 51;
219
+ r1 = r1 & 0x7ffffffffffff;
220
+ r2 += c;
221
+ } while (--count);
222
+
223
+ output[0] = r0;
224
+ output[1] = r1;
225
+ output[2] = r2;
226
+ output[3] = r3;
227
+ output[4] = r4;
189
228
  }
190
229
 
191
230
  #ifdef NATIVE_LITTLE_ENDIAN
192
231
  static inline limb
193
- load_limb(const u8 *in) {
232
+ load_limb(const u8 *in)
233
+ {
194
234
  limb out;
195
- memcpy(&out, in, sizeof (limb));
235
+
236
+ memcpy(&out, in, sizeof(limb));
196
237
  return out;
197
238
  }
198
239
  static inline void
199
- store_limb(u8 *out, limb in) {
200
- memcpy(out, &in, sizeof (limb));
240
+ store_limb(u8 *out, limb in)
241
+ {
242
+ memcpy(out, &in, sizeof(limb));
201
243
  }
202
244
  #else
203
245
  static inline limb
204
- load_limb(const u8 *in) {
205
- return
206
- ((limb)in[0]) |
207
- (((limb)in[1]) << 8) |
208
- (((limb)in[2]) << 16) |
209
- (((limb)in[3]) << 24) |
210
- (((limb)in[4]) << 32) |
211
- (((limb)in[5]) << 40) |
212
- (((limb)in[6]) << 48) |
213
- (((limb)in[7]) << 56);
246
+ load_limb(const u8 *in)
247
+ {
248
+ return ((limb)in[0]) | (((limb)in[1]) << 8) | (((limb)in[2]) << 16)
249
+ | (((limb)in[3]) << 24) | (((limb)in[4]) << 32)
250
+ | (((limb)in[5]) << 40) | (((limb)in[6]) << 48)
251
+ | (((limb)in[7]) << 56);
214
252
  }
215
253
 
216
254
  static inline void
217
- store_limb(u8 *out, limb in) {
218
- out[0] = in & 0xff;
219
- out[1] = (in >> 8) & 0xff;
220
- out[2] = (in >> 16) & 0xff;
221
- out[3] = (in >> 24) & 0xff;
222
- out[4] = (in >> 32) & 0xff;
223
- out[5] = (in >> 40) & 0xff;
224
- out[6] = (in >> 48) & 0xff;
225
- out[7] = (in >> 56) & 0xff;
255
+ store_limb(u8 *out, limb in)
256
+ {
257
+ out[0] = in & 0xff;
258
+ out[1] = (in >> 8) & 0xff;
259
+ out[2] = (in >> 16) & 0xff;
260
+ out[3] = (in >> 24) & 0xff;
261
+ out[4] = (in >> 32) & 0xff;
262
+ out[5] = (in >> 40) & 0xff;
263
+ out[6] = (in >> 48) & 0xff;
264
+ out[7] = (in >> 56) & 0xff;
226
265
  }
227
266
  #endif
228
267
 
229
268
  /* Take a little-endian, 32-byte number and expand it into polynomial form */
230
269
  static void
231
- fexpand(limb *output, const u8 *in) {
232
- output[0] = load_limb(in) & 0x7ffffffffffff;
233
- output[1] = (load_limb(in+6) >> 3) & 0x7ffffffffffff;
234
- output[2] = (load_limb(in+12) >> 6) & 0x7ffffffffffff;
235
- output[3] = (load_limb(in+19) >> 1) & 0x7ffffffffffff;
236
- output[4] = (load_limb(in+24) >> 12) & 0x7ffffffffffff;
270
+ fexpand(limb *output, const u8 *in)
271
+ {
272
+ output[0] = load_limb(in) & 0x7ffffffffffff;
273
+ output[1] = (load_limb(in + 6) >> 3) & 0x7ffffffffffff;
274
+ output[2] = (load_limb(in + 12) >> 6) & 0x7ffffffffffff;
275
+ output[3] = (load_limb(in + 19) >> 1) & 0x7ffffffffffff;
276
+ output[4] = (load_limb(in + 24) >> 12) & 0x7ffffffffffff;
237
277
  }
238
278
 
239
279
  /* Take a fully reduced polynomial form number and contract it into a
240
280
  * little-endian, 32-byte array
241
281
  */
242
282
  static void
243
- fcontract(u8 *output, const felem input) {
244
- uint128_t t[5];
245
-
246
- t[0] = input[0];
247
- t[1] = input[1];
248
- t[2] = input[2];
249
- t[3] = input[3];
250
- t[4] = input[4];
251
-
252
- t[1] += t[0] >> 51; t[0] &= 0x7ffffffffffff;
253
- t[2] += t[1] >> 51; t[1] &= 0x7ffffffffffff;
254
- t[3] += t[2] >> 51; t[2] &= 0x7ffffffffffff;
255
- t[4] += t[3] >> 51; t[3] &= 0x7ffffffffffff;
256
- t[0] += 19 * (t[4] >> 51); t[4] &= 0x7ffffffffffff;
257
-
258
- t[1] += t[0] >> 51; t[0] &= 0x7ffffffffffff;
259
- t[2] += t[1] >> 51; t[1] &= 0x7ffffffffffff;
260
- t[3] += t[2] >> 51; t[2] &= 0x7ffffffffffff;
261
- t[4] += t[3] >> 51; t[3] &= 0x7ffffffffffff;
262
- t[0] += 19 * (t[4] >> 51); t[4] &= 0x7ffffffffffff;
263
-
264
- /* now t is between 0 and 2^255-1, properly carried. */
265
- /* case 1: between 0 and 2^255-20. case 2: between 2^255-19 and 2^255-1. */
266
-
267
- t[0] += 19;
268
-
269
- t[1] += t[0] >> 51; t[0] &= 0x7ffffffffffff;
270
- t[2] += t[1] >> 51; t[1] &= 0x7ffffffffffff;
271
- t[3] += t[2] >> 51; t[2] &= 0x7ffffffffffff;
272
- t[4] += t[3] >> 51; t[3] &= 0x7ffffffffffff;
273
- t[0] += 19 * (t[4] >> 51); t[4] &= 0x7ffffffffffff;
274
-
275
- /* now between 19 and 2^255-1 in both cases, and offset by 19. */
276
-
277
- t[0] += 0x8000000000000 - 19;
278
- t[1] += 0x8000000000000 - 1;
279
- t[2] += 0x8000000000000 - 1;
280
- t[3] += 0x8000000000000 - 1;
281
- t[4] += 0x8000000000000 - 1;
282
-
283
- /* now between 2^255 and 2^256-20, and offset by 2^255. */
284
-
285
- t[1] += t[0] >> 51; t[0] &= 0x7ffffffffffff;
286
- t[2] += t[1] >> 51; t[1] &= 0x7ffffffffffff;
287
- t[3] += t[2] >> 51; t[2] &= 0x7ffffffffffff;
288
- t[4] += t[3] >> 51; t[3] &= 0x7ffffffffffff;
289
- t[4] &= 0x7ffffffffffff;
290
-
291
- store_limb(output, t[0] | (t[1] << 51));
292
- store_limb(output + 8, (t[1] >> 13) | (t[2] << 38));
293
- store_limb(output + 16, (t[2] >> 26) | (t[3] << 25));
294
- store_limb(output + 24, (t[3] >> 39) | (t[4] << 12));
283
+ fcontract(u8 *output, const felem input)
284
+ {
285
+ uint128_t t[5];
286
+
287
+ t[0] = input[0];
288
+ t[1] = input[1];
289
+ t[2] = input[2];
290
+ t[3] = input[3];
291
+ t[4] = input[4];
292
+
293
+ t[1] += t[0] >> 51;
294
+ t[0] &= 0x7ffffffffffff;
295
+ t[2] += t[1] >> 51;
296
+ t[1] &= 0x7ffffffffffff;
297
+ t[3] += t[2] >> 51;
298
+ t[2] &= 0x7ffffffffffff;
299
+ t[4] += t[3] >> 51;
300
+ t[3] &= 0x7ffffffffffff;
301
+ t[0] += 19 * (t[4] >> 51);
302
+ t[4] &= 0x7ffffffffffff;
303
+
304
+ t[1] += t[0] >> 51;
305
+ t[0] &= 0x7ffffffffffff;
306
+ t[2] += t[1] >> 51;
307
+ t[1] &= 0x7ffffffffffff;
308
+ t[3] += t[2] >> 51;
309
+ t[2] &= 0x7ffffffffffff;
310
+ t[4] += t[3] >> 51;
311
+ t[3] &= 0x7ffffffffffff;
312
+ t[0] += 19 * (t[4] >> 51);
313
+ t[4] &= 0x7ffffffffffff;
314
+
315
+ /* now t is between 0 and 2^255-1, properly carried. */
316
+ /* case 1: between 0 and 2^255-20. case 2: between 2^255-19 and 2^255-1. */
317
+
318
+ t[0] += 19;
319
+
320
+ t[1] += t[0] >> 51;
321
+ t[0] &= 0x7ffffffffffff;
322
+ t[2] += t[1] >> 51;
323
+ t[1] &= 0x7ffffffffffff;
324
+ t[3] += t[2] >> 51;
325
+ t[2] &= 0x7ffffffffffff;
326
+ t[4] += t[3] >> 51;
327
+ t[3] &= 0x7ffffffffffff;
328
+ t[0] += 19 * (t[4] >> 51);
329
+ t[4] &= 0x7ffffffffffff;
330
+
331
+ /* now between 19 and 2^255-1 in both cases, and offset by 19. */
332
+
333
+ t[0] += 0x8000000000000 - 19;
334
+ t[1] += 0x8000000000000 - 1;
335
+ t[2] += 0x8000000000000 - 1;
336
+ t[3] += 0x8000000000000 - 1;
337
+ t[4] += 0x8000000000000 - 1;
338
+
339
+ /* now between 2^255 and 2^256-20, and offset by 2^255. */
340
+
341
+ t[1] += t[0] >> 51;
342
+ t[0] &= 0x7ffffffffffff;
343
+ t[2] += t[1] >> 51;
344
+ t[1] &= 0x7ffffffffffff;
345
+ t[3] += t[2] >> 51;
346
+ t[2] &= 0x7ffffffffffff;
347
+ t[4] += t[3] >> 51;
348
+ t[3] &= 0x7ffffffffffff;
349
+ t[4] &= 0x7ffffffffffff;
350
+
351
+ store_limb(output, t[0] | (t[1] << 51));
352
+ store_limb(output + 8, (t[1] >> 13) | (t[2] << 38));
353
+ store_limb(output + 16, (t[2] >> 26) | (t[3] << 25));
354
+ store_limb(output + 24, (t[3] >> 39) | (t[4] << 12));
295
355
  }
296
356
 
297
357
  /* Input: Q, Q', Q-Q'
@@ -304,37 +364,38 @@ fcontract(u8 *output, const felem input) {
304
364
  * qmqp: short form, preserved
305
365
  */
306
366
  static void
307
- fmonty(limb *x2, limb *z2, /* output 2Q */
308
- limb *x3, limb *z3, /* output Q + Q' */
309
- limb *x, limb *z, /* input Q */
367
+ fmonty(limb *x2, limb *z2, /* output 2Q */
368
+ limb *x3, limb *z3, /* output Q + Q' */
369
+ limb *x, limb *z, /* input Q */
310
370
  limb *xprime, limb *zprime, /* input Q' */
311
- const limb *qmqp /* input Q - Q' */) {
312
- limb origx[5], origxprime[5], zzz[5], xx[5], zz[5], xxprime[5],
313
- zzprime[5], zzzprime[5];
314
-
315
- memcpy(origx, x, 5 * sizeof(limb));
316
- fsum(x, z);
317
- fdifference_backwards(z, origx); /* does x - z */
318
-
319
- memcpy(origxprime, xprime, sizeof(limb) * 5);
320
- fsum(xprime, zprime);
321
- fdifference_backwards(zprime, origxprime);
322
- fmul(xxprime, xprime, z);
323
- fmul(zzprime, x, zprime);
324
- memcpy(origxprime, xxprime, sizeof(limb) * 5);
325
- fsum(xxprime, zzprime);
326
- fdifference_backwards(zzprime, origxprime);
327
- fsquare_times(x3, xxprime, 1);
328
- fsquare_times(zzzprime, zzprime, 1);
329
- fmul(z3, zzzprime, qmqp);
330
-
331
- fsquare_times(xx, x, 1);
332
- fsquare_times(zz, z, 1);
333
- fmul(x2, xx, zz);
334
- fdifference_backwards(zz, xx); /* does zz = xx - zz */
335
- fscalar_product(zzz, zz, 121665);
336
- fsum(zzz, xx);
337
- fmul(z2, zz, zzz);
371
+ const limb *qmqp /* input Q - Q' */)
372
+ {
373
+ limb origx[5], origxprime[5], zzz[5], xx[5], zz[5], xxprime[5], zzprime[5],
374
+ zzzprime[5];
375
+
376
+ memcpy(origx, x, 5 * sizeof(limb));
377
+ fsum(x, z);
378
+ fdifference_backwards(z, origx); /* does x - z */
379
+
380
+ memcpy(origxprime, xprime, sizeof(limb) * 5);
381
+ fsum(xprime, zprime);
382
+ fdifference_backwards(zprime, origxprime);
383
+ fmul(xxprime, xprime, z);
384
+ fmul(zzprime, x, zprime);
385
+ memcpy(origxprime, xxprime, sizeof(limb) * 5);
386
+ fsum(xxprime, zzprime);
387
+ fdifference_backwards(zzprime, origxprime);
388
+ fsquare_times(x3, xxprime, 1);
389
+ fsquare_times(zzzprime, zzprime, 1);
390
+ fmul(z3, zzzprime, qmqp);
391
+
392
+ fsquare_times(xx, x, 1);
393
+ fsquare_times(zz, z, 1);
394
+ fmul(x2, xx, zz);
395
+ fdifference_backwards(zz, xx); /* does zz = xx - zz */
396
+ fscalar_product(zzz, zz, 121665);
397
+ fsum(zzz, xx);
398
+ fmul(z2, zz, zzz);
338
399
  }
339
400
 
340
401
  /* -----------------------------------------------------------------------------
@@ -343,17 +404,19 @@ fmonty(limb *x2, limb *z2, /* output 2Q */
343
404
 
344
405
  This function performs the swap without leaking any side-channel
345
406
  information.
346
- ----------------------------------------------------------------------------- */
407
+ -----------------------------------------------------------------------------
408
+ */
347
409
  static void
348
- swap_conditional(limb a[5], limb b[5], limb iswap) {
349
- unsigned i;
350
- const limb swap = -iswap;
351
-
352
- for (i = 0; i < 5; ++i) {
353
- const limb x = swap & (a[i] ^ b[i]);
354
- a[i] ^= x;
355
- b[i] ^= x;
356
- }
410
+ swap_conditional(limb a[5], limb b[5], limb iswap)
411
+ {
412
+ const limb swap = -iswap;
413
+ unsigned i;
414
+
415
+ for (i = 0; i < 5; ++i) {
416
+ const limb x = swap & (a[i] ^ b[i]);
417
+ a[i] ^= x;
418
+ b[i] ^= x;
419
+ }
357
420
  }
358
421
 
359
422
  /* Calculates nQ where Q is the x-coordinate of a point on the curve
@@ -363,118 +426,120 @@ swap_conditional(limb a[5], limb b[5], limb iswap) {
363
426
  * q: a point of the curve (short form)
364
427
  */
365
428
  static void
366
- cmult(limb *resultx, limb *resultz, const u8 *n, const limb *q) {
367
- limb a[5] = {0}, b[5] = {1}, c[5] = {1}, d[5] = {0};
368
- limb *nqpqx = a, *nqpqz = b, *nqx = c, *nqz = d, *t;
369
- limb e[5] = {0}, f[5] = {1}, g[5] = {0}, h[5] = {1};
370
- limb *nqpqx2 = e, *nqpqz2 = f, *nqx2 = g, *nqz2 = h;
371
-
372
- unsigned i, j;
373
-
374
- memcpy(nqpqx, q, sizeof(limb) * 5);
375
-
376
- for (i = 0; i < 32; ++i) {
377
- u8 byte = n[31 - i];
378
- for (j = 0; j < 8; ++j) {
379
- const limb bit = byte >> 7;
380
-
381
- swap_conditional(nqx, nqpqx, bit);
382
- swap_conditional(nqz, nqpqz, bit);
383
- fmonty(nqx2, nqz2,
384
- nqpqx2, nqpqz2,
385
- nqx, nqz,
386
- nqpqx, nqpqz,
387
- q);
388
- swap_conditional(nqx2, nqpqx2, bit);
389
- swap_conditional(nqz2, nqpqz2, bit);
390
-
391
- t = nqx;
392
- nqx = nqx2;
393
- nqx2 = t;
394
- t = nqz;
395
- nqz = nqz2;
396
- nqz2 = t;
397
- t = nqpqx;
398
- nqpqx = nqpqx2;
399
- nqpqx2 = t;
400
- t = nqpqz;
401
- nqpqz = nqpqz2;
402
- nqpqz2 = t;
403
-
404
- byte <<= 1;
429
+ cmult(limb *resultx, limb *resultz, const u8 *n, const limb *q)
430
+ {
431
+ limb a[5] = { 0 }, b[5] = { 1 }, c[5] = { 1 }, d[5] = { 0 };
432
+ limb *nqpqx = a, *nqpqz = b, *nqx = c, *nqz = d, *t;
433
+ limb e[5] = { 0 }, f[5] = { 1 }, g[5] = { 0 }, h[5] = { 1 };
434
+ limb *nqpqx2 = e, *nqpqz2 = f, *nqx2 = g, *nqz2 = h;
435
+
436
+ unsigned i, j;
437
+
438
+ memcpy(nqpqx, q, sizeof(limb) * 5);
439
+
440
+ for (i = 0; i < 32; ++i) {
441
+ u8 byte = n[31 - i];
442
+ for (j = 0; j < 8; ++j) {
443
+ const limb bit = byte >> 7;
444
+
445
+ swap_conditional(nqx, nqpqx, bit);
446
+ swap_conditional(nqz, nqpqz, bit);
447
+ fmonty(nqx2, nqz2, nqpqx2, nqpqz2, nqx, nqz, nqpqx, nqpqz, q);
448
+ swap_conditional(nqx2, nqpqx2, bit);
449
+ swap_conditional(nqz2, nqpqz2, bit);
450
+
451
+ t = nqx;
452
+ nqx = nqx2;
453
+ nqx2 = t;
454
+ t = nqz;
455
+ nqz = nqz2;
456
+ nqz2 = t;
457
+ t = nqpqx;
458
+ nqpqx = nqpqx2;
459
+ nqpqx2 = t;
460
+ t = nqpqz;
461
+ nqpqz = nqpqz2;
462
+ nqpqz2 = t;
463
+
464
+ byte <<= 1;
465
+ }
405
466
  }
406
- }
407
467
 
408
- memcpy(resultx, nqx, sizeof(limb) * 5);
409
- memcpy(resultz, nqz, sizeof(limb) * 5);
468
+ memcpy(resultx, nqx, sizeof(limb) * 5);
469
+ memcpy(resultz, nqz, sizeof(limb) * 5);
410
470
  }
411
471
 
412
-
413
472
  /* -----------------------------------------------------------------------------
414
473
  Shamelessly copied from djb's code, tightened a little
415
- ----------------------------------------------------------------------------- */
474
+ -----------------------------------------------------------------------------
475
+ */
416
476
  static void
417
- crecip(felem out, const felem z) {
418
- felem a,t0,b,c;
419
-
420
- /* 2 */ fsquare_times(a, z, 1); /* a = 2 */
421
- /* 8 */ fsquare_times(t0, a, 2);
422
- /* 9 */ fmul(b, t0, z); /* b = 9 */
423
- /* 11 */ fmul(a, b, a); /* a = 11 */
424
- /* 22 */ fsquare_times(t0, a, 1);
425
- /* 2^5 - 2^0 = 31 */ fmul(b, t0, b);
426
- /* 2^10 - 2^5 */ fsquare_times(t0, b, 5);
427
- /* 2^10 - 2^0 */ fmul(b, t0, b);
428
- /* 2^20 - 2^10 */ fsquare_times(t0, b, 10);
429
- /* 2^20 - 2^0 */ fmul(c, t0, b);
430
- /* 2^40 - 2^20 */ fsquare_times(t0, c, 20);
431
- /* 2^40 - 2^0 */ fmul(t0, t0, c);
432
- /* 2^50 - 2^10 */ fsquare_times(t0, t0, 10);
433
- /* 2^50 - 2^0 */ fmul(b, t0, b);
434
- /* 2^100 - 2^50 */ fsquare_times(t0, b, 50);
435
- /* 2^100 - 2^0 */ fmul(c, t0, b);
436
- /* 2^200 - 2^100 */ fsquare_times(t0, c, 100);
437
- /* 2^200 - 2^0 */ fmul(t0, t0, c);
438
- /* 2^250 - 2^50 */ fsquare_times(t0, t0, 50);
439
- /* 2^250 - 2^0 */ fmul(t0, t0, b);
440
- /* 2^255 - 2^5 */ fsquare_times(t0, t0, 5);
441
- /* 2^255 - 21 */ fmul(out, t0, a);
477
+ crecip(felem out, const felem z)
478
+ {
479
+ felem a, t0, b, c;
480
+
481
+ /* 2 */ fsquare_times(a, z, 1); /* a = 2 */
482
+ /* 8 */ fsquare_times(t0, a, 2);
483
+ /* 9 */ fmul(b, t0, z); /* b = 9 */
484
+ /* 11 */ fmul(a, b, a); /* a = 11 */
485
+ /* 22 */ fsquare_times(t0, a, 1);
486
+ /* 2^5 - 2^0 = 31 */ fmul(b, t0, b);
487
+ /* 2^10 - 2^5 */ fsquare_times(t0, b, 5);
488
+ /* 2^10 - 2^0 */ fmul(b, t0, b);
489
+ /* 2^20 - 2^10 */ fsquare_times(t0, b, 10);
490
+ /* 2^20 - 2^0 */ fmul(c, t0, b);
491
+ /* 2^40 - 2^20 */ fsquare_times(t0, c, 20);
492
+ /* 2^40 - 2^0 */ fmul(t0, t0, c);
493
+ /* 2^50 - 2^10 */ fsquare_times(t0, t0, 10);
494
+ /* 2^50 - 2^0 */ fmul(b, t0, b);
495
+ /* 2^100 - 2^50 */ fsquare_times(t0, b, 50);
496
+ /* 2^100 - 2^0 */ fmul(c, t0, b);
497
+ /* 2^200 - 2^100 */ fsquare_times(t0, c, 100);
498
+ /* 2^200 - 2^0 */ fmul(t0, t0, c);
499
+ /* 2^250 - 2^50 */ fsquare_times(t0, t0, 50);
500
+ /* 2^250 - 2^0 */ fmul(t0, t0, b);
501
+ /* 2^255 - 2^5 */ fsquare_times(t0, t0, 5);
502
+ /* 2^255 - 21 */ fmul(out, t0, a);
442
503
  }
443
504
 
444
- static const unsigned char basepoint[32] = {9};
505
+ static const unsigned char basepoint[32] = { 9 };
445
506
 
446
507
  static int
447
508
  crypto_scalarmult_curve25519_donna_c64(unsigned char *mypublic,
448
509
  const unsigned char *secret,
449
- const unsigned char *basepoint) {
450
- limb bp[5], x[5], z[5], zmone[5];
451
- uint8_t e[32];
452
- int i;
453
-
454
- for (i = 0;i < 32;++i) e[i] = secret[i];
455
- e[0] &= 248;
456
- e[31] &= 127;
457
- e[31] |= 64;
458
-
459
- fexpand(bp, basepoint);
460
- cmult(x, z, e, bp);
461
- crecip(zmone, z);
462
- fmul(z, x, zmone);
463
- fcontract(mypublic, z);
464
- return 0;
510
+ const unsigned char *basepoint)
511
+ {
512
+ limb bp[5], x[5], z[5], zmone[5];
513
+ uint8_t e[32];
514
+ int i;
515
+
516
+ for (i = 0; i < 32; ++i) {
517
+ e[i] = secret[i];
518
+ }
519
+ e[0] &= 248;
520
+ e[31] &= 127;
521
+ e[31] |= 64;
522
+
523
+ fexpand(bp, basepoint);
524
+ cmult(x, z, e, bp);
525
+ crecip(zmone, z);
526
+ fmul(z, x, zmone);
527
+ fcontract(mypublic, z);
528
+
529
+ return 0;
465
530
  }
466
531
 
467
532
  static int
468
533
  crypto_scalarmult_curve25519_donna_c64_base(unsigned char *q,
469
534
  const unsigned char *n)
470
535
  {
471
- return crypto_scalarmult_curve25519_donna_c64(q, n, basepoint);
536
+ return crypto_scalarmult_curve25519_donna_c64(q, n, basepoint);
472
537
  }
473
538
 
474
539
  struct crypto_scalarmult_curve25519_implementation
475
- crypto_scalarmult_curve25519_donna_c64_implementation = {
476
- SODIUM_C99(.mult = ) crypto_scalarmult_curve25519_donna_c64,
477
- SODIUM_C99(.mult_base = ) crypto_scalarmult_curve25519_donna_c64_base
478
- };
540
+ crypto_scalarmult_curve25519_donna_c64_implementation = {
541
+ SODIUM_C99(.mult =) crypto_scalarmult_curve25519_donna_c64,
542
+ SODIUM_C99(.mult_base =) crypto_scalarmult_curve25519_donna_c64_base
543
+ };
479
544
 
480
545
  #endif