rbnacl-libsodium 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (243) 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 +10 -3
  5. data/vendor/libsodium/ChangeLog +19 -1
  6. data/vendor/libsodium/Makefile.in +1 -0
  7. data/vendor/libsodium/README.markdown +1 -1
  8. data/vendor/libsodium/THANKS +1 -0
  9. data/vendor/libsodium/autogen.sh +24 -4
  10. data/vendor/libsodium/autom4te.cache/output.1 +208 -24
  11. data/vendor/libsodium/autom4te.cache/output.5 +208 -24
  12. data/vendor/libsodium/autom4te.cache/requests +869 -869
  13. data/vendor/libsodium/autom4te.cache/traces.1 +426 -406
  14. data/vendor/libsodium/autom4te.cache/traces.5 +255 -245
  15. data/vendor/libsodium/builds/msvc/version.h +2 -2
  16. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +14 -44
  17. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +36 -132
  18. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +14 -44
  19. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +36 -132
  20. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +14 -44
  21. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +36 -132
  22. data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +14 -44
  23. data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +62 -158
  24. data/vendor/libsodium/configure +208 -24
  25. data/vendor/libsodium/configure.ac +70 -15
  26. data/vendor/libsodium/dist-build/Makefile.in +1 -0
  27. data/vendor/libsodium/dist-build/emscripten.sh +52 -19
  28. data/vendor/libsodium/dist-build/ios.sh +8 -8
  29. data/vendor/libsodium/dist-build/msys2-win32.sh +2 -1
  30. data/vendor/libsodium/dist-build/msys2-win64.sh +2 -1
  31. data/vendor/libsodium/dist-build/osx.sh +2 -2
  32. data/vendor/libsodium/examples/box.c +3 -1
  33. data/vendor/libsodium/examples/box_detached.c +4 -2
  34. data/vendor/libsodium/examples/utils.h +3 -1
  35. data/vendor/libsodium/libsodium.vcxproj +13 -13
  36. data/vendor/libsodium/libsodium.vcxproj.filters +31 -35
  37. data/vendor/libsodium/msvc-scripts/Makefile.in +1 -0
  38. data/vendor/libsodium/msvc-scripts/process.bat +2 -2
  39. data/vendor/libsodium/src/Makefile.in +1 -0
  40. data/vendor/libsodium/src/libsodium/Makefile.am +43 -45
  41. data/vendor/libsodium/src/libsodium/Makefile.in +250 -249
  42. data/vendor/libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +28 -22
  43. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/cp/hmac_hmacsha256.c +3 -4
  44. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/cp/verify_hmacsha256.c +3 -3
  45. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/hmac_hmacsha512.c +3 -4
  46. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/verify_hmacsha512.c +4 -4
  47. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/hmac_hmacsha512256.c +4 -4
  48. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/verify_hmacsha512256.c +6 -4
  49. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_easy.c +6 -2
  50. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/after_curve25519xsalsa20poly1305.c +3 -3
  51. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c +5 -3
  52. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/box_curve25519xsalsa20poly1305.c +13 -9
  53. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c +3 -3
  54. data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20.c +2 -2
  55. data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/core_salsa20.c +2 -2
  56. data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/core_salsa2012.c +2 -2
  57. data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/core_salsa208.c +2 -2
  58. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h +2 -2
  59. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +36 -26
  60. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/generichash_blake2b.c +1 -1
  61. data/vendor/libsodium/src/libsodium/crypto_generichash/crypto_generichash.c +1 -2
  62. data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +2 -3
  63. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +2 -3
  64. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/{auth_poly1305_donna.c → poly1305_donna.c} +18 -11
  65. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +1 -5
  66. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +10 -9
  67. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +17 -9
  68. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c +10 -1
  69. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c +708 -0
  70. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.h +31 -0
  71. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +1 -0
  72. data/vendor/libsodium/src/libsodium/crypto_scalarmult/crypto_scalarmult.c +11 -12
  73. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/{smult_curve25519_donna_c64.c → curve25519_donna_c64.c} +32 -15
  74. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.h +9 -0
  75. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/curve25519_ref10.c +73 -0
  76. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/curve25519_ref10.h +9 -0
  77. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_frombytes_curve25519_ref10.c +1 -0
  78. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/consts.S +25 -0
  79. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/consts_namespace.h +20 -0
  80. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/curve25519_sandy2x.c +114 -0
  81. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/curve25519_sandy2x.h +9 -0
  82. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe.h +25 -0
  83. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51.h +33 -0
  84. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_invert.c +57 -0
  85. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_mul.S +189 -0
  86. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_namespace.h +16 -0
  87. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_nsquare.S +165 -0
  88. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_pack.S +219 -0
  89. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe_frombytes_sandy2x.c +76 -0
  90. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder.S +1432 -0
  91. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder.h +18 -0
  92. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base.S +1287 -0
  93. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base.h +18 -0
  94. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base_namespace.h +8 -0
  95. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_namespace.h +8 -0
  96. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/sandy2x.S +17 -0
  97. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519.c +67 -0
  98. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519.h +11 -0
  99. data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/ref/box_xsalsa20poly1305.c +3 -3
  100. data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash24.c +3 -2
  101. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge.h +2 -0
  102. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_double_scalarmult.c +42 -0
  103. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +7 -7
  104. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/obsolete.c +113 -0
  105. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +10 -7
  106. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sign.c +10 -10
  107. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/afternm_aes128ctr.c +2 -2
  108. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/beforenm_aes128ctr.c +2 -2
  109. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/stream_aes128ctr.c +10 -9
  110. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/xor_afternm_aes128ctr.c +2 -3
  111. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c +72 -68
  112. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/{api.h → stream_chacha20_ref.h} +5 -0
  113. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/{stream_chacha20_api.c → stream_chacha20.c} +27 -7
  114. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/stream_chacha20.h +22 -0
  115. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/vec/stream_chacha20_vec.c +329 -0
  116. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/vec/stream_chacha20_vec.h +27 -0
  117. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.S +1 -1
  118. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20_ref.c +2 -2
  119. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c +1 -1
  120. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c +2 -2
  121. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c +2 -2
  122. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c +2 -2
  123. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c +2 -2
  124. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c +2 -2
  125. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c +4 -4
  126. data/vendor/libsodium/src/libsodium/crypto_verify/16/ref/verify_16.c +14 -21
  127. data/vendor/libsodium/src/libsodium/crypto_verify/32/ref/verify_32.c +14 -37
  128. data/vendor/libsodium/src/libsodium/crypto_verify/64/ref/verify_64.c +14 -69
  129. data/vendor/libsodium/src/libsodium/include/Makefile.in +1 -0
  130. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box.h +8 -4
  131. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +4 -2
  132. data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h +2 -2
  133. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h +2 -3
  134. data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult.h +2 -1
  135. data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h +6 -1
  136. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_chacha20.h +5 -0
  137. data/vendor/libsodium/src/libsodium/include/sodium/randombytes_nativeclient.h +6 -20
  138. data/vendor/libsodium/src/libsodium/include/sodium/randombytes_salsa20_random.h +1 -28
  139. data/vendor/libsodium/src/libsodium/include/sodium/randombytes_sysrandom.h +1 -27
  140. data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +3 -0
  141. data/vendor/libsodium/src/libsodium/include/sodium/utils.h +6 -0
  142. data/vendor/libsodium/src/libsodium/randombytes/nativeclient/randombytes_nativeclient.c +3 -3
  143. data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +58 -51
  144. data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +23 -18
  145. data/vendor/libsodium/src/libsodium/sodium/core.c +4 -0
  146. data/vendor/libsodium/src/libsodium/sodium/runtime.c +34 -15
  147. data/vendor/libsodium/src/libsodium/sodium/utils.c +104 -14
  148. data/vendor/libsodium/test/Makefile.in +1 -0
  149. data/vendor/libsodium/test/default/Makefile.in +1 -0
  150. data/vendor/libsodium/test/default/auth.c +5 -5
  151. data/vendor/libsodium/test/default/auth2.c +3 -3
  152. data/vendor/libsodium/test/default/auth3.c +3 -3
  153. data/vendor/libsodium/test/default/auth5.c +4 -4
  154. data/vendor/libsodium/test/default/auth6.c +3 -3
  155. data/vendor/libsodium/test/default/auth7.c +4 -4
  156. data/vendor/libsodium/test/default/box.c +13 -9
  157. data/vendor/libsodium/test/default/box2.c +11 -8
  158. data/vendor/libsodium/test/default/box7.c +11 -9
  159. data/vendor/libsodium/test/default/box8.c +32 -19
  160. data/vendor/libsodium/test/default/box_easy.c +31 -10
  161. data/vendor/libsodium/test/default/box_easy.exp +3 -19
  162. data/vendor/libsodium/test/default/box_easy2.c +30 -15
  163. data/vendor/libsodium/test/default/box_seed.c +1 -1
  164. data/vendor/libsodium/test/default/cmptest.h +22 -1
  165. data/vendor/libsodium/test/default/core1.c +6 -5
  166. data/vendor/libsodium/test/default/core2.c +6 -5
  167. data/vendor/libsodium/test/default/core3.c +8 -7
  168. data/vendor/libsodium/test/default/core4.c +11 -8
  169. data/vendor/libsodium/test/default/core5.c +7 -5
  170. data/vendor/libsodium/test/default/core6.c +8 -6
  171. data/vendor/libsodium/test/default/generichash.c +0 -15
  172. data/vendor/libsodium/test/default/generichash.exp +0 -1
  173. data/vendor/libsodium/test/default/generichash3.c +1 -21
  174. data/vendor/libsodium/test/default/generichash3.exp +1 -1
  175. data/vendor/libsodium/test/default/hash.c +3 -3
  176. data/vendor/libsodium/test/default/hash3.c +2 -2
  177. data/vendor/libsodium/test/default/index.html.tpl +84 -0
  178. data/vendor/libsodium/test/default/onetimeauth.c +3 -3
  179. data/vendor/libsodium/test/default/onetimeauth2.c +5 -4
  180. data/vendor/libsodium/test/default/onetimeauth7.c +4 -4
  181. data/vendor/libsodium/test/default/pre.js.inc +14 -6
  182. data/vendor/libsodium/test/default/randombytes.c +2 -2
  183. data/vendor/libsodium/test/default/scalarmult.c +19 -6
  184. data/vendor/libsodium/test/default/scalarmult.exp +1 -0
  185. data/vendor/libsodium/test/default/scalarmult2.c +2 -2
  186. data/vendor/libsodium/test/default/scalarmult5.c +6 -4
  187. data/vendor/libsodium/test/default/scalarmult6.c +5 -3
  188. data/vendor/libsodium/test/default/scalarmult7.c +11 -7
  189. data/vendor/libsodium/test/default/secretbox.c +7 -6
  190. data/vendor/libsodium/test/default/secretbox2.c +7 -6
  191. data/vendor/libsodium/test/default/secretbox7.c +5 -5
  192. data/vendor/libsodium/test/default/secretbox8.c +5 -5
  193. data/vendor/libsodium/test/default/secretbox_easy.c +27 -17
  194. data/vendor/libsodium/test/default/secretbox_easy.exp +7 -95
  195. data/vendor/libsodium/test/default/secretbox_easy2.c +22 -10
  196. data/vendor/libsodium/test/default/sign.c +5 -0
  197. data/vendor/libsodium/test/default/sodium_utils.c +73 -0
  198. data/vendor/libsodium/test/default/sodium_utils.exp +6 -0
  199. data/vendor/libsodium/test/default/stream.c +7 -6
  200. data/vendor/libsodium/test/default/stream2.c +4 -4
  201. data/vendor/libsodium/test/default/stream3.c +6 -5
  202. data/vendor/libsodium/test/default/stream4.c +7 -6
  203. data/vendor/libsodium/test/default/verify1.c +61 -18
  204. data/vendor/libsodium/test/default/verify1.exp +2 -6
  205. metadata +37 -44
  206. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/cp/api.h +0 -9
  207. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/api.h +0 -9
  208. data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/api.h +0 -9
  209. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h +0 -20
  210. data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/api.h +0 -10
  211. data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/api.h +0 -10
  212. data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/api.h +0 -10
  213. data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/api.h +0 -10
  214. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/api.h +0 -2
  215. data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/api.h +0 -10
  216. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/api.h +0 -10
  217. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/api.h +0 -6
  218. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/base_curve25519_donna_c64.c +0 -13
  219. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/api.h +0 -5
  220. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/base_curve25519_ref10.c +0 -14
  221. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/scalarmult_curve25519_ref10.c +0 -54
  222. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519_api.c +0 -14
  223. data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/ref/api.h +0 -11
  224. data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/api.h +0 -7
  225. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/api.h +0 -15
  226. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/api.h +0 -12
  227. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/fe25519.h +0 -54
  228. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/fe25519_edwards25519sha512batch.c +0 -348
  229. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/ge25519.h +0 -34
  230. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/ge25519_edwards25519sha512batch.c +0 -230
  231. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sc25519.h +0 -51
  232. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sc25519_edwards25519sha512batch.c +0 -150
  233. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sign_edwards25519sha512batch.c +0 -106
  234. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/sign_edwards25519sha512batch_api.c +0 -16
  235. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/api.h +0 -13
  236. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/amd64_xmm6/api.h +0 -1
  237. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/api.h +0 -5
  238. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/api.h +0 -10
  239. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/api.h +0 -9
  240. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/api.h +0 -11
  241. data/vendor/libsodium/src/libsodium/crypto_verify/16/ref/api.h +0 -2
  242. data/vendor/libsodium/src/libsodium/crypto_verify/32/ref/api.h +0 -2
  243. data/vendor/libsodium/src/libsodium/crypto_verify/64/ref/api.h +0 -2
