rbnacl-libsodium 0.7.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) 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/ChangeLog +13 -0
  5. data/vendor/libsodium/THANKS +1 -0
  6. data/vendor/libsodium/autom4te.cache/output.1 +14 -90
  7. data/vendor/libsodium/autom4te.cache/output.3 +14 -90
  8. data/vendor/libsodium/autom4te.cache/requests +127 -127
  9. data/vendor/libsodium/autom4te.cache/traces.1 +224 -224
  10. data/vendor/libsodium/autom4te.cache/traces.3 +137 -144
  11. data/vendor/libsodium/builds/msvc/version.h +2 -2
  12. data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj +3 -0
  13. data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj.filters +3 -0
  14. data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj +3 -0
  15. data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj.filters +3 -0
  16. data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj +3 -0
  17. data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj.filters +3 -0
  18. data/vendor/libsodium/configure +14 -90
  19. data/vendor/libsodium/configure.ac +5 -12
  20. data/vendor/libsodium/msvc-scripts/process.bat +2 -2
  21. data/vendor/libsodium/packaging/nuget/package.config +1 -1
  22. data/vendor/libsodium/packaging/nuget/package.nuspec +25 -25
  23. data/vendor/libsodium/packaging/nuget/package.targets +20 -20
  24. data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +2 -0
  25. data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_easy.c +7 -0
  26. data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c +1 -1
  27. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2-impl.h +9 -4
  28. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +6 -1
  29. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/generichash_blake2b.c +4 -4
  30. data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +2 -0
  31. data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +2 -0
  32. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/auth_poly1305_donna.c +2 -1
  33. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c +2 -0
  34. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +13 -13
  35. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.c +28 -27
  36. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +16 -12
  37. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/scrypt_platform.c +2 -2
  38. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +2 -2
  39. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +3 -3
  40. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +1 -1
  41. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sign.c +7 -3
  42. data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sign_edwards25519sha512batch.c +1 -1
  43. data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c +3 -2
  44. data/vendor/libsodium/src/libsodium/include/sodium/randombytes.h +10 -8
  45. data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +13 -8
  46. data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +10 -8
  47. data/vendor/libsodium/src/libsodium/sodium/core.c +1 -1
  48. data/vendor/libsodium/src/libsodium/sodium/runtime.c +3 -3
  49. data/vendor/libsodium/src/libsodium/sodium/utils.c +12 -12
  50. data/vendor/libsodium/test/default/Makefile.am +9 -1
  51. data/vendor/libsodium/test/default/Makefile.in +35 -13
  52. data/vendor/libsodium/test/default/aead_chacha20poly1305.c +37 -31
  53. data/vendor/libsodium/test/default/auth.c +48 -9
  54. data/vendor/libsodium/test/default/auth.exp +18 -0
  55. data/vendor/libsodium/test/default/auth2.c +19 -24
  56. data/vendor/libsodium/test/default/auth3.c +17 -25
  57. data/vendor/libsodium/test/default/auth5.c +24 -24
  58. data/vendor/libsodium/test/default/auth6.c +9 -8
  59. data/vendor/libsodium/test/default/auth7.c +24 -24
  60. data/vendor/libsodium/test/default/box.c +74 -51
  61. data/vendor/libsodium/test/default/box.exp +19 -0
  62. data/vendor/libsodium/test/default/box2.c +48 -51
  63. data/vendor/libsodium/test/default/box2.exp +17 -0
  64. data/vendor/libsodium/test/default/box7.c +20 -18
  65. data/vendor/libsodium/test/default/box8.c +27 -25
  66. data/vendor/libsodium/test/default/box_easy.c +32 -42
  67. data/vendor/libsodium/test/default/box_easy2.c +3 -5
  68. data/vendor/libsodium/test/default/box_seed.c +20 -20
  69. data/vendor/libsodium/test/default/chacha20.c +41 -21
  70. data/vendor/libsodium/test/default/chacha20.exp +8 -5
  71. data/vendor/libsodium/test/default/cmptest.h +4 -0
  72. data/vendor/libsodium/test/default/core1.c +26 -19
  73. data/vendor/libsodium/test/default/core2.c +24 -23
  74. data/vendor/libsodium/test/default/core3.c +30 -26
  75. data/vendor/libsodium/test/default/core4.c +22 -23
  76. data/vendor/libsodium/test/default/core5.c +18 -22
  77. data/vendor/libsodium/test/default/core6.c +33 -34
  78. data/vendor/libsodium/test/default/ed25519_convert.c +16 -20
  79. data/vendor/libsodium/test/default/generichash.c +59 -15
  80. data/vendor/libsodium/test/default/generichash.exp +2 -0
  81. data/vendor/libsodium/test/default/generichash2.c +30 -13
  82. data/vendor/libsodium/test/default/generichash3.c +156 -22
  83. data/vendor/libsodium/test/default/generichash3.exp +11 -0
  84. data/vendor/libsodium/test/default/hash.c +31 -6
  85. data/vendor/libsodium/test/default/hash.exp +3 -0
  86. data/vendor/libsodium/test/default/hash3.c +10 -7
  87. data/vendor/libsodium/test/default/onetimeauth.c +46 -34
  88. data/vendor/libsodium/test/default/onetimeauth.exp +2 -0
  89. data/vendor/libsodium/test/default/onetimeauth2.c +20 -32
  90. data/vendor/libsodium/test/default/onetimeauth7.c +24 -24
  91. data/vendor/libsodium/test/default/pwhash.c +276 -68
  92. data/vendor/libsodium/test/default/pwhash.exp +20 -0
  93. data/vendor/libsodium/test/default/pwhash_scrypt_ll.c +31 -37
  94. data/vendor/libsodium/test/default/randombytes.c +85 -8
  95. data/vendor/libsodium/test/default/randombytes.exp +1 -0
  96. data/vendor/libsodium/test/default/scalarmult.c +28 -15
  97. data/vendor/libsodium/test/default/scalarmult2.c +20 -15
  98. data/vendor/libsodium/test/default/scalarmult5.c +24 -21
  99. data/vendor/libsodium/test/default/scalarmult6.c +24 -21
  100. data/vendor/libsodium/test/default/scalarmult7.c +31 -0
  101. data/vendor/libsodium/test/default/scalarmult7.exp +1 -0
  102. data/vendor/libsodium/test/default/secretbox.c +50 -45
  103. data/vendor/libsodium/test/default/secretbox2.c +32 -45
  104. data/vendor/libsodium/test/default/secretbox7.c +19 -17
  105. data/vendor/libsodium/test/default/secretbox8.c +26 -24
  106. data/vendor/libsodium/test/default/secretbox_easy.c +46 -52
  107. data/vendor/libsodium/test/default/secretbox_easy2.c +3 -5
  108. data/vendor/libsodium/test/default/shorthash.c +17 -10
  109. data/vendor/libsodium/test/default/sign.c +74 -39
  110. data/vendor/libsodium/test/default/sodium_core.c +6 -3
  111. data/vendor/libsodium/test/default/sodium_utils.c +57 -28
  112. data/vendor/libsodium/test/default/sodium_utils.exp +6 -0
  113. data/vendor/libsodium/test/default/sodium_utils2.c +13 -11
  114. data/vendor/libsodium/test/default/sodium_utils3.c +5 -10
  115. data/vendor/libsodium/test/default/sodium_version.c +4 -5
  116. data/vendor/libsodium/test/default/stream.c +23 -17
  117. data/vendor/libsodium/test/default/stream2.c +17 -15
  118. data/vendor/libsodium/test/default/stream3.c +17 -19
  119. data/vendor/libsodium/test/default/stream4.c +36 -45
  120. data/vendor/libsodium/test/default/verify1.c +20 -18
  121. metadata +5 -3
  122. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2s-ref.c +0 -356
