rbnacl-libsodium 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) 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 +10 -0
  5. data/vendor/libsodium/LICENSE +1 -1
  6. data/vendor/libsodium/Makefile.in +10 -2
  7. data/vendor/libsodium/THANKS +1 -0
  8. data/vendor/libsodium/autom4te.cache/output.1 +52 -17
  9. data/vendor/libsodium/autom4te.cache/output.3 +52 -17
  10. data/vendor/libsodium/autom4te.cache/requests +558 -558
  11. data/vendor/libsodium/autom4te.cache/traces.1 +543 -542
  12. data/vendor/libsodium/autom4te.cache/traces.3 +320 -319
  13. data/vendor/libsodium/build-aux/compile +347 -0
  14. data/vendor/libsodium/build-aux/config.guess +1568 -0
  15. data/vendor/libsodium/build-aux/config.sub +1793 -0
  16. data/vendor/libsodium/build-aux/depcomp +791 -0
  17. data/vendor/libsodium/build-aux/install-sh +527 -0
  18. data/vendor/libsodium/build-aux/ltmain.sh +9655 -0
  19. data/vendor/libsodium/build-aux/missing +215 -0
  20. data/vendor/libsodium/build-aux/test-driver +139 -0
  21. data/vendor/libsodium/builds/msvc/properties/Common.props +1 -3
  22. data/vendor/libsodium/builds/msvc/properties/Release.props +3 -1
  23. data/vendor/libsodium/builds/msvc/resource.rc +0 -0
  24. data/vendor/libsodium/builds/msvc/version.h +2 -2
  25. data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.props +1 -1
  26. data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj +12 -6
  27. data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj.filters +11 -5
  28. data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.props +1 -1
  29. data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj +12 -6
  30. data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj.filters +11 -5
  31. data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.props +1 -1
  32. data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj +12 -6
  33. data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj.filters +11 -5
  34. data/vendor/libsodium/configure +52 -17
  35. data/vendor/libsodium/configure.ac +7 -4
  36. data/vendor/libsodium/dist-build/ios.sh +4 -3
  37. data/vendor/libsodium/libsodium.vcxproj +4 -4
  38. data/vendor/libsodium/msvc-scripts/process.bat +2 -2
  39. data/vendor/libsodium/packaging/nuget/package.config +1 -1
  40. data/vendor/libsodium/packaging/nuget/package.nuspec +25 -25
  41. data/vendor/libsodium/packaging/nuget/package.targets +20 -20
  42. data/vendor/libsodium/src/libsodium/Makefile.in +2 -2
  43. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2-impl.h +2 -2
  44. data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h +8 -8
  45. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/auth_poly1305_donna.c +6 -6
  46. data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +2 -2
  47. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +1 -1
  48. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +2 -2
  49. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.h +2 -2
  50. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +1 -1
  51. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +1 -1
  52. data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sysendian.h +2 -2
  53. data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/smult_curve25519_donna_c64.c +38 -38
  54. data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +8 -0
  55. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_frombytes.c +10 -10
  56. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_mul.c +10 -10
  57. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_sq.c +10 -10
  58. data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_sq2.c +10 -10
  59. data/vendor/libsodium/src/libsodium/include/sodium.h +2 -2
  60. data/vendor/libsodium/src/libsodium/include/sodium/core.h +2 -2
  61. data/vendor/libsodium/src/libsodium/include/sodium/export.h +3 -3
  62. data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +2 -2
  63. data/vendor/libsodium/src/libsodium/include/sodium/utils.h +4 -4
  64. data/vendor/libsodium/src/libsodium/include/sodium/version.h.in +2 -2
  65. data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +9 -9
  66. data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +9 -9
  67. data/vendor/libsodium/src/libsodium/sodium/utils.c +17 -15
  68. data/vendor/libsodium/test/default/Makefile.in +5 -4
  69. data/vendor/libsodium/test/default/aead_chacha20poly1305.c +25 -0
  70. data/vendor/libsodium/test/default/aead_chacha20poly1305.exp +4 -0
  71. data/vendor/libsodium/test/default/box_easy2.c +23 -8
  72. data/vendor/libsodium/test/default/box_easy2.exp +2 -0
  73. data/vendor/libsodium/test/default/generichash.c +23 -15
  74. data/vendor/libsodium/test/default/generichash3.c +24 -20
  75. data/vendor/libsodium/test/default/pwhash.c +27 -28
  76. data/vendor/libsodium/test/default/scalarmult6.c +19 -3
  77. data/vendor/libsodium/test/default/secretbox_easy2.c +27 -11
  78. data/vendor/libsodium/test/default/secretbox_easy2.exp +3 -0
  79. data/vendor/libsodium/test/default/shorthash.c +15 -10
  80. data/vendor/libsodium/test/default/sign.c +23 -0
  81. data/vendor/libsodium/test/default/sodium_utils2.c +4 -0
  82. data/vendor/libsodium/test/default/sodium_utils3.c +4 -0
  83. metadata +10 -2
