rbnacl-libsodium 0.4.5 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (282) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rbnacl/libsodium/version.rb +1 -1
  3. data/vendor/libsodium/AUTHORS +14 -9
  4. data/vendor/libsodium/ChangeLog +26 -0
  5. data/vendor/libsodium/LICENSE +1 -1
  6. data/vendor/libsodium/Makefile.am +1 -0
  7. data/vendor/libsodium/README.markdown +185 -46
  8. data/vendor/libsodium/THANKS +10 -0
  9. data/vendor/libsodium/builds/msvc/properties/Common.props +21 -0
  10. data/vendor/libsodium/builds/msvc/properties/DLL.props +16 -0
  11. data/vendor/libsodium/builds/msvc/properties/Debug.props +29 -0
  12. data/vendor/libsodium/builds/msvc/properties/DebugDEXE.props +21 -0
  13. data/vendor/libsodium/builds/msvc/properties/DebugDLL.props +20 -0
  14. data/vendor/libsodium/builds/msvc/properties/DebugLEXE.props +20 -0
  15. data/vendor/libsodium/builds/msvc/properties/DebugLIB.props +20 -0
  16. data/vendor/libsodium/builds/msvc/properties/DebugLTCG.props +19 -0
  17. data/vendor/libsodium/builds/msvc/properties/DebugSEXE.props +21 -0
  18. data/vendor/libsodium/builds/msvc/properties/EXE.props +17 -0
  19. data/vendor/libsodium/builds/msvc/properties/LIB.props +16 -0
  20. data/vendor/libsodium/builds/msvc/properties/LTCG.props +13 -0
  21. data/vendor/libsodium/builds/msvc/properties/Link.props +21 -0
  22. data/vendor/libsodium/builds/msvc/properties/Messages.props +15 -0
  23. data/vendor/libsodium/builds/msvc/properties/Output.props +30 -0
  24. data/vendor/libsodium/builds/msvc/properties/Release.props +41 -0
  25. data/vendor/libsodium/builds/msvc/properties/ReleaseDEXE.props +20 -0
  26. data/vendor/libsodium/builds/msvc/properties/ReleaseDLL.props +19 -0
  27. data/vendor/libsodium/builds/msvc/properties/ReleaseLEXE.props +20 -0
  28. data/vendor/libsodium/builds/msvc/properties/ReleaseLIB.props +19 -0
  29. data/vendor/libsodium/builds/msvc/properties/ReleaseLTCG.props +19 -0
  30. data/vendor/libsodium/builds/msvc/properties/ReleaseSEXE.props +20 -0
  31. data/vendor/libsodium/builds/msvc/properties/Win32.props +20 -0
  32. data/vendor/libsodium/builds/msvc/properties/x64.props +23 -0
  33. data/vendor/libsodium/builds/msvc/resource.h +0 -0
  34. data/vendor/libsodium/builds/msvc/resource.rc +0 -0
  35. data/vendor/libsodium/builds/msvc/version.h +29 -0
  36. data/vendor/libsodium/builds/msvc/vs2010/libsodium.import.props +52 -0
  37. data/vendor/libsodium/builds/msvc/vs2010/libsodium.import.xml +17 -0
  38. data/vendor/libsodium/builds/msvc/vs2010/libsodium.sln +79 -0
  39. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.props +43 -0
  40. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +345 -0
  41. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +1037 -0
  42. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.xml +15 -0
  43. data/vendor/libsodium/builds/msvc/vs2010/test/test.props +37 -0
  44. data/vendor/libsodium/builds/msvc/vs2010/test/test.runner.bat +78 -0
  45. data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj +220 -0
  46. data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj.filters +168 -0
  47. data/vendor/libsodium/builds/msvc/vs2012/libsodium.import.props +52 -0
  48. data/vendor/libsodium/builds/msvc/vs2012/libsodium.import.xml +17 -0
  49. data/vendor/libsodium/builds/msvc/vs2012/libsodium.sln +79 -0
  50. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.props +43 -0
  51. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +345 -0
  52. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +1037 -0
  53. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.xml +15 -0
  54. data/vendor/libsodium/builds/msvc/vs2012/test/test.props +37 -0
  55. data/vendor/libsodium/builds/msvc/vs2012/test/test.runner.bat +78 -0
  56. data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj +220 -0
  57. data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj.filters +168 -0
  58. data/vendor/libsodium/builds/msvc/vs2013/libsodium.import.props +52 -0
  59. data/vendor/libsodium/builds/msvc/vs2013/libsodium.import.xml +17 -0
  60. data/vendor/libsodium/builds/msvc/vs2013/libsodium.sln +81 -0
  61. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.props +43 -0
  62. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +345 -0
  63. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +1037 -0
  64. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.xml +15 -0
  65. data/vendor/libsodium/builds/msvc/vs2013/test/test.props +37 -0
  66. data/vendor/libsodium/builds/msvc/vs2013/test/test.runner.bat +78 -0
  67. data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj +220 -0
  68. data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj.filters +168 -0
  69. data/vendor/libsodium/configure.ac +87 -68
  70. data/vendor/libsodium/dist-build/Makefile.am +10 -0
  71. data/vendor/libsodium/dist-build/android-arm.sh +3 -0
  72. data/vendor/libsodium/dist-build/android-armv7.sh +3 -0
  73. data/vendor/libsodium/dist-build/android-build.sh +37 -0
  74. data/vendor/libsodium/dist-build/android-mips.sh +3 -0
  75. data/vendor/libsodium/dist-build/android-x86.sh +3 -0
  76. data/vendor/libsodium/dist-build/emscripten.sh +13 -0
  77. data/vendor/libsodium/dist-build/{iphone.sh → ios.sh} +2 -2
  78. data/vendor/libsodium/dist-build/msys2-win32.sh +10 -0
  79. data/vendor/libsodium/dist-build/msys2-win64.sh +10 -0
  80. data/vendor/libsodium/libsodium.vcxproj +25 -13
  81. data/vendor/libsodium/libsodium.vcxproj.filters +60 -24
  82. data/vendor/libsodium/msvc-scripts/process.bat +3 -7
  83. data/vendor/libsodium/packaging/nuget/package.bat +13 -0
  84. data/vendor/libsodium/packaging/nuget/package.config +4 -0
  85. data/vendor/libsodium/packaging/nuget/package.gsl +255 -0
  86. data/vendor/libsodium/packaging/nuget/package.nuspec +93 -0
  87. data/vendor/libsodium/packaging/nuget/package.targets +128 -0
  88. data/vendor/libsodium/packaging/nuget/package.xml +22 -0
  89. data/vendor/libsodium/src/libsodium/Makefile.am +32 -20
  90. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/auth_hmacsha256_api.c +0 -5
  91. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/{ref → cp}/api.h +0 -1
  92. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/cp/hmac_hmacsha256.c +110 -0
  93. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/{ref → cp}/verify_hmacsha256.c +0 -0
  94. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/auth_hmacsha512_api.c +11 -0
  95. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/api.h +9 -0
  96. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/hmac_hmacsha512.c +110 -0
  97. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/verify_hmacsha512.c +10 -0
  98. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/auth_hmacsha512256_api.c +0 -5
  99. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/{ref → cp}/api.h +0 -1
  100. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/hmac_hmacsha512256.c +54 -0
  101. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/{ref → cp}/verify_hmacsha512256.c +2 -1
  102. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_easy.c +94 -0
  103. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305_api.c +0 -5
  104. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h +0 -1
  105. data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/core_hsalsa20_api.c +0 -5
  106. data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/api.h +0 -1
  107. data/vendor/libsodium/src/libsodium/crypto_core/salsa20/core_salsa20_api.c +0 -5
  108. data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/api.h +0 -1
  109. data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/core_salsa2012_api.c +0 -5
  110. data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/api.h +0 -1
  111. data/vendor/libsodium/src/libsodium/crypto_core/salsa208/core_salsa208_api.c +0 -5
  112. data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/api.h +0 -1
  113. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c +15 -5
  114. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/api.h +0 -2
  115. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h +14 -6
  116. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +95 -0
  117. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/generichash_blake2b.c +50 -3
  118. data/vendor/libsodium/src/libsodium/crypto_generichash/crypto_generichash.c +4 -10
  119. data/vendor/libsodium/src/libsodium/crypto_hash/crypto_hash.c +11 -0
  120. data/vendor/libsodium/src/libsodium/crypto_hash/sha256/{ref → cp}/api.h +3 -1
  121. data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +294 -0
  122. data/vendor/libsodium/src/libsodium/crypto_hash/sha256/hash_sha256_api.c +0 -5
  123. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/{ref → cp}/api.h +3 -1
  124. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +321 -0
  125. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/hash_sha512_api.c +0 -5
  126. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/auth_poly1305_donna.c +51 -127
  127. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +12 -0
  128. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +221 -0
  129. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +209 -0
  130. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_api.c +0 -5
  131. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c +1 -140
  132. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/crypto_scrypt-common.c +250 -0
  133. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/crypto_scrypt.h +100 -0
  134. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/nosse/pwhash_scryptxsalsa208sha256_nosse.c +302 -0
  135. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/pbkdf2-sha256.c +94 -0
  136. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/pbkdf2-sha256.h +45 -0
  137. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/pwhash_scryptxsalsa208sha256.c +172 -0
  138. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/scrypt_platform.c +96 -0
  139. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/sse/pwhash_scryptxsalsa208sha256_sse.c +391 -0
  140. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/sysendian.h +146 -0
  141. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/api.h +2 -2
  142. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/smult_curve25519_donna_c64.c +39 -9
  143. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref/api.h +2 -2
  144. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox.c +6 -0
  145. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +94 -0
  146. data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/ref/api.h +0 -1
  147. data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305_api.c +3 -3
  148. data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/api.h +0 -1
  149. data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/shorthash_siphash24_api.c +3 -3
  150. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/api.h +0 -1
  151. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_scalarmult_base.c +6 -0
  152. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +5 -3
  153. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +28 -18
  154. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sign.c +14 -9
  155. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/sign_ed25519_api.c +0 -5
  156. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/api.h +0 -1
  157. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/sign_edwards25519sha512batch_api.c +0 -5
  158. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/afternm_aes128ctr.c +21 -21
  159. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/api.h +0 -1
  160. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128.h +6 -0
  161. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/xor_afternm_aes128ctr.c +42 -42
  162. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/stream_aes128ctr_api.c +0 -5
  163. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes-table-be.h +4 -4
  164. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes-table-le.h +4 -4
  165. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes256-ctr.c +15 -14
  166. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/api.h +0 -1
  167. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/ecrypt-sync.h +1 -1
  168. data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/stream_aes256estream_api.c +0 -5
  169. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.S +153 -160
  170. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/api.h +2 -5
  171. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20_ref.c +9 -3
  172. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c +9 -3
  173. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20_api.c +0 -5
  174. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/api.h +0 -1
  175. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/stream_salsa2012_api.c +0 -5
  176. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/api.h +0 -1
  177. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/stream_salsa208_api.c +0 -5
  178. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/api.h +0 -1
  179. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/stream_xsalsa20_api.c +0 -5
  180. data/vendor/libsodium/src/libsodium/crypto_verify/64/ref/api.h +2 -0
  181. data/vendor/libsodium/src/libsodium/crypto_verify/64/ref/verify_64.c +72 -0
  182. data/vendor/libsodium/src/libsodium/crypto_verify/64/verify_64_api.c +6 -0
  183. data/vendor/libsodium/src/libsodium/include/Makefile.am +6 -7
  184. data/vendor/libsodium/src/libsodium/include/sodium.h +4 -3
  185. data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth.h +3 -0
  186. data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha256.h +31 -9
  187. data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512.h +58 -0
  188. data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512256.h +26 -9
  189. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box.h +13 -0
  190. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +38 -24
  191. data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_hsalsa20.h +6 -11
  192. data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_salsa20.h +6 -11
  193. data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_salsa2012.h +6 -11
  194. data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_salsa208.h +6 -11
  195. data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash.h +7 -8
  196. data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h +36 -16
  197. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash.h +13 -4
  198. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha256.h +25 -7
  199. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha512.h +25 -7
  200. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth.h +3 -0
  201. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h +5 -5
  202. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_donna.h +3 -0
  203. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_scryptxsalsa208sha256.h +48 -0
  204. data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h +31 -0
  205. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox.h +17 -0
  206. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h +21 -11
  207. data/vendor/libsodium/src/libsodium/include/sodium/crypto_shorthash.h +3 -0
  208. data/vendor/libsodium/src/libsodium/include/sodium/crypto_shorthash_siphash24.h +8 -7
  209. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign.h +3 -0
  210. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_ed25519.h +16 -17
  211. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h +18 -14
  212. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream.h +3 -0
  213. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes128ctr.h +18 -18
  214. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes256estream.h +19 -18
  215. data/vendor/libsodium/src/libsodium/include/sodium/{crypto_stream_salsa20.h.in → crypto_stream_salsa20.h} +8 -19
  216. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa2012.h +8 -8
  217. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa208.h +8 -8
  218. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_xsalsa20.h +10 -11
  219. data/vendor/libsodium/src/libsodium/include/sodium/crypto_verify_16.h +1 -4
  220. data/vendor/libsodium/src/libsodium/include/sodium/crypto_verify_32.h +1 -4
  221. data/vendor/libsodium/src/libsodium/include/sodium/crypto_verify_64.h +22 -0
  222. data/vendor/libsodium/src/libsodium/include/sodium/randombytes.h +3 -0
  223. data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +27 -0
  224. data/vendor/libsodium/src/libsodium/include/sodium/utils.h +15 -3
  225. data/vendor/libsodium/src/libsodium/randombytes/randombytes.c +3 -1
  226. data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +18 -7
  227. data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +57 -9
  228. data/vendor/libsodium/src/libsodium/sodium/compat.c +62 -0
  229. data/vendor/libsodium/src/libsodium/sodium/core.c +2 -0
  230. data/vendor/libsodium/src/libsodium/sodium/runtime.c +134 -0
  231. data/vendor/libsodium/src/libsodium/sodium/utils.c +100 -8
  232. data/vendor/libsodium/test/default/Makefile.am +63 -3
  233. data/vendor/libsodium/test/default/auth6.c +21 -0
  234. data/vendor/libsodium/test/default/auth6.exp +8 -0
  235. data/vendor/libsodium/test/default/auth7.c +37 -0
  236. data/vendor/libsodium/test/default/auth7.exp +0 -0
  237. data/vendor/libsodium/test/default/box_easy.c +59 -0
  238. data/vendor/libsodium/test/default/box_easy.exp +19 -0
  239. data/vendor/libsodium/test/default/box_easy2.c +31 -0
  240. data/vendor/libsodium/test/default/box_easy2.exp +1 -0
  241. data/vendor/libsodium/test/default/cmptest.h +7 -1
  242. data/vendor/libsodium/test/default/generichash3.c +36 -0
  243. data/vendor/libsodium/test/default/generichash3.exp +64 -0
  244. data/vendor/libsodium/test/default/pwhash.c +59 -0
  245. data/vendor/libsodium/test/default/pwhash.exp +2 -0
  246. data/vendor/libsodium/test/default/scalarmult7.c +0 -2
  247. data/vendor/libsodium/test/default/scalarmult8.c +0 -2
  248. data/vendor/libsodium/test/default/secretbox_easy.c +51 -0
  249. data/vendor/libsodium/test/default/secretbox_easy.exp +19 -0
  250. data/vendor/libsodium/test/default/secretbox_easy2.c +27 -0
  251. data/vendor/libsodium/test/default/secretbox_easy2.exp +1 -0
  252. data/vendor/libsodium/test/default/sign.c +1106 -0
  253. data/vendor/libsodium/test/default/sign.exp +3 -0
  254. data/vendor/libsodium/test/default/sodium_utils.c +8 -0
  255. data/vendor/libsodium/test/default/sodium_utils.exp +2 -1
  256. data/vendor/libsodium/test/default/sodium_version.c +1 -1
  257. data/vendor/libsodium/test/default/verify1.c +34 -0
  258. data/vendor/libsodium/test/default/verify1.exp +6 -0
  259. metadata +138 -33
  260. data/vendor/libsodium/dist-build/android.sh +0 -48
  261. data/vendor/libsodium/dist-build/msys.sh +0 -9
  262. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/ref/hmac_hmacsha256.c +0 -83
  263. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/ref/hmac_hmacsha512256.c +0 -86
  264. data/vendor/libsodium/src/libsodium/crypto_hash/sha256/ref/hash_sha256.c +0 -69
  265. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/ref/hash_sha512.c +0 -71
  266. data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha256/checksum +0 -1
  267. data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha256/hashblocks_sha256_api.c +0 -16
  268. data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha256/ref/api.h +0 -9
  269. data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha256/ref/blocks_sha256.c +0 -212
  270. data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha512/checksum +0 -1
  271. data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha512/hashblocks_sha512_api.c +0 -16
  272. data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha512/ref/api.h +0 -9
  273. data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha512/ref/blocks_sha512.c +0 -239
  274. data/vendor/libsodium/src/libsodium/crypto_hashblocks/try.c +0 -78
  275. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/53/api.h +0 -8
  276. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/53/auth_poly1305_53.c +0 -1661
  277. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/53/verify_poly1305_53.c +0 -10
  278. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/portable-jane.h +0 -772
  279. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hashblocks_sha256.h +0 -32
  280. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hashblocks_sha512.h +0 -32
  281. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_53.h +0 -34
  282. data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h.in +0 -44
