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,18 +1,14 @@
1
- #include <stdio.h>
2
1
 
3
2
  #define TEST_NAME "stream2"
4
3
  #include "cmptest.h"
5
4
 
6
- unsigned char secondkey[32] = {
7
- 0xdc,0x90,0x8d,0xda,0x0b,0x93,0x44,0xa9
8
- ,0x53,0x62,0x9b,0x73,0x38,0x20,0x77,0x88
9
- ,0x80,0xf3,0xce,0xb4,0x21,0xbb,0x61,0xb9
10
- ,0x1c,0xbd,0x4c,0x3e,0x66,0x25,0x6c,0xe4
11
- } ;
5
+ unsigned char secondkey[32]
6
+ = { 0xdc, 0x90, 0x8d, 0xda, 0x0b, 0x93, 0x44, 0xa9, 0x53, 0x62, 0x9b,
7
+ 0x73, 0x38, 0x20, 0x77, 0x88, 0x80, 0xf3, 0xce, 0xb4, 0x21, 0xbb,
8
+ 0x61, 0xb9, 0x1c, 0xbd, 0x4c, 0x3e, 0x66, 0x25, 0x6c, 0xe4 };
12
9
 
13
- unsigned char noncesuffix[8] = {
14
- 0x82,0x19,0xe0,0x03,0x6b,0x7a,0x0b,0x37
15
- } ;
10
+ unsigned char noncesuffix[8]
11
+ = { 0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 };
16
12
 
17
13
  unsigned char output[4194304];
18
14
 
@@ -20,9 +16,15 @@ unsigned char h[32];
20
16
 
21
17
  int main(void)
22
18
  {
23
- int i;
24
- crypto_stream_salsa20(output,4194304,noncesuffix,secondkey);
25
- crypto_hash_sha256(h,output,sizeof output);
26
- for (i = 0;i < 32;++i) printf("%02x",h[i]); printf("\n");
27
- return 0;
19
+ int i;
20
+ crypto_stream_salsa20(output, 4194304, noncesuffix, secondkey);
21
+ crypto_hash_sha256(h, output, sizeof output);
22
+ for (i = 0; i < 32; ++i)
23
+ printf("%02x", h[i]);
24
+ printf("\n");
25
+
26
+ assert(crypto_stream_salsa20_keybytes() > 0U);
27
+ assert(crypto_stream_salsa20_noncebytes() > 0U);
28
+
29
+ return 0;
28
30
  }
@@ -1,30 +1,28 @@
1
- #include <stdio.h>
2
1
 
3
2
  #define TEST_NAME "stream3"
4
3
  #include "cmptest.h"
5
4
 
6
- unsigned char firstkey[32] = {
7
- 0x1b,0x27,0x55,0x64,0x73,0xe9,0x85,0xd4
8
- ,0x62,0xcd,0x51,0x19,0x7a,0x9a,0x46,0xc7
9
- ,0x60,0x09,0x54,0x9e,0xac,0x64,0x74,0xf2
10
- ,0x06,0xc4,0xee,0x08,0x44,0xf6,0x83,0x89
11
- } ;
5
+ unsigned char firstkey[32]
6
+ = { 0x1b, 0x27, 0x55, 0x64, 0x73, 0xe9, 0x85, 0xd4, 0x62, 0xcd, 0x51,
7
+ 0x19, 0x7a, 0x9a, 0x46, 0xc7, 0x60, 0x09, 0x54, 0x9e, 0xac, 0x64,
8
+ 0x74, 0xf2, 0x06, 0xc4, 0xee, 0x08, 0x44, 0xf6, 0x83, 0x89 };
12
9
 
13
- unsigned char nonce[24] = {
14
- 0x69,0x69,0x6e,0xe9,0x55,0xb6,0x2b,0x73
15
- ,0xcd,0x62,0xbd,0xa8,0x75,0xfc,0x73,0xd6
16
- ,0x82,0x19,0xe0,0x03,0x6b,0x7a,0x0b,0x37
17
- } ;
10
+ unsigned char nonce[24] = { 0x69, 0x69, 0x6e, 0xe9, 0x55, 0xb6, 0x2b, 0x73,
11
+ 0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6,
12
+ 0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 };
18
13
 
19
14
  unsigned char rs[32];