@@ -1,2 +1,4 @@
1
1
  0
2
2
  0
3
+ 0
4
+ 0
@@ -2,43 +2,51 @@
2
2
  #define TEST_NAME "generichash"
3
3
  #include "cmptest.h"
4
4
 
5
+ #define MAXLEN 64
6
+
5
7
  int main(void)
6
8
  {
7
- #define MAXLEN 64
8
- unsigned char in[MAXLEN], out[crypto_generichash_BYTES_MAX],
9
- k[crypto_generichash_KEYBYTES_MAX];
10
- size_t h, i, j;
9
+ unsigned char in[MAXLEN];
10
+ unsigned char out[crypto_generichash_BYTES_MAX];
11
+ unsigned char k[crypto_generichash_KEYBYTES_MAX];
12
+ size_t h;
13
+ size_t i;
14
+ size_t j;
11
15
 
12
- for (h = 0; h < crypto_generichash_KEYBYTES_MAX; ++h)
13
- k[h] = h;
16
+ for (h = 0; h < crypto_generichash_KEYBYTES_MAX; ++h) {
17
+ k[h] = (unsigned char) h;
18
+ }
14
19
 
15
20
  for (i = 0; i < MAXLEN; ++i) {
16
- in[i] = i;
17
- crypto_generichash(out, 1 + i % crypto_generichash_BYTES_MAX, in, i, k,
21
+ in[i] = (unsigned char) i;
22
+ crypto_generichash(out, 1 + i % crypto_generichash_BYTES_MAX, in,
23
+ (unsigned long long) i, k,
18
24
  1 + i % crypto_generichash_KEYBYTES_MAX);
19
25
  for (j = 0; j < 1 + i % crypto_generichash_BYTES_MAX; ++j) {
20
- printf("%02x", (unsigned int)out[j]);
26
+ printf("%02x", (unsigned int) out[j]);
21
27
  }
22
28
  printf("\n");
23
29
  }
24
30
 
25
31
  memset(out, 0, sizeof out);
26
- crypto_generichash(out, crypto_generichash_BYTES_MAX, in, i, k, 0U);
32
+ crypto_generichash(out, crypto_generichash_BYTES_MAX, in,
33
+ (unsigned long long) i, k, 0U);
27
34
  for (j = 0; j < crypto_generichash_BYTES_MAX; ++j) {
28
- printf("%02x", (unsigned int)out[j]);
35
+ printf("%02x", (unsigned int) out[j]);
29
36
  }
30
37
  printf("\n");
31
38
 
32
39
  memset(out, 0, sizeof out);
33
- crypto_generichash(out, crypto_generichash_BYTES_MAX, in, i, NULL, 1U);
40
+ crypto_generichash(out, crypto_generichash_BYTES_MAX, in,
41
+ (unsigned long long) i, NULL, 1U);
34
42
  for (j = 0; j < crypto_generichash_BYTES_MAX; ++j) {
35
- printf("%02x", (unsigned int)out[j]);
43
+ printf("%02x", (unsigned int) out[j]);
36
44
  }
37
45
  printf("\n");
38
46
 
39
47
  assert(crypto_generichash(out, 0U, in, sizeof in, k, sizeof k) == -1);
40
- assert(crypto_generichash(out, crypto_generichash_BYTES_MAX + 1U, in, sizeof in,
41
- k, sizeof k) == -1);
48
+ assert(crypto_generichash(out, crypto_generichash_BYTES_MAX + 1U,
49
+ in, sizeof in, k, sizeof k) == -1);
42
50
  assert(crypto_generichash(out, sizeof out, in, sizeof in,
43
51
  k, crypto_generichash_KEYBYTES_MAX + 1U) == -1);
44
52
 
@@ -12,23 +12,27 @@ int main(void)
12
12
  unsigned char personal[crypto_generichash_blake2b_PERSONALBYTES]
13
13
  = { '5', '1', '2', '6', 'f', 'b', '2', 'a',
14
14
  '3', '7', '4', '0', '0', 'd', '2', 'a' };
15
- unsigned char in[MAXLEN], out[crypto_generichash_blake2b_BYTES_MAX],
16
- k[crypto_generichash_blake2b_KEYBYTES_MAX];
17
- size_t h, i, j;
18
-
19
- for (h = 0; h < crypto_generichash_blake2b_KEYBYTES_MAX; ++h)
20
- k[h] = h;
15
+ unsigned char in[MAXLEN];
16
+ unsigned char out[crypto_generichash_blake2b_BYTES_MAX];
17
+ unsigned char k[crypto_generichash_blake2b_KEYBYTES_MAX];
18
+ size_t h;
19
+ size_t i;
20
+ size_t j;
21
+
22
+ for (h = 0; h < crypto_generichash_blake2b_KEYBYTES_MAX; ++h) {
23
+ k[h] = (unsigned char) h;
24
+ }
21
25
 
22
26
  for (i = 0; i < MAXLEN; ++i) {
23
- in[i] = i;
27
+ in[i] = (unsigned char) i;
24
28
  crypto_generichash_blake2b_init_salt_personal(
25
29
  &st, k, 1 + i % crypto_generichash_blake2b_KEYBYTES_MAX,
26
30
  1 + i % crypto_generichash_blake2b_BYTES_MAX, salt, personal);
27
- crypto_generichash_blake2b_update(&st, in, i);
31
+ crypto_generichash_blake2b_update(&st, in, (unsigned long long) i);
28
32
  crypto_generichash_blake2b_final(
29
33
  &st, out, 1 + i % crypto_generichash_blake2b_BYTES_MAX);
30
34
  for (j = 0; j < 1 + i % crypto_generichash_blake2b_BYTES_MAX; ++j) {
31
- printf("%02x", (unsigned int)out[j]);
35
+ printf("%02x", (unsigned int) out[j]);
32
36
  }
33
37
  printf("\n");
34
38
  }
@@ -40,7 +44,7 @@ int main(void)
40
44
  crypto_generichash_blake2b_final(&st, out,
41
45
  crypto_generichash_blake2b_BYTES_MAX);
42
46
  for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
43
- printf("%02x", (unsigned int)out[j]);
47
+ printf("%02x", (unsigned int) out[j]);
44
48
  }
45
49
  printf("\n");
46
50
 
@@ -51,7 +55,7 @@ int main(void)
51
55
  crypto_generichash_blake2b_final(&st, out,
52
56
  crypto_generichash_blake2b_BYTES_MAX);
53
57
  for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
54
- printf("%02x", (unsigned int)out[j]);
58
+ printf("%02x", (unsigned int) out[j]);
55
59
  }
