rbnacl-libsodium 1.0.13 → 1.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +5 -0
  3. data/lib/rbnacl/libsodium.rb +1 -0
  4. data/lib/rbnacl/libsodium/version.rb +1 -1
  5. data/vendor/libsodium/AUTHORS +2 -2
  6. data/vendor/libsodium/ChangeLog +64 -0
  7. data/vendor/libsodium/Makefile.am +1 -0
  8. data/vendor/libsodium/README.markdown +1 -3
  9. data/vendor/libsodium/THANKS +13 -3
  10. data/vendor/libsodium/builds/Makefile.am +65 -0
  11. data/vendor/libsodium/builds/msvc/resource.rc +2 -2
  12. data/vendor/libsodium/builds/msvc/version.h +3 -3
  13. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +168 -173
  14. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +382 -394
  15. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +168 -173
  16. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +382 -394
  17. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +168 -173
  18. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +382 -394
  19. data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +168 -173
  20. data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +382 -394
  21. data/vendor/libsodium/builds/msvc/vs2017/libsodium/libsodium.vcxproj +168 -173
  22. data/vendor/libsodium/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters +382 -394
  23. data/vendor/libsodium/configure.ac +59 -10
  24. data/vendor/libsodium/contrib/Findsodium.cmake +2 -0
  25. data/vendor/libsodium/dist-build/emscripten-symbols.def +72 -32
  26. data/vendor/libsodium/dist-build/emscripten.sh +33 -6
  27. data/vendor/libsodium/dist-build/generate-emscripten-symbols.sh +52 -38
  28. data/vendor/libsodium/dist-build/ios.sh +2 -2
  29. data/vendor/libsodium/libsodium.vcxproj +168 -173
  30. data/vendor/libsodium/libsodium.vcxproj.filters +220 -235
  31. data/vendor/libsodium/m4/ax_check_catchable_abrt.m4 +57 -0
  32. data/vendor/libsodium/m4/ax_check_gnu_make.m4 +2 -2
  33. data/vendor/libsodium/m4/ax_pthread.m4 +2 -2
  34. data/vendor/libsodium/msvc-scripts/process.bat +3 -3
  35. data/vendor/libsodium/packaging/dotnet-core/README.md +5 -5
  36. data/vendor/libsodium/packaging/dotnet-core/libsodium.props +5 -2
  37. data/vendor/libsodium/packaging/dotnet-core/prepare.py +13 -31
  38. data/vendor/libsodium/packaging/dotnet-core/recipes/linux-x64 +4 -0
  39. data/vendor/libsodium/packaging/nuget/package.config +1 -1
  40. data/vendor/libsodium/src/libsodium/Makefile.am +11 -12
  41. data/vendor/libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +11 -4
  42. data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +17 -4
  43. data/vendor/libsodium/src/libsodium/crypto_aead/xchacha20poly1305/sodium/aead_xchacha20poly1305.c +8 -1
  44. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box.c +6 -0
  45. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_easy.c +5 -4
  46. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xchacha20poly1305/box_curve25519xchacha20poly1305.c +11 -4
  47. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305.c +6 -0
  48. data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.c +78 -17
  49. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-ref.c +74 -64
  50. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512_cp.c +2 -0
  51. data/vendor/libsodium/src/libsodium/crypto_kx/crypto_kx.c +7 -0
  52. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +1 -1
  53. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +1 -0
  54. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c +17 -17
  55. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.c +53 -48
  56. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.h +37 -11
  57. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c +23 -179
  58. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-avx2.c +4 -12
  59. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-avx512f.c +244 -0
  60. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ref.c +3 -12
  61. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ssse3.c +4 -12
  62. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.c +1 -5
  63. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.h +1 -1
  64. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blamka-round-avx512f.h +145 -0
  65. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/pwhash_argon2i.c +91 -14
  66. data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/pwhash_argon2id.c +35 -14
  67. data/vendor/libsodium/src/libsodium/crypto_pwhash/crypto_pwhash.c +41 -4
  68. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +31 -17
  69. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +4 -0
  70. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.c +5 -1
  71. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +30 -1
  72. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +8 -0
  73. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519.c +3 -3
  74. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox.c +6 -0
  75. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +5 -4
  76. data/vendor/libsodium/src/libsodium/crypto_secretbox/xchacha20poly1305/secretbox_xchacha20poly1305.c +11 -4
  77. data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305.c +6 -0
  78. data/vendor/libsodium/src/libsodium/crypto_secretstream/xchacha20poly1305/secretstream_xchacha20poly1305.c +311 -0
  79. data/vendor/libsodium/src/libsodium/crypto_sign/crypto_sign.c +6 -0
  80. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ed25519_ref10.h +3 -0
  81. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +9 -2
  82. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/obsolete.c +1 -1
  83. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +6 -5
  84. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/sign_ed25519.c +6 -0
  85. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/chacha20_dolbeau-avx2.c +3 -2
  86. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/chacha20_dolbeau-ssse3.c +3 -2
  87. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/u0.h +1 -1
  88. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/chacha20_ref.c +3 -2
  89. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/stream_chacha20.c +12 -0
  90. data/vendor/libsodium/src/libsodium/crypto_stream/crypto_stream.c +6 -0
  91. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20.c +7 -1
  92. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/u0.h +1 -1
  93. data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/stream_salsa2012.c +6 -0
  94. data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/stream_salsa208.c +6 -0
  95. data/vendor/libsodium/src/libsodium/crypto_stream/xchacha20/stream_xchacha20.c +6 -0
  96. data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/stream_xsalsa20.c +6 -0
  97. data/vendor/libsodium/src/libsodium/crypto_verify/sodium/verify.c +66 -29
  98. data/vendor/libsodium/src/libsodium/include/Makefile.am +1 -1
  99. data/vendor/libsodium/src/libsodium/include/sodium.h +2 -2
  100. data/vendor/libsodium/src/libsodium/include/sodium/core.h +9 -0
  101. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_aes256gcm.h +26 -0
  102. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h +16 -4
  103. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_xchacha20poly1305.h +10 -4
  104. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box.h +4 -0
  105. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xchacha20poly1305.h +6 -0
  106. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +24 -15
  107. data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_salsa208.h +8 -4
  108. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash.h +40 -18
  109. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_argon2i.h +8 -2
  110. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_argon2id.h +8 -2
  111. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h +11 -3
  112. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox.h +4 -0
  113. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xchacha20poly1305.h +6 -0
  114. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h +17 -8
  115. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretstream_xchacha20poly1305.h +102 -0
  116. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign.h +4 -0
  117. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_ed25519.h +4 -0
  118. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h +1 -0
  119. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream.h +4 -0
  120. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_chacha20.h +10 -0
  121. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa20.h +4 -0
  122. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa2012.h +4 -0
  123. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa208.h +15 -5
  124. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_xchacha20.h +4 -0
  125. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_xsalsa20.h +4 -0
  126. data/vendor/libsodium/src/libsodium/include/sodium/export.h +9 -0
  127. data/vendor/libsodium/src/libsodium/include/sodium/private/common.h +11 -0
  128. data/vendor/libsodium/src/libsodium/include/sodium/private/curve25519_ref10.h +2 -30
  129. data/vendor/libsodium/src/libsodium/include/sodium/randombytes.h +2 -0
  130. data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +12 -9
  131. data/vendor/libsodium/src/libsodium/include/sodium/utils.h +36 -0
  132. data/vendor/libsodium/src/libsodium/randombytes/nativeclient/randombytes_nativeclient.c +3 -2
  133. data/vendor/libsodium/src/libsodium/randombytes/randombytes.c +18 -14
  134. data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +11 -10
  135. data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +20 -8
  136. data/vendor/libsodium/src/libsodium/sodium/codecs.c +333 -0
  137. data/vendor/libsodium/src/libsodium/sodium/core.c +36 -4
  138. data/vendor/libsodium/src/libsodium/sodium/runtime.c +18 -0
  139. data/vendor/libsodium/src/libsodium/sodium/utils.c +87 -100
  140. data/vendor/libsodium/test/constcheck.sh +19 -0
  141. data/vendor/libsodium/test/default/Makefile.am +39 -7
  142. data/vendor/libsodium/test/default/aead_aes256gcm.c +6 -0
  143. data/vendor/libsodium/test/default/aead_chacha20poly1305.c +16 -0
  144. data/vendor/libsodium/test/default/aead_xchacha20poly1305.c +25 -15
  145. data/vendor/libsodium/test/default/auth.c +13 -0
  146. data/vendor/libsodium/test/default/auth.exp +8 -0
  147. data/vendor/libsodium/test/default/box.c +3 -0
  148. data/vendor/libsodium/test/default/box2.c +2 -0
  149. data/vendor/libsodium/test/default/box_easy.c +1 -4
  150. data/vendor/libsodium/test/default/box_easy2.c +7 -3
  151. data/vendor/libsodium/test/default/chacha20.c +9 -2
  152. data/vendor/libsodium/test/default/cmptest.h +47 -1
  153. data/vendor/libsodium/test/default/codecs.c +226 -0
  154. data/vendor/libsodium/test/default/codecs.exp +28 -0
  155. data/vendor/libsodium/test/default/core3.c +42 -15
  156. data/vendor/libsodium/test/default/ed25519_convert.c +17 -0
  157. data/vendor/libsodium/test/default/kdf.c +8 -4
  158. data/vendor/libsodium/test/default/keygen.c +5 -2
  159. data/vendor/libsodium/test/default/kx.c +30 -0
  160. data/vendor/libsodium/test/default/metamorphic.c +187 -0
  161. data/vendor/libsodium/test/default/metamorphic.exp +1 -0
  162. data/vendor/libsodium/test/default/misuse.c +145 -0
  163. data/vendor/libsodium/test/default/misuse.exp +0 -0
  164. data/vendor/libsodium/test/default/onetimeauth.c +2 -0
  165. data/vendor/libsodium/test/default/{pwhash.c → pwhash_argon2i.c} +133 -106
  166. data/vendor/libsodium/test/default/{pwhash.exp → pwhash_argon2i.exp} +0 -1
  167. data/vendor/libsodium/test/default/pwhash_argon2id.c +254 -144
  168. data/vendor/libsodium/test/default/pwhash_argon2id.exp +2 -3
  169. data/vendor/libsodium/test/default/pwhash_scrypt.c +61 -18
  170. data/vendor/libsodium/test/default/pwhash_scrypt.exp +6 -0
  171. data/vendor/libsodium/test/default/randombytes.c +8 -3
  172. data/vendor/libsodium/test/default/secretbox.c +8 -0
  173. data/vendor/libsodium/test/default/secretbox2.c +5 -0
  174. data/vendor/libsodium/test/default/secretbox_easy.c +19 -1
  175. data/vendor/libsodium/test/default/secretbox_easy.exp +2 -0
  176. data/vendor/libsodium/test/default/secretbox_easy2.c +4 -0
  177. data/vendor/libsodium/test/default/secretstream.c +280 -0
  178. data/vendor/libsodium/test/default/secretstream.exp +1 -0
  179. data/vendor/libsodium/test/default/sign.c +31 -0
  180. data/vendor/libsodium/test/default/sodium_core.c +23 -1
  181. data/vendor/libsodium/test/default/sodium_core.exp +1 -1
  182. data/vendor/libsodium/test/default/sodium_utils.c +45 -56
  183. data/vendor/libsodium/test/default/sodium_utils.exp +0 -8
  184. data/vendor/libsodium/test/default/stream.c +2 -0
  185. data/vendor/libsodium/test/default/stream2.c +1 -0
  186. data/vendor/libsodium/test/default/xchacha20.c +58 -7
  187. metadata +21 -18
  188. data/vendor/libsodium/dist-build/emscripten-wasm.sh +0 -132
  189. data/vendor/libsodium/m4/pkg.m4 +0 -214
  190. data/vendor/libsodium/packaging/dotnet-core/desktop.targets +0 -16
  191. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/afternm_aes128ctr.c +0 -174
  192. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/beforenm_aes128ctr.c +0 -66
  193. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/common.h +0 -766
  194. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/consts.h +0 -28
  195. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/consts_aes128ctr.c +0 -28
  196. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/int128.h +0 -50
  197. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/int128_aes128ctr.c +0 -149
  198. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/stream_aes128ctr_nacl.c +0 -31
  199. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/xor_afternm_aes128ctr.c +0 -195
  200. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/stream_aes128ctr.c +0 -19
  201. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes128ctr.h +0 -65