20
15
 
21
16
  int main(void)
22
17
  {
23
- int i;
24
- crypto_stream_xsalsa20(rs,32,nonce,firstkey);
25
- for (i = 0;i < 32;++i) {
26
- printf(",0x%02x",(unsigned int) rs[i]);
27
- if (i % 8 == 7) printf("\n");
28
- }
29
- return 0;
18
+ int i;
19
+
20
+ crypto_stream(rs, 32, nonce, firstkey);
21
+
22
+ for (i = 0; i < 32; ++i) {
23
+ printf(",0x%02x", (unsigned int)rs[i]);
24
+ if (i % 8 == 7)
25
+ printf("\n");
26
+ }
27
+ return 0;
30
28
  }
@@ -1,55 +1,46 @@
1
- #include <stdio.h>
2
1
 
3
2
  #define TEST_NAME "stream4"
4
3
  #include "cmptest.h"
5
4
 
6
- unsigned char firstkey[32] = {
7
- 0x1b,0x27,0x55,0x64,0x73,0xe9,0x85,0xd4
8
- ,0x62,0xcd,0x51,0x19,0x7a,0x9a,0x46,0xc7
9
- ,0x60,0x09,0x54,0x9e,0xac,0x64,0x74,0xf2
10
- ,0x06,0xc4,0xee,0x08,0x44,0xf6,0x83,0x89
11
- } ;
12
-
13
- unsigned char nonce[24] = {
14
- 0x69,0x69,0x6e,0xe9,0x55,0xb6,0x2b,0x73
15
- ,0xcd,0x62,0xbd,0xa8,0x75,0xfc,0x73,0xd6
16
- ,0x82,0x19,0xe0,0x03,0x6b,0x7a,0x0b,0x37
17
- } ;
18
-
19
- unsigned char m[163] = {
20
- 0, 0, 0, 0, 0, 0, 0, 0
21
- , 0, 0, 0, 0, 0, 0, 0, 0
22
- , 0, 0, 0, 0, 0, 0, 0, 0
23
- , 0, 0, 0, 0, 0, 0, 0, 0
24
- ,0xbe,0x07,0x5f,0xc5,0x3c,0x81,0xf2,0xd5
25
- ,0xcf,0x14,0x13,0x16,0xeb,0xeb,0x0c,0x7b
26
- ,0x52,0x28,0xc5,0x2a,0x4c,0x62,0xcb,0xd4
27
- ,0x4b,0x66,0x84,0x9b,0x64,0x24,0x4f,0xfc
28
- ,0xe5,0xec,0xba,0xaf,0x33,0xbd,0x75,0x1a
29
- ,0x1a,0xc7,0x28,0xd4,0x5e,0x6c,0x61,0x29
30
- ,0x6c,0xdc,0x3c,0x01,0x23,0x35,0x61,0xf4
31
- ,0x1d,0xb6,0x6c,0xce,0x31,0x4a,0xdb,0x31
32
- ,0x0e,0x3b,0xe8,0x25,0x0c,0x46,0xf0,0x6d
33
- ,0xce,0xea,0x3a,0x7f,0xa1,0x34,0x80,0x57
34
- ,0xe2,0xf6,0x55,0x6a,0xd6,0xb1,0x31,0x8a
35
- ,0x02,0x4a,0x83,0x8f,0x21,0xaf,0x1f,0xde
36
- ,0x04,0x89,0x77,0xeb,0x48,0xf5,0x9f,0xfd
37
- ,0x49,0x24,0xca,0x1c,0x60,0x90,0x2e,0x52
38
- ,0xf0,0xa0,0x89,0xbc,0x76,0x89,0x70,0x40
39
- ,0xe0,0x82,0xf9,0x37,0x76,0x38,0x48,0x64
40
- ,0x5e,0x07,0x05
41
- } ;
5
+ unsigned char firstkey[32]
6
+ = { 0x1b, 0x27, 0x55, 0x64, 0x73, 0xe9, 0x85, 0xd4, 0x62, 0xcd, 0x51,
7
+ 0x19, 0x7a, 0x9a, 0x46, 0xc7, 0x60, 0x09, 0x54, 0x9e, 0xac, 0x64,
8
+ 0x74, 0xf2, 0x06, 0xc4, 0xee, 0x08, 0x44, 0xf6, 0x83, 0x89 };
9
+
10
+ unsigned char nonce[24] = { 0x69, 0x69, 0x6e, 0xe9, 0x55, 0xb6, 0x2b, 0x73,
11
+ 0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6,
12
+ 0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 };
13
+
14
+ unsigned char m[163]
15
+ = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
16
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
17
+ 0, 0, 0, 0, 0, 0, 0, 0, 0xbe, 0x07, 0x5f, 0xc5,
18
+ 0x3c, 0x81, 0xf2, 0xd5, 0xcf, 0x14, 0x13, 0x16, 0xeb, 0xeb, 0x0c, 0x7b,
19
+ 0x52, 0x28, 0xc5, 0x2a, 0x4c, 0x62, 0xcb, 0xd4, 0x4b, 0x66, 0x84, 0x9b,
20
+ 0x64, 0x24, 0x4f, 0xfc, 0xe5, 0xec, 0xba, 0xaf, 0x33, 0xbd, 0x75, 0x1a,
21
+ 0x1a, 0xc7, 0x28, 0xd4, 0x5e, 0x6c, 0x61, 0x29, 0x6c, 0xdc, 0x3c, 0x01,
22
+ 0x23, 0x35, 0x61, 0xf4, 0x1d, 0xb6, 0x6c, 0xce, 0x31, 0x4a, 0xdb, 0x31,
23
+ 0x0e, 0x3b, 0xe8, 0x25, 0x0c, 0x46, 0xf0, 0x6d, 0xce, 0xea, 0x3a, 0x7f,
24
+ 0xa1, 0x34, 0x80, 0x57, 0xe2, 0xf6, 0x55, 0x6a, 0xd6, 0xb1, 0x31, 0x8a,
25
+ 0x02, 0x4a, 0x83, 0x8f, 0x21, 0xaf, 0x1f, 0xde, 0x04, 0x89, 0x77, 0xeb,
26
+ 0x48, 0xf5, 0x9f, 0xfd, 0x49, 0x24, 0xca, 0x1c, 0x60, 0x90, 0x2e, 0x52,
27
+ 0xf0, 0xa0, 0x89, 0xbc, 0x76, 0x89, 0x70, 0x40, 0xe0, 0x82, 0xf9, 0x37,
28
+ 0x76, 0x38, 0x48, 0x64, 0x5e, 0x07, 0x05 };
42
29
 
