rbnacl-libsodium 0.5.0.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) 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 +62 -81
  5. data/vendor/libsodium/ChangeLog +31 -1
  6. data/vendor/libsodium/README.markdown +15 -364
  7. data/vendor/libsodium/THANKS +6 -0
  8. data/vendor/libsodium/autom4te.cache/output.0 +67 -36
  9. data/vendor/libsodium/autom4te.cache/output.1 +67 -36
  10. data/vendor/libsodium/autom4te.cache/output.2 +67 -36
  11. data/vendor/libsodium/autom4te.cache/traces.0 +52 -51
  12. data/vendor/libsodium/autom4te.cache/traces.1 +137 -133
  13. data/vendor/libsodium/autom4te.cache/traces.2 +52 -51
  14. data/vendor/libsodium/builds/msvc/version.h +2 -2
  15. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +365 -345
  16. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +1114 -1037
  17. data/vendor/libsodium/builds/msvc/vs2010/test/test.props +8 -2
  18. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +364 -344
  19. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +1113 -1036
  20. data/vendor/libsodium/builds/msvc/vs2012/test/test.props +8 -2
  21. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +365 -345
  22. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +1114 -1037
  23. data/vendor/libsodium/builds/msvc/vs2013/test/test.props +8 -2
  24. data/vendor/libsodium/configure +66 -35
  25. data/vendor/libsodium/configure.ac +25 -14
  26. data/vendor/libsodium/dist-build/ios.sh +1 -1
  27. data/vendor/libsodium/dist-build/msys2-win64.sh +1 -1
  28. data/vendor/libsodium/libsodium.vcxproj +29 -14
  29. data/vendor/libsodium/libsodium.vcxproj.filters +77 -28
  30. data/vendor/libsodium/msvc-scripts/process.bat +3 -3
  31. data/vendor/libsodium/packaging/nuget/package.config +1 -1
  32. data/vendor/libsodium/packaging/nuget/package.gsl +6 -1
  33. data/vendor/libsodium/packaging/nuget/package.nuspec +1 -1
  34. data/vendor/libsodium/src/libsodium/Makefile.am +31 -13
  35. data/vendor/libsodium/src/libsodium/Makefile.in +406 -155
  36. data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +146 -0
  37. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box.c +13 -0
  38. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_easy.c +39 -73
  39. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305_api.c +5 -0
  40. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h +2 -0
  41. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c +15 -0
  42. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +6 -5
  43. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2s-ref.c +6 -5
  44. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/crypto_onetimeauth.c +25 -0
  45. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/auth_poly1305_donna.c +76 -47
  46. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +30 -7
  47. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +3 -16
  48. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +3 -10
  49. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/verify_poly1305_donna.c +11 -6
  50. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c +23 -1
  51. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c +1 -1
  52. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/crypto_scrypt-common.c +7 -7
  53. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/crypto_scrypt.h +6 -20
  54. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256/nosse/pwhash_scryptxsalsa208sha256_nosse.c → scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c} +0 -0
  55. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/pbkdf2-sha256.c +1 -11
  56. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/pbkdf2-sha256.h +0 -0
  57. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256/pwhash_scryptxsalsa208sha256.c → scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c} +50 -25
  58. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/scrypt_platform.c +4 -0
  59. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256/sse/pwhash_scryptxsalsa208sha256_sse.c → scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c} +0 -0
  60. data/vendor/libsodium/src/libsodium/crypto_pwhash/{scryptxsalsa208sha256 → scryptsalsa208sha256}/sysendian.h +0 -0
  61. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/smult_curve25519_donna_c64.c +1 -1
  62. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/{ref → ref10}/api.h +0 -3
  63. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/base_curve25519_ref10.c +14 -0
  64. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe.h +44 -0
  65. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_0_curve25519_ref10.c +23 -0
  66. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_1_curve25519_ref10.c +23 -0
  67. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_add_curve25519_ref10.c +61 -0
  68. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_copy_curve25519_ref10.c +33 -0
  69. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_cswap_curve25519_ref10.c +77 -0
  70. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_frombytes_curve25519_ref10.c +73 -0
  71. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_invert_curve25519_ref10.c +18 -0
  72. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_mul121666_curve25519_ref10.c +74 -0
  73. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_mul_curve25519_ref10.c +257 -0
  74. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_sq_curve25519_ref10.c +153 -0
  75. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_sub_curve25519_ref10.c +61 -0
  76. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_tobytes_curve25519_ref10.c +123 -0
  77. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/montgomery.h +140 -0
  78. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/pow225521.h +160 -0
  79. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/scalarmult_curve25519_ref10.c +54 -0
  80. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +92 -61
  81. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_scalarmult_base.c +3 -3
  82. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/pow22523.h +2 -2
  83. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/pow225521.h +2 -2
  84. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sc25519_edwards25519sha512batch.c +8 -4
  85. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/consts_aes128ctr.c +3 -3
  86. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128.h +6 -3
  87. data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128_aes128ctr.c +23 -23
  88. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/api.h +12 -0
  89. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c +275 -0
  90. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/stream_chacha20_api.c +36 -0
  91. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.S +11 -10
  92. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c +8 -3
  93. data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20_api.c +8 -0
  94. data/vendor/libsodium/src/libsodium/include/Makefile.am +3 -2
  95. data/vendor/libsodium/src/libsodium/include/Makefile.in +3 -2
  96. data/vendor/libsodium/src/libsodium/include/sodium.h +3 -1
  97. data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h +55 -0
  98. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box.h +21 -0
  99. data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +11 -1
  100. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash.h +7 -0
  101. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha256.h +7 -0
  102. data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha512.h +7 -0
  103. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth.h +15 -0
  104. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h +25 -0
  105. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h +80 -0
  106. data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h +2 -2
  107. data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox.h +14 -0
  108. data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h +11 -0
  109. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes256estream.h +11 -6
  110. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_chacha20.h +49 -0
  111. data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa20.h +6 -0
  112. data/vendor/libsodium/src/libsodium/include/sodium/randombytes.h +7 -7
  113. data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +10 -14
  114. data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +10 -13
  115. data/vendor/libsodium/src/libsodium/sodium/compat.c +55 -4
  116. data/vendor/libsodium/src/libsodium/sodium/utils.c +18 -0
  117. data/vendor/libsodium/test/default/Makefile.am +24 -12
  118. data/vendor/libsodium/test/default/Makefile.in +116 -73
  119. data/vendor/libsodium/test/default/aead_chacha20poly1305.c +97 -0
  120. data/vendor/libsodium/test/default/aead_chacha20poly1305.exp +8 -0
  121. data/vendor/libsodium/test/default/box_easy.c +1 -1
  122. data/vendor/libsodium/test/default/box_seed.c +28 -0
  123. data/vendor/libsodium/test/default/box_seed.exp +8 -0
  124. data/vendor/libsodium/test/default/chacha20.c +45 -0
  125. data/vendor/libsodium/test/default/chacha20.exp +5 -0
  126. data/vendor/libsodium/test/default/pwhash.c +83 -15
  127. data/vendor/libsodium/test/default/pwhash.exp +10 -1
  128. data/vendor/libsodium/test/default/pwhash_scrypt_ll.c +67 -0
  129. data/vendor/libsodium/test/default/pwhash_scrypt_ll.exp +15 -0
  130. data/vendor/libsodium/test/default/secretbox_easy.c +13 -1
  131. data/vendor/libsodium/test/default/secretbox_easy.exp +19 -0
  132. data/vendor/libsodium/test/default/secretbox_easy2.c +5 -0
  133. data/vendor/libsodium/test/default/secretbox_easy2.exp +1 -0
  134. data/vendor/libsodium/test/default/sign.c +7 -3
  135. metadata +44 -21
  136. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/api.h +0 -8
  137. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref/base_curve25519_ref.c +0 -20
  138. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref/smult_curve25519_ref.c +0 -268
  139. data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_donna.h +0 -37
  140. data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_scryptxsalsa208sha256.h +0 -48
  141. data/vendor/libsodium/test/default/scalarmult7.c +0 -32
  142. data/vendor/libsodium/test/default/scalarmult7.exp +0 -1
  143. data/vendor/libsodium/test/default/scalarmult8.c +0 -32
  144. data/vendor/libsodium/test/default/scalarmult8.exp +0 -1