@@ -2,6 +2,7 @@
2
2
  #define crypto_secretbox_xsalsa20poly1305_H
3
3
 
4
4
  #include <stddef.h>
5
+ #include "crypto_stream_xsalsa20.h"
5
6
  #include "export.h"
6
7
 
7
8
  #ifdef __cplusplus
@@ -23,15 +24,11 @@ size_t crypto_secretbox_xsalsa20poly1305_noncebytes(void);
23
24
  SODIUM_EXPORT
24
25
  size_t crypto_secretbox_xsalsa20poly1305_macbytes(void);
25
26
 
26
- #define crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES 16U
27
- SODIUM_EXPORT
28
- size_t crypto_secretbox_xsalsa20poly1305_boxzerobytes(void);
29
-
30
- #define crypto_secretbox_xsalsa20poly1305_ZEROBYTES \
31
- (crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES + \
32
- crypto_secretbox_xsalsa20poly1305_MACBYTES)
27
+ /* Only for the libsodium API - The NaCl compatibility API would require BOXZEROBYTES extra bytes */
28
+ #define crypto_secretbox_xsalsa20poly1305_MESSAGEBYTES_MAX \
29
+ (crypto_stream_xsalsa20_MESSAGEBYTES_MAX - crypto_secretbox_xsalsa20poly1305_MACBYTES)
33
30
  SODIUM_EXPORT