@@ -1,2 +1,4 @@
1
1
  ,0xf3,0xff,0xc7,0x70,0x3f,0x94,0x00,0xe5
2
2
  ,0x2a,0x7d,0xfb,0x4b,0x3d,0x33,0x05,0xd9
3
+ ,0xf3,0xff,0xc7,0x70,0x3f,0x94,0x00,0xe5
4
+ ,0x2a,0x7d,0xfb,0x4b,0x3d,0x33,0x05,0xd9
@@ -1,42 +1,30 @@
1
- #include <stdio.h>
2
1
 
3
2
  #define TEST_NAME "onetimeauth2"
4
3
  #include "cmptest.h"
5
4
 
6
- unsigned char rs[32] = {
7
- 0xee,0xa6,0xa7,0x25,0x1c,0x1e,0x72,0x91
8
- ,0x6d,0x11,0xc2,0xcb,0x21,0x4d,0x3c,0x25
9
- ,0x25,0x39,0x12,0x1d,0x8e,0x23,0x4e,0x65
10
- ,0x2d,0x65,0x1f,0xa4,0xc8,0xcf,0xf8,0x80
11
- } ;
5
+ unsigned char rs[32]
6
+ = { 0xee, 0xa6, 0xa7, 0x25, 0x1c, 0x1e, 0x72, 0x91, 0x6d, 0x11, 0xc2,
7
+ 0xcb, 0x21, 0x4d, 0x3c, 0x25, 0x25, 0x39, 0x12, 0x1d, 0x8e, 0x23,
8
+ 0x4e, 0x65, 0x2d, 0x65, 0x1f, 0xa4, 0xc8, 0xcf, 0xf8, 0x80 };
12
9
 