@@ -0,0 +1,146 @@
1
+ #ifndef _SYSENDIAN_H_
2
+ #define _SYSENDIAN_H_
3
+
4
+ #include <stdint.h>
5
+
6
+ /* Avoid namespace collisions with BSD <sys/endian.h>. */
7
+ #define be16dec scrypt_be16dec
8
+ #define be16enc scrypt_be16enc
9
+ #define be32dec scrypt_be32dec
10
+ #define be32enc scrypt_be32enc
11
+ #define be64dec scrypt_be64dec
12
+ #define be64enc scrypt_be64enc
13
+ #define le16dec scrypt_le16dec
14
+ #define le16enc scrypt_le16enc
15
+ #define le32dec scrypt_le32dec
16
+ #define le32enc scrypt_le32enc
17
+ #define le64dec scrypt_le64dec
18
+ #define le64enc scrypt_le64enc
19
+
20
+ static inline uint16_t
21
+ be16dec(const void *pp)
22
+ {
23
+ const uint8_t *p = (uint8_t const *)pp;
24
+
25
+ return ((uint16_t)(p[1]) + ((uint16_t)(p[0]) << 8));
26
+ }
27
+
28
+ static inline void
29
+ be16enc(void *pp, uint16_t x)
30
+ {
31
+ uint8_t * p = (uint8_t *)pp;
32
+
33
+ p[1] = x & 0xff;
34
+ p[0] = (x >> 8) & 0xff;
35
+ }
36
+
37
+ static inline uint32_t
38
+ be32dec(const void *pp)
39
+ {
40
+ const uint8_t *p = (uint8_t const *)pp;
41
+
42
+ return ((uint32_t)(p[3]) + ((uint32_t)(p[2]) << 8) +
43
+ ((uint32_t)(p[1]) << 16) + ((uint32_t)(p[0]) << 24));
44
+ }
45
+
46
+ static inline void
47
+ be32enc(void *pp, uint32_t x)
48
+ {
49
+ uint8_t * p = (uint8_t *)pp;
50
+
51
+ p[3] = x & 0xff;
52
+ p[2] = (x >> 8) & 0xff;
53
+ p[1] = (x >> 16) & 0xff;
54
+ p[0] = (x >> 24) & 0xff;
55
+ }
56
+
57
+ static inline uint64_t
58
+ be64dec(const void *pp)
59
+ {
60
+ const uint8_t *p = (uint8_t const *)pp;
61
+
62
+ return ((uint64_t)(p[7]) + ((uint64_t)(p[6]) << 8) +
63
+ ((uint64_t)(p[5]) << 16) + ((uint64_t)(p[4]) << 24) +
64
+ ((uint64_t)(p[3]) << 32) + ((uint64_t)(p[2]) << 40) +
65
+ ((uint64_t)(p[1]) << 48) + ((uint64_t)(p[0]) << 56));
66
+ }
67
+
68
+ static inline void
69
+ be64enc(void *pp, uint64_t x)
70
+ {
71
+ uint8_t * p = (uint8_t *)pp;
72
+
73
+ p[7] = x & 0xff;
74
+ p[6] = (x >> 8) & 0xff;
75
+ p[5] = (x >> 16) & 0xff;
76
+ p[4] = (x >> 24) & 0xff;
77
+ p[3] = (x >> 32) & 0xff;
78
+ p[2] = (x >> 40) & 0xff;
79
+ p[1] = (x >> 48) & 0xff;
80
+ p[0] = (x >> 56) & 0xff;
81
+ }
82
+
83
+ static inline uint16_t
84
+ le16dec(const void *pp)
85
+ {
86
+ const uint8_t *p = (uint8_t const *)pp;
87
+
88
+ return ((uint16_t)(p[0]) + ((uint16_t)(p[1]) << 8));
89
+ }
90
+
91
+ static inline void
92
+ le16enc(void *pp, uint16_t x)
93
+ {
94
+ uint8_t * p = (uint8_t *)pp;
95
+
96
+ p[0] = x & 0xff;
97
+ p[1] = (x >> 8) & 0xff;
98
+ }
99
+
100
+ static inline uint32_t
101
+ le32dec(const void *pp)
102
+ {
103
+ const uint8_t *p = (uint8_t const *)pp;
104
+
105
+ return ((uint32_t)(p[0]) + ((uint32_t)(p[1]) << 8) +
106
+ ((uint32_t)(p[2]) << 16) + ((uint32_t)(p[3]) << 24));
107
+ }
108
+
109
+ static inline void
110
+ le32enc(void *pp, uint32_t x)
111
+ {
112
+ uint8_t * p = (uint8_t *)pp;
113
+
114
+ p[0] = x & 0xff;
115
+ p[1] = (x >> 8) & 0xff;
116
+ p[2] = (x >> 16) & 0xff;
117
+ p[3] = (x >> 24) & 0xff;
118
+ }
119
+
120
+ static inline uint64_t
121
+ le64dec(const void *pp)
122
+ {
123
+ const uint8_t *p = (uint8_t const *)pp;
124
+
125
+ return ((uint64_t)(p[0]) + ((uint64_t)(p[1]) << 8) +
126
+ ((uint64_t)(p[2]) << 16) + ((uint64_t)(p[3]) << 24) +
127
+ ((uint64_t)(p[4]) << 32) + ((uint64_t)(p[5]) << 40) +
128
+ ((uint64_t)(p[6]) << 48) + ((uint64_t)(p[7]) << 56));
129
+ }
130
+
131
+ static inline void
132
+ le64enc(void *pp, uint64_t x)
133
+ {
134
+ uint8_t * p = (uint8_t *)pp;
135
+
136
+ p[0] = x & 0xff;
137
+ p[1] = (x >> 8) & 0xff;
138
+ p[2] = (x >> 16) & 0xff;
139
+ p[3] = (x >> 24) & 0xff;
140
+ p[4] = (x >> 32) & 0xff;
141
+ p[5] = (x >> 40) & 0xff;
142
+ p[6] = (x >> 48) & 0xff;
143
+ p[7] = (x >> 56) & 0xff;
144
+ }
145
+
146
+ #endif /* !_SYSENDIAN_H_ */
@@ -4,6 +4,6 @@
4
4
  #define crypto_scalarmult_curve25519_implementation_name \