56
60
  printf("\n");
57
61
 
@@ -63,7 +67,7 @@ int main(void)
63
67
  crypto_generichash_blake2b_final(&st, out,
64
68
  crypto_generichash_blake2b_BYTES_MAX);
65
69
  for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
66
- printf("%02x", (unsigned int)out[j]);
70
+ printf("%02x", (unsigned int) out[j]);
67
71
  }
68
72
  printf("\n");
69
73
 
@@ -77,7 +81,7 @@ int main(void)
77
81
  crypto_generichash_blake2b_final(
78
82
  &st, out, crypto_generichash_blake2b_BYTES_MAX);
79
83
  for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
80
- printf("%02x", (unsigned int)out[j]);
84
+ printf("%02x", (unsigned int) out[j]);
81
85
  }
82
86
  printf("\n");
83
87
 
@@ -86,7 +90,7 @@ int main(void)
86
90
  out, crypto_generichash_blake2b_BYTES_MAX, in, MAXLEN,
87
91
  k, 0U, salt, personal);
88
92
  for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
89
- printf("%02x", (unsigned int)out[j]);
93
+ printf("%02x", (unsigned int) out[j]);
90
94
  }
91
95
  printf("\n");
92
96
 
@@ -95,7 +99,7 @@ int main(void)
95
99
  out, crypto_generichash_blake2b_BYTES_MAX, in, MAXLEN,
