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
@@ -0,0 +1,28 @@
1
+ 30313233343536373839414243444546
2
+ 4:cafe6942
3
+ dt1: 11
4
+ 4:cafe6942
5
+ dt2: 2
6
+ dt3: 11
7
+ dt4: 11
8
+ dt5: 11
9
+ dt6: 11
10
+ +/DxMDEyMzQ1Njc4OUFCQ0RFRmFi
11
+ +/DxMDEyMzQ1Njc4OUFCQ0RFRmFiYw
12
+ -_DxMDEyMzQ1Njc4OUFCQ0RFRmFi
13
+ -_DxMDEyMzQ1Njc4OUFCQ0RFRmFiYw
14
+
15
+ YQ==
16
+ YWI=
17
+ YWJj
18
+
19
+ YQ
20
+ YWI
21
+ YWJj
22
+ []
23
+ [BpcyBhIGpvdXJu
24
+ ZXkgaW50by Bzb3VuZA==]
25
+ [This is a journey into sound]
26
+ [This is a journ]
27
+ [
28
+ ZXkgaW50by Bzb3VuZA==]
@@ -2,43 +2,70 @@
2
2
  #define TEST_NAME "core3"
3
3
  #include "cmptest.h"
4
4
 
5
- static unsigned char secondkey[32] = { 0xdc, 0x90, 0x8d, 0xda, 0x0b, 0x93, 0x44,
5
+ static unsigned char SECONDKEY[32] = { 0xdc, 0x90, 0x8d, 0xda, 0x0b, 0x93, 0x44,
6
6
  0xa9, 0x53, 0x62, 0x9b, 0x73, 0x38, 0x20,
7
7
  0x77, 0x88, 0x80, 0xf3, 0xce, 0xb4, 0x21,
8
8
  0xbb, 0x61, 0xb9, 0x1c, 0xbd, 0x4c, 0x3e,
9
9
  0x66, 0x25, 0x6c, 0xe4 };
10
10
 
11
- static unsigned char noncesuffix[8] = { 0x82, 0x19, 0xe0, 0x03,
11
+ static unsigned char NONCESUFFIX[8] = { 0x82, 0x19, 0xe0, 0x03,
12
12
  0x6b, 0x7a, 0x0b, 0x37 };
13
13
 
14
- static unsigned char c[16] = { 0x65, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x20, 0x33,
14
+ static unsigned char C[16] = { 0x65, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x20, 0x33,
15
15
  0x32, 0x2d, 0x62, 0x79, 0x74, 0x65, 0x20, 0x6b };
16
16
 
17
- static unsigned char in[16];
18
-
19
- static unsigned char output[64 * 256 * 256];
20
-
21
- static unsigned char h[32];
22
-
23
17
  int
24
18
  main(void)
25
19
  {
26
- int i;
27
- long long pos = 0;
20
+ unsigned char *secondkey;
21
+ unsigned char *c;
22
+ unsigned char *noncesuffix;
23
+ unsigned char *in;
24
+ unsigned char *output;
25
+ unsigned char *h;
26
+ size_t output_len = 64 * 256 * 256;
27
+ size_t pos = 0;
28
+ int i;
28
29
 
29
- for (i = 0; i < 8; ++i)
30
+ secondkey = (unsigned char *) sodium_malloc(32);
31
+ memcpy(secondkey, SECONDKEY, 32);
32
+ noncesuffix = (unsigned char *) sodium_malloc(8);
33
+ memcpy(noncesuffix, NONCESUFFIX, 8);
34
+ c = (unsigned char *) sodium_malloc(16);
35
+ memcpy(c, C, 16);
36
+ in = (unsigned char *) sodium_malloc(16);
37
+ output = (unsigned char *) sodium_malloc(output_len);
38
+ h = (unsigned char *) sodium_malloc(32);
39
+
40
+ for (i = 0; i < 8; i++) {
30
41
  in[i] = noncesuffix[i];
42
+ }
43
+ for (; i < 16; i++) {
44
+ in[i] = 0;
45
+ }
31
46
  do {
32
47
  do {
33
48
  crypto_core_salsa20(output + pos, in, secondkey, c);
34
49
  pos += 64;
35
- } while (++in[8]);
36
- } while (++in[9]);
37
- crypto_hash_sha256(h, output, sizeof output);
50
+ in[8]++;
51
+ } while (in[8] != 0);
52
+ in[9]++;
53
+ } while (in[9] != 0);
54
+
55
+ crypto_hash_sha256(h, output, output_len);
56
+
38
57
  for (i = 0; i < 32; ++i) {
39
58
  printf("%02x", h[i]);
40
59
  }
41
60
  printf("\n");
61
+
62
+ sodium_free(h);
63
+ sodium_free(output);
64
+ sodium_free(in);
65
+ sodium_free(c);
66
+ sodium_free(noncesuffix);
67
+ sodium_free(secondkey);
68
+
42
69
  assert(crypto_core_salsa20_outputbytes() > 0U);
43
70
  assert(crypto_core_salsa20_inputbytes() > 0U);
44
71
  assert(crypto_core_salsa20_keybytes() > 0U);
@@ -45,6 +45,23 @@ main(void)
45
45
  printf("conversion failed\n");
46
46
  }
47
47
  }