43
30
  unsigned char c[163];
44
31
 
45
32
  int main(void)
46
33
  {
47
- int i;
48
- crypto_stream_xsalsa20_xor(c,m,163,nonce,firstkey);
49
- for (i = 32;i < 163;++i) {
50
- printf(",0x%02x",(unsigned int) c[i]);
51
- if (i % 8 == 7) printf("\n");
52
- }
53
- printf("\n");
54
- return 0;
34
+ int i;
35
+
36
+ crypto_stream_xor(c, m, 163, nonce, firstkey);
37
+
38
+ for (i = 32; i < 163; ++i) {
39
+ printf(",0x%02x", (unsigned int)c[i]);
40
+ if (i % 8 == 7)
41
+ printf("\n");
42
+ }
43
+ printf("\n");
44
+
45
+ return 0;
55
46
  }
@@ -1,5 +1,3 @@
1
- #include <stdio.h>
2
- #include <string.h>
3
1
 
4
2
  #define TEST_NAME "verify1"
5
3
  #include "cmptest.h"
@@ -10,25 +8,29 @@ unsigned char v64[64], v64x[64];
10
8
 
11
9
  int main(void)
12
10
  {
13
- randombytes_buf(v16, sizeof v16);
14
- randombytes_buf(v32, sizeof v32);
15
- randombytes_buf(v64, sizeof v64);
11
+ randombytes_buf(v16, sizeof v16);
12
+ randombytes_buf(v32, sizeof v32);
13
+ randombytes_buf(v64, sizeof v64);
16
14
 
17
- memcpy(v16x, v16, sizeof v16);
18
- memcpy(v32x, v32, sizeof v32);
19
- memcpy(v64x, v64, sizeof v64);
15
+ memcpy(v16x, v16, sizeof v16);
16
+ memcpy(v32x, v32, sizeof v32);
17
+ memcpy(v64x, v64, sizeof v64);
20
18
 
21
- printf("%d\n", crypto_verify_16(v16, v16x));
22
- printf("%d\n", crypto_verify_32(v32, v32x));
23
- printf("%d\n", crypto_verify_64(v64, v64x));
19
+ printf("%d\n", crypto_verify_16(v16, v16x));
20
+ printf("%d\n", crypto_verify_32(v32, v32x));
21
+ printf("%d\n", crypto_verify_64(v64, v64x));
24
22
 
25
- v16x[randombytes_random() & 15U]++;
26
- v32x[randombytes_random() & 31U]++;
27
- v64x[randombytes_random() & 63U]++;
23
+ v16x[randombytes_random() & 15U]++;
24
+ v32x[randombytes_random() & 31U]++;
25
+ v64x[randombytes_random() & 63U]++;
28
26
 
29
- printf("%d\n", crypto_verify_16(v16, v16x));
30
- printf("%d\n", crypto_verify_32(v32, v32x));
31
- printf("%d\n", crypto_verify_64(v64, v64x));
27
+ printf("%d\n", crypto_verify_16(v16, v16x));
28
+ printf("%d\n", crypto_verify_32(v32, v32x));
29
+ printf("%d\n", crypto_verify_64(v64, v64x));
32
30
 
33
- return 0;
31
+ assert(crypto_verify_16_bytes() == 16U);
32
+ assert(crypto_verify_32_bytes() == 32U);
33
+ assert(crypto_verify_64_bytes() == 64U);
34
+
35
+ return 0;
34
36
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbnacl-libsodium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artiom Di
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-24 00:00:00.000000000 Z
11
+ date: 2014-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbnacl
@@ -254,7 +254,6 @@ files:
254
254
  - vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2-impl.h
255
255
  - vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h
256
256
  - vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c
257
- - vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2s-ref.c
258
257
  - vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/generichash_blake2b.c
259
258
  - vendor/libsodium/src/libsodium/crypto_generichash/crypto_generichash.c
260
259
  - vendor/libsodium/src/libsodium/crypto_hash/crypto_hash.c
@@ -571,6 +570,7 @@ files:
571
570
  - vendor/libsodium/test/default/pwhash_scrypt_ll.c
572
571
  - vendor/libsodium/test/default/pwhash_scrypt_ll.exp
573
572
  - vendor/libsodium/test/default/randombytes.c
573
+ - vendor/libsodium/test/default/randombytes.exp
574
574
  - vendor/libsodium/test/default/scalarmult.c
575
575
  - vendor/libsodium/test/default/scalarmult.exp
576
576
  - vendor/libsodium/test/default/scalarmult2.c
@@ -579,6 +579,8 @@ files:
579
579
  - vendor/libsodium/test/default/scalarmult5.exp
580
580
  - vendor/libsodium/test/default/scalarmult6.c
581
581
  - vendor/libsodium/test/default/scalarmult6.exp
582
+ - vendor/libsodium/test/default/scalarmult7.c
583
+ - vendor/libsodium/test/default/scalarmult7.exp
582
584
  - vendor/libsodium/test/default/secretbox.c
583
585
  - vendor/libsodium/test/default/secretbox.exp
584
586
  - vendor/libsodium/test/default/secretbox2.c
@@ -1,356 +0,0 @@
1
- /*
2
- BLAKE2 reference source code package - reference C implementations
3
-
4
- Written in 2012 by Samuel Neves <sneves@dei.uc.pt>
5
-
6
- To the extent possible under law, the author(s) have dedicated all copyright
7
- and related and neighboring rights to this software to the public domain
8
- worldwide. This software is distributed without any warranty.
9
-
10
- You should have received a copy of the CC0 Public Domain Dedication along with
11
- this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
12
- */
13
-
14
- #include <stdint.h>
15
- #include <string.h>
16
- #include <stdio.h>
17
-
18
- #include "crypto_generichash_blake2b.h"
19
- #include "blake2.h"
20
- #include "blake2-impl.h"
21
-
22
- static const uint32_t blake2s_IV[8] =
23
- {
24
- 0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL,
25
- 0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL
26
- };
27
-
28
- static const uint8_t blake2s_sigma[10][16] =
29
- {
30
- { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } ,
31
- { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } ,
32
- { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } ,
33
- { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } ,
34
- { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } ,
35
- { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } ,
36
- { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } ,
37
- { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } ,
38
- { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } ,
39
- { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 } ,
40
- };
41
-
42
- static inline int blake2s_set_lastnode( blake2s_state *S )
43
- {
44
- S->f[1] = ~0U;
45
- return 0;
46
- }
47
- #if 0
48
- static inline int blake2s_clear_lastnode( blake2s_state *S )
49
- {
50
- S->f[1] = 0U;
51
- return 0;
52
- }
53
- #endif
54
- /* Some helper functions, not necessarily useful */
55
- static inline int blake2s_set_lastblock( blake2s_state *S )
56
- {
57
- if( S->last_node ) blake2s_set_lastnode( S );
58
-
59
- S->f[0] = ~0U;
60
- return 0;
61
- }
62
- #if 0
63
- static inline int blake2s_clear_lastblock( blake2s_state *S )
64
- {
65
- if( S->last_node ) blake2s_clear_lastnode( S );
66
-
67
- S->f[0] = 0U;
68
- return 0;
69
- }
70
- #endif
71
- static inline int blake2s_increment_counter( blake2s_state *S, const uint32_t inc )
72
- {
73
- S->t[0] += inc;
74
- S->t[1] += ( S->t[0] < inc );
75
- return 0;
76
- }
77
-
78
- // Parameter-related functions
79
- #if 0
80
- static inline int blake2s_param_set_digest_length( blake2s_param *P, const uint8_t digest_length )
81
- {
82
- P->digest_length = digest_length;
83
- return 0;
84
- }
85
-
86
- static inline int blake2s_param_set_fanout( blake2s_param *P, const uint8_t fanout )
87
- {
88
- P->fanout = fanout;
89
- return 0;
90
- }
91
-
92
- static inline int blake2s_param_set_max_depth( blake2s_param *P, const uint8_t depth )
93
- {
94
- P->depth = depth;
95
- return 0;
96
- }
97
-
98
- static inline int blake2s_param_set_leaf_length( blake2s_param *P, const uint32_t leaf_length )
99
- {
100
- store32( &P->leaf_length, leaf_length );
101
- return 0;
102
- }
103
-
104
- static inline int blake2s_param_set_node_offset( blake2s_param *P, const uint64_t node_offset )
105
- {
106
- store48( P->node_offset, node_offset );
107
- return 0;
108
- }
109
-
110
- static inline int blake2s_param_set_node_depth( blake2s_param *P, const uint8_t node_depth )
111
- {
112
- P->node_depth = node_depth;
113
- return 0;
114
- }
115
-
116
- static inline int blake2s_param_set_inner_length( blake2s_param *P, const uint8_t inner_length )
117
- {
118
- P->inner_length = inner_length;
119
- return 0;
120
- }
121
- #endif
122
- static inline int blake2s_param_set_salt( blake2s_param *P, const uint8_t salt[BLAKE2S_SALTBYTES] )
123
- {
124
- memcpy( P->salt, salt, BLAKE2S_SALTBYTES );
125
- return 0;
126
- }
127
-
128
- static inline int blake2s_param_set_personal( blake2s_param *P, const uint8_t personal[BLAKE2S_PERSONALBYTES] )
129
- {
130
- memcpy( P->personal, personal, BLAKE2S_PERSONALBYTES );
131
- return 0;
132
- }
133
-
134
- static inline int blake2s_init0( blake2s_state *S )
135
- {
136
- int i;
137
-
138
- memset( S, 0, sizeof( blake2s_state ) );
139
-
140
- for( i = 0; i < 8; ++i ) S->h[i] = blake2s_IV[i];
141
-
142
- return 0;
143
- }
144
-
145
- /* init2 xors IV with input parameter block */
146
- int blake2s_init_param( blake2s_state *S, const blake2s_param *P )
147
- {
148
- size_t i;
149
- uint32_t *p;
150
-
151
- blake2s_init0( S );
152
- p = ( uint32_t * )( P );
153
-
154
- /* IV XOR ParamBlock */
155
- for( i = 0; i < 8; ++i )
156
- S->h[i] ^= load32( &p[i] );
157
-
158
- return 0;
159
- }
160
-
161
-
162
- // Sequential blake2s initialization
163
- int blake2s_init( blake2s_state *S, const uint8_t outlen )
164
- {
165
- blake2s_param P[1];
166
-
167
- /* Move interval verification here? */
168
- if ( ( !outlen ) || ( outlen > BLAKE2S_OUTBYTES ) ) return -1;
169
-
170
- P->digest_length = outlen;
171
- P->key_length = 0;
172
- P->fanout = 1;
173
- P->depth = 1;
174
- store32( &P->leaf_length, 0 );
175
- store48( &P->node_offset, 0 );
176
- P->node_depth = 0;
177
- P->inner_length = 0;
178
- // memset(P->reserved, 0, sizeof(P->reserved) );
179
- memset( P->salt, 0, sizeof( P->salt ) );
180
- memset( P->personal, 0, sizeof( P->personal ) );
181
- return blake2s_init_param( S, P );
182
- }
183
-
184
- int blake2s_init_key( blake2s_state *S, const uint8_t outlen, const void *key, const uint8_t keylen )
185
- {
186
- blake2s_param P[1];
187
-
188
- if ( ( !outlen ) || ( outlen > BLAKE2S_OUTBYTES ) ) return -1;
189
-
190
- if ( !key || !keylen || keylen > BLAKE2S_KEYBYTES ) return -1;
191
-
192
- P->digest_length = outlen;
193
- P->key_length = keylen;
194
- P->fanout = 1;
195
- P->depth = 1;
196
- store32( &P->leaf_length, 0 );
197
- store48( &P->node_offset, 0 );
198
- P->node_depth = 0;
199
- P->inner_length = 0;
200
- // memset(P->reserved, 0, sizeof(P->reserved) );
201
- memset( P->salt, 0, sizeof( P->salt ) );
202
- memset( P->personal, 0, sizeof( P->personal ) );
203
-
204
- if( blake2s_init_param( S, P ) < 0 ) return -1;
205
-
206
- {
207
- uint8_t block[BLAKE2S_BLOCKBYTES];
208
- memset( block, 0, BLAKE2S_BLOCKBYTES );
209
- memcpy( block, key, keylen );
210
- blake2s_update( S, block, BLAKE2S_BLOCKBYTES );
211
- secure_zero_memory( block, BLAKE2S_BLOCKBYTES ); /* Burn the key from stack */
212
- }
213
- return 0;
214
- }
215
-
216
- static int blake2s_compress( blake2s_state *S, const uint8_t block[BLAKE2S_BLOCKBYTES] )
217
- {
218
- uint32_t m[16];
219
- uint32_t v[16];
220
- size_t i;
221
-
222
- for( i = 0; i < 16; ++i )
223
- m[i] = load32( block + i * sizeof( m[i] ) );
224
-
225
- for( i = 0; i < 8; ++i )
226
- v[i] = S->h[i];
227
-
228
- v[ 8] = blake2s_IV[0];
229
- v[ 9] = blake2s_IV[1];
230
- v[10] = blake2s_IV[2];
231
- v[11] = blake2s_IV[3];
232
- v[12] = S->t[0] ^ blake2s_IV[4];
233
- v[13] = S->t[1] ^ blake2s_IV[5];
234
- v[14] = S->f[0] ^ blake2s_IV[6];
235
- v[15] = S->f[1] ^ blake2s_IV[7];
236
- #define G(r,i,a,b,c,d) \
237
- do { \
238
- a = a + b + m[blake2s_sigma[r][2*i+0]]; \
239
- d = rotr32(d ^ a, 16); \
240
- c = c + d; \
241
- b = rotr32(b ^ c, 12); \
242
- a = a + b + m[blake2s_sigma[r][2*i+1]]; \
243
- d = rotr32(d ^ a, 8); \
244
- c = c + d; \
245
- b = rotr32(b ^ c, 7); \
246
- } while(0)
247
- #define ROUND(r) \
248
- do { \
249
- G(r,0,v[ 0],v[ 4],v[ 8],v[12]); \
250
- G(r,1,v[ 1],v[ 5],v[ 9],v[13]); \
251
- G(r,2,v[ 2],v[ 6],v[10],v[14]); \
252
- G(r,3,v[ 3],v[ 7],v[11],v[15]); \
253
- G(r,4,v[ 0],v[ 5],v[10],v[15]); \
254
- G(r,5,v[ 1],v[ 6],v[11],v[12]); \
255
- G(r,6,v[ 2],v[ 7],v[ 8],v[13]); \
256
- G(r,7,v[ 3],v[ 4],v[ 9],v[14]); \
257
- } while(0)
258
- ROUND( 0 );
259
- ROUND( 1 );
260
- ROUND( 2 );
261
- ROUND( 3 );
262
- ROUND( 4 );
263
- ROUND( 5 );
264
- ROUND( 6 );
265
- ROUND( 7 );
266
- ROUND( 8 );
267
- ROUND( 9 );
268
-
269
- for( i = 0; i < 8; ++i )
270
- S->h[i] = S->h[i] ^ v[i] ^ v[i + 8];
271
-
272
- #undef G
273
- #undef ROUND
274
- return 0;
275
- }
276
-
277
-
278
- int blake2s_update( blake2s_state *S, const uint8_t *in, uint64_t inlen )
279
- {
280
- while( inlen > 0 )
281
- {
282
- size_t left = S->buflen;
283
- size_t fill = 2 * BLAKE2S_BLOCKBYTES - left;
284
-
285
- if( inlen > fill )
286
- {
287
- memcpy( S->buf + left, in, fill ); // Fill buffer
288
- S->buflen += fill;
289
- blake2s_increment_counter( S, BLAKE2S_BLOCKBYTES );
290
- blake2s_compress( S, S->buf ); // Compress
291
- memcpy( S->buf, S->buf + BLAKE2S_BLOCKBYTES, BLAKE2S_BLOCKBYTES ); // Shift buffer left
292
- S->buflen -= BLAKE2S_BLOCKBYTES;
293
- in += fill;
294
- inlen -= fill;
295
- }
296
- else // inlen <= fill
297
- {
298
- memcpy( S->buf + left, in, inlen );
299
- S->buflen += inlen; // Be lazy, do not compress
300
- in += inlen;
301
- inlen -= inlen;
302
- }
303
- }
304
-
305
- return 0;
306
- }
307
-
308
- int blake2s_final( blake2s_state *S, uint8_t *out, uint8_t outlen )
309
- {
310
- uint8_t buffer[BLAKE2S_OUTBYTES];
311
- int i;
312
-
313
- if( S->buflen > BLAKE2S_BLOCKBYTES )
314
- {
315
- blake2s_increment_counter( S, BLAKE2S_BLOCKBYTES );
316
- blake2s_compress( S, S->buf );
317
- S->buflen -= BLAKE2S_BLOCKBYTES;
318
- memcpy( S->buf, S->buf + BLAKE2S_BLOCKBYTES, S->buflen );
319
- }
320
-
321
- blake2s_increment_counter( S, ( uint32_t )S->buflen );
322
- blake2s_set_lastblock( S );
323
- memset( S->buf + S->buflen, 0, 2 * BLAKE2S_BLOCKBYTES - S->buflen ); /* Padding */
324
- blake2s_compress( S, S->buf );
325
-
326
- for( i = 0; i < 8; ++i ) /* Output full hash to temp buffer */
327
- store32( buffer + sizeof( S->h[i] ) * i, S->h[i] );
328
-
329
- memcpy( out, buffer, outlen );
330
- return 0;
331
- }
332
-
333
- int blake2s( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen )
334
- {
335
- blake2s_state S[1];
336
-
337
- /* Verify parameters */
338
- if ( NULL == in ) return -1;
339
-
340
- if ( NULL == out ) return -1;
341
-
342
- if ( NULL == key ) keylen = 0; /* Fail here instead if keylen != 0 and key == NULL? */
343
-
344
- if( keylen > 0 )
345
- {
346
- if( blake2s_init_key( S, outlen, key, keylen ) < 0 ) return -1;
347
- }
348
- else
349
- {
350
- if( blake2s_init( S, outlen ) < 0 ) return -1;
351
- }
352
-
353
- blake2s_update( S, ( uint8_t * )in, inlen );
354
- blake2s_final( S, out, outlen );
355
- return 0;
356
- }