13
- unsigned char c[131] = {
14
- 0x8e,0x99,0x3b,0x9f,0x48,0x68,0x12,0x73
15
- ,0xc2,0x96,0x50,0xba,0x32,0xfc,0x76,0xce
16
- ,0x48,0x33,0x2e,0xa7,0x16,0x4d,0x96,0xa4
17
- ,0x47,0x6f,0xb8,0xc5,0x31,0xa1,0x18,0x6a
18
- ,0xc0,0xdf,0xc1,0x7c,0x98,0xdc,0xe8,0x7b
19
- ,0x4d,0xa7,0xf0,0x11,0xec,0x48,0xc9,0x72
20
- ,0x71,0xd2,0xc2,0x0f,0x9b,0x92,0x8f,0xe2
21
- ,0x27,0x0d,0x6f,0xb8,0x63,0xd5,0x17,0x38
22
- ,0xb4,0x8e,0xee,0xe3,0x14,0xa7,0xcc,0x8a
23
- ,0xb9,0x32,0x16,0x45,0x48,0xe5,0x26,0xae
24
- ,0x90,0x22,0x43,0x68,0x51,0x7a,0xcf,0xea
25
- ,0xbd,0x6b,0xb3,0x73,0x2b,0xc0,0xe9,0xda
26
- ,0x99,0x83,0x2b,0x61,0xca,0x01,0xb6,0xde
27
- ,0x56,0x24,0x4a,0x9e,0x88,0xd5,0xf9,0xb3
28
- ,0x79,0x73,0xf6,0x22,0xa4,0x3d,0x14,0xa6
29
- ,0x59,0x9b,0x1f,0x65,0x4c,0xb4,0x5a,0x74
30
- ,0xe3,0x55,0xa5
31
- } ;
10
+ unsigned char c[131]
11
+ = { 0x8e, 0x99, 0x3b, 0x9f, 0x48, 0x68, 0x12, 0x73, 0xc2, 0x96, 0x50, 0xba,
12
+ 0x32, 0xfc, 0x76, 0xce, 0x48, 0x33, 0x2e, 0xa7, 0x16, 0x4d, 0x96, 0xa4,
13
+ 0x47, 0x6f, 0xb8, 0xc5, 0x31, 0xa1, 0x18, 0x6a, 0xc0, 0xdf, 0xc1, 0x7c,
14
+ 0x98, 0xdc, 0xe8, 0x7b, 0x4d, 0xa7, 0xf0, 0x11, 0xec, 0x48, 0xc9, 0x72,
15
+ 0x71, 0xd2, 0xc2, 0x0f, 0x9b, 0x92, 0x8f, 0xe2, 0x27, 0x0d, 0x6f, 0xb8,
16
+ 0x63, 0xd5, 0x17, 0x38, 0xb4, 0x8e, 0xee, 0xe3, 0x14, 0xa7, 0xcc, 0x8a,
17
+ 0xb9, 0x32, 0x16, 0x45, 0x48, 0xe5, 0x26, 0xae, 0x90, 0x22, 0x43, 0x68,
18
+ 0x51, 0x7a, 0xcf, 0xea, 0xbd, 0x6b, 0xb3, 0x73, 0x2b, 0xc0, 0xe9, 0xda,
19
+ 0x99, 0x83, 0x2b, 0x61, 0xca, 0x01, 0xb6, 0xde, 0x56, 0x24, 0x4a, 0x9e,
20
+ 0x88, 0xd5, 0xf9, 0xb3, 0x79, 0x73, 0xf6, 0x22, 0xa4, 0x3d, 0x14, 0xa6,
21
+ 0x59, 0x9b, 0x1f, 0x65, 0x4c, 0xb4, 0x5a, 0x74, 0xe3, 0x55, 0xa5 };
32
22
 
33
- unsigned char a[16] = {
34
- 0xf3,0xff,0xc7,0x70,0x3f,0x94,0x00,0xe5
35
- ,0x2a,0x7d,0xfb,0x4b,0x3d,0x33,0x05,0xd9
36
- } ;
23
+ unsigned char a[16] = { 0xf3, 0xff, 0xc7, 0x70, 0x3f, 0x94, 0x00, 0xe5,
24
+ 0x2a, 0x7d, 0xfb, 0x4b, 0x3d, 0x33, 0x05, 0xd9 };
37
25
 
38
26
  int main(void)
39
27
  {
40
- printf("%d\n",crypto_onetimeauth_poly1305_verify(a,c,131,rs));
41
- return 0;
28
+ printf("%d\n", crypto_onetimeauth_verify(a, c, 131, rs));
29
+ return 0;
42
30
  }
@@ -1,5 +1,4 @@
1
- #include <stdio.h>
2
- #include <stdlib.h>
1
+
3
2
  #include "windows/windows-quirks.h"
4
3
 
5
4
  #define TEST_NAME "onetimeauth7"
@@ -11,27 +10,28 @@ unsigned char a[16];
11
10
 
12
11
  int main(void)