48
+
49
+ sodium_hex2bin(ed25519_pk, crypto_sign_ed25519_PUBLICKEYBYTES,
50
+ "0000000000000000000000000000000000000000000000000000000000000000"
51
+ "0000000000000000000000000000000000000000000000000000000000000000",
52
+ 64, NULL, NULL, NULL);
53
+ assert(crypto_sign_ed25519_pk_to_curve25519(curve25519_pk, ed25519_pk) == -1);
54
+ sodium_hex2bin(ed25519_pk, crypto_sign_ed25519_PUBLICKEYBYTES,
55
+ "0200000000000000000000000000000000000000000000000000000000000000"
56
+ "0000000000000000000000000000000000000000000000000000000000000000",
57
+ 64, NULL, NULL, NULL);
58
+ assert(crypto_sign_ed25519_pk_to_curve25519(curve25519_pk, ed25519_pk) == -1);
59
+ sodium_hex2bin(ed25519_pk, crypto_sign_ed25519_PUBLICKEYBYTES,
60
+ "0500000000000000000000000000000000000000000000000000000000000000"
61
+ "0000000000000000000000000000000000000000000000000000000000000000",
62
+ 64, NULL, NULL, NULL);
63
+ assert(crypto_sign_ed25519_pk_to_curve25519(curve25519_pk, ed25519_pk) == -1);
64
+
48
65
  printf("ok\n");
49
66
 
50
67
  return 0;
@@ -19,8 +19,8 @@ tv_kdf(void)
19
19
  }
20
20
  subkey = (unsigned char *) sodium_malloc(crypto_kdf_BYTES_MAX);
21
21
  for (i = 0; i < 10; i++) {
22
- assert(crypto_kdf_blake2b_derive_from_key(subkey, crypto_kdf_BYTES_MAX,
23
- i, context, master_key) == 0);
22
+ assert(crypto_kdf_derive_from_key(subkey, crypto_kdf_BYTES_MAX,
23
+ i, context, master_key) == 0);
24
24
  sodium_bin2hex(hex, sizeof hex, subkey, crypto_kdf_BYTES_MAX);
25
25
  printf("%s\n", hex);
26
26
  }
@@ -28,8 +28,8 @@ tv_kdf(void)
28
28
 