96
100
  NULL, crypto_generichash_blake2b_KEYBYTES_MAX, salt, personal);
97
101
  for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
98
- printf("%02x", (unsigned int)out[j]);
102
+ printf("%02x", (unsigned int) out[j]);
99
103
  }
100
104
  printf("\n");
101
105
 
@@ -104,7 +108,7 @@ int main(void)
104
108
  out, crypto_generichash_blake2b_BYTES_MAX, in, MAXLEN,
105
109
  k, crypto_generichash_blake2b_KEYBYTES_MAX, salt, personal);
106
110
  for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
107
- printf("%02x", (unsigned int)out[j]);
111
+ printf("%02x", (unsigned int) out[j]);
108
112
  }
109
113
  printf("\n");
110
114
 
@@ -113,7 +117,7 @@ int main(void)
113
117
  out, crypto_generichash_blake2b_BYTES_MAX, in, MAXLEN,
114
118
  k, crypto_generichash_blake2b_KEYBYTES_MAX, NULL, personal);
115
119
  for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
116
- printf("%02x", (unsigned int)out[j]);
120
+ printf("%02x", (unsigned int) out[j]);
117
121
  }
118
122
  printf("\n");
119
123
 
@@ -122,7 +126,7 @@ int main(void)
122
126
  out, crypto_generichash_blake2b_BYTES_MAX, in, MAXLEN,
123
127
  k, crypto_generichash_blake2b_KEYBYTES_MAX, salt, NULL);
124
128
  for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
125
- printf("%02x", (unsigned int)out[j]);
129
+ printf("%02x", (unsigned int) out[j]);
126
130
  }
127
131
  printf("\n");
128
132
 
@@ -131,7 +135,7 @@ int main(void)
131
135
  crypto_generichash_blake2b_update(&st, in, MAXLEN);
132
136
  crypto_generichash_blake2b_final(&st, out, crypto_generichash_blake2b_BYTES_MAX);
133
137
  for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
134
- printf("%02x", (unsigned int)out[j]);
138
+ printf("%02x", (unsigned int) out[j]);
135
139
  }
136
140
  printf("\n");
137
141
 
@@ -140,7 +144,7 @@ int main(void)
140
144
  crypto_generichash_blake2b_update(&st, in, MAXLEN);
141
145
  crypto_generichash_blake2b_final(&st, out, crypto_generichash_blake2b_BYTES_MAX);
142
146
  for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
143
- printf("%02x", (unsigned int)out[j]);
147
+ printf("%02x", (unsigned int) out[j]);
144
148
  }
145
149
  printf("\n");
146
150
 
@@ -5,12 +5,12 @@
5
5
  static void tv(void)