13
12
  {
14
- int clen;
15
- for (clen = 0;clen < 10000;++clen) {
16
- randombytes(key,sizeof key);
17
- randombytes(c,clen);
18
- crypto_onetimeauth_poly1305(a,c,clen,key);
19
- if (crypto_onetimeauth_poly1305_verify(a,c,clen,key) != 0) {
20
- printf("fail %d\n",clen);
21
- return 100;
22
- }
23
- if (clen > 0) {
24
- c[rand() % clen] += 1 + (rand() % 255);
25
- if (crypto_onetimeauth_poly1305_verify(a,c,clen,key) == 0) {
26
- printf("forgery %d\n",clen);
27
- return 100;
28
- }
29
- a[rand() % sizeof a] += 1 + (rand() % 255);
30
- if (crypto_onetimeauth_poly1305_verify(a,c,clen,key) == 0) {
31
- printf("forgery %d\n",clen);
32
- return 100;
33
- }
13
+ int clen;
14
+
15
+ for (clen = 0; clen < 10000; ++clen) {
16
+ randombytes_buf(key, sizeof key);
17
+ randombytes_buf(c, clen);
18
+ crypto_onetimeauth(a, c, clen, key);
19
+ if (crypto_onetimeauth_verify(a, c, clen, key) != 0) {
20
+ printf("fail %d\n", clen);
21
+ return 100;
22
+ }
23
+ if (clen > 0) {
24
+ c[rand() % clen] += 1 + (rand() % 255);
25
+ if (crypto_onetimeauth_verify(a, c, clen, key) == 0) {
26
+ printf("forgery %d\n", clen);
27
+ return 100;
28
+ }
29
+ a[rand() % sizeof a] += 1 + (rand() % 255);
30
+ if (crypto_onetimeauth_verify(a, c, clen, key) == 0) {
31
+ printf("forgery %d\n", clen);
32
+ return 100;
33
+ }
34
+ }
34
35
  }
35
- }
36
- return 0;
36
+ return 0;
37
37
  }
@@ -1,5 +1,3 @@
1
- #include <stdio.h>
2
- #include <string.h>
3
1
 
4
2
  #define TEST_NAME "pwhash"
5
3
  #include "cmptest.h"
@@ -7,42 +5,102 @@
7
5
  static void tv(void)
8
6
  {
9
7
  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;
8
+ const char *passwd_hex;
9
+ unsigned long long passwdlen;
10
+ const char *salt_hex;
11
+ unsigned long long outlen;
12
+ unsigned long long opslimit;
13
+ size_t memlimit;
16
14
  } 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];