29
29
  for (i = 0; i < crypto_kdf_BYTES_MAX + 2; i++) {
30
30
  subkey = (unsigned char *) sodium_malloc(crypto_kdf_BYTES_MAX);
31
- if (crypto_kdf_blake2b_derive_from_key(subkey, (size_t) i,
32
- i, context, master_key) == 0) {
31
+ if (crypto_kdf_derive_from_key(subkey, (size_t) i,
32
+ i, context, master_key) == 0) {
33
33
  sodium_bin2hex(hex, sizeof hex, subkey, (size_t) i);
34
34
  printf("%s\n", hex);
35
35
  } else {
@@ -48,6 +48,10 @@ tv_kdf(void)
48
48
  assert(crypto_kdf_contextbytes() == crypto_kdf_CONTEXTBYTES);
49
49
  assert(crypto_kdf_KEYBYTES >= 16);
50
50
  assert(crypto_kdf_keybytes() == crypto_kdf_KEYBYTES);
51
+ assert(crypto_kdf_bytes_min() == crypto_kdf_blake2b_bytes_min());
52
+ assert(crypto_kdf_bytes_max() == crypto_kdf_blake2b_bytes_max());
53
+ assert(crypto_kdf_contextbytes() == crypto_kdf_blake2b_contextbytes());
54
+ assert(crypto_kdf_keybytes() == crypto_kdf_blake2b_keybytes());
51
55
 
52
56
  printf("tv_kdf: ok\n");
53
57
  }
@@ -23,8 +23,11 @@ tv_keygen(void)
23
23
  { crypto_onetimeauth_poly1305_keygen, crypto_onetimeauth_poly1305_KEYBYTES },
24
24
  { crypto_aead_chacha20poly1305_ietf_keygen, crypto_aead_chacha20poly1305_ietf_KEYBYTES },
25
25
  { crypto_aead_chacha20poly1305_keygen, crypto_aead_chacha20poly1305_KEYBYTES },
26
+ { crypto_aead_chacha20poly1305_ietf_keygen, crypto_aead_chacha20poly1305_ietf_KEYBYTES },
27
+ { crypto_aead_xchacha20poly1305_ietf_keygen, crypto_aead_xchacha20poly1305_ietf_KEYBYTES },
26
28
  { crypto_secretbox_xsalsa20poly1305_keygen, crypto_secretbox_xsalsa20poly1305_KEYBYTES },
27
29
  { crypto_secretbox_keygen, crypto_secretbox_KEYBYTES },
30
+ { crypto_secretstream_xchacha20poly1305_keygen, crypto_secretstream_xchacha20poly1305_KEYBYTES },
28
31
  { crypto_shorthash_keygen, crypto_shorthash_KEYBYTES },
29
32
  { crypto_stream_keygen, crypto_stream_KEYBYTES },
30
33
  { crypto_stream_chacha20_keygen, crypto_stream_chacha20_KEYBYTES },
@@ -34,7 +37,7 @@ tv_keygen(void)
34
37
  };
35
38
  const KeygenTV *tv;
36
39
  unsigned char *key;
37
- int i;
40
+ size_t i;
38
41
  int j;
39
42
 
40
43
  for (i = 0; i < (sizeof tvs) / (sizeof tvs[0]); i++) {
@@ -49,7 +52,7 @@ tv_keygen(void)
49
52
  }
50
53
  sodium_free(key);
51
54
  if (j >= 10000) {
52
- printf("Buffer underflow with test vector %d\n", i);
55
+ printf("Buffer underflow with test vector %u\n", (unsigned int) i);
53
56
  }
54
57
  }
55
58
  printf("tv_keygen: ok\n");
@@ -2,6 +2,12 @@
2
2
  #define TEST_NAME "kx"
3
3
  #include "cmptest.h"
4
4
 
5
+ static const unsigned char small_order_p[crypto_scalarmult_BYTES] = {
6
+ 0xe0, 0xeb, 0x7a, 0x7c, 0x3b, 0x41, 0xb8, 0xae, 0x16, 0x56, 0xe3,
7
+ 0xfa, 0xf1, 0x9f, 0xc4, 0x6a, 0xda, 0x09, 0x8d, 0xeb, 0x9c, 0x32,
8
+ 0xb1, 0xfd, 0x86, 0x62, 0x05, 0x16, 0x5f, 0x49, 0xb8, 0x00
9
+ };
10
+
5
11
  static void