34
- size_t crypto_secretbox_xsalsa20poly1305_zerobytes(void);
31
+ size_t crypto_secretbox_xsalsa20poly1305_messagebytes_max(void);
35
32
 
36
33
  SODIUM_EXPORT
37
34
  int crypto_secretbox_xsalsa20poly1305(unsigned char *c,
@@ -51,6 +48,18 @@ int crypto_secretbox_xsalsa20poly1305_open(unsigned char *m,
51
48
  SODIUM_EXPORT
52
49
  void crypto_secretbox_xsalsa20poly1305_keygen(unsigned char k[crypto_secretbox_xsalsa20poly1305_KEYBYTES]);
53
50
 
51
+ /* -- NaCl compatibility interface ; Requires padding -- */
52
+
53
+ #define crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES 16U
54
+ SODIUM_EXPORT
55
+ size_t crypto_secretbox_xsalsa20poly1305_boxzerobytes(void);
56
+
57
+ #define crypto_secretbox_xsalsa20poly1305_ZEROBYTES \
58
+ (crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES + \
59
+ crypto_secretbox_xsalsa20poly1305_MACBYTES)
60
+ SODIUM_EXPORT
61
+ size_t crypto_secretbox_xsalsa20poly1305_zerobytes(void);
62
+
54
63
  #ifdef __cplusplus
55
64
  }
56
65
  #endif
@@ -0,0 +1,102 @@
1
+ #ifndef crypto_secretstream_xchacha20poly1305_H
2
+ #define crypto_secretstream_xchacha20poly1305_H
3
+
4
+ #include <stddef.h>
5
+
6
+ #include "crypto_aead_xchacha20poly1305.h"
7
+ #include "crypto_stream_chacha20.h"
8
+ #include "export.h"
9
+
10
+ #ifdef __cplusplus
11
+ # ifdef __GNUC__
12
+ # pragma GCC diagnostic ignored "-Wlong-long"
13
+ # endif
14
+ extern "C" {
15
+ #endif
16
+
17
+ #define crypto_secretstream_xchacha20poly1305_ABYTES \
18
+ (1U + crypto_aead_xchacha20poly1305_ietf_ABYTES)
19
+ SODIUM_EXPORT
20
+ size_t crypto_secretstream_xchacha20poly1305_abytes(void);
21
+
22
+ #define crypto_secretstream_xchacha20poly1305_HEADERBYTES \
23
+ crypto_aead_xchacha20poly1305_ietf_NPUBBYTES
24
+ SODIUM_EXPORT
25
+ size_t crypto_secretstream_xchacha20poly1305_headerbytes(void);
26
+
27
+ #define crypto_secretstream_xchacha20poly1305_KEYBYTES \
28
+ crypto_aead_xchacha20poly1305_ietf_KEYBYTES
29
+ SODIUM_EXPORT
30
+ size_t crypto_secretstream_xchacha20poly1305_keybytes(void);
31
+
32
+ #define crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX \
33
+ SODIUM_MIN(SODIUM_SIZE_MAX, ((1ULL << 32) - 2ULL) * 64ULL)
34
+ SODIUM_EXPORT
35
+ size_t crypto_secretstream_xchacha20poly1305_messagebytes_max(void);
36
+
37
+ #define crypto_secretstream_xchacha20poly1305_TAG_MESSAGE 0x00
38
+ SODIUM_EXPORT
39
+ unsigned char crypto_secretstream_xchacha20poly1305_tag_message(void);
40
+
41
+ #define crypto_secretstream_xchacha20poly1305_TAG_PUSH 0x01
42
+ SODIUM_EXPORT
43
+ unsigned char crypto_secretstream_xchacha20poly1305_tag_push(void);
44
+
45
+ #define crypto_secretstream_xchacha20poly1305_TAG_REKEY 0x02
46
+ SODIUM_EXPORT
47
+ unsigned char crypto_secretstream_xchacha20poly1305_tag_rekey(void);
48
+
49
+ #define crypto_secretstream_xchacha20poly1305_TAG_FINAL \
50
+ (crypto_secretstream_xchacha20poly1305_TAG_PUSH | \
51
+ crypto_secretstream_xchacha20poly1305_TAG_REKEY)
52
+ SODIUM_EXPORT
53
+ unsigned char crypto_secretstream_xchacha20poly1305_tag_final(void);
54
+
55
+ typedef struct crypto_secretstream_xchacha20poly1305_state {
56
+ unsigned char k[crypto_stream_chacha20_ietf_KEYBYTES];
57
+ unsigned char nonce[crypto_stream_chacha20_ietf_NONCEBYTES];
58
+ unsigned char _pad[8];
59
+ } crypto_secretstream_xchacha20poly1305_state;
60
+
61
+ SODIUM_EXPORT
62
+ size_t crypto_secretstream_xchacha20poly1305_statebytes(void);
63
+
64
+ SODIUM_EXPORT
65
+ void crypto_secretstream_xchacha20poly1305_keygen
66
+ (unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES]);
67
+
68
+ SODIUM_EXPORT
69
+ int crypto_secretstream_xchacha20poly1305_init_push
70
+ (crypto_secretstream_xchacha20poly1305_state *state,
71
+ unsigned char header[crypto_secretstream_xchacha20poly1305_HEADERBYTES],
72
+ const unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES]);
73
+
74
+ SODIUM_EXPORT
75
+ int crypto_secretstream_xchacha20poly1305_push
76
+ (crypto_secretstream_xchacha20poly1305_state *state,
77
+ unsigned char *c, unsigned long long *clen_p,
78
+ const unsigned char *m, unsigned long long mlen,
79
+ const unsigned char *ad, unsigned long long adlen, unsigned char tag);
80
+
81
+ SODIUM_EXPORT
82
+ int crypto_secretstream_xchacha20poly1305_init_pull
83
+ (crypto_secretstream_xchacha20poly1305_state *state,
84
+ const unsigned char header[crypto_secretstream_xchacha20poly1305_HEADERBYTES],
85
+ const unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES]);
86
+
87
+ SODIUM_EXPORT
88
+ int crypto_secretstream_xchacha20poly1305_pull
89
+ (crypto_secretstream_xchacha20poly1305_state *state,
90
+ unsigned char *m, unsigned long long *mlen_p, unsigned char *tag_p,
91
+ const unsigned char *c, unsigned long long clen,
92
+ const unsigned char *ad, unsigned long long adlen);
93
+
94
+ SODIUM_EXPORT
95
+ void crypto_secretstream_xchacha20poly1305_rekey
96
+ (crypto_secretstream_xchacha20poly1305_state *state);
97
+
98
+ #ifdef __cplusplus
99
+ }
100
+ #endif
101
+
102
+ #endif
@@ -41,6 +41,10 @@ size_t crypto_sign_publickeybytes(void);
41
41
  SODIUM_EXPORT