@@ -2,6 +2,8 @@
2
2
  #include "core.h"
3
3
  #include "crypto_generichash.h"
4
4
  #include "crypto_onetimeauth.h"
5
+ #include "crypto_scalarmult.h"
6
+ #include "crypto_stream_chacha20.h"
5
7
  #include "randombytes.h"
6
8
  #include "runtime.h"
7
9
  #include "utils.h"
@@ -19,6 +21,8 @@ sodium_init(void)
19
21
  _sodium_alloc_init();
20
22
  _crypto_generichash_blake2b_pick_best_implementation();
21
23
  _crypto_onetimeauth_poly1305_pick_best_implementation();
24
+ _crypto_scalarmult_curve25519_pick_best_implementation();
25
+ _crypto_stream_chacha20_pick_best_implementation();
22
26
  initialized = 1;
23
27
 
24
28
  return 0;
@@ -12,6 +12,7 @@ typedef struct CPUFeatures_ {
12
12
  int has_sse3;
13
13
  int has_ssse3;
14
14
  int has_sse41;
15
+ int has_avx;
15
16
  int has_pclmul;
16
17
  int has_aesni;
17
18
  } CPUFeatures;
@@ -22,6 +23,7 @@ static CPUFeatures _cpu_features;
22
23
  #define CPUIDECX_SSE3 0x00000001