15
+ { "a347ae92bce9f80f6f595a4480fc9c2fe7e7d7148d371e9487d75f5c23008ffae0"
16
+ "65577a928febd9b1973a5a95073acdbeb6a030cfc0d79caa2dc5cd011cef02c08d"
17
+ "a232d76d52dfbca38ca8dcbd665b17d1665f7cf5fe59772ec909733b24de97d6f5"
18
+ "8d220b20c60d7c07ec1fd93c52c31020300c6c1facd77937a597c7a6",
19
+ 127,
20
+ "5541fbc995d5c197ba290346d2c559dedf405cf97e5f95482143202f9e74f5c2",
21
+ 155, 481326, 7256678 },
22
+ { "e125cee61c8cb7778d9e5ad0a6f5d978ce9f84de213a8556d9ffe202020ab4a6ed"
23
+ "9074a4eb3416f9b168f137510f3a30b70b96cbfa219ff99f6c6eaffb15c06b60e0"
24
+ "0cc2890277f0fd3c622115772f7048adaebed86e",
25
+ 86,
26
+ "f1192dd5dc2368b9cd421338b22433455ee0a3699f9379a08b9650ea2c126f0d",
27
+ 250, 535778, 7849083 },
28
+ { "92263cbf6ac376499f68a4289d3bb59e5a22335eba63a32e6410249155b956b6a3"
29
+ "b48d4a44906b18b897127300b375b8f834f1ceffc70880a885f47c33876717e392"
30
+ "be57f7da3ae58da4fd1f43daa7e44bb82d3717af4319349c24cd31e46d295856b0"
31
+ "441b6b289992a11ced1cc3bf3011604590244a3eb737ff221129215e4e4347f491"
32
+ "5d41292b5173d196eb9add693be5319fdadc242906178bb6c0286c9b6ca6012746"
33
+ "711f58c8c392016b2fdfc09c64f0f6b6ab7b",
34
+ 183,
35
+ "3b840e20e9555e9fb031c4ba1f1747ce25cc1d0ff664be676b9b4a90641ff194",
36
+ 249, 311757, 7994791 },
37
+ { "027b6d8e8c8c474e9b69c7d9ed4f9971e8e1ce2f6ba95048414c3970f0f09b70e3"
38
+ "b6c5ae05872b3d8678705b7d381829c351a5a9c88c233569b35d6b0b809df44b64"
39
+ "51a9c273f1150e2ef8a0b5437eb701e373474cd44b97ef0248ebce2ca0400e1b53"
40
+ "f3d86221eca3f18eb45b702b9172440f774a82cbf1f6f525df30a6e293c873cce6"
41
+ "9bb078ed1f0d31e7f9b8062409f37f19f8550aae",
42
+ 152,
43
+ "eb2a3056a09ad2d7d7f975bcd707598f24cd32518cde3069f2e403b34bfee8a5",
44
+ 5, 643464, 1397645 },
45
+ { "4a857e2ee8aa9b6056f2424e84d24a72473378906ee04a46cb05311502d5250b82"
46
+ "ad86b83c8f20a23dbb74f6da60b0b6ecffd67134d45946ac8ebfb3064294bc097d"
47
+ "43ced68642bfb8bbbdd0f50b30118f5e",
48
+ 82,
49
+ "39d82eef32010b8b79cc5ba88ed539fbaba741100f2edbeca7cc171ffeabf258",
50
+ 190, 758010, 5432947 },
51
+ { "1845e375479537e9dd4f4486d5c91ac72775d66605eeb11a787b78a7745f1fd005"
52
+ "2d526c67235dbae1b2a4d575a74cb551c8e9096c593a497aee74ba3047d911358e"
53
+ "de57bc27c9ea1829824348daaab606217cc931dcb6627787bd6e4e5854f0e8",
54
+ 97,
55
+ "3ee91a805aa62cfbe8dce29a2d9a44373a5006f4a4ce24022aca9cecb29d1473",
56
+ 212, 233177, 13101817 },
57
+ { "c7b09aec680e7b42fedd7fc792e78b2f6c1bea8f4a884320b648f81e8cf515e8ba"
58
+ "9dcfb11d43c4aae114c1734aa69ca82d44998365db9c93744fa28b63fd16000e82"
59
+ "61cbbe083e7e2da1e5f696bde0834fe53146d7e0e35e7de9920d041f5a5621aabe"
60
+ "02da3e2b09b405b77937efef3197bd5772e41fdb73fb5294478e45208063b5f58e"
61
+ "089dbeb6d6342a909c1307b3fff5fe2cf4da56bdae50848f",
62
+ 156,
63
+ "039c056d933b475032777edbaffac50f143f64c123329ed9cf59e3b65d3f43b6",
64
+ 178, 234753, 4886999 },
65
+ { "8f3a06e2fd8711350a517bb12e31f3d3423e8dc0bb14aac8240fca0995938d59bb"
66
+ "37bd0a7dfc9c9cc0705684b46612e8c8b1d6655fb0f9887562bb9899791a0250d1"
67
+ "320f945eda48cdc20c233f40a5bb0a7e3ac5ad7250ce684f68fc0b8c9633bfd75a"
68
+ "ad116525af7bdcdbbdb4e00ab163fd4df08f243f12557e",
69
+ 122,
70
+ "90631f686a8c3dbc0703ffa353bc1fdf35774568ac62406f98a13ed8f47595fd",
71
+ 55, 695191, 15738350 },
72
+ { "b540beb016a5366524d4605156493f9874514a5aa58818cd0c6dfffaa9e90205f1"
73
+ "7b",
74
+ 34,
75
+ "44071f6d181561670bda728d43fb79b443bb805afdebaf98622b5165e01b15fb",
76
+ 231, 78652, 6631659 },
77
+ { "a14975c26c088755a8b715ff2528d647cd343987fcf4aa25e7194a8417fb2b4b3f"
78
+ "7268da9f3182b4cfb22d138b2749d673a47ecc7525dd15a0a3c66046971784bb63"
79
+ "d7eae24cc84f2631712075a10e10a96b0e0ee67c43e01c423cb9c44e5371017e9c"
80
+ "496956b632158da3fe12addecb88912e6759bc37f9af2f45af72c5cae3b179ffb6"
81
+ "76a697de6ebe45cd4c16d4a9d642d29ddc0186a0a48cb6cd62bfc3dd229d313b30"
82
+ "1560971e740e2cf1f99a9a090a5b283f35475057e96d7064e2e0fc81984591068d"
83
+ "55a3b4169f22cccb0745a2689407ea1901a0a766eb99",
84
+ 220,
85
+ "3d968b2752b8838431165059319f3ff8910b7b8ecb54ea01d3f54769e9d98daf",
86
+ 167, 717248, 10784179 },
87
+ };
88
+ char passwd[256];
29
89
  unsigned char salt[crypto_pwhash_scryptsalsa208sha256_SALTBYTES];
30
90
  unsigned char out[256];
31
- char out_hex[256 * 2 + 1];
32
- size_t i = 0U;
91
+ char out_hex[256 * 2 + 1];
92
+ size_t i = 0U;
33
93
 