42
42
  size_t crypto_sign_secretkeybytes(void);
43
43
 
44
+ #define crypto_sign_MESSAGEBYTES_MAX crypto_sign_ed25519_MESSAGEBYTES_MAX
45
+ SODIUM_EXPORT
46
+ size_t crypto_sign_messagebytes_max(void);
47
+
44
48
  #define crypto_sign_PRIMITIVE "ed25519"
45
49
  SODIUM_EXPORT
46
50
  const char *crypto_sign_primitive(void);
@@ -35,6 +35,10 @@ size_t crypto_sign_ed25519_publickeybytes(void);
35
35
  SODIUM_EXPORT
36
36
  size_t crypto_sign_ed25519_secretkeybytes(void);
37
37
 
38
+ #define crypto_sign_ed25519_MESSAGEBYTES_MAX (SODIUM_SIZE_MAX - crypto_sign_ed25519_BYTES)
39
+ SODIUM_EXPORT
40
+ size_t crypto_sign_ed25519_messagebytes_max(void);
41
+
38
42
  SODIUM_EXPORT
39
43
  int crypto_sign_ed25519(unsigned char *sm, unsigned long long *smlen_p,
40
44
  const unsigned char *m, unsigned long long mlen,
@@ -25,6 +25,7 @@ extern "C" {
25
25
  #define crypto_sign_edwards25519sha512batch_BYTES 64U
26
26
  #define crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES 32U
27
27
  #define crypto_sign_edwards25519sha512batch_SECRETKEYBYTES (32U + 32U)
28
+ #define crypto_sign_edwards25519sha512batch_MESSAGEBYTES_MAX (SODIUM_SIZE_MAX - crypto_sign_edwards25519sha512batch_BYTES)
28
29
 
29
30
  SODIUM_EXPORT
30
31
  int crypto_sign_edwards25519sha512batch(unsigned char *sm,
@@ -29,6 +29,10 @@ size_t crypto_stream_keybytes(void);
29
29
  SODIUM_EXPORT
30
30
  size_t crypto_stream_noncebytes(void);
31
31
 
32
+ #define crypto_stream_MESSAGEBYTES_MAX crypto_stream_xsalsa20_MESSAGEBYTES_MAX
33
+ SODIUM_EXPORT
34
+ size_t crypto_stream_messagebytes_max(void);
35
+
32
36
  #define crypto_stream_PRIMITIVE "xsalsa20"
33
37
  SODIUM_EXPORT
34
38
  const char *crypto_stream_primitive(void);
@@ -28,6 +28,10 @@ size_t crypto_stream_chacha20_keybytes(void);
28
28
  SODIUM_EXPORT
29
29
  size_t crypto_stream_chacha20_noncebytes(void);
30
30
 
31
+ #define crypto_stream_chacha20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX
32
+ SODIUM_EXPORT
33
+ size_t crypto_stream_chacha20_messagebytes_max(void);
34
+
31
35
  /* ChaCha20 with a 64-bit nonce and a 64-bit counter, as originally designed */
32
36
 
33
37
  SODIUM_EXPORT
@@ -58,6 +62,11 @@ size_t crypto_stream_chacha20_ietf_keybytes(void);
58
62
  SODIUM_EXPORT
59
63
  size_t crypto_stream_chacha20_ietf_noncebytes(void);
60
64
 
65
+ #define crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX \
66
+ SODIUM_MIN(SODIUM_SIZE_MAX, 64ULL * (1ULL << 32))
67
+ SODIUM_EXPORT
68
+ size_t crypto_stream_chacha20_ietf_messagebytes_max(void);
69
+
61
70
  SODIUM_EXPORT
62
71
  int crypto_stream_chacha20_ietf(unsigned char *c, unsigned long long clen,
63
72
  const unsigned char *n, const unsigned char *k);
@@ -80,6 +89,7 @@ void crypto_stream_chacha20_ietf_keygen(unsigned char k[crypto_stream_chacha20_i
80
89
 
81
90
  #define crypto_stream_chacha20_IETF_KEYBYTES crypto_stream_chacha20_ietf_KEYBYTES
82
91
  #define crypto_stream_chacha20_IETF_NONCEBYTES crypto_stream_chacha20_ietf_NONCEBYTES
92
+ #define crypto_stream_chacha20_IETF_MESSAGEBYTES_MAX crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX
83
93
 
84
94
  #ifdef __cplusplus
85
95
  }
@@ -28,6 +28,10 @@ size_t crypto_stream_salsa20_keybytes(void);
28
28
  SODIUM_EXPORT
29
29
  size_t crypto_stream_salsa20_noncebytes(void);
30
30
 
31
+ #define crypto_stream_salsa20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX
32
+ SODIUM_EXPORT
33
+ size_t crypto_stream_salsa20_messagebytes_max(void);
34
+
31
35
  SODIUM_EXPORT
32
36
  int crypto_stream_salsa20(unsigned char *c, unsigned long long clen,
33
37
  const unsigned char *n, const unsigned char *k);
@@ -27,6 +27,10 @@ size_t crypto_stream_salsa2012_keybytes(void);
27
27
  SODIUM_EXPORT
28
28
  size_t crypto_stream_salsa2012_noncebytes(void);
29
29
 
30
+ #define crypto_stream_salsa2012_MESSAGEBYTES_MAX SODIUM_SIZE_MAX
31
+ SODIUM_EXPORT
32
+ size_t crypto_stream_salsa2012_messagebytes_max(void);
33
+
30
34
  SODIUM_EXPORT
31
35
  int crypto_stream_salsa2012(unsigned char *c, unsigned long long clen,
32
36
  const unsigned char *n, const unsigned char *k);
@@ -21,23 +21,33 @@ extern "C" {
21
21
 
22
22
  #define crypto_stream_salsa208_KEYBYTES 32U
23
23
  SODIUM_EXPORT
24
- size_t crypto_stream_salsa208_keybytes(void);
24
+ size_t crypto_stream_salsa208_keybytes(void)
25
+ __attribute__ ((deprecated));
25
26
 
26
27
  #define crypto_stream_salsa208_NONCEBYTES 8U
27
28
  SODIUM_EXPORT
28
- size_t crypto_stream_salsa208_noncebytes(void);
29
+ size_t crypto_stream_salsa208_noncebytes(void)
30
+ __attribute__ ((deprecated));
31
+
32
+ #define crypto_stream_salsa208_MESSAGEBYTES_MAX SODIUM_SIZE_MAX
33
+ SODIUM_EXPORT
34
+ size_t crypto_stream_salsa208_messagebytes_max(void)
35
+ __attribute__ ((deprecated));
29
36
 
30
37
  SODIUM_EXPORT
31
38
  int crypto_stream_salsa208(unsigned char *c, unsigned long long clen,
32
- const unsigned char *n, const unsigned char *k);
39
+ const unsigned char *n, const unsigned char *k)
40
+ __attribute__ ((deprecated));
33
41
 
34
42
  SODIUM_EXPORT
35
43
  int crypto_stream_salsa208_xor(unsigned char *c, const unsigned char *m,
36
44
  unsigned long long mlen, const unsigned char *n,
37
- const unsigned char *k);
45
+ const unsigned char *k)
46
+ __attribute__ ((deprecated));
38
47
 
39
48
  SODIUM_EXPORT
40
- void crypto_stream_salsa208_keygen(unsigned char k[crypto_stream_salsa208_KEYBYTES]);
49
+ void crypto_stream_salsa208_keygen(unsigned char k[crypto_stream_salsa208_KEYBYTES])
50
+ __attribute__ ((deprecated));
41
51
 
42
52
  #ifdef __cplusplus
43
53
  }
@@ -28,6 +28,10 @@ size_t crypto_stream_xchacha20_keybytes(void);
28
28
  SODIUM_EXPORT
29
29
  size_t crypto_stream_xchacha20_noncebytes(void);
30
30
 
31
+ #define crypto_stream_xchacha20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX
32
+ SODIUM_EXPORT
33
+ size_t crypto_stream_xchacha20_messagebytes_max(void);
34
+
31
35
  SODIUM_EXPORT
32
36
  int crypto_stream_xchacha20(unsigned char *c, unsigned long long clen,
33
37
  const unsigned char *n, const unsigned char *k);
@@ -28,6 +28,10 @@ size_t crypto_stream_xsalsa20_keybytes(void);
28
28
  SODIUM_EXPORT
29
29
  size_t crypto_stream_xsalsa20_noncebytes(void);
30
30
 
31
+ #define crypto_stream_xsalsa20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX
32
+ SODIUM_EXPORT
33
+ size_t crypto_stream_xsalsa20_messagebytes_max(void);
34
+
31
35
  SODIUM_EXPORT
32
36
  int crypto_stream_xsalsa20(unsigned char *c, unsigned long long clen,
33
37
  const unsigned char *n, const unsigned char *k);
@@ -11,6 +11,7 @@
11
11
 
12
12
  #ifdef SODIUM_STATIC
13
13
  # define SODIUM_EXPORT
14
+ # define SODIUM_EXPORT_WEAK
14
15
  #else
15
16
  # if defined(_MSC_VER)
16
17
  # ifdef SODIUM_DLL_EXPORT
@@ -31,6 +32,11 @@
31
32
  # define SODIUM_EXPORT __attribute__ ((visibility ("default")))
32
33
  # endif
33
34
  # endif
35
+ # if defined(__ELF__) && !defined(SODIUM_DISABLE_WEAK_FUNCTIONS)
36
+ # define SODIUM_EXPORT_WEAK SODIUM_EXPORT __attribute__((weak))
37
+ # else
38
+ # define SODIUM_EXPORT_WEAK SODIUM_EXPORT
39
+ # endif
34
40
  #endif
35
41
 
36
42
  #ifndef CRYPTO_ALIGN
@@ -41,4 +47,7 @@
41
47
  # endif
42
48
  #endif
43
49
 
50
+ #define SODIUM_MIN(A, B) ((A) < (B) ? (A) : (B))
51
+ #define SODIUM_SIZE_MAX SODIUM_MIN(UINT64_MAX, SIZE_MAX)
52
+
44
53
  #endif
@@ -177,6 +177,17 @@ store32_be(uint8_t dst[4], uint32_t w)
177
177
  #endif
178
178
  }
179
179
 
180
+ #define XOR_BUF(OUT, IN, N) xor_buf((OUT), (IN), (N))
181
+ static inline void
182
+ xor_buf(unsigned char *out, const unsigned char *in, size_t n)
183
+ {
184
+ size_t i;
185
+
186
+ for (i = 0; i < n; i++) {
187
+ out[i] ^= in[i];
188
+ }
189
+ }
190
+
180
191
  #ifndef __GNUC__
181
192
  # ifdef __attribute__
182
193
  # undef __attribute__
@@ -19,36 +19,26 @@ typedef int32_t fe[10];
19
19
  #define fe_tobytes crypto_core_curve25519_ref10_fe_tobytes
20
20
  #define fe_copy crypto_core_curve25519_ref10_fe_copy
21
21
  #define fe_isnonzero crypto_core_curve25519_ref10_fe_isnonzero
22
- #define fe_isnegative crypto_core_curve25519_ref10_fe_isnegative
23
22
  #define fe_0 crypto_core_curve25519_ref10_fe_0
24
23
  #define fe_1 crypto_core_curve25519_ref10_fe_1
25
- #define fe_cmov crypto_core_curve25519_ref10_fe_cmov
26
24
  #define fe_add crypto_core_curve25519_ref10_fe_add
27
25
  #define fe_sub crypto_core_curve25519_ref10_fe_sub
28
- #define fe_neg crypto_core_curve25519_ref10_fe_neg
29
26
  #define fe_mul crypto_core_curve25519_ref10_fe_mul
30
27
  #define fe_sq crypto_core_curve25519_ref10_fe_sq
31
- #define fe_sq2 crypto_core_curve25519_ref10_fe_sq2
32
28
  #define fe_invert crypto_core_curve25519_ref10_fe_invert
33
- #define fe_pow22523 crypto_core_curve25519_ref10_fe_pow22523
34
29
 
35
30
  extern void fe_frombytes(fe,const unsigned char *);
36
31
  extern void fe_tobytes(unsigned char *,const fe);
37
32
 
38
33
  extern void fe_copy(fe,const fe);
39
34
  extern int fe_isnonzero(const fe);
40
- extern int fe_isnegative(const fe);
41
35
  extern void fe_0(fe);
42
36
  extern void fe_1(fe);
43
- extern void fe_cmov(fe,const fe,unsigned int);
44
37
  extern void fe_add(fe,const fe,const fe);
45
38
  extern void fe_sub(fe,const fe,const fe);
46
- extern void fe_neg(fe,const fe);
47
39
  extern void fe_mul(fe,const fe,const fe);
48
40
  extern void fe_sq(fe,const fe);
49
- extern void fe_sq2(fe,const fe);
50
41
  extern void fe_invert(fe,const fe);
51
- extern void fe_pow22523(fe,const fe);
52
42
 
53
43
  /*
54
44
  ge means group element.
@@ -106,45 +96,27 @@ typedef struct {
106
96
  #define ge_tobytes crypto_core_curve25519_ref10_ge_tobytes
107
97
  #define ge_p3_tobytes crypto_core_curve25519_ref10_ge_p3_tobytes
108
98
 
109
- #define ge_p2_0 crypto_core_curve25519_ref10_ge_p2_0
110
- #define ge_p3_0 crypto_core_curve25519_ref10_ge_p3_0
111
- #define ge_precomp_0 crypto_core_curve25519_ref10_ge_precomp_0
112
- #define ge_p3_to_p2 crypto_core_curve25519_ref10_ge_p3_to_p2
113
99
  #define ge_p3_to_cached crypto_core_curve25519_ref10_ge_p3_to_cached
114
100
  #define ge_p1p1_to_p2 crypto_core_curve25519_ref10_ge_p1p1_to_p2
115
- #define ge_p1p1_to_p3 crypto_core_curve25519_ref10_ge_p1p1_to_p3
116
- #define ge_p2_dbl crypto_core_curve25519_ref10_ge_p2_dbl
117
- #define ge_p3_dbl crypto_core_curve25519_ref10_ge_p3_dbl
118
101
 
119
- #define ge_madd crypto_core_curve25519_ref10_ge_madd
120
- #define ge_msub crypto_core_curve25519_ref10_ge_msub
121
102
  #define ge_add crypto_core_curve25519_ref10_ge_add
122
- #define ge_sub crypto_core_curve25519_ref10_ge_sub
123
103
  #define ge_scalarmult_base crypto_core_curve25519_ref10_ge_scalarmult_base
124
104
  #define ge_double_scalarmult_vartime crypto_core_curve25519_ref10_ge_double_scalarmult_vartime
125
105
  #define ge_scalarmult_vartime crypto_core_curve25519_ref10_ge_scalarmult_vartime
106
+ #define ge_mul_l crypto_core_curve25519_ref10_ge_mul_l
126
107
 
127
108
  extern void ge_tobytes(unsigned char *,const ge_p2 *);
128
109
  extern void ge_p3_tobytes(unsigned char *,const ge_p3 *);
129
110
  extern int ge_frombytes_negate_vartime(ge_p3 *,const unsigned char *);
130
111
 
131
- extern void ge_p2_0(ge_p2 *);
132
- extern void ge_p3_0(ge_p3 *);
133
- extern void ge_precomp_0(ge_precomp *);
134
- extern void ge_p3_to_p2(ge_p2 *,const ge_p3 *);
135
112
  extern void ge_p3_to_cached(ge_cached *,const ge_p3 *);
136
113
  extern void ge_p1p1_to_p2(ge_p2 *,const ge_p1p1 *);
137
- extern void ge_p1p1_to_p3(ge_p3 *,const ge_p1p1 *);
138
- extern void ge_p2_dbl(ge_p1p1 *,const ge_p2 *);
139
- extern void ge_p3_dbl(ge_p1p1 *,const ge_p3 *);
140
114
 
141
- extern void ge_madd(ge_p1p1 *,const ge_p3 *,const ge_precomp *);
142
- extern void ge_msub(ge_p1p1 *,const ge_p3 *,const ge_precomp *);
143
115
  extern void ge_add(ge_p1p1 *,const ge_p3 *,const ge_cached *);
144
- extern void ge_sub(ge_p1p1 *,const ge_p3 *,const ge_cached *);
145
116
  extern void ge_scalarmult_base(ge_p3 *,const unsigned char *);
146
117
  extern void ge_double_scalarmult_vartime(ge_p2 *,const unsigned char *,const ge_p3 *,const unsigned char *);
147
118
  extern void ge_scalarmult_vartime(ge_p3 *,const unsigned char *,const ge_p3 *);
119
+ extern void ge_mul_l(ge_p3 *r, const ge_p3 *A);
148
120
 
149
121
  /*
150
122
  The set of scalars is \Z/l
@@ -25,6 +25,8 @@ typedef struct randombytes_implementation {
25
25
  int (*close)(void); /* optional */
26
26
  } randombytes_implementation;
27
27
 
28
+ #define randombytes_BYTES_MAX SODIUM_MIN(SODIUM_SIZE_MAX, 0xffffffffUL)
29
+
28
30
  #define randombytes_SEEDBYTES 32U
29
31
  SODIUM_EXPORT
30
32
  size_t randombytes_seedbytes(void);