23
24
  #define CPUIDECX_SSSE3 0x00000200
24
25
  #define CPUIDECX_SSE41 0x00080000
26
+ #define CPUIDECX_AVX 0x10000000
25
27
  #define CPUIDECX_PCLMUL 0x00000002
26
28
  #define CPUIDECX_AESNI 0x02000000
27
29
 
@@ -100,36 +102,48 @@ _sodium_runtime_intel_cpu_features(CPUFeatures * const cpu_features)
100
102
  return -1; /* LCOV_EXCL_LINE */
101
103
  }
102
104
  _cpuid(cpu_info, 0x00000001);
103
- #ifndef HAVE_EMMINTRIN_H
104
- cpu_features->has_sse2 = 0;
105
- #else
105
+ #if defined(HAVE_EMMINTRIN_H) || \
106
+ (defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
106
107
  cpu_features->has_sse2 = ((cpu_info[3] & CPUID_SSE2) != 0x0);
108
+ #else
109
+ cpu_features->has_sse2 = 0;
107
110
  #endif
108
111
 
109
- #ifndef HAVE_PMMINTRIN_H
110
- cpu_features->has_sse3 = 0;
111
- #else
112
+ #if defined(HAVE_PMMINTRIN_H) || \
113
+ (defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
112
114
  cpu_features->has_sse3 = ((cpu_info[2] & CPUIDECX_SSE3) != 0x0);
115
+ #else
116
+ cpu_features->has_sse3 = 0;
113
117
  #endif
114
118
 
115
- #ifndef HAVE_TMMINTRIN_H
116
- cpu_features->has_ssse3 = 0;
117
- #else
119
+ #if defined(HAVE_TMMINTRIN_H) || \
120
+ (defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
118
121
  cpu_features->has_ssse3 = ((cpu_info[2] & CPUIDECX_SSSE3) != 0x0);
122
+ #else
123
+ cpu_features->has_ssse3 = 0;
119
124
  #endif
120
125
 
121
- #ifndef HAVE_SMMINTRIN_H
122
- cpu_features->has_sse41 = 0;
123
- #else
126
+ #if defined(HAVE_SMMINTRIN_H) || \
127
+ (defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
124
128
  cpu_features->has_sse41 = ((cpu_info[2] & CPUIDECX_SSE41) != 0x0);
129
+ #else
130
+ cpu_features->has_sse41 = 0;
125
131
  #endif
126
132
 
127
- #ifndef HAVE_WMMINTRIN_H
128
- cpu_features->has_pclmul = 0;
129
- cpu_features->has_aesni = 0;
133
+ #if defined(HAVE_AVXINTRIN_H) || \
134
+ (defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
135
+ cpu_features->has_avx = ((cpu_info[2] & CPUIDECX_AVX) != 0x0);
130
136
  #else
137
+ cpu_features->has_avx = 0;
138
+ #endif
139
+
140
+ #if defined(HAVE_WMMINTRIN_H) || \
141
+ (defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
131
142
  cpu_features->has_pclmul = ((cpu_info[2] & CPUIDECX_PCLMUL) != 0x0);
132
143
  cpu_features->has_aesni = ((cpu_info[2] & CPUIDECX_AESNI) != 0x0);
144
+ #else
145
+ cpu_features->has_pclmul = 0;
146
+ cpu_features->has_aesni = 0;
133
147
  #endif
134
148
 
135
149
  return 0;
@@ -172,6 +186,11 @@ sodium_runtime_has_sse41(void) {
172
186
  return _cpu_features.has_sse41;
173
187
  }
174
188
 
189
+ int
190
+ sodium_runtime_has_avx(void) {
191
+ return _cpu_features.has_avx;
192
+ }
193
+
175
194
  int
176
195
  sodium_runtime_has_pclmul(void) {
177
196
  return _cpu_features.has_pclmul;
@@ -113,7 +113,7 @@ sodium_memcmp(const void * const b1_, const void * const b2_, size_t len)
113
113
  for (i = 0U; i < len; i++) {
114
114
  d |= b1[i] ^ b2[i];
115
115
  }
116
- return (int) ((1 & ((d - 1) >> 8)) - 1);
116
+ return (1 & ((d - 1) >> 8)) - 1;
117
117
  }
118
118
 
119
119
  #ifdef HAVE_WEAK_SYMBOLS
@@ -154,6 +154,109 @@ sodium_compare(const unsigned char *b1_, const unsigned char *b2_, size_t len)
154
154
  return (int) (gt + gt + eq) - 1;
155
155
  }
156
156
 
157
+ int
158
+ sodium_is_zero(const unsigned char *n, const size_t nlen)
159
+ {
160
+ size_t i;
161
+ unsigned char d = 0U;
162
+
163
+ for (i = 0U; i < nlen; i++) {
164
+ d |= n[i];
165
+ }
166
+ return 1 & ((d - 1) >> 8);
167
+ }
168
+
169
+ void
170
+ sodium_increment(unsigned char *n, const size_t nlen)
171
+ {
172
+ size_t i = 0U;
173
+ uint_fast16_t c = 1U;
174
+
175
+ #ifdef HAVE_AMD64_ASM
176
+ uint64_t t64, t64_2;
177
+ uint32_t t32;
178
+
179
+ if (nlen == 12U) {
180
+ __asm__ __volatile__("xorq %[t64], %[t64] \n"
181
+ "xorl %[t32], %[t32] \n"
182
+ "stc \n"
183
+ "adcq %[t64], (%[out]) \n"
184
+ "adcl %[t32], 8(%[out]) \n"
185
+ : [t64] "=&r"(t64), [t32] "=&r" (t32)
186
+ : [out] "D"(n)
187
+ : "memory", "flags", "cc");
188
+ return;
189
+ } else if (nlen == 24U) {
190
+ __asm__ __volatile__("movq $1, %[t64] \n"
191
+ "xorq %[t64_2], %[t64_2] \n"
192
+ "addq %[t64], (%[out]) \n"
193
+ "adcq %[t64_2], 8(%[out]) \n"
194
+ "adcq %[t64_2], 16(%[out]) \n"
195
+ : [t64] "=&r"(t64), [t64_2] "=&r" (t64_2)
196
+ : [out] "D"(n)
197
+ : "memory", "flags", "cc");
198
+ return;
199
+ } else if (nlen == 8U) {
200
+ __asm__ __volatile__("incq (%[out]) \n"
201
+ :
202
+ : [out] "D"(n)
203
+ : "memory", "flags", "cc");
204
+ return;
205
+ }
206
+ #endif
207
+ for (; i < nlen; i++) {
208
+ c += (uint_fast16_t) n[i];
209
+ n[i] = (unsigned char) c;
210
+ c >>= 8;
211
+ }
212
+ }
213
+
214
+ void
215
+ sodium_add(unsigned char *a, const unsigned char *b, const size_t len)
216
+ {
217
+ size_t i = 0U;
218
+ uint_fast16_t c = 0U;
219
+
220
+ #ifdef HAVE_AMD64_ASM
221
+ uint64_t t64, t64_2, t64_3;
222
+ uint32_t t32;
223
+
224
+ if (len == 12U) {
225
+ __asm__ __volatile__("movq (%[in]), %[t64] \n"
226
+ "movl 8(%[in]), %[t32] \n"
227
+ "addq %[t64], (%[out]) \n"
228
+ "adcl %[t32], 8(%[out]) \n"
229
+ : [t64] "=&r"(t64), [t32] "=&r" (t32)
230
+ : [in] "S"(b), [out] "D"(a)
231
+ : "memory", "flags", "cc");
232
+ return;
233
+ } else if (len == 24U) {
234
+ __asm__ __volatile__("movq (%[in]), %[t64] \n"
235
+ "movq 8(%[in]), %[t64_2] \n"
236
+ "movq 16(%[in]), %[t64_3] \n"
237
+ "addq %[t64], (%[out]) \n"
238
+ "adcq %[t64_2], 8(%[out]) \n"
239
+ "adcq %[t64_3], 16(%[out]) \n"
240
+ : [t64] "=&r"(t64), [t64_2] "=&r"(t64_2), [t64_3] "=&r"(t64_3)
241
+ : [in] "S"(b), [out] "D"(a)
242
+ : "memory", "flags", "cc");
243
+ return;
244
+ } else if (len == 8U) {
245
+ __asm__ __volatile__("movq (%[in]), %[t64] \n"
246
+ "addq %[t64], (%[out]) \n"
247
+ : [t64] "=&r"(t64)
248
+ : [in] "S"(b), [out] "D"(a)
249
+ : "memory", "flags", "cc");
250
+ return;
251
+ }
252
+ #endif
253
+ for (; i < len; i++) {
254
+ c += (uint_fast16_t) a[i] + (uint_fast16_t) b[i];
255
+ a[i] = (unsigned char) c;
256
+ c >>= 8;
257
+ }
258
+ }
259
+
157
260
  /* Derived from original code by CodesInChaos */
158
261
  char *
159
262
  sodium_bin2hex(char * const hex, const size_t hex_maxlen,
@@ -568,16 +671,3 @@ sodium_mprotect_readwrite(void *ptr)
568
671
  {
569
672
  return _sodium_mprotect(ptr, _mprotect_readwrite);
570
673
  }
571
-
572
- void
573
- sodium_increment(unsigned char *n, const size_t nlen)
574
- {
575
- size_t i;
576
- unsigned int c = 1U << 8;
577
-
578
- for (i = (size_t) 0U; i < nlen; i++) {
579
- c >>= 8;
580
- c += n[i];
581
- n[i] = (unsigned char) c;
582
- }
583
- }
@@ -224,6 +224,7 @@ EXEEXT = @EXEEXT@
224
224
  FGREP = @FGREP@
225
225
  GREP = @GREP@
226
226
  HAVE_AMD64_ASM_V = @HAVE_AMD64_ASM_V@
227
+ HAVE_AVX_ASM_V = @HAVE_AVX_ASM_V@
227
228
  HAVE_CPUID_V = @HAVE_CPUID_V@
228
229
  HAVE_TI_MODE_V = @HAVE_TI_MODE_V@
229
230
  INSTALL = @INSTALL@
@@ -641,6 +641,7 @@ EXEEXT = @EXEEXT@
641
641
  FGREP = @FGREP@
642
642
  GREP = @GREP@
643
643
  HAVE_AMD64_ASM_V = @HAVE_AMD64_ASM_V@
644
+ HAVE_AVX_ASM_V = @HAVE_AVX_ASM_V@
644
645
  HAVE_CPUID_V = @HAVE_CPUID_V@
645
646
  HAVE_TI_MODE_V = @HAVE_TI_MODE_V@
646
647
  INSTALL = @INSTALL@
@@ -3,14 +3,14 @@
3
3
  #include "cmptest.h"
4
4
 
5
5
  /* "Test Case 2" from RFC 4231 */
6
- unsigned char key[32] = "Jefe";
7
- unsigned char c[] = "what do ya want for nothing?";
6
+ static unsigned char key[32] = "Jefe";
7
+ static unsigned char c[] = "what do ya want for nothing?";
8
8
 
9
9
  /* Hacker manifesto */
10
- unsigned char key2[] = "Another one got caught today, it's all over the papers. \"Teenager Arrested in Computer Crime Scandal\", \"Hacker Arrested after Bank Tampering\"... Damn kids. They're all alike.";
10
+ static unsigned char key2[] = "Another one got caught today, it's all over the papers. \"Teenager Arrested in Computer Crime Scandal\", \"Hacker Arrested after Bank Tampering\"... Damn kids. They're all alike.";
11
11
 
12
- unsigned char a[crypto_auth_BYTES];
13
- unsigned char a2[crypto_auth_hmacsha512_BYTES];
12
+ static unsigned char a[crypto_auth_BYTES];
13
+ static unsigned char a2[crypto_auth_hmacsha512_BYTES];
14
14
 
15
15
  int main(void)
16
16
  {
@@ -3,19 +3,19 @@
3
3
  #define TEST_NAME "auth2"
4
4
  #include "cmptest.h"
5
5
 
6
- unsigned char key[32]
6
+ static unsigned char key[32]
7
7
  = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
8
8
  0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
9
9
  0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20 };
10
10
 
11
- unsigned char c[50]
11
+ static unsigned char c[50]
12
12
  = { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
13
13
  0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
14
14
  0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
15
15
  0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
16
16
  0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd };
17
17
 
18
- unsigned char a[32];
18
+ static unsigned char a[32];
19
19
 
20
20
  int main(void)
21
21
  {
@@ -3,19 +3,19 @@
3
3
  #define TEST_NAME "auth3"
4
4
  #include "cmptest.h"
5
5
 
6
- unsigned char key[32]
6
+ static unsigned char key[32]
7
7
  = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
8
8
  0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
9
9
  0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20 };
10
10
 
11
- unsigned char c[50]
11
+ static unsigned char c[50]
12
12
  = { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
13
13
  0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
14
14
  0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
15
15
  0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
16
16
  0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd };
17
17
 
18
- unsigned char a[32]
18
+ static unsigned char a[32]
19
19
  = { 0x37, 0x2e, 0xfc, 0xf9, 0xb4, 0x0b, 0x35, 0xc2, 0x11, 0x5b, 0x13,
20
20
  0x46, 0x90, 0x3d, 0x2e, 0xf4, 0x2f, 0xce, 0xd4, 0x6f, 0x08, 0x46,
21
21
  0xe7, 0x25, 0x7b, 0xb1, 0x56, 0xd3, 0xd7, 0xb3, 0x0d, 0x3f };
@@ -2,15 +2,15 @@
2
2
  #define TEST_NAME "auth5"
3
3
  #include "cmptest.h"
4
4
 
5
- unsigned char key[32];
6
- unsigned char c[10000];
7
- unsigned char a[32];
5
+ static unsigned char key[32];
6
+ static unsigned char c[1000];
7
+ static unsigned char a[32];
8
8
 
9
9
  int main(void)
10
10
  {
11
11
  size_t clen;
12
12
 
13
- for (clen = 0; clen < 10000; ++clen) {
13
+ for (clen = 0; clen < 1000; ++clen) {
14
14
  randombytes_buf(key, sizeof key);
15
15
  randombytes_buf(c, clen);
16
16
  crypto_auth(a, c, clen, key);
@@ -3,10 +3,10 @@
3
3
  #include "cmptest.h"
4
4
 
5
5
  /* "Test Case 2" from RFC 4231 */
6
- unsigned char key[32] = "Jefe";
7
- unsigned char c[] = "what do ya want for nothing?";
6
+ static unsigned char key[32] = "Jefe";
7
+ static unsigned char c[] = "what do ya want for nothing?";
8
8
 
9
- unsigned char a[64];
9
+ static unsigned char a[64];
10
10
 
11
11
  int main(void)
12
12
  {
@@ -2,15 +2,15 @@
2
2
  #define TEST_NAME "auth7"
3
3
  #include "cmptest.h"
4
4
 
5
- unsigned char key[32];
6
- unsigned char c[10000];
7
- unsigned char a[64];
5
+ static unsigned char key[32];
6
+ static unsigned char c[600];
7
+ static unsigned char a[64];
8
8
 
9
9
  int main(void)
10
10
  {
11
11
  int clen;
12
12
 
13
- for (clen = 0; clen < 10000; ++clen) {
13
+ for (clen = 0; clen < sizeof c; ++clen) {
14
14
  randombytes_buf(key, sizeof key);
15
15
  randombytes_buf(c, clen);
16
16
  crypto_auth_hmacsha512(a, c, clen, key);
@@ -2,22 +2,23 @@
2
2
  #define TEST_NAME "box"
3
3
  #include "cmptest.h"
4
4
 
5
- unsigned char alicesk[32]
5
+ static unsigned char alicesk[32]
6
6
  = { 0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d, 0x3c, 0x16, 0xc1,
7
7
  0x72, 0x51, 0xb2, 0x66, 0x45, 0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0,
8
8
  0x99, 0x2a, 0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a };
9
9
 
10
- unsigned char bobpk[32]
10
+ static unsigned char bobpk[32]
11
11
  = { 0xde, 0x9e, 0xdb, 0x7d, 0x7b, 0x7d, 0xc1, 0xb4, 0xd3, 0x5b, 0x61,
12
12
  0xc2, 0xec, 0xe4, 0x35, 0x37, 0x3f, 0x83, 0x43, 0xc8, 0x5b, 0x78,
13
13
  0x67, 0x4d, 0xad, 0xfc, 0x7e, 0x14, 0x6f, 0x88, 0x2b, 0x4f };
14
14
 
15
- unsigned char nonce[24] = { 0x69, 0x69, 0x6e, 0xe9, 0x55, 0xb6, 0x2b, 0x73,
16
- 0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6,
17
- 0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 };
15
+ static unsigned char nonce[24]
16
+ = { 0x69, 0x69, 0x6e, 0xe9, 0x55, 0xb6, 0x2b, 0x73,
17
+ 0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6,
18
+ 0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 };
18
19
 
19
20
  // API requires first 32 bytes to be 0
20
- unsigned char m[163]
21
+ static unsigned char m[163]
21
22
  = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
22
23
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
23
24
  0, 0, 0, 0, 0, 0, 0, 0, 0xbe, 0x07, 0x5f, 0xc5,
@@ -33,14 +34,16 @@ unsigned char m[163]
33
34
  0xf0, 0xa0, 0x89, 0xbc, 0x76, 0x89, 0x70, 0x40, 0xe0, 0x82, 0xf9, 0x37,
34
35
  0x76, 0x38, 0x48, 0x64, 0x5e, 0x07, 0x05 };
35
36
 
36
- unsigned char c[163];
37
+ static unsigned char c[163];
37
38
 
38
39
  int main(void)
39
40
  {
40
41
  unsigned char k[crypto_box_BEFORENMBYTES];
41
42
  int i;
43
+ int ret;
42
44
 
43
- crypto_box(c, m, 163, nonce, bobpk, alicesk);
45
+ ret = crypto_box(c, m, 163, nonce, bobpk, alicesk);
46
+ assert(ret == 0);
44
47
  for (i = 16; i < 163; ++i) {
45
48
  printf(",0x%02x", (unsigned int)c[i]);
46
49
  if (i % 8 == 7)
@@ -49,7 +52,8 @@ int main(void)
49
52
  printf("\n");
50
53
 
51
54
  memset(c, 0, sizeof c);
52
- crypto_box_beforenm(k, bobpk, alicesk);
55
+ ret = crypto_box_beforenm(k, bobpk, alicesk);
56
+ assert(ret == 0);
53
57
  crypto_box_afternm(c, m, 163, nonce, k);
54
58
  for (i = 16; i < 163; ++i) {
55
59
  printf(",0x%02x", (unsigned int)c[i]);
@@ -2,22 +2,23 @@
2
2
  #define TEST_NAME "box2"
3
3
  #include "cmptest.h"
4
4
 
5
- unsigned char bobsk[32]
5
+ static unsigned char bobsk[32]
6
6
  = { 0x5d, 0xab, 0x08, 0x7e, 0x62, 0x4a, 0x8a, 0x4b, 0x79, 0xe1, 0x7f,
7
7
  0x8b, 0x83, 0x80, 0x0e, 0xe6, 0x6f, 0x3b, 0xb1, 0x29, 0x26, 0x18,
8
8
  0xb6, 0xfd, 0x1c, 0x2f, 0x8b, 0x27, 0xff, 0x88, 0xe0, 0xeb };
9
9
 
10
- unsigned char alicepk[32]
10
+ static unsigned char alicepk[32]
11
11
  = { 0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 0x74, 0x8b, 0x7d,
12
12
  0xdc, 0xb4, 0x3e, 0xf7, 0x5a, 0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38,
13
13
  0x1a, 0xf4, 0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a };
14
14
 
15
- unsigned char nonce[24] = { 0x69, 0x69, 0x6e, 0xe9, 0x55, 0xb6, 0x2b, 0x73,
16
- 0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6,
17
- 0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 };
15
+ static unsigned char nonce[24]
16
+ = { 0x69, 0x69, 0x6e, 0xe9, 0x55, 0xb6, 0x2b, 0x73,
17
+ 0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6,
18
+ 0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 };
18
19
 
19
20
  // API requires first 16 bytes to be 0
20
- unsigned char c[163]
21
+ static unsigned char c[163]
21
22
  = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
22
23
  0, 0, 0, 0, 0xf3, 0xff, 0xc7, 0x70, 0x3f, 0x94, 0x00, 0xe5,
23
24
  0x2a, 0x7d, 0xfb, 0x4b, 0x3d, 0x33, 0x05, 0xd9, 0x8e, 0x99, 0x3b, 0x9f,
@@ -33,12 +34,13 @@ unsigned char c[163]
33
34
  0x79, 0x73, 0xf6, 0x22, 0xa4, 0x3d, 0x14, 0xa6, 0x59, 0x9b, 0x1f, 0x65,
34
35
  0x4c, 0xb4, 0x5a, 0x74, 0xe3, 0x55, 0xa5 };
35
36
 
36
- unsigned char m[163];
37
+ static unsigned char m[163];
37
38
 
38
39
  int main(void)
39
40
  {
40
41
  unsigned char k[crypto_box_BEFORENMBYTES];
41
42
  int i;
43
+ int ret;
42
44
 
43
45
  if (crypto_box_open(m, c, 163, nonce, alicepk, bobsk) == 0) {
44
46
  for (i = 32; i < 163; ++i) {
@@ -50,7 +52,8 @@ int main(void)
50
52
  }
51
53
 
52
54
  memset(m, 0, sizeof m);
53
- crypto_box_beforenm(k, alicepk, bobsk);
55
+ ret = crypto_box_beforenm(k, alicepk, bobsk);
56
+ assert(ret == 0);
54
57
  if (crypto_box_open_afternm(m, c, 163, nonce, k) == 0) {
55
58
  for (i = 32; i < 163; ++i) {
56
59
  printf(",0x%02x", (unsigned int)m[i]);