34
94
  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) {
95
+ sodium_hex2bin((unsigned char *)passwd, sizeof passwd,
96
+ tests[i].passwd_hex, strlen(tests[i].passwd_hex), NULL,
97
+ NULL, NULL);
98
+ sodium_hex2bin(salt, sizeof salt, tests[i].salt_hex,
99
+ strlen(tests[i].salt_hex), NULL, NULL, NULL);
100
+ if (crypto_pwhash_scryptsalsa208sha256(
101
+ out, tests[i].outlen, passwd, tests[i].passwdlen,
102
+ (const unsigned char *)salt, tests[i].opslimit,
103
+ tests[i].memlimit) != 0) {
46
104
  printf("pwhash failure\n");
47
105
  }
48
106
  sodium_bin2hex(out_hex, sizeof out_hex, out, tests[i].outlen);
@@ -53,28 +111,169 @@ static void tv(void)
53
111
  static void tv2(void)
54
112
  {
55
113
  static struct {
56
- const char *passwd;
57
- const char *out;
114
+ const char *passwd_hex;
115
+ unsigned long long passwdlen;
116
+ const char *salt_hex;
117
+ unsigned long long outlen;
118
+ unsigned long long opslimit;
119
+ size_t memlimit;
58
120
  } 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
- };
121
+ { "a347ae92bce9f80f6f595a4480fc9c2fe7e7d7148d371e9487d75f5c23008ffae0"
122
+ "65577a928febd9b1973a5a95073acdbeb6a030cfc0d79caa2dc5cd011cef02c08d"
123
+ "a232d76d52dfbca38ca8dcbd665b17d1665f7cf5fe59772ec909733b24de97d6f5"
124
+ "8d220b20c60d7c07ec1fd93c52c31020300c6c1facd77937a597c7a6",
125
+ 127,
126
+ "5541fbc995d5c197ba290346d2c559dedf405cf97e5f95482143202f9e74f5c2",
127
+ 155, 64, 1397645 },
128
+ { "a347ae92bce9f80f6f595a4480fc9c2fe7e7d7148d371e9487d75f5c23008ffae0"
129
+ "65577a928febd9b1973a5a95073acdbeb6a030cfc0d79caa2dc5cd011cef02c08d"
130
+ "a232d76d52dfbca38ca8dcbd665b17d1665f7cf5fe59772ec909733b24de97d6f5"
131
+ "8d220b20c60d7c07ec1fd93c52c31020300c6c1facd77937a597c7a6",
132
+ 127,
133
+ "5541fbc995d5c197ba290346d2c559dedf405cf97e5f95482143202f9e74f5c2",
134
+ 155, 32768, 1397645 },
135
+ };
136
+ char passwd[256];
137
+ unsigned char salt[crypto_pwhash_scryptsalsa208sha256_SALTBYTES];
138
+ unsigned char out[256];
139
+ char out_hex[256 * 2 + 1];
70
140
  size_t i = 0U;
71
141
 
72
142
  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");
143
+ sodium_hex2bin((unsigned char *)passwd, sizeof passwd,
144
+ tests[i].passwd_hex, strlen(tests[i].passwd_hex), NULL,
145
+ NULL, NULL);
146
+ sodium_hex2bin(salt, sizeof salt, tests[i].salt_hex,
147
+ strlen(tests[i].salt_hex), NULL, NULL, NULL);
148
+ if (crypto_pwhash_scryptsalsa208sha256(
149
+ out, tests[i].outlen, passwd, tests[i].passwdlen,
150
+ (const unsigned char *)salt, tests[i].opslimit,
151
+ tests[i].memlimit) != 0) {
152
+ printf("pwhash failure\n");
77
153
  }