5
5
  crypto_scalarmult_curve25519_donna_c64_implementation_name
6
6
 
7
- #define crypto_scalarmult crypto_scalarmult_curve25519_donna_c64
8
- #define crypto_scalarmult_base crypto_scalarmult_curve25519_donna_c64_base
7
+ #define crypto_scalarmult crypto_scalarmult_curve25519
8
+ #define crypto_scalarmult_base crypto_scalarmult_curve25519_base
9
9
 
@@ -189,14 +189,44 @@ fsquare_times(felem output, const felem in, limb count) {
189
189
  output[4] = r4;
190
190
  }
191
191
 
192
+ #if !defined(CPU_ALIGNED_ACCESS_REQUIRED) && defined(NATIVE_LITTLE_ENDIAN)
193
+ # define U8TO64(p) (*((const uint64_t *) (p)))
194
+ # define U64TO8(p, v) (*((uint64_t *) (p)) = (v))
195
+ #else
196
+ static force_inline uint64_t
197
+ U8TO64(const unsigned char *p) {
198
+ return
199
+ (((uint64_t)(p[0] & 0xff) ) |
200
+ ((uint64_t)(p[1] & 0xff) << 8) |
201
+ ((uint64_t)(p[2] & 0xff) << 16) |
202
+ ((uint64_t)(p[3] & 0xff) << 24) |
203
+ ((uint64_t)(p[4] & 0xff) << 32) |
204
+ ((uint64_t)(p[5] & 0xff) << 40) |
205
+ ((uint64_t)(p[6] & 0xff) << 48) |
206
+ ((uint64_t)(p[7] & 0xff) << 56));
207
+ }
208
+
209
+ static force_inline void
210
+ U64TO8(unsigned char *p, uint64_t v) {
211
+ p[0] = (v ) & 0xff;
212
+ p[1] = (v >> 8) & 0xff;
213
+ p[2] = (v >> 16) & 0xff;
214
+ p[3] = (v >> 24) & 0xff;
215
+ p[4] = (v >> 32) & 0xff;
216
+ p[5] = (v >> 40) & 0xff;
217
+ p[6] = (v >> 48) & 0xff;
218
+ p[7] = (v >> 56) & 0xff;
219
+ }
220
+ #endif
221
+
192
222
  /* Take a little-endian, 32-byte number and expand it into polynomial form */