6
12
  tv_kx(void)
7
13
  {
@@ -33,6 +39,9 @@ tv_kx(void)
33
39
  client_rx = (unsigned char *) sodium_malloc(crypto_kx_SESSIONKEYBYTES);
34
40
  client_tx = (unsigned char *) sodium_malloc(crypto_kx_SESSIONKEYBYTES);
35
41
 
42
+ assert(crypto_kx_client_session_keys(client_rx, client_tx,
43
+ client_pk, client_sk,
44
+ small_order_p) == -1);
36
45
  if (crypto_kx_client_session_keys(client_rx, client_tx,
37
46
  client_pk, client_sk, server_pk) != 0) {
38
47
  printf("crypto_kx_client_session_keys() failed\n");
@@ -41,6 +50,9 @@ tv_kx(void)
41
50
  server_rx = (unsigned char *) sodium_malloc(crypto_kx_SESSIONKEYBYTES);
42
51
  server_tx = (unsigned char *) sodium_malloc(crypto_kx_SESSIONKEYBYTES);
43
52
 
53
+ assert(crypto_kx_server_session_keys(server_rx, server_tx,
54
+ server_pk, server_sk,
55
+ small_order_p) == -1);
44
56
  if (crypto_kx_server_session_keys(server_rx, server_tx,
45
57
  server_pk, server_sk, client_pk) != 0) {
46
58
  printf("crypto_kx_server_session_keys() failed\n");
@@ -91,6 +103,24 @@ tv_kx(void)
91
103
  sodium_bin2hex(hex, sizeof hex, client_tx, crypto_kx_SESSIONKEYBYTES);
92
104
  printf("client_tx: [%s]\n", hex);
93
105
 
106
+ randombytes_buf(client_rx, crypto_kx_SESSIONKEYBYTES);
107
+ randombytes_buf(client_tx, crypto_kx_SESSIONKEYBYTES);
108
+ randombytes_buf(server_rx, crypto_kx_SESSIONKEYBYTES);
109
+ randombytes_buf(server_tx, crypto_kx_SESSIONKEYBYTES);
110
+ if (crypto_kx_client_session_keys(client_rx, NULL,
111
+ client_pk, client_sk, server_pk) != 0 ||
112
+ crypto_kx_client_session_keys(NULL, client_tx,
113
+ client_pk, client_sk, server_pk) != 0 ||
114
+ crypto_kx_server_session_keys(server_rx, NULL,
115
+ server_pk, server_sk, client_pk) != 0 ||
116
+ crypto_kx_server_session_keys(NULL, server_tx,
117
+ server_pk, server_sk, client_pk) != 0) {
118
+ printf("failure when one of the pointers happens to be NULL");
119
+ }
120
+ assert(memcmp(client_rx, client_tx, crypto_kx_SESSIONKEYBYTES) == 0);
121
+ assert(memcmp(client_tx, server_rx, crypto_kx_SESSIONKEYBYTES) == 0);
122
+ assert(memcmp(server_rx, server_tx, crypto_kx_SESSIONKEYBYTES) == 0);
123
+
94
124
  sodium_free(client_rx);
95
125
  sodium_free(client_tx);
96
126
  sodium_free(server_rx);
@@ -0,0 +1,187 @@
1
+
2
+ #define TEST_NAME "metamorphic"
3
+ #include "cmptest.h"
4
+
5
+ #define MAXLEN 512
6
+ #define MAX_ITER 1000
7
+
8
+ static void
9
+ mm_generichash(void)
10
+ {
11
+ crypto_generichash_state st;
12
+ unsigned char *h, *h2;
13
+ unsigned char *k;
14
+ unsigned char *m;
15
+ size_t hlen;
16
+ size_t klen;
17
+ size_t mlen;
18
+ size_t l1, l2;
19
+ int i;
20
+
21
+ for (i = 0; i < MAX_ITER; i++) {
22
+ mlen = randombytes_uniform(MAXLEN);
23
+ m = (unsigned char *) sodium_malloc(mlen);
24
+ klen = randombytes_uniform(crypto_generichash_KEYBYTES_MAX -
25
+ crypto_generichash_KEYBYTES_MIN + 1U)
26
+ + crypto_generichash_KEYBYTES_MIN;
27
+ k = (unsigned char *) sodium_malloc(klen);
28
+ hlen = randombytes_uniform(crypto_generichash_BYTES_MAX -
29
+ crypto_generichash_BYTES_MIN + 1U)
30
+ + crypto_generichash_BYTES_MIN;
31
+ h = (unsigned char *) sodium_malloc(hlen);
32
+ h2 = (unsigned char *) sodium_malloc(hlen);
33
+
34
+ randombytes_buf(k, klen);
35
+ randombytes_buf(m, mlen);
36
+
37
+ crypto_generichash_init(&st, k, klen, hlen);
38
+ l1 = randombytes_uniform(mlen);
39
+ l2 = randombytes_uniform(mlen - l1);
40
+ crypto_generichash_update(&st, m, l1);
41
+ crypto_generichash_update(&st, m + l1, l2);
42
+ crypto_generichash_update(&st, m + l1 + l2, mlen - l1 - l2);
43
+ crypto_generichash_final(&st, h, hlen);
44
+
45
+ crypto_generichash(h2, hlen, m, mlen, k, klen);
46
+
47
+ assert(memcmp(h, h2, hlen) == 0);
48
+
49
+ sodium_free(h2);
50
+ sodium_free(h);
51
+ sodium_free(k);
52
+ sodium_free(m);
53
+ }
54
+ }
55
+
56
+ static void
57
+ mm_onetimeauth(void)
58
+ {
59
+ crypto_onetimeauth_state st;
60
+ unsigned char *h, *h2;
61
+ unsigned char *k;
62
+ unsigned char *m;
63
+ size_t mlen;
64
+ size_t l1, l2;
65
+ int i;
66
+
67
+ for (i = 0; i < MAX_ITER; i++) {
68
+ mlen = randombytes_uniform(MAXLEN);
69
+ m = (unsigned char *) sodium_malloc(mlen);
70
+ k = (unsigned char *) sodium_malloc(crypto_onetimeauth_KEYBYTES);
71
+ h = (unsigned char *) sodium_malloc(crypto_onetimeauth_BYTES);
72
+ h2 = (unsigned char *) sodium_malloc(crypto_onetimeauth_BYTES);
73
+
74
+ crypto_onetimeauth_keygen(k);
75
+ randombytes_buf(m, mlen);
76
+
77
+ crypto_onetimeauth_init(&st, k);
78
+ l1 = randombytes_uniform(mlen);
79
+ l2 = randombytes_uniform(mlen - l1);
80
+ crypto_onetimeauth_update(&st, m, l1);
81
+ crypto_onetimeauth_update(&st, m + l1, l2);
82
+ crypto_onetimeauth_update(&st, m + l1 + l2, mlen - l1 - l2);
83
+ crypto_onetimeauth_final(&st, h);
84
+
85
+ crypto_onetimeauth(h2, m, mlen, k);
86
+
87
+ assert(memcmp(h, h2, crypto_onetimeauth_BYTES) == 0);
88
+
89
+ sodium_free(h2);
90
+ sodium_free(h);
91
+ sodium_free(k);
92
+ sodium_free(m);
93
+ }
94
+ }
95
+
96
+ static void
97
+ mm_hmacsha256(void)
98
+ {
99
+ crypto_auth_hmacsha256_state st;
100
+ unsigned char *h, *h2;
101
+ unsigned char *k;
102
+ unsigned char *m;
103
+ size_t mlen;
104
+ size_t l1, l2;
105
+ int i;
106
+
107
+ for (i = 0; i < MAX_ITER; i++) {
108
+ mlen = randombytes_uniform(MAXLEN);
109
+ m = (unsigned char *) sodium_malloc(mlen);
110
+ k = (unsigned char *) sodium_malloc(crypto_auth_hmacsha256_KEYBYTES);
111
+ h = (unsigned char *) sodium_malloc(crypto_auth_hmacsha256_BYTES);
112
+ h2 = (unsigned char *) sodium_malloc(crypto_auth_hmacsha256_BYTES);
113
+
114
+ crypto_auth_hmacsha256_keygen(k);
115
+ randombytes_buf(m, mlen);
116
+
117
+ crypto_auth_hmacsha256_init(&st, k, crypto_auth_hmacsha256_KEYBYTES);
118
+ l1 = randombytes_uniform(mlen);
119
+ l2 = randombytes_uniform(mlen - l1);
120
+ crypto_auth_hmacsha256_update(&st, m, l1);
121
+ crypto_auth_hmacsha256_update(&st, m + l1, l2);
122
+ crypto_auth_hmacsha256_update(&st, m + l1 + l2, mlen - l1 - l2);
123
+ crypto_auth_hmacsha256_final(&st, h);
124
+
125
+ crypto_auth_hmacsha256(h2, m, mlen, k);
126
+
127
+ assert(memcmp(h, h2, crypto_auth_hmacsha256_BYTES) == 0);
128
+
129
+ sodium_free(h2);
130
+ sodium_free(h);
131
+ sodium_free(k);
132
+ sodium_free(m);
133
+ }
134
+ }
135
+
136
+ static void
137
+ mm_hmacsha512(void)
138
+ {
139
+ crypto_auth_hmacsha512_state st;
140
+ unsigned char *h, *h2;
141
+ unsigned char *k;
142
+ unsigned char *m;
143
+ size_t mlen;
144
+ size_t l1, l2;
145
+ int i;
146
+
147
+ for (i = 0; i < MAX_ITER; i++) {
148
+ mlen = randombytes_uniform(MAXLEN);
149
+ m = (unsigned char *) sodium_malloc(mlen);
150
+ k = (unsigned char *) sodium_malloc(crypto_auth_hmacsha512_KEYBYTES);
151
+ h = (unsigned char *) sodium_malloc(crypto_auth_hmacsha512_BYTES);
152
+ h2 = (unsigned char *) sodium_malloc(crypto_auth_hmacsha512_BYTES);
153
+
154
+ crypto_auth_hmacsha512_keygen(k);
155
+ randombytes_buf(m, mlen);
156
+
157
+ crypto_auth_hmacsha512_init(&st, k, crypto_auth_hmacsha512_KEYBYTES);
158
+ l1 = randombytes_uniform(mlen);
159
+ l2 = randombytes_uniform(mlen - l1);
160
+ crypto_auth_hmacsha512_update(&st, m, l1);
161
+ crypto_auth_hmacsha512_update(&st, m + l1, l2);
162
+ crypto_auth_hmacsha512_update(&st, m + l1 + l2, mlen - l1 - l2);
163
+ crypto_auth_hmacsha512_final(&st, h);
164
+
165
+ crypto_auth_hmacsha512(h2, m, mlen, k);
166
+
167
+ assert(memcmp(h, h2, crypto_auth_hmacsha512_BYTES) == 0);
168
+
169
+ sodium_free(h2);
170
+ sodium_free(h);
171
+ sodium_free(k);
172
+ sodium_free(m);
173
+ }
174
+ }
175
+
176
+ int
177
+ main(void)
178
+ {
179
+ mm_generichash();
180
+ mm_onetimeauth();
181
+ mm_hmacsha256();
182
+ mm_hmacsha512();
183
+
184
+ printf("OK\n");
185
+
186
+ return 0;
187
+ }