@@ -0,0 +1,8 @@
1
+ ,0xe3,0xe4,0x46,0xf7,0xed,0xe9,0xa1,0x9b
2
+ ,0x62,0xa4,0x67,0x7d,0xab,0xf4,0xe3,0xd2
3
+ ,0x4b,0x87,0x6b,0xb2,0x84,0x75,0x38,0x96
4
+ ,0xe1,0xd6
5
+ ,0xe3,0xe4,0x46,0xf7,0xed,0xe9,0xa1,0x9b
6
+ ,0x62,0xa4,0x69,0xe7,0x78,0x9b,0xcd,0x95
7
+ ,0x4e,0x65,0x8e,0xd3,0x84,0x23,0xe2,0x31
8
+ ,0x61,0xdc
@@ -47,7 +47,7 @@ unsigned char c[147 + crypto_box_MACBYTES];
47
47
 
48
48
  int main(void)
49
49
  {
50
- int i;
50
+ size_t i;
51
51
 
52
52
  crypto_box_easy(c, m, 131, nonce, bobpk, alicesk);
53
53
  for (i = 0; i < 131 + crypto_box_MACBYTES; ++i) {
@@ -0,0 +1,28 @@
1
+ #include <stdio.h>
2
+
3
+ #define TEST_NAME "box_seed"
4
+ #include "cmptest.h"
5
+
6
+ unsigned char seed[32] = {
7
+ 0x77,0x07,0x6d,0x0a,0x73,0x18,0xa5,0x7d
8
+ ,0x3c,0x16,0xc1,0x72,0x51,0xb2,0x66,0x45
9
+ ,0xdf,0x4c,0x2f,0x87,0xeb,0xc0,0x99,0x2a
10
+ ,0xb1,0x77,0xfb,0xa5,0x1d,0xb9,0x2c,0x2a
11
+ };
12
+
13
+ int main(void)
14
+ {
15
+ int i;
16
+ unsigned char sk[32];
17
+ unsigned char pk[32];
18
+ crypto_box_curve25519xsalsa20poly1305_seed_keypair(pk, sk, seed);
19
+ for (i = 0;i < 32;++i) {
20
+ printf(",0x%02x",(unsigned int) pk[i]);
21
+ if (i % 8 == 7) printf("\n");
22
+ }
23
+ for (i = 0;i < 32;++i) {
24
+ printf(",0x%02x",(unsigned int) sk[i]);
25
+ if (i % 8 == 7) printf("\n");
26
+ }
27
+ return 0;
28
+ }
@@ -0,0 +1,8 @@
1
+ ,0xed,0x77,0x49,0xb4,0xd9,0x89,0xf6,0x95
2
+ ,0x7f,0x3b,0xfd,0xe6,0xc5,0x67,0x67,0xe9
3
+ ,0x88,0xe2,0x1c,0x9f,0x87,0x84,0xd9,0x1d
4
+ ,0x61,0x00,0x11,0xcd,0x55,0x3f,0x9b,0x06
5
+ ,0xac,0xcd,0x44,0xeb,0x8e,0x93,0x31,0x9c
6
+ ,0x05,0x70,0xbc,0x11,0x00,0x5c,0x0e,0x01
7
+ ,0x89,0xd3,0x4f,0xf0,0x2f,0x6c,0x17,0x77
8
+ ,0x34,0x11,0xad,0x19,0x12,0x93,0xc9,0x8f
@@ -0,0 +1,45 @@
1
+
2
+ #include <stdio.h>
3
+ #include <string.h>
4
+
5
+ #define TEST_NAME "chacha20"
6
+ #include "cmptest.h"
7
+
8
+ static void tv(void)
9
+ {
10
+ static struct {
11
+ const char *key_hex;
12
+ const char *nonce_hex;
13
+ } tests[] = {
14
+ {"0000000000000000000000000000000000000000000000000000000000000000","0000000000000000"},
15
+ {"0000000000000000000000000000000000000000000000000000000000000001","0000000000000000"},
16
+ {"0000000000000000000000000000000000000000000000000000000000000000","0000000000000001"},
17
+ {"0000000000000000000000000000000000000000000000000000000000000000","0100000000000000"},
18
+ {"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f","0001020304050607"}
19
+ };
20
+ unsigned char key[crypto_stream_chacha20_KEYBYTES];
21
+ unsigned char nonce[crypto_stream_chacha20_NONCEBYTES];
22
+ unsigned char out[60];
23
+ char out_hex[60 * 2 + 1];
24
+ size_t i = 0U;
25
+
26
+ do {
27
+ sodium_hex2bin((unsigned char *) key, sizeof key,
28
+ tests[i].key_hex, strlen(tests[i].key_hex),
29
+ NULL, NULL, NULL);
30
+ sodium_hex2bin(nonce, sizeof nonce,
31
+ tests[i].nonce_hex, strlen(tests[i].nonce_hex),
32
+ NULL, NULL, NULL);
33
+ crypto_stream_chacha20(out, sizeof out, nonce, key);
34
+ sodium_bin2hex(out_hex, sizeof out_hex, out, sizeof out);
35
+ printf("[%s]\n", out_hex);
36
+ } while (++i < (sizeof tests) / (sizeof tests[0]));
37
+ };
38
+
39
+ int main(void)
40
+ {
41
+ tv();
42
+
43
+ return 0;
44
+ }
45
+
@@ -0,0 +1,5 @@
1
+ [76b8e0ada0f13d90405d6ae55386bd28bdd219b8a08ded1aa836efcc8b770dc7da41597c5157488d7724e03fb8d84a376a43b8f41518a11cc387b669]
2
+ [4540f05a9f1fb296d7736e7b208e3c96eb4fe1834688d2604f450952ed432d41bbe2a0b6ea7566d2a5d1e7e20d42af2c53d792b1c43fea817e9ad275]
3
+ [de9cba7bf3d69ef5e786dc63973f653a0b49e015adbff7134fcb7df137821031e85a050278a7084527214f73efc7fa5b5277062eb7a0433e445f41e3]
4
+ [ef3fdfd6c61578fbf5cf35bd3dd33b8009631634d21e42ac33960bd138e50d32111e4caf237ee53ca8ad6426194a88545ddc497a0b466e7d6bbdb004]
5
+ [f798a189f195e66982105ffb640bb7757f579da31602fc93ec01ac56f85ac3c134a4547b733b46413042c9440049176905d3be59ea1c53f15916155c]
@@ -4,50 +4,118 @@
4
4
  #define TEST_NAME "pwhash"
5
5
  #include "cmptest.h"
6
6
 
7
+ static void tv(void)
8
+ {
9
+ static struct {
10
+ const char *passwd_hex;
11
+ unsigned long long passwdlen;
12
+ const char *salt_hex;
13
+ unsigned long long outlen;
14
+ unsigned long long opslimit;
15
+ size_t memlimit;
16
+ } tests[] = {
17
+ {"a347ae92bce9f80f6f595a4480fc9c2fe7e7d7148d371e9487d75f5c23008ffae065577a928febd9b1973a5a95073acdbeb6a030cfc0d79caa2dc5cd011cef02c08da232d76d52dfbca38ca8dcbd665b17d1665f7cf5fe59772ec909733b24de97d6f58d220b20c60d7c07ec1fd93c52c31020300c6c1facd77937a597c7a6", 127, "5541fbc995d5c197ba290346d2c559dedf405cf97e5f95482143202f9e74f5c2", 155, 481326, 7256678},
18
+ {"e125cee61c8cb7778d9e5ad0a6f5d978ce9f84de213a8556d9ffe202020ab4a6ed9074a4eb3416f9b168f137510f3a30b70b96cbfa219ff99f6c6eaffb15c06b60e00cc2890277f0fd3c622115772f7048adaebed86e", 86, "f1192dd5dc2368b9cd421338b22433455ee0a3699f9379a08b9650ea2c126f0d", 250, 535778, 7849083},
19
+ {"92263cbf6ac376499f68a4289d3bb59e5a22335eba63a32e6410249155b956b6a3b48d4a44906b18b897127300b375b8f834f1ceffc70880a885f47c33876717e392be57f7da3ae58da4fd1f43daa7e44bb82d3717af4319349c24cd31e46d295856b0441b6b289992a11ced1cc3bf3011604590244a3eb737ff221129215e4e4347f4915d41292b5173d196eb9add693be5319fdadc242906178bb6c0286c9b6ca6012746711f58c8c392016b2fdfc09c64f0f6b6ab7b", 183, "3b840e20e9555e9fb031c4ba1f1747ce25cc1d0ff664be676b9b4a90641ff194", 249, 311757, 7994791},
20
+ {"027b6d8e8c8c474e9b69c7d9ed4f9971e8e1ce2f6ba95048414c3970f0f09b70e3b6c5ae05872b3d8678705b7d381829c351a5a9c88c233569b35d6b0b809df44b6451a9c273f1150e2ef8a0b5437eb701e373474cd44b97ef0248ebce2ca0400e1b53f3d86221eca3f18eb45b702b9172440f774a82cbf1f6f525df30a6e293c873cce69bb078ed1f0d31e7f9b8062409f37f19f8550aae", 152, "eb2a3056a09ad2d7d7f975bcd707598f24cd32518cde3069f2e403b34bfee8a5", 5, 643464, 1397645},
21
+ {"4a857e2ee8aa9b6056f2424e84d24a72473378906ee04a46cb05311502d5250b82ad86b83c8f20a23dbb74f6da60b0b6ecffd67134d45946ac8ebfb3064294bc097d43ced68642bfb8bbbdd0f50b30118f5e", 82, "39d82eef32010b8b79cc5ba88ed539fbaba741100f2edbeca7cc171ffeabf258", 190, 758010, 5432947},
22
+ {"1845e375479537e9dd4f4486d5c91ac72775d66605eeb11a787b78a7745f1fd0052d526c67235dbae1b2a4d575a74cb551c8e9096c593a497aee74ba3047d911358ede57bc27c9ea1829824348daaab606217cc931dcb6627787bd6e4e5854f0e8", 97, "3ee91a805aa62cfbe8dce29a2d9a44373a5006f4a4ce24022aca9cecb29d1473", 212, 233177, 13101817},
23
+ {"c7b09aec680e7b42fedd7fc792e78b2f6c1bea8f4a884320b648f81e8cf515e8ba9dcfb11d43c4aae114c1734aa69ca82d44998365db9c93744fa28b63fd16000e8261cbbe083e7e2da1e5f696bde0834fe53146d7e0e35e7de9920d041f5a5621aabe02da3e2b09b405b77937efef3197bd5772e41fdb73fb5294478e45208063b5f58e089dbeb6d6342a909c1307b3fff5fe2cf4da56bdae50848f", 156, "039c056d933b475032777edbaffac50f143f64c123329ed9cf59e3b65d3f43b6", 178, 234753, 4886999},
24
+ {"8f3a06e2fd8711350a517bb12e31f3d3423e8dc0bb14aac8240fca0995938d59bb37bd0a7dfc9c9cc0705684b46612e8c8b1d6655fb0f9887562bb9899791a0250d1320f945eda48cdc20c233f40a5bb0a7e3ac5ad7250ce684f68fc0b8c9633bfd75aad116525af7bdcdbbdb4e00ab163fd4df08f243f12557e", 122, "90631f686a8c3dbc0703ffa353bc1fdf35774568ac62406f98a13ed8f47595fd", 55, 695191, 15738350},
25
+ {"b540beb016a5366524d4605156493f9874514a5aa58818cd0c6dfffaa9e90205f17b", 34, "44071f6d181561670bda728d43fb79b443bb805afdebaf98622b5165e01b15fb", 231, 78652, 6631659},
26
+ {"a14975c26c088755a8b715ff2528d647cd343987fcf4aa25e7194a8417fb2b4b3f7268da9f3182b4cfb22d138b2749d673a47ecc7525dd15a0a3c66046971784bb63d7eae24cc84f2631712075a10e10a96b0e0ee67c43e01c423cb9c44e5371017e9c496956b632158da3fe12addecb88912e6759bc37f9af2f45af72c5cae3b179ffb676a697de6ebe45cd4c16d4a9d642d29ddc0186a0a48cb6cd62bfc3dd229d313b301560971e740e2cf1f99a9a090a5b283f35475057e96d7064e2e0fc81984591068d55a3b4169f22cccb0745a2689407ea1901a0a766eb99", 220, "3d968b2752b8838431165059319f3ff8910b7b8ecb54ea01d3f54769e9d98daf", 167, 717248, 10784179},
27
+ };
28
+ char passwd[256];
29
+ unsigned char salt[crypto_pwhash_scryptsalsa208sha256_SALTBYTES];
30
+ unsigned char out[256];
31
+ char out_hex[256 * 2 + 1];
32
+ size_t i = 0U;
33
+
34
+ do {
35
+ sodium_hex2bin((unsigned char *) passwd, sizeof passwd,
36
+ tests[i].passwd_hex, strlen(tests[i].passwd_hex),
37
+ NULL, NULL, NULL);
38
+ sodium_hex2bin(salt, sizeof salt,
39
+ tests[i].salt_hex, strlen(tests[i].salt_hex),
40
+ NULL, NULL, NULL);
41
+ if (crypto_pwhash_scryptsalsa208sha256(out, tests[i].outlen,
42
+ passwd, tests[i].passwdlen,
43
+ (const unsigned char *) salt,
44
+ tests[i].opslimit,
45
+ tests[i].memlimit) != 0) {
46
+ printf("pwhash failure\n");
47
+ }
48
+ sodium_bin2hex(out_hex, sizeof out_hex, out, tests[i].outlen);
49
+ printf("%s\n", out_hex);
50
+ } while (++i < (sizeof tests) / (sizeof tests[0]));
51
+ }
52
+
53
+ static void tv2(void)
54
+ {
55
+ static struct {
56
+ const char *passwd;
57
+ const char *out;
58
+ } tests[] = {
59
+ {"^T5H$JYt39n%K*j:W]!1s?vg!:jGi]Ax?..l7[p0v:1jHTpla9;]bUN;?bWyCbtqg nrDFal+Jxl3,2`#^tFSu%v_+7iYse8-cCkNf!tD=KrW)", "$7$B6....1....75gBMAGwfFWZqBdyF3WdTQnWdUsuTiWjG1fF9c1jiSD$tc8RoB3.Em3/zNgMLWo2u00oGIoTyJv4fl3Fl8Tix72"},
60
+ {"bl72h6#y<':MFRZ>B IA1=NRkCKS%W8`1I.2uQxJN0g)N N aTt^4K!Iw5r H6;crDsv^a55j9tsk'/GqweZn;cdk6+F_St6:#*=?ZCD_lw>.", "$7$A6....3....Iahc6qM0.UQJHVgE4h9oa1/4OWlWLm9CCtfguvz6bQD$QnXCo3M7nIqtry2WKsUZ5gQ.mY0wAlJu.WUhtE8vF66"},
61
+ {"Py >e.5b+tLo@rL`dC2k@eJ&4eVl!W=JJ4+k&mAt@gt',FS1JjqKW3aq21:]^kna`mde7kVkN5NrpKUptu)@4*b&?BE_sJMG1=&@`3GBCV]Wg7xwgo7x3El", "$7$96..../....f6bEusKt79kK4wdYN0ki2nw4bJQ7P3rN6k3BSigsK/D$Dsvuw7vXj5xijmrb/NOhdgoyK/OiSIYv88cEtl9Cik7"},
62
+ {"2vj;Um]FKOL27oam(:Uo8+UmSTvb1FD*h?jk_,S=;RDgF-$Fjk?]9yvfxe@fN^!NN(Cuml?+2Raa", "$7$86....I....7XwIxLtCx4VphmFeUa6OGuGJrFaIaYzDiLNu/tyUPhD$U3q5GCEqCWxMwh.YQHDJrlg7FIZgViv9pcXE3h1vg61"},
63
+ {"CT=[9uUoGav,J`kU+348tA50ue#sL:ABZ3QgF+r[#vh:tTOiL>s8tv%,Jeo]jH/_4^i(*jD-_ku[9Ko[=86 06V", "$7$A6....2....R3.bjH6YS9wz9z8Jsj.3weGQ3J80ZZElGw2oVux1TP6$i5u6lFzXDHaIgYEICinLD6WNaovbiXP8SnLrDRdKgA9"},
64
+ {"J#wNn`hDgOpTHNI.w^1a70%f,.9V_m038H_JIJQln`vdWnn/rmILR?9H5g(+`;@H(2VosN9Fgk[WEjaBr'yB9Q19-imNa04[Mk5kvGcSn-TV", "$7$B6....1....Dj1y.4mF1J9XmT/6IDskYdCLaPFJTq9xcCwXQ1DpT92$92/hYfZLRq1nTLyIz.uc/dC6wLqwnsoqpkadrCXusm6"},
65
+ {"j4BS38Asa;p)[K+9TY!3YDj<LK-`nLVXQw9%*QfM", "$7$B6....1....5Ods8mojVwXJq4AywF/uI9BdMSiJ/zT8hQP/4cB68VC$nk4ExHNXJ802froj51/1wJTrSZvTIyyK7PecOxRRaz0"},
66
+ {"M.R>Qw+!qJb]>pP :_.9`dxM9k [eR7Y!yL-3)sNs[R,j_/^ TH=5ny'15>6UXWcQW^6D%XCsO[vN[%ReA-`tV1vW(Nt*0KVK#]45P_A", "$7$B6....1....D/eyk8N5y6Z8YVQEsw521cTx.9zzLuK7YDs1KMMh.o4$alfW8ZbsUWnXc.vqon2zoljVk24Tt1.IsCuo2KurvS2"},
67
+ {"K3S=KyH#)36_?]LxeR8QNKw6X=gFb'ai$C%29V* tyh^Wo$TN-#Q4qkmtTCf0LLb.^E$0uykkP", "$7$B6....1....CuBuU97xgAage8whp/JNKobo0TFbsORGVbfcQIefyP8$aqalP.XofGViB8EPLONqHma8vs1xc9uTIMYh9CgE.S8"},
68
+ {"Y0!?iQa9M%5ekffW(`", "$7$A6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5"},
69
+ };
70
+ size_t i = 0U;
71
+
72
+ do {
73
+ if (crypto_pwhash_scryptsalsa208sha256_str_verify(tests[i].out,
74
+ tests[i].passwd,
75
+ strlen(tests[i].passwd)) != 0) {
76
+ printf("pwhash_str failure\n");
77
+ }
78
+ } while (++i < (sizeof tests) / (sizeof tests[0]));
79
+ }
80
+
7
81
  #define OUT_LEN 128
8
82
  #define OPSLIMIT 1000000
9
83
  #define MEMLIMIT 10000000
10
84
 
11
85
  int main(void)
12
86
  {
13
- char str_out[crypto_pwhash_scryptxsalsa208sha256_STRBYTES];
14
- char str_out2[crypto_pwhash_scryptxsalsa208sha256_STRBYTES];
87
+ char str_out[crypto_pwhash_scryptsalsa208sha256_STRBYTES];
88
+ char str_out2[crypto_pwhash_scryptsalsa208sha256_STRBYTES];
15
89
  unsigned char out[OUT_LEN];
16
90
  char out_hex[OUT_LEN * 2 + 1];
17
91
  const char *salt = "[<~A 32-bytes salt for scrypt~>]";
18
92
  const char *passwd = "Correct Horse Battery Staple";
19
93
  size_t i;
20
94
 
21
- if (crypto_pwhash_scryptxsalsa208sha256(out, sizeof out,
22
- passwd, strlen(passwd),
23
- (const unsigned char *) salt,
24
- OPSLIMIT, MEMLIMIT) != 0) {
25
- printf("pwhash failure\n");
26
- }
27
- sodium_bin2hex(out_hex, sizeof out_hex, out, sizeof out);
28
- printf("out_hex: [%s]\n", out_hex);
29
- if (crypto_pwhash_scryptxsalsa208sha256_str(str_out, passwd, strlen(passwd),
95
+ tv();
96
+ tv2();
97
+ if (crypto_pwhash_scryptsalsa208sha256_str(str_out, passwd, strlen(passwd),
30
98
  OPSLIMIT, MEMLIMIT) != 0) {
31
99
  printf("pwhash_str failure\n");
32
100
  }
33
- if (crypto_pwhash_scryptxsalsa208sha256_str(str_out2, passwd, strlen(passwd),
101
+ if (crypto_pwhash_scryptsalsa208sha256_str(str_out2, passwd, strlen(passwd),
34
102
  OPSLIMIT, MEMLIMIT) != 0) {
35
103
  printf("pwhash_str(2) failure\n");
36
104
  }
37
105
  if (strcmp(str_out, str_out2) == 0) {
38
106
  printf("pwhash_str doesn't generate different salts\n");
39
107
  }
40
- if (crypto_pwhash_scryptxsalsa208sha256_str_verify(str_out, passwd,
108
+ if (crypto_pwhash_scryptsalsa208sha256_str_verify(str_out, passwd,
41
109
  strlen(passwd)) != 0) {
42
110
  printf("pwhash_str_verify failure\n");
43
111
  }
44
- if (crypto_pwhash_scryptxsalsa208sha256_str_verify(str_out, passwd,
112
+ if (crypto_pwhash_scryptsalsa208sha256_str_verify(str_out, passwd,
45
113
  strlen(passwd)) != 0) {
46
114
  printf("pwhash_str_verify failure\n");
47
115
  }
48
116
  for (i = 14U; i < sizeof str_out; i++) {
49
117
  str_out[i]++;
50
- if (crypto_pwhash_scryptxsalsa208sha256_str_verify(str_out, passwd,
118
+ if (crypto_pwhash_scryptsalsa208sha256_str_verify(str_out, passwd,
51
119
  strlen(passwd)) == 0) {
52
120
  printf("pwhash_str_verify(2) failure\n");
53
121
  }
@@ -1,2 +1,11 @@
1
- out_hex: [5707165c270e26315cd0ac3620fee9d839ba6692d8cfbc213beb1c1a9f18797846c9122c6287afda48c8c5e4af3df87889a2b0633a7e21ba61fd34003337bb6086439460fca2f2c6701df34f8005c08996bba4adaed294c48fa60a18421c766df35aa4623a7fcf0eadd65c6dc6392a3e1f35045fa91a551212756f4ede68362f]
1
+ 8d40f5f8c6a1791204f03e19a98cd74f918b6e331b39cfc2415e5014d7738b7bb0a83551fb14a035e07fdd4dc0c60c1a6822ac253918979f6324ff0c87cba75d3b91f88f41ca5414a0f152bdc4d636f42ab2250afd058c19ec31a3374d1bd7133289bf21513ff67cbf8482e626aee9864c58fd05f9ea02e508a10182b7d838157119866f072004987ef6c56683ed207705923921af9d76444a331a
2
+ d985d4c278343a46d82af0c4268b7ae6b6d1d2dd289675ef45bfb6d0648bffe5bab8c91228f3a31b091154a9c1142670a07b92e70a298333066de07db9300e046fd7cacc99780804683df7babdfc9d019047178400b2875bde0a1ad824dda7a422d9ed48475af9a3876378dd3a2f206e34984e223afb82c0c1e4644c9a458f4666379fdd3e2d9206d87e3c32c3977f35826a27590baaa1ec1a3bd7d15a92bc84c95dcfc56c14fca7c4c9810162dfdf9dc08a191e79fe40250b7e07d3a9317d9a5cb56e1062c419a6cd6a9b73128e8ad79ab7efffbb3cc52c1f49f86d2ebb46e6e4846aecdb14c2d046f5380517ff8cc794e4a772a58b93083dad
3
+ ee7e9e1369267ec555981f0ea088ff6f93953abfcb767d88ec3c46393d24cfbaba5e4e26e0f35b5d5259647748476d65cd8881c96f8cda049d9c877b2d33d932e67f4c0df2cb434b4b4900e0c49c3f8ba9663795420577e65d0b456201ad9162fbc485c7b44f2b34e6673aa3692c123021ee3b624c3bb22b808b89613d8ecc7b87da47f57152eb3f7b10ad206f6b09cb6935b347b5e42bc3b8c9c9bcd8d7b7c44929b367fc279dec48ea78e6ee3e2620d7459700bd0aedb1c9aa5a323ca94403927f5e5c2b73bda7c5c3287b62fe51874cfeb1dc3151cd886b26d83ece68833229d2d432798c602d85b0505947207d8430febbe901164b12ce
4
+ 1828b82997
5
+ bcc5c2fd785e4781d1201ed43d84925537e2a540d3de55f5812f29e9dd0a4a00451a5c8ddbb4862c03d45c75bf91b7fb49265feb667ad5c899fdbf2ca19eac67aa5e48595d5b02f8183ab07f71b1ce0d76e5df54919f63810ad0893ded7d1ca18fc956ec06ffd4c3d1f77a00ed53608947b25eea5df6bea02272be15815f974c321a2a9208674fdf59d1d798c2a12f1889df68b0c222b37ee9ef0d6391fc160b0281ec53073cb3a3706ce1d71c3af2f5237a1b3d8545d99012eecc0b4abb
6
+ 82765c040c58c1810f8c053ef5c248556299385476bde44bdd91a0d9a239f24e9b1717fd8b23209ffa45b7aa7937296c601b79e77da99e8d2fda0ea4459be2d0900f5bc5a269b5488d873d4632d1baf75965e509ee24b12501a9ce3bbbd8b7d759987d545a1c221a363195e5802d768b3b9e00ebe5ac0ed8ad2362c1c4157b910a40f94adf2561a2b0d3e65dbb06f244e5ac44d362103df54c9b9175777b3db1cdadb03e977ab8a79baf1e1e18ec9f5d0f25c487ddc53d7e81910f83576b44e9caeece26e2eb376569ad3a8cdccbde8bc355210e
7
+ ca9216d4127e2e4a6ee3584b49be106217bb61cc807016d46d0cfbb1fd722e2bbac33541386bdfeac41a299ead22790993fcaa8e1d23bd1c8426afa5ff4c08e731dc476ef834f142c32dfb2c1be12b9978802e63b2cd6f226b1a8df59f0c79154d7ef4296a68ec654538d987104f9a11aca1b7c83ab2ed8fd69da6b88f0bcbd27d3fea01329cecf10c57ec3ba163d57b38801bd6c3b31ce527b33717bb56a46f78fb96be9f2424a21b3284232388cbba6a74
8
+ 2732a7566023c8db90a5fdd08dbe6c1b5e70c046d50c5735c8d86a589ba177f69db12d6cc3596319fa27c9e063ed05b8a31970a07dc905
9
+ d7b1ef464be03ce9050b5108e25f0b8e821299986fe0ff89e17fbae65ba9fad167fbd265866ac03efc86ab0b50d46d6740a59adf5949b44f7f9f3ac3f3d4cc9f128966db9099deb1b6b78505242b2401a193820408eb0780b27162ebafb7c505b0e7c32ce66c6efc0be487008c1201454680498a2fc06e00b454e0b20933906bbb0e43b399b9ee46d882f107df1ebdd1e7cd867c9cdba6015b7e80064ae8b3417d969524bec046e782a13b125f058cd36b5d1ae65886ae7caab45a6d98651ada435b8ee11d5c1224232f5f515df974138dd6cf347b730481d4b073af8ff0394fe9f0b8cdfd99f5
10
+ 1839be14287053bfcd4ea60db82777fad1a6e9535c388b770743e61235449e668717199defd516c438b3ebd79b3529eb32482ef414525292ea1bbec09da10790a2330a4399f2fe6dd63d80954e3c547a5f1c619db5a30bde495b23f2214b4fa7572851d75246f2817775f0b521acc6efbc7832c9a76de7465e3c65cade88e86c973f85a882bb54f92b983977c6e937c88f083ba68c70fb49497065b158e2e789809b1d4cc9ec2d
2
11
  OK
@@ -0,0 +1,67 @@
1
+ #include <stdio.h>
2
+ #include <stdint.h>
3
+ #include <string.h>
4
+
5
+ #define TEST_NAME "pwhash_scrypt_ll"
6
+ #include "cmptest.h"
7
+
8
+ /* Tarsnap test vectors, see: https://www.tarsnap.com/scrypt/scrypt.pdf */
9
+
10
+ static const char *password1 = "";
11
+ static const char *salt1 = "";
12
+ static uint64_t N1 = 16U;
13
+ static uint32_t r1 = 1U;
14
+ static uint32_t p1 = 1U;
15
+
16
+ static const char *password2 = "password";
17
+ static const char *salt2 = "NaCl";
18
+ static uint64_t N2 = 1024U;
19
+ static uint32_t r2 = 8U;
20
+ static uint32_t p2 = 16U;
21
+
22
+ static const char *password3 = "pleaseletmein";
23
+ static const char *salt3 = "SodiumChloride";
24
+ static uint64_t N3 = 16384U;
25
+ static uint32_t r3 = 8U;
26
+ static uint32_t p3 = 1U;
27
+
28
+ static void test_vector(const char *password, const char *salt,
29
+ uint64_t N, uint32_t r, uint32_t p)
30
+ {
31
+ uint8_t data[64];
32
+ size_t i;
33
+ size_t olen = (sizeof data / sizeof data[0]);
34
+ size_t passwordLength = strlen(password);
35
+ size_t saltLenght = strlen(salt);
36
+ int lineitems = 0;
37
+ int lineitemsLimit = 15;
38
+
39
+ if (crypto_pwhash_scryptsalsa208sha256_ll((const uint8_t *) password,
40
+ passwordLength,
41
+ (const uint8_t *) salt,
42
+ saltLenght,
43
+ N, r, p, data, olen) != 0) {
44
+ printf("pwhash_scryptsalsa208sha256_ll([%s],[%s]) failure\n",
45
+ password, salt);
46
+ return;
47
+ }
48
+
49
+ printf("scrypt('%s', '%s', %llu, %lu, %lu, %lu) =\n",
50
+ password, salt,
51
+ (unsigned long long) N, (unsigned long) r, (unsigned long) p,
52
+ (unsigned long) olen);
53
+
54
+ for (i = 0; i < olen; ++i) {
55
+ printf("%02x%c", data[i], lineitems < lineitemsLimit ? ' ' : '\n');
56
+ lineitems = lineitems < lineitemsLimit ? lineitems + 1 : 0;
57
+ }
58
+ }
59
+
60
+ int main(void)
61
+ {
62
+ test_vector(password1, salt1, N1, r1, p1);
63
+ test_vector(password2, salt2, N2, r2, p2);
64
+ test_vector(password3, salt3, N3, r3, p3);
65
+
66
+ return 0;
67
+ }
@@ -0,0 +1,15 @@
1
+ scrypt('', '', 16, 1, 1, 64) =
2
+ 77 d6 57 62 38 65 7b 20 3b 19 ca 42 c1 8a 04 97
3
+ f1 6b 48 44 e3 07 4a e8 df df fa 3f ed e2 14 42
4
+ fc d0 06 9d ed 09 48 f8 32 6a 75 3a 0f c8 1f 17
5
+ e8 d3 e0 fb 2e 0d 36 28 cf 35 e2 0c 38 d1 89 06
6
+ scrypt('password', 'NaCl', 1024, 8, 16, 64) =
7
+ fd ba be 1c 9d 34 72 00 78 56 e7 19 0d 01 e9 fe
8
+ 7c 6a d7 cb c8 23 78 30 e7 73 76 63 4b 37 31 62
9
+ 2e af 30 d9 2e 22 a3 88 6f f1 09 27 9d 98 30 da
10
+ c7 27 af b9 4a 83 ee 6d 83 60 cb df a2 cc 06 40
11
+ scrypt('pleaseletmein', 'SodiumChloride', 16384, 8, 1, 64) =
12
+ 70 23 bd cb 3a fd 73 48 46 1c 06 cd 81 fd 38 eb
13
+ fd a8 fb ba 90 4f 8e 3e a9 b5 43 f6 54 5d a1 f2
14
+ d5 43 29 55 61 3f 0f cf 62 d4 97 05 24 2a 9a f9
15
+ e6 1e 85 dc 0d 65 1e 40 df cf 01 7b 45 57 58 87
@@ -37,15 +37,27 @@ unsigned char m[131] = {
37
37
  } ;
38
38
 
39
39
  unsigned char c[147 + crypto_secretbox_MACBYTES];
40
+ unsigned char mac[crypto_secretbox_MACBYTES];
40
41
 
41
42
  int main(void)
42
43
  {
43
- int i;
44
+ size_t i;
45
+
44
46
  crypto_secretbox_easy(c, m, 131, nonce, firstkey);
45
47
  for (i = 0;i < 131 + crypto_secretbox_MACBYTES; ++i) {
46
48
  printf(",0x%02x",(unsigned int) c[i]);
47
49
  if (i % 8 == 7) printf("\n");
48
50
  }
49
51
  printf("\n");
52
+
53
+ crypto_secretbox_detached(c, mac, m, 131, nonce, firstkey);
54
+ for (i = 0;i < crypto_secretbox_MACBYTES; ++i) {
55
+ printf(",0x%02x",(unsigned int) mac[i]);
56
+ if (i % 8 == 7) printf("\n");
57
+ }
58
+ for (i = 0;i < 131; ++i) {
59
+ printf(",0x%02x",(unsigned int) c[i]);
60
+ if (i % 8 == 7) printf("\n");
61
+ }
50
62
  return 0;
51
63
  }
@@ -17,3 +17,22 @@
17
17
  ,0x79,0x73,0xf6,0x22,0xa4,0x3d,0x14,0xa6
18
18
  ,0x59,0x9b,0x1f,0x65,0x4c,0xb4,0x5a,0x74
19
19
  ,0xe3,0x55,0xa5
20
+ ,0xf3,0xff,0xc7,0x70,0x3f,0x94,0x00,0xe5
21
+ ,0x2a,0x7d,0xfb,0x4b,0x3d,0x33,0x05,0xd9
22
+ ,0x8e,0x99,0x3b,0x9f,0x48,0x68,0x12,0x73
23
+ ,0xc2,0x96,0x50,0xba,0x32,0xfc,0x76,0xce
24
+ ,0x48,0x33,0x2e,0xa7,0x16,0x4d,0x96,0xa4
25
+ ,0x47,0x6f,0xb8,0xc5,0x31,0xa1,0x18,0x6a
26
+ ,0xc0,0xdf,0xc1,0x7c,0x98,0xdc,0xe8,0x7b
27
+ ,0x4d,0xa7,0xf0,0x11,0xec,0x48,0xc9,0x72
28
+ ,0x71,0xd2,0xc2,0x0f,0x9b,0x92,0x8f,0xe2
29
+ ,0x27,0x0d,0x6f,0xb8,0x63,0xd5,0x17,0x38
30
+ ,0xb4,0x8e,0xee,0xe3,0x14,0xa7,0xcc,0x8a
31
+ ,0xb9,0x32,0x16,0x45,0x48,0xe5,0x26,0xae
32
+ ,0x90,0x22,0x43,0x68,0x51,0x7a,0xcf,0xea
33
+ ,0xbd,0x6b,0xb3,0x73,0x2b,0xc0,0xe9,0xda
34
+ ,0x99,0x83,0x2b,0x61,0xca,0x01,0xb6,0xde
35
+ ,0x56,0x24,0x4a,0x9e,0x88,0xd5,0xf9,0xb3
36
+ ,0x79,0x73,0xf6,0x22,0xa4,0x3d,0x14,0xa6
37
+ ,0x59,0x9b,0x1f,0x65,0x4c,0xb4,0x5a,0x74
38
+ ,0xe3,0x55,0xa5
@@ -9,6 +9,7 @@ unsigned char m2[10000];
9
9
  unsigned char c[crypto_secretbox_MACBYTES + 10000];
10
10
  unsigned char nonce[crypto_secretbox_NONCEBYTES];
11
11
  unsigned char k[crypto_secretbox_KEYBYTES];
12
+ unsigned char mac[crypto_secretbox_MACBYTES];
12
13
 
13
14
  int main(void)
14
15
  {
@@ -23,5 +24,9 @@ int main(void)
23
24
  nonce, k);
24
25
  printf("%d\n", memcmp(m, m2, mlen));
25
26
 
27
+ crypto_secretbox_detached(c, mac, m, mlen, nonce, k);
28
+ crypto_secretbox_open_detached(m2, c, mac, mlen, nonce, k);
29
+ printf("%d\n", memcmp(m, m2, mlen));
30
+
26
31
  return 0;
27
32
  }
@@ -23,7 +23,7 @@ typedef struct TestData_ {
23
23
  const char *m;
24
24
  } TestData;
25
25
 
26
- TestData test_data[] = {
26
+ static TestData test_data[] = {
27
27
  {{0x9d,0x61,0xb1,0x9d,0xef,0xfd,0x5a,0x60,0xba,0x84,0x4a,0xf4,0x92,0xec,0x2c,0xc4,0x44,0x49,0xc5,0x69,0x7b,0x32,0x69,0x19,0x70,0x3b,0xac,0x03,0x1c,0xae,0x7f,0x60,},{0xd7,0x5a,0x98,0x01,0x82,0xb1,0x0a,0xb7,0xd5,0x4b,0xfe,0xd3,0xc9,0x64,0x07,0x3a,0x0e,0xe1,0x72,0xf3,0xda,0xa6,0x23,0x25,0xaf,0x02,0x1a,0x68,0xf7,0x07,0x51,0x1a,},{0xe5,0x56,0x43,0x00,0xc3,0x60,0xac,0x72,0x90,0x86,0xe2,0xcc,0x80,0x6e,0x82,0x8a,0x84,0x87,0x7f,0x1e,0xb8,0xe5,0xd9,0x74,0xd8,0x73,0xe0,0x65,0x22,0x49,0x01,0x55,0x5f,0xb8,0x82,0x15,0x90,0xa3,0x3b,0xac,0xc6,0x1e,0x39,0x70,0x1c,0xf9,0xb4,0x6b,0xd2,0x5b,0xf5,0xf0,0x59,0x5b,0xbe,0x24,0x65,0x51,0x41,0x43,0x8e,0x7a,0x10,0x0b,},""},
28
28
  {{0x4c,0xcd,0x08,0x9b,0x28,0xff,0x96,0xda,0x9d,0xb6,0xc3,0x46,0xec,0x11,0x4e,0x0f,0x5b,0x8a,0x31,0x9f,0x35,0xab,0xa6,0x24,0xda,0x8c,0xf6,0xed,0x4f,0xb8,0xa6,0xfb,},{0x3d,0x40,0x17,0xc3,0xe8,0x43,0x89,0x5a,0x92,0xb7,0x0a,0xa7,0x4d,0x1b,0x7e,0xbc,0x9c,0x98,0x2c,0xcf,0x2e,0xc4,0x96,0x8c,0xc0,0xcd,0x55,0xf1,0x2a,0xf4,0x66,0x0c,},{0x92,0xa0,0x09,0xa9,0xf0,0xd4,0xca,0xb8,0x72,0x0e,0x82,0x0b,0x5f,0x64,0x25,0x40,0xa2,0xb2,0x7b,0x54,0x16,0x50,0x3f,0x8f,0xb3,0x76,0x22,0x23,0xeb,0xdb,0x69,0xda,0x08,0x5a,0xc1,0xe4,0x3e,0x15,0x99,0x6e,0x45,0x8f,0x36,0x13,0xd0,0xf1,0x1d,0x8c,0x38,0x7b,0x2e,0xae,0xb4,0x30,0x2a,0xee,0xb0,0x0d,0x29,0x16,0x12,0xbb,0x0c,0x00,},"\x72"},
29
29
  {{0xc5,0xaa,0x8d,0xf4,0x3f,0x9f,0x83,0x7b,0xed,0xb7,0x44,0x2f,0x31,0xdc,0xb7,0xb1,0x66,0xd3,0x85,0x35,0x07,0x6f,0x09,0x4b,0x85,0xce,0x3a,0x2e,0x0b,0x44,0x58,0xf7,},{0xfc,0x51,0xcd,0x8e,0x62,0x18,0xa1,0xa3,0x8d,0xa4,0x7e,0xd0,0x02,0x30,0xf0,0x58,0x08,0x16,0xed,0x13,0xba,0x33,0x03,0xac,0x5d,0xeb,0x91,0x15,0x48,0x90,0x80,0x25,},{0x62,0x91,0xd6,0x57,0xde,0xec,0x24,0x02,0x48,0x27,0xe6,0x9c,0x3a,0xbe,0x01,0xa3,0x0c,0xe5,0x48,0xa2,0x84,0x74,0x3a,0x44,0x5e,0x36,0x80,0xd7,0xdb,0x5a,0xc3,0xac,0x18,0xff,0x9b,0x53,0x8d,0x16,0xf2,0x90,0xae,0x67,0xf7,0x60,0x98,0x4d,0xc6,0x59,0x4a,0x7c,0x15,0xe9,0x71,0x6e,0xd2,0x8d,0xc0,0x27,0xbe,0xce,0xea,0x1e,0xc4,0x0a,},"\xaf\x82"},
@@ -1054,6 +1054,8 @@ int main(void)
1054
1054
  {
1055
1055
  unsigned char sm[1024 + crypto_sign_BYTES];
1056
1056
  unsigned char m[1024];
1057
+ unsigned char skpk[crypto_sign_SECRETKEYBYTES +
1058
+ crypto_sign_PUBLICKEYBYTES];
1057
1059
  unsigned char pk[crypto_sign_PUBLICKEYBYTES];
1058
1060
  unsigned char sk[crypto_sign_SECRETKEYBYTES];
1059
1061
  char pk_hex[crypto_sign_PUBLICKEYBYTES * 2 + 1];
@@ -1063,9 +1065,11 @@ int main(void)
1063
1065
  unsigned int i;
1064
1066
 
1065
1067
  for (i = 0U; i < (sizeof test_data) / (sizeof test_data[0]); i++) {
1068
+ memcpy(skpk, test_data[i].sk, crypto_sign_SECRETKEYBYTES_WITHOUT_PK);
1069
+ memcpy(skpk + crypto_sign_SECRETKEYBYTES_WITHOUT_PK,
1070
+ test_data[i].pk, crypto_sign_PUBLICKEYBYTES);
1066
1071
  if (crypto_sign(sm, &smlen,
1067
- (const unsigned char *) test_data[i].m, i,
1068
- test_data[i].sk) != 0) {
1072
+ (const unsigned char *) test_data[i].m, i, skpk) != 0) {
1069
1073
  printf("crypto_sign() failure: [%u]\n", i);
1070
1074
  continue;
1071
1075
  }