193
223
  static void
194
224
  fexpand(limb *output, const u8 *in) {
195
- output[0] = *((const uint64_t *)(in)) & 0x7ffffffffffff;
196
- output[1] = (*((const uint64_t *)(in+6)) >> 3) & 0x7ffffffffffff;
197
- output[2] = (*((const uint64_t *)(in+12)) >> 6) & 0x7ffffffffffff;
198
- output[3] = (*((const uint64_t *)(in+19)) >> 1) & 0x7ffffffffffff;
199
- output[4] = (*((const uint64_t *)(in+25)) >> 4) & 0xfffffffffffff;
225
+ output[0] = U8TO64(in) & 0x7ffffffffffff;
226
+ output[1] = (U8TO64(in+6) >> 3) & 0x7ffffffffffff;
227
+ output[2] = (U8TO64(in+12) >> 6) & 0x7ffffffffffff;
228
+ output[3] = (U8TO64(in+19) >> 1) & 0x7ffffffffffff;
229
+ output[4] = (U8TO64(in+25) >> 4) & 0xfffffffffffff;
200
230
  }
201
231
 
202
232
  /* Take a fully reduced polynomial form number and contract it into a
@@ -251,10 +281,10 @@ fcontract(u8 *output, const felem input) {
251
281
  t[4] += t[3] >> 51; t[3] &= 0x7ffffffffffff;
252
282
  t[4] &= 0x7ffffffffffff;
253
283
 
254
- *((uint64_t *)(output)) = t[0] | (t[1] << 51);
255
- *((uint64_t *)(output+8)) = (t[1] >> 13) | (t[2] << 38);
256
- *((uint64_t *)(output+16)) = (t[2] >> 26) | (t[3] << 25);
257
- *((uint64_t *)(output+24)) = (t[3] >> 39) | (t[4] << 12);
284
+ U64TO8(output, t[0] | (t[1] << 51));
285
+ U64TO8(output + 8, (t[1] >> 13) | (t[2] << 38));
286
+ U64TO8(output + 16, (t[2] >> 26) | (t[3] << 25));
287
+ U64TO8(output + 24, (t[3] >> 39) | (t[4] << 12));
258
288
  }
259
289
 
260
290
  /* Input: Q, Q', Q-Q'
@@ -4,5 +4,5 @@
4
4
  #define crypto_scalarmult_curve25519_implementation_name \
5
5
  crypto_scalarmult_curve25519_ref_implementation_name
6
6
 
7
- #define crypto_scalarmult crypto_scalarmult_curve25519_ref
8
- #define crypto_scalarmult_base crypto_scalarmult_curve25519_ref_base
7
+ #define crypto_scalarmult crypto_scalarmult_curve25519
8
+ #define crypto_scalarmult_base crypto_scalarmult_curve25519_base
@@ -25,6 +25,12 @@ crypto_secretbox_boxzerobytes(void)
25
25
  return crypto_secretbox_BOXZEROBYTES;
26
26
  }
27
27
 
28
+ size_t
29
+ crypto_secretbox_macbytes(void)
30
+ {
31
+ return crypto_secretbox_MACBYTES;
32
+ }
33
+
28
34
  const char *
29
35
  crypto_secretbox_primitive(void)
30
36
  {
@@ -0,0 +1,94 @@
1
+
2
+ #include <assert.h>
3
+ #include <limits.h>
4
+ #include <stdint.h>
5
+ #include <stdlib.h>
6
+ #include <string.h>
7
+
8
+ #include "crypto_secretbox.h"
9
+ #include "utils.h"
10
+
11
+ int
12
+ crypto_secretbox_easy(unsigned char *c, const unsigned char *m,
13
+ unsigned long long mlen, const unsigned char *n,
14
+ const unsigned char *k)
15
+ {
16
+ unsigned char *c_boxed;
17
+ unsigned char *m_boxed;
18
+ size_t c_boxed_len;
19
+ size_t m_boxed_len;
20
+ int rc;
21
+
22
+ if (mlen > SIZE_MAX - crypto_secretbox_ZEROBYTES) {
23
+ return -1;
24
+ }
25
+ (void) sizeof(char[crypto_secretbox_ZEROBYTES >=
26
+ crypto_secretbox_BOXZEROBYTES ? 1 : -1]);
27
+ m_boxed_len = (size_t) mlen + crypto_secretbox_ZEROBYTES;
28
+ if ((m_boxed = (unsigned char *) malloc((size_t) m_boxed_len)) == NULL) {
29
+ return -1;
30
+ }
31
+ c_boxed_len = (size_t) mlen + crypto_secretbox_ZEROBYTES;
32
+ if ((c_boxed = (unsigned char *) malloc(c_boxed_len)) == NULL) {
33
+ free(m_boxed);
34
+ return -1;
35
+ }
36
+ memset(m_boxed, 0, crypto_secretbox_ZEROBYTES);
37
+ memcpy(m_boxed + crypto_secretbox_ZEROBYTES, m, mlen);
38
+ rc = crypto_secretbox(c_boxed, m_boxed, m_boxed_len, n, k);
39
+ sodium_memzero(m_boxed, m_boxed_len);
40
+ free(m_boxed);
41
+ if (rc != 0) {
42
+ free(c_boxed);
43
+ return -1;
44
+ }
45
+ assert(m_boxed_len - crypto_secretbox_BOXZEROBYTES ==
46
+ mlen + crypto_secretbox_MACBYTES);
47
+ memcpy(c, c_boxed + crypto_secretbox_BOXZEROBYTES,
48
+ mlen + crypto_secretbox_MACBYTES);
49
+ free(c_boxed);
50
+
51
+ return 0;
52
+ }
53
+
54
+ int
55
+ crypto_secretbox_open_easy(unsigned char *m, const unsigned char *c,
56
+ unsigned long long clen, const unsigned char *n,
57
+ const unsigned char *k)
58
+ {
59
+ unsigned char *c_boxed;
60
+ unsigned char *m_boxed;
61
+ size_t c_boxed_len;
62
+ size_t m_boxed_len;
63
+ int rc;
64
+
65
+ (void) sizeof(int[crypto_secretbox_BOXZEROBYTES + crypto_secretbox_MACBYTES
66
+ == crypto_secretbox_ZEROBYTES]);
67
+ if (clen < crypto_secretbox_MACBYTES ||
68
+ clen > SIZE_MAX - crypto_secretbox_BOXZEROBYTES) {
69
+ return -1;
70
+ }
71
+ c_boxed_len = clen + crypto_secretbox_BOXZEROBYTES;
72
+ if ((c_boxed = (unsigned char *) malloc(c_boxed_len)) == NULL) {
73
+ return -1;
74
+ }
75
+ memset(c_boxed, 0, crypto_secretbox_BOXZEROBYTES);
76
+ memcpy(c_boxed + crypto_secretbox_BOXZEROBYTES, c, clen);
77
+ m_boxed_len = c_boxed_len + crypto_secretbox_MACBYTES;
78
+ if ((m_boxed = (unsigned char *) malloc(m_boxed_len)) == NULL) {
79
+ free(c_boxed);
80
+ return -1;
81
+ }
82
+ rc = crypto_secretbox_open(m_boxed, c_boxed,
83
+ (unsigned long long) c_boxed_len, n, k);
84
+ free(c_boxed);
85
+ if (rc != 0) {
86
+ free(m_boxed);
87
+ return -1;
88
+ }
89
+ memcpy(m, m_boxed + crypto_secretbox_ZEROBYTES,
90
+ clen - crypto_secretbox_MACBYTES);
91
+ free(m_boxed);
92
+
93
+ return 0;
94
+ }
@@ -7,6 +7,5 @@
7
7
  #define crypto_secretbox_NONCEBYTES crypto_secretbox_xsalsa20poly1305_NONCEBYTES
8
8
  #define crypto_secretbox_ZEROBYTES crypto_secretbox_xsalsa20poly1305_ZEROBYTES
9
9
  #define crypto_secretbox_BOXZEROBYTES crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES
10
- #define crypto_secretbox_PRIMITIVE "xsalsa20poly1305"
11
10
  #define crypto_secretbox_IMPLEMENTATION crypto_secretbox_xsalsa20poly1305_IMPLEMENTATION
12
11
  #define crypto_secretbox_VERSION crypto_secretbox_xsalsa20poly1305_VERSION
@@ -20,7 +20,7 @@ crypto_secretbox_xsalsa20poly1305_boxzerobytes(void) {
20
20
  return crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES;
21
21
  }
22
22
 
23
- const char *
24
- crypto_secretbox_xsalsa20poly1305_primitive(void) {
25
- return "xsalsa20poly1305";
23
+ size_t
24
+ crypto_secretbox_xsalsa20poly1305_macbytes(void) {
25
+ return crypto_secretbox_xsalsa20poly1305_MACBYTES;
26
26
  }
@@ -3,6 +3,5 @@
3
3
 
4
4
  #define crypto_shorthash crypto_shorthash_siphash24
5
5
  #define crypto_shorthash_BYTES crypto_shorthash_siphash24_BYTES
6
- #define crypto_shorthash_PRIMITIVE "siphash24"
7
6
  #define crypto_shorthash_IMPLEMENTATION crypto_shorthash_siphash24_IMPLEMENTATION
8
7
  #define crypto_shorthash_VERSION crypto_shorthash_siphash24_VERSION
@@ -5,7 +5,7 @@ crypto_shorthash_siphash24_bytes(void) {
5
5
  return crypto_shorthash_siphash24_BYTES;
6
6
  }
7
7
 
8
- const char *
9
- crypto_shorthash_siphash24_primitive(void) {
10
- return "siphash24";
8
+ size_t
9
+ crypto_shorthash_siphash24_keybytes(void) {
10
+ return crypto_shorthash_siphash24_KEYBYTES;
11
11
  }
@@ -9,6 +9,5 @@
9
9
  #define crypto_sign_SEEDBYTES crypto_sign_ed25519_SEEDBYTES
10
10
  #define crypto_sign_PUBLICKEYBYTES crypto_sign_ed25519_PUBLICKEYBYTES
11
11
  #define crypto_sign_SECRETKEYBYTES crypto_sign_ed25519_SECRETKEYBYTES
12
- #define crypto_sign_PRIMITIVE "ed25519"
13
12
  #define crypto_sign_IMPLEMENTATION crypto_sign_ed25519_IMPLEMENTATION
14
13
  #define crypto_sign_VERSION crypto_sign_ed25519_VERSION
@@ -1,6 +1,12 @@
1
1
  #include "ge.h"
2
2
  #include "crypto_uint32.h"
3
3
 
4
+ #ifdef __cplusplus
5
+ # if __GNUC__
6
+ # pragma GCC diagnostic ignored "-Wlong-long"
7
+ # endif
8
+ #endif
9
+
4
10
  static unsigned char equal(signed char b,signed char c)
5
11
  {
6
12
  unsigned char ub = b;
@@ -1,3 +1,6 @@
1
+
2
+ #include <string.h>
3
+
1
4
  #include "api.h"
2
5
  #include "randombytes.h"
3
6
  #include "crypto_hash_sha512.h"
@@ -7,7 +10,6 @@ int crypto_sign_seed_keypair(unsigned char *pk, unsigned char *sk,
7
10
  const unsigned char *seed)
8
11
  {
9
12
  ge_p3 A;
10
- int i;
11
13
 
12
14
  crypto_hash_sha512(sk,seed,32);
13
15
  sk[0] &= 248;
@@ -17,8 +19,8 @@ int crypto_sign_seed_keypair(unsigned char *pk, unsigned char *sk,
17
19
  ge_scalarmult_base(&A,sk);
18
20
  ge_p3_tobytes(pk,&A);
19
21
 
20
- for (i = 0;i < 32;++i) sk[i] = seed[i];
21
- for (i = 0;i < 32;++i) sk[32 + i] = pk[i];
22
+ memmove(sk, seed, 32);
23
+ memmove(sk + 32, pk, 32);
22
24
  return 0;
23
25
  }
24
26
 
@@ -1,3 +1,6 @@
1
+
2
+ #include <string.h>
3
+
1
4
  #include "api.h"
2
5
  #include "crypto_hash_sha512.h"
3
6
  #include "crypto_verify_32.h"
@@ -10,31 +13,38 @@ int crypto_sign_open(
10
13
  const unsigned char *pk
11
14
  )
12
15
  {
16
+ crypto_hash_sha512_state hs;
13
17
  unsigned char h[64];
14
- unsigned char checkr[32];
18
+ unsigned char rcheck[32];
19
+ unsigned int i;
20
+ unsigned char d = 0;
15
21
  ge_p3 A;
16
22
  ge_p2 R;
17
- unsigned long long i;
18
23
 
19
- *mlen = -1;
20
- if (smlen < 64) return -1;
21
- if (sm[63] & 224) return -1;
22
- if (ge_frombytes_negate_vartime(&A,pk) != 0) return -1;
24
+ if (smlen < 64) goto badsig;
25
+ if (sm[63] & 224) goto badsig;
26
+ if (ge_frombytes_negate_vartime(&A,pk) != 0) goto badsig;
27
+
28
+ for (i = 0; i < 32; ++i) d |= pk[i];
29
+ if (d == 0) return -1;
23
30
 
24
- for (i = 0;i < smlen;++i) m[i] = sm[i];
25
- for (i = 0;i < 32;++i) m[32 + i] = pk[i];
26
- crypto_hash_sha512(h,m,smlen);
31
+ crypto_hash_sha512_init(&hs);
32
+ crypto_hash_sha512_update(&hs, sm, 32);
33
+ crypto_hash_sha512_update(&hs, pk, 32);
34
+ crypto_hash_sha512_update(&hs, sm + 64, smlen - 64);
35
+ crypto_hash_sha512_final(&hs, h);
27
36
  sc_reduce(h);
28
37
 
29
- ge_double_scalarmult_vartime(&R,h,&A,sm + 32);
30
- ge_tobytes(checkr,&R);
31
- if (crypto_verify_32(checkr,sm) != 0) {
32
- for (i = 0;i < smlen;++i) m[i] = 0;
33
- return -1;
38
+ ge_double_scalarmult_vartime(&R,h,&A,sm+32);
39
+ ge_tobytes(rcheck,&R);
40
+ if (crypto_verify_32(rcheck,sm) == 0) {
41
+ memmove(m, sm + 64,smlen - 64);
42
+ *mlen = smlen - 64;
43
+ return 0;
34
44
  }
35
45
 
36
- for (i = 0;i < smlen - 64;++i) m[i] = sm[64 + i];
37
- for (i = smlen - 64;i < smlen;++i) m[i] = 0;
38
- *mlen = smlen - 64;
39
- return 0;
46
+ badsig:
47
+ *mlen = 0;
48
+ memset(m, 0, smlen - 64);
49
+ return -1;
40
50
  }