6
6
  {
7
7
  static struct {
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;
8
+ const char *passwd_hex;
9
+ size_t passwdlen;
10
+ const char *salt_hex;
11
+ size_t outlen;
12
+ unsigned long long opslimit;
13
+ size_t memlimit;
14
14
  } tests[] = {
15
15
  { "a347ae92bce9f80f6f595a4480fc9c2fe7e7d7148d371e9487d75f5c23008ffae0"
16
16
  "65577a928febd9b1973a5a95073acdbeb6a030cfc0d79caa2dc5cd011cef02c08d"
@@ -85,21 +85,22 @@ static void tv(void)
85
85
  "3d968b2752b8838431165059319f3ff8910b7b8ecb54ea01d3f54769e9d98daf",
86
86
  167, 717248, 10784179 },
87
87
  };
88
- char passwd[256];
88
+ char passwd[256];
89
89
  unsigned char salt[crypto_pwhash_scryptsalsa208sha256_SALTBYTES];
90
90
  unsigned char out[256];
91
- char out_hex[256 * 2 + 1];
92
- size_t i = 0U;
91
+ char out_hex[256 * 2 + 1];
92
+ size_t i = 0U;
93
93
 
94
94
  do {
95
- sodium_hex2bin((unsigned char *)passwd, sizeof passwd,
95
+ sodium_hex2bin((unsigned char *) passwd, sizeof passwd,
96
96
  tests[i].passwd_hex, strlen(tests[i].passwd_hex), NULL,
97
97
  NULL, NULL);
98
98
  sodium_hex2bin(salt, sizeof salt, tests[i].salt_hex,
99
99
  strlen(tests[i].salt_hex), NULL, NULL, NULL);
100
100
  if (crypto_pwhash_scryptsalsa208sha256(
101
- out, tests[i].outlen, passwd, tests[i].passwdlen,
102
- (const unsigned char *)salt, tests[i].opslimit,
101
+ out, (unsigned long long) tests[i].outlen,
102
+ passwd, tests[i].passwdlen,
103
+ (const unsigned char *) salt, tests[i].opslimit,
103
104
  tests[i].memlimit) != 0) {
104
105
  printf("pwhash failure\n");
105
106
  }
@@ -111,12 +112,12 @@ static void tv(void)
111
112
  static void tv2(void)
112
113
  {
113
114
  static struct {
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;
115
+ const char *passwd_hex;
116
+ size_t passwdlen;
117
+ const char *salt_hex;
118
+ size_t outlen;
119
+ unsigned long long opslimit;
120
+ size_t memlimit;
120
121
  } tests[] = {
121
122
  { "a347ae92bce9f80f6f595a4480fc9c2fe7e7d7148d371e9487d75f5c23008ffae0"
122
123
  "65577a928febd9b1973a5a95073acdbeb6a030cfc0d79caa2dc5cd011cef02c08d"
@@ -133,11 +134,11 @@ static void tv2(void)
133
134
  "5541fbc995d5c197ba290346d2c559dedf405cf97e5f95482143202f9e74f5c2",
134
135
  155, 32768, 1397645 },
135
136
  };
136
- char passwd[256];
137
+ char passwd[256];
137
138
  unsigned char salt[crypto_pwhash_scryptsalsa208sha256_SALTBYTES];
138
139
  unsigned char out[256];
139
- char out_hex[256 * 2 + 1];
140
- size_t i = 0U;
140
+ char out_hex[256 * 2 + 1];
141
+ size_t i = 0U;
141
142
 
142
143
  do {
143
144
  sodium_hex2bin((unsigned char *)passwd, sizeof passwd,
@@ -146,8 +147,9 @@ static void tv2(void)
146
147
  sodium_hex2bin(salt, sizeof salt, tests[i].salt_hex,
147
148
  strlen(tests[i].salt_hex), NULL, NULL, NULL);
148
149
  if (crypto_pwhash_scryptsalsa208sha256(
149
- out, tests[i].outlen, passwd, tests[i].passwdlen,
150
- (const unsigned char *)salt, tests[i].opslimit,
150
+ out, (unsigned long long) tests[i].outlen,
151
+ passwd, tests[i].passwdlen,
152
+ (const unsigned char *) salt, tests[i].opslimit,
151
153
  tests[i].memlimit) != 0) {
152
154
  printf("pwhash failure\n");
153
155
  }
@@ -283,13 +285,10 @@ static void tv3(void)
283
285
 
284
286
  int main(void)
285
287
  {
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];
288
+ char str_out[crypto_pwhash_scryptsalsa208sha256_STRBYTES];
289
+ char str_out2[crypto_pwhash_scryptsalsa208sha256_STRBYTES];
290
290
  const char *salt = "[<~A 32-bytes salt for scrypt~>]";
291
291
  const char *passwd = "Correct Horse Battery Staple";
292
- size_t i;
293
292
 
294
293
  tv();
295
294
  tv2();
@@ -2,12 +2,12 @@
2
2
  #define TEST_NAME "scalarmult6"
3
3
  #include "cmptest.h"
4
4
 
5
- unsigned char bobsk[32]
5
+ unsigned char bobsk_[crypto_scalarmult_SCALARBYTES]
6
6
  = { 0x5d, 0xab, 0x08, 0x7e, 0x62, 0x4a, 0x8a, 0x4b, 0x79, 0xe1, 0x7f,
7
7
  0x8b, 0x83, 0x80, 0x0e, 0xe6, 0x6f, 0x3b, 0xb1, 0x29, 0x26, 0x18,
8
8
  0xb6, 0xfd, 0x1c, 0x2f, 0x8b, 0x27, 0xff, 0x88, 0xe0, 0xeb };
9
9
 
10
- unsigned char alicepk[32]
10
+ unsigned char alicepk_[crypto_scalarmult_SCALARBYTES]
11
11
  = { 0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 0x74, 0x8b, 0x7d,
12
12
  0xdc, 0xb4, 0x3e, 0xf7, 0x5a, 0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38,
13
13
  0x1a, 0xf4, 0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a };
@@ -16,10 +16,24 @@ unsigned char k[32];
16
16
 
17
17
  int main(void)
18
18
  {
19
- int i;
19
+ unsigned char *k;
20
+ unsigned char *bobsk;
21
+ unsigned char *alicepk;
22
+ int i;
23
+
24
+ k = (unsigned char *) sodium_malloc(crypto_scalarmult_BYTES);
25
+ bobsk = (unsigned char *) sodium_malloc(crypto_scalarmult_SCALARBYTES);
26
+ alicepk = (unsigned char *) sodium_malloc(crypto_scalarmult_SCALARBYTES);
27
+ assert(k != NULL && bobsk != NULL && alicepk != NULL);
28
+
29
+ memcpy(bobsk, bobsk_, crypto_scalarmult_SCALARBYTES);
30
+ memcpy(alicepk, alicepk_, crypto_scalarmult_SCALARBYTES);
20
31
 
21
32
  crypto_scalarmult(k, bobsk, alicepk);
22
33
 
34
+ sodium_free(alicepk);
35
+ sodium_free(bobsk);
36
+
23
37
  for (i = 0; i < 32; ++i) {
24
38
  if (i > 0) {
25
39
  printf(",");
@@ -31,5 +45,7 @@ int main(void)
31
45
  printf("\n");
32
46
  }
33
47
  }
48
+ sodium_free(k);
49
+
34
50
  return 0;
35
51
  }
@@ -11,27 +11,43 @@ unsigned char mac[crypto_secretbox_MACBYTES];
11
11
 
12
12
  int main(void)
13
13
  {
14
- unsigned long long mlen;
15
- unsigned long long i;
14
+ size_t mlen;
15
+ size_t i;
16
16
 
17
17
  randombytes_buf(k, sizeof k);
18
- mlen = (unsigned long long)randombytes_uniform((uint32_t)sizeof m);
19
- randombytes_buf(m, mlen);
18
+ mlen = (size_t) randombytes_uniform((uint32_t) sizeof m);
19
+ randombytes_buf(m, (unsigned long long) mlen);
20
20
  randombytes_buf(nonce, sizeof nonce);
21
- crypto_secretbox_easy(c, m, mlen, nonce, k);
22
- crypto_secretbox_open_easy(m2, c, mlen + crypto_secretbox_MACBYTES, nonce,
23
- k);
21
+ crypto_secretbox_easy(c, m, (unsigned long long) mlen, nonce, k);
22
+ crypto_secretbox_open_easy(m2, c,
23
+ (unsigned long long) mlen + crypto_secretbox_MACBYTES,
24
+ nonce, k);
24
25
  printf("%d\n", memcmp(m, m2, mlen));
25
26
 
26
27
  for (i = 0; i < mlen + crypto_secretbox_MACBYTES - 1; i++) {
27
- if (crypto_secretbox_open_easy(m2, c, i, nonce, k) == 0) {
28
- printf("short open() should have failed");
28
+ if (crypto_secretbox_open_easy(m2, c, (unsigned long long) i,
29
+ nonce, k) == 0) {
30
+ printf("short open() should have failed\n");
29
31
  return 1;
30
32
  }
31
33
  }
32
- crypto_secretbox_detached(c, mac, m, mlen, nonce, k);
33
- crypto_secretbox_open_detached(m2, c, mac, mlen, nonce, k);
34
+ crypto_secretbox_detached(c, mac, m, (unsigned long long) mlen, nonce, k);
35
+ if (crypto_secretbox_open_detached(m2, c, mac, (unsigned long long) mlen,
36
+ nonce, k) != 0) {
37
+ printf("crypto_secretbox_open_detached() failed\n");
38
+ }
34
39
  printf("%d\n", memcmp(m, m2, mlen));
35
40
 
41
+ memcpy(c, m, mlen);
42
+ crypto_secretbox_easy(c, c, (unsigned long long) mlen, nonce, k);
43
+ printf("%d\n", memcmp(m, c, mlen) == 0);
44
+ printf("%d\n", memcmp(m, c + crypto_secretbox_MACBYTES, mlen) == 0);
45
+ if (crypto_secretbox_open_easy(c, c,
46
+ (unsigned long long) mlen + crypto_secretbox_MACBYTES,
47
+ nonce, k) != 0) {
48
+ printf("crypto_secretbox_open_easy() failed\n");
49
+ }
50
+ printf("%d\n", memcmp(m, c, mlen));
51
+
36
52
  return 0;
37
53
  }
@@ -1,2 +1,5 @@
1
1
  0
2
2
  0
3
+ 0
4
+ 0
5
+ 0
@@ -2,21 +2,26 @@
2
2
  #define TEST_NAME "shorthash"
3
3
  #include "cmptest.h"
4
4
 
5
+ #define MAXLEN 64
6
+
5
7
  int main(void)
6
8
  {
7
- #define MAXLEN 64
8
- unsigned char in[MAXLEN], out[crypto_shorthash_BYTES],
9
- k[crypto_shorthash_KEYBYTES];
10
- size_t i, j;
9
+ unsigned char in[MAXLEN];
10
+ unsigned char out[crypto_shorthash_BYTES];
11
+ unsigned char k[crypto_shorthash_KEYBYTES];
12
+ size_t i;
13
+ size_t j;
11
14
 
12
- for (i = 0; i < crypto_shorthash_KEYBYTES; ++i)
13
- k[i] = i;
15
+ for (i = 0; i < crypto_shorthash_KEYBYTES; ++i) {
16
+ k[i] = (unsigned char) i;
17
+ }
14
18
 
15
19
  for (i = 0; i < MAXLEN; ++i) {
16
- in[i] = i;
17
- crypto_shorthash(out, in, i, k);
18
- for (j = 0; j < crypto_shorthash_BYTES; ++j)
19
- printf("%02x", (unsigned int)out[j]);
20
+ in[i] = (unsigned char) i;
21
+ crypto_shorthash(out, in, (unsigned long long) i, k);
22
+ for (j = 0; j < crypto_shorthash_BYTES; ++j) {
23
+ printf("%02x", (unsigned int) out[j]);
24
+ }
20
25
  printf("\n");
21
26
  }
22
27
  assert(crypto_shorthash_bytes() > 0);