154
+ sodium_bin2hex(out_hex, sizeof out_hex, out, tests[i].outlen);
155
+ printf("%s\n", out_hex);
156
+ } while (++i < (sizeof tests) / (sizeof tests[0]));
157
+ }
158
+
159
+ static void tv3(void)
160
+ {
161
+ static struct {
162
+ const char *passwd;
163
+ const char *out;
164
+ } tests[] = {
165
+ { "^T5H$JYt39n%K*j:W]!1s?vg!:jGi]Ax?..l7[p0v:1jHTpla9;]bUN;?bWyCbtqg "
166
+ "nrDFal+Jxl3,2`#^tFSu%v_+7iYse8-cCkNf!tD=KrW)",
167
+ "$7$B6....1....75gBMAGwfFWZqBdyF3WdTQnWdUsuTiWjG1fF9c1jiSD$tc8RoB3."
168
+ "Em3/zNgMLWo2u00oGIoTyJv4fl3Fl8Tix72" },
169
+ { "bl72h6#y<':MFRZ>B IA1=NRkCKS%W8`1I.2uQxJN0g)N N aTt^4K!Iw5r "
170
+ "H6;crDsv^a55j9tsk'/GqweZn;cdk6+F_St6:#*=?ZCD_lw>.",
171
+ "$7$A6....3....Iahc6qM0.UQJHVgE4h9oa1/"
172
+ "4OWlWLm9CCtfguvz6bQD$QnXCo3M7nIqtry2WKsUZ5gQ.mY0wAlJu."
173
+ "WUhtE8vF66" },
174
+ { "Py "
175
+ ">e.5b+tLo@rL`dC2k@eJ&4eVl!W=JJ4+k&mAt@gt',FS1JjqKW3aq21:]^kna`"
176
+ "mde7kVkN5NrpKUptu)@4*b&?BE_sJMG1=&@`3GBCV]Wg7xwgo7x3El",
177
+ "$7$96..../....f6bEusKt79kK4wdYN0ki2nw4bJQ7P3rN6k3BSigsK/"
178
+ "D$Dsvuw7vXj5xijmrb/NOhdgoyK/OiSIYv88cEtl9Cik7" },
179
+ { "2vj;Um]FKOL27oam(:Uo8+UmSTvb1FD*h?jk_,S=;RDgF-$Fjk?]9yvfxe@fN^!NN("
180
+ "Cuml?+2Raa",
181
+ "$7$86....I....7XwIxLtCx4VphmFeUa6OGuGJrFaIaYzDiLNu/"
182
+ "tyUPhD$U3q5GCEqCWxMwh.YQHDJrlg7FIZgViv9pcXE3h1vg61" },
183
+ { "CT=[9uUoGav,J`kU+348tA50ue#sL:ABZ3QgF+r[#vh:tTOiL>s8tv%,Jeo]jH/"
184
+ "_4^i(*jD-_ku[9Ko[=86 06V",
185
+ "$7$A6....2....R3.bjH6YS9wz9z8Jsj.3weGQ3J80ZZElGw2oVux1TP6$"
186
+ "i5u6lFzXDHaIgYEICinLD6WNaovbiXP8SnLrDRdKgA9" },
187
+ { "J#wNn`hDgOpTHNI.w^1a70%f,.9V_m038H_JIJQln`vdWnn/"
188
+ "rmILR?9H5g(+`;@H(2VosN9Fgk[WEjaBr'yB9Q19-imNa04[Mk5kvGcSn-TV",
189
+ "$7$B6....1....Dj1y.4mF1J9XmT/6IDskYdCLaPFJTq9xcCwXQ1DpT92$92/"
190
+ "hYfZLRq1nTLyIz.uc/dC6wLqwnsoqpkadrCXusm6" },
191
+ { "j4BS38Asa;p)[K+9TY!3YDj<LK-`nLVXQw9%*QfM",
192
+ "$7$B6....1....5Ods8mojVwXJq4AywF/uI9BdMSiJ/zT8hQP/"
193
+ "4cB68VC$nk4ExHNXJ802froj51/1wJTrSZvTIyyK7PecOxRRaz0" },
194
+ { "M.R>Qw+!qJb]>pP :_.9`dxM9k [eR7Y!yL-3)sNs[R,j_/^ "
195
+ "TH=5ny'15>6UXWcQW^6D%XCsO[vN[%ReA-`tV1vW(Nt*0KVK#]45P_A",
196
+ "$7$B6....1....D/"
197
+ "eyk8N5y6Z8YVQEsw521cTx.9zzLuK7YDs1KMMh.o4$alfW8ZbsUWnXc."
198
+ "vqon2zoljVk24Tt1.IsCuo2KurvS2" },
199
+ { "K3S=KyH#)36_?]LxeR8QNKw6X=gFb'ai$C%29V* "
200
+ "tyh^Wo$TN-#Q4qkmtTCf0LLb.^E$0uykkP",
201
+ "$7$B6....1....CuBuU97xgAage8whp/"
202
+ "JNKobo0TFbsORGVbfcQIefyP8$aqalP."
203
+ "XofGViB8EPLONqHma8vs1xc9uTIMYh9CgE.S8" },
204
+ { "Y0!?iQa9M%5ekffW(`",
205
+ "$7$A6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
206
+ "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
207
+
208
+ /* Invalid pwhash strings */
209
+
210
+ { "Y0!?iQa9M%5ekffW(`",
211
+ "$7$A6....1....$TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4"
212
+ "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
213
+ { "Y0!?iQa9M%5ekffW(`",
214
+ "$7$.6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
215
+ "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
216
+ { "Y0!?iQa9M%5ekffW(`",
217
+ "$7$A.....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
218
+ "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
219
+ { "Y0!?iQa9M%5ekffW(`",
220
+ "$7$A6.........TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
221
+ "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
222
+ { "Y0!?iQa9M%5ekffW(`",
223
+ "$7$A6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i44269$"
224
+ "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AH" },
225
+ { "Y0!?iQa9M%5ekffW(`",
226
+ "$7$A6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
227
+ "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx54269" },
228
+ { "Y0!?iQa9M%5ekffW(`",
229
+ "$7^A6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
230
+ "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
231
+ { "Y0!?iQa9M%5ekffW(`",
232
+ "$7$!6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
233
+ "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
234
+ { "Y0!?iQa9M%5ekffW(`",
235
+ "$7$A!....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
236
+ "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
237
+ { "Y0!?iQa9M%5ekffW(`",
238
+ "$7$A6....!....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
239
+ "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
240
+ { "",
241
+ "$7$A6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
242
+ "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
243
+ { "Y0!?iQa9M%5ekffW(`",
244
+ "$7fA6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4#"
245
+ "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
246
+ { "Y0!?iQa9M%5ekffW(`",
247
+ "$7$AX....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
248
+ "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
249
+ { "Y0!?iQa9M%5ekffW(`",
250
+ "$7$A6....1!...TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
251
+ "a4ik5hGDN7foMuHOW.cp.CtX01UyCeO0.JAG.AHPpx5" },
252
+ { "Y0!?iQa9M%5ekffW(`",
253
+ "$7$A6....1" },
254
+ { "Y0!?iQa9M%5ekffW(`",
255
+ "$7$" },
256
+ { "Y0!?iQa9M%5ekffW(`",
257
+ "" },
258
+ { "Y0!?iQa9M%5ekffW(`",
259
+ "$7$A6....1....TrXs5Zk6s8sWHpQgWDIXTR8kUU3s6Jc3s.DtdS8M2i4$"
260
+ "" },
261
+ };
262
+ char *out;
263
+ char *passwd;
264
+ size_t i = 0U;
265
+
266
+ do {
267
+ out = (char *) sodium_malloc(strlen(tests[i].out) + 1U);
268
+ memcpy(out, tests[i].out, strlen(tests[i].out) + 1U);
269
+ passwd = (char *) sodium_malloc(strlen(tests[i].passwd) + 1U);
270
+ memcpy(passwd, tests[i].passwd, strlen(tests[i].passwd) + 1U);
271
+ if (crypto_pwhash_scryptsalsa208sha256_str_verify(
272
+ out, passwd, strlen(passwd)) != 0) {
273
+ printf("pwhash_str failure: [%u]\n", (unsigned int)i);
274
+ }
275
+ sodium_free(out);
276
+ sodium_free(passwd);
78
277
  } while (++i < (sizeof tests) / (sizeof tests[0]));
79
278
  }
80
279
 
@@ -84,43 +283,52 @@ static void tv2(void)
84
283
 
85
284
  int main(void)
86
285
  {
87
- char str_out[crypto_pwhash_scryptsalsa208sha256_STRBYTES];
88
- char str_out2[crypto_pwhash_scryptsalsa208sha256_STRBYTES];
89
- unsigned char out[OUT_LEN];
90
- char out_hex[OUT_LEN * 2 + 1];
91
- const char *salt = "[<~A 32-bytes salt for scrypt~>]";
92
- const char *passwd = "Correct Horse Battery Staple";
93
- size_t i;
286
+ char str_out[crypto_pwhash_scryptsalsa208sha256_STRBYTES];
287
+ char str_out2[crypto_pwhash_scryptsalsa208sha256_STRBYTES];
288
+ unsigned char out[OUT_LEN];
289
+ char out_hex[OUT_LEN * 2 + 1];
290
+ const char *salt = "[<~A 32-bytes salt for scrypt~>]";
291
+ const char *passwd = "Correct Horse Battery Staple";
292
+ size_t i;
94
293
 
95
294
  tv();
96
295
  tv2();
296
+ tv3();
97
297
  if (crypto_pwhash_scryptsalsa208sha256_str(str_out, passwd, strlen(passwd),
98
- OPSLIMIT, MEMLIMIT) != 0) {
298
+ OPSLIMIT, MEMLIMIT) != 0) {
99
299
  printf("pwhash_str failure\n");
100
300
  }
101
301
  if (crypto_pwhash_scryptsalsa208sha256_str(str_out2, passwd, strlen(passwd),
102
- OPSLIMIT, MEMLIMIT) != 0) {
302
+ OPSLIMIT, MEMLIMIT) != 0) {
103
303
  printf("pwhash_str(2) failure\n");
104
304
  }
105
305
  if (strcmp(str_out, str_out2) == 0) {
106
306
  printf("pwhash_str doesn't generate different salts\n");
107
307
  }
108
308
  if (crypto_pwhash_scryptsalsa208sha256_str_verify(str_out, passwd,
109
- strlen(passwd)) != 0) {
309
+ strlen(passwd)) != 0) {
110
310
  printf("pwhash_str_verify failure\n");
111
311
  }
112
312
  if (crypto_pwhash_scryptsalsa208sha256_str_verify(str_out, passwd,
113
- strlen(passwd)) != 0) {
313
+ strlen(passwd)) != 0) {
114
314
  printf("pwhash_str_verify failure\n");
115
315
  }
116
- for (i = 14U; i < sizeof str_out; i++) {
117
- str_out[i]++;
118
- if (crypto_pwhash_scryptsalsa208sha256_str_verify(str_out, passwd,
119
- strlen(passwd)) == 0) {
120
- printf("pwhash_str_verify(2) failure\n");
121
- }
122
- str_out[i]--;
316
+ str_out[14]++;
317
+ if (crypto_pwhash_scryptsalsa208sha256_str_verify(
318
+ str_out, passwd, strlen(passwd)) == 0) {
319
+ printf("pwhash_str_verify(2) failure\n");
123
320
  }
321
+ str_out[14]--;
322
+
323
+ assert(crypto_pwhash_scryptsalsa208sha256_saltbytes() > 0U);
324
+ assert(crypto_pwhash_scryptsalsa208sha256_strbytes() > 1U);
325
+ assert(crypto_pwhash_scryptsalsa208sha256_strbytes() >
326
+ strlen(crypto_pwhash_scryptsalsa208sha256_strprefix()));
327
+ assert(crypto_pwhash_scryptsalsa208sha256_opslimit_interactive() > 0U);
328
+ assert(crypto_pwhash_scryptsalsa208sha256_memlimit_interactive() > 0U);
329
+ assert(crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive() > 0U);
330
+ assert(crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive() > 0U);
331
+
124
332
  printf("OK\n");
125
333
 
126
334
  return 0;