rbnacl-libsodium 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/rbnacl/libsodium/version.rb +1 -1
- data/vendor/libsodium/ChangeLog +20 -1
- data/vendor/libsodium/Makefile.in +39 -27
- data/vendor/libsodium/README.markdown +2 -2
- data/vendor/libsodium/THANKS +2 -0
- data/vendor/libsodium/aclocal.m4 +36 -33
- data/vendor/libsodium/autom4te.cache/output.1 +1118 -841
- data/vendor/libsodium/autom4te.cache/output.4 +17517 -0
- data/vendor/libsodium/autom4te.cache/requests +760 -531
- data/vendor/libsodium/autom4te.cache/traces.1 +13 -14
- data/vendor/libsodium/autom4te.cache/traces.4 +2951 -0
- data/vendor/libsodium/build-aux/compile +1 -1
- data/vendor/libsodium/build-aux/config.guess +13 -160
- data/vendor/libsodium/build-aux/config.sub +25 -11
- data/vendor/libsodium/build-aux/depcomp +1 -1
- data/vendor/libsodium/build-aux/install-sh +170 -196
- data/vendor/libsodium/build-aux/ltmain.sh +3459 -2026
- data/vendor/libsodium/build-aux/missing +1 -1
- data/vendor/libsodium/build-aux/test-driver +12 -3
- data/vendor/libsodium/builds/msvc/version.h +2 -2
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +1 -4
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +3 -8
- data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj +11 -2
- data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj.filters +11 -2
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +2 -5
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +3 -8
- data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj +11 -2
- data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj.filters +11 -2
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +1 -4
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +3 -8
- data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj +11 -2
- data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj.filters +11 -2
- data/vendor/libsodium/builds/msvc/vs2015/libsodium.import.props +52 -0
- data/vendor/libsodium/{packaging/nuget/package.xml → builds/msvc/vs2015/libsodium.import.xml} +2 -7
- data/vendor/libsodium/builds/msvc/vs2015/libsodium.sln +81 -0
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.props +43 -0
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +352 -0
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +1073 -0
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.xml +15 -0
- data/vendor/libsodium/builds/msvc/vs2015/test/test.props +43 -0
- data/vendor/libsodium/builds/msvc/vs2015/test/test.runner.bat +78 -0
- data/vendor/libsodium/builds/msvc/vs2015/test/test.vcxproj +241 -0
- data/vendor/libsodium/builds/msvc/vs2015/test/test.vcxproj.filters +189 -0
- data/vendor/libsodium/configure +1117 -840
- data/vendor/libsodium/configure.ac +4 -4
- data/vendor/libsodium/dist-build/Makefile.am +2 -2
- data/vendor/libsodium/dist-build/Makefile.in +19 -7
- data/vendor/libsodium/dist-build/android-arm.sh +3 -2
- data/vendor/libsodium/dist-build/android-armv7-a.sh +4 -0
- data/vendor/libsodium/dist-build/android-build.sh +4 -5
- data/vendor/libsodium/dist-build/android-mips32.sh +4 -0
- data/vendor/libsodium/dist-build/android-x86.sh +3 -2
- data/vendor/libsodium/dist-build/emscripten.sh +4 -5
- data/vendor/libsodium/dist-build/ios.sh +56 -25
- data/vendor/libsodium/dist-build/osx.sh +20 -0
- data/vendor/libsodium/libsodium.vcxproj +1 -0
- data/vendor/libsodium/libsodium.vcxproj.filters +3 -0
- data/vendor/libsodium/m4/libtool.m4 +1366 -1030
- data/vendor/libsodium/m4/ltoptions.m4 +90 -37
- data/vendor/libsodium/m4/ltsugar.m4 +4 -3
- data/vendor/libsodium/m4/ltversion.m4 +6 -6
- data/vendor/libsodium/m4/lt~obsolete.m4 +4 -3
- data/vendor/libsodium/msvc-scripts/Makefile.in +17 -5
- data/vendor/libsodium/msvc-scripts/process.bat +2 -2
- data/vendor/libsodium/packaging/nuget/package.config +1 -1
- data/vendor/libsodium/src/Makefile.in +17 -5
- data/vendor/libsodium/src/libsodium/Makefile.am +7 -2
- data/vendor/libsodium/src/libsodium/Makefile.in +83 -55
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/auth_hmacsha256_api.c +5 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/cp/verify_hmacsha256.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/auth_hmacsha512_api.c +5 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/verify_hmacsha512.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/auth_hmacsha512256_api.c +5 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/verify_hmacsha512256.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_seal.c +67 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/crypto_generichash.c +8 -1
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/hash_sha256_api.c +5 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/hash_sha512_api.c +5 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/crypto_onetimeauth.c +12 -6
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +11 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c +60 -25
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +12 -12
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/smult_curve25519_donna_c64.c +11 -3
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sign.c +1 -4
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/api.h +1 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c +13 -3
- data/vendor/libsodium/src/libsodium/include/Makefile.in +18 -6
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha256.h +9 -5
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512.h +9 -5
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512256.h +6 -2
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_box.h +15 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash.h +2 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h +1 -1
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha256.h +2 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha512.h +2 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth.h +2 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_xsalsa20.h +6 -0
- data/vendor/libsodium/src/libsodium/include/sodium/randombytes.h +6 -6
- data/vendor/libsodium/src/libsodium/include/sodium/utils.h +2 -2
- data/vendor/libsodium/src/libsodium/randombytes/randombytes.c +82 -3
- data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +85 -33
- data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +80 -42
- data/vendor/libsodium/src/libsodium/sodium/utils.c +16 -13
- data/vendor/libsodium/test/Makefile.am +1 -1
- data/vendor/libsodium/test/Makefile.in +18 -6
- data/vendor/libsodium/test/default/Makefile.am +9 -3
- data/vendor/libsodium/test/default/Makefile.in +72 -38
- data/vendor/libsodium/test/default/auth.c +8 -0
- data/vendor/libsodium/test/default/auth5.c +0 -2
- data/vendor/libsodium/test/default/auth7.c +0 -2
- data/vendor/libsodium/test/default/box8.c +0 -2
- data/vendor/libsodium/test/default/box_easy2.c +1 -1
- data/vendor/libsodium/test/default/box_seal.c +43 -0
- data/vendor/libsodium/test/default/box_seal.exp +4 -0
- data/vendor/libsodium/test/default/cmptest.h +1 -0
- data/vendor/libsodium/test/default/generichash2.c +1 -0
- data/vendor/libsodium/test/default/hash.c +2 -0
- data/vendor/libsodium/test/default/onetimeauth.c +1 -0
- data/vendor/libsodium/test/default/onetimeauth7.c +0 -2
- data/vendor/libsodium/test/default/pre.js.inc +0 -27
- data/vendor/libsodium/test/default/pwhash.c +18 -5
- data/vendor/libsodium/test/default/randombytes.c +44 -2
- data/vendor/libsodium/test/default/secretbox8.c +0 -2
- data/vendor/libsodium/test/default/sodium_utils2.c +5 -1
- data/vendor/libsodium/test/default/sodium_utils3.c +1 -1
- data/vendor/libsodium/test/default/stream.c +13 -1
- data/vendor/libsodium/test/default/stream.exp +1 -0
- data/vendor/libsodium/test/default/stream2.c +13 -1
- data/vendor/libsodium/test/default/stream2.exp +1 -0
- data/vendor/libsodium/test/quirks/quirks.h +26 -0
- metadata +23 -12
- data/vendor/libsodium/builds/msvc/resource.h +0 -0
- data/vendor/libsodium/builds/msvc/resource.rc +0 -0
- data/vendor/libsodium/dist-build/android-armv7.sh +0 -3
- data/vendor/libsodium/dist-build/android-mips.sh +0 -3
- data/vendor/libsodium/packaging/nuget/package.nuspec +0 -95
- data/vendor/libsodium/packaging/nuget/package.targets +0 -128
- data/vendor/libsodium/test/quirks/windows/windows-quirks.h +0 -18
@@ -17,6 +17,8 @@ int main(void)
|
|
17
17
|
crypto_auth_hmacsha512_state st;
|
18
18
|
int i;
|
19
19
|
|
20
|
+
assert(crypto_auth_hmacsha512_statebytes() ==
|
21
|
+
sizeof(crypto_auth_hmacsha512_state));
|
20
22
|
crypto_auth(a, c, sizeof c - 1U, key);
|
21
23
|
for (i = 0; i < sizeof a; ++i) {
|
22
24
|
printf(",0x%02x", (unsigned int)a[i]);
|
@@ -55,6 +57,12 @@ int main(void)
|
|
55
57
|
assert(crypto_auth_hmacsha512_keybytes() > 0U);
|
56
58
|
assert(crypto_auth_hmacsha512256_bytes() == crypto_auth_bytes());
|
57
59
|
assert(crypto_auth_hmacsha512256_keybytes() == crypto_auth_keybytes());
|
60
|
+
assert(crypto_auth_hmacsha512256_statebytes() >=
|
61
|
+
crypto_auth_hmacsha512256_keybytes());
|
62
|
+
assert(crypto_auth_hmacsha256_statebytes() ==
|
63
|
+
sizeof(crypto_auth_hmacsha256_state));
|
64
|
+
assert(crypto_auth_hmacsha512_statebytes() ==
|
65
|
+
sizeof(crypto_auth_hmacsha512_state));
|
58
66
|
|
59
67
|
return 0;
|
60
68
|
}
|
@@ -31,7 +31,7 @@ int main(void)
|
|
31
31
|
crypto_box_keypair(bobpk, bobsk);
|
32
32
|
mlen = (size_t) randombytes_uniform((uint32_t)sizeof m);
|
33
33
|
randombytes_buf(m, mlen);
|
34
|
-
randombytes_buf(nonce,
|
34
|
+
randombytes_buf(nonce, crypto_box_NONCEBYTES);
|
35
35
|
crypto_box_easy(c, m, mlen, nonce, bobpk, alicesk);
|
36
36
|
if (crypto_box_open_easy(m2, c,
|
37
37
|
(unsigned long long) mlen + crypto_box_MACBYTES,
|
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
#define TEST_NAME "box_seal"
|
3
|
+
#include "cmptest.h"
|
4
|
+
|
5
|
+
int main(void)
|
6
|
+
{
|
7
|
+
unsigned char pk[crypto_box_PUBLICKEYBYTES];
|
8
|
+
unsigned char sk[crypto_box_SECRETKEYBYTES];
|
9
|
+
unsigned char *c;
|
10
|
+
unsigned char *m;
|
11
|
+
unsigned char *m2;
|
12
|
+
size_t m_len;
|
13
|
+
size_t c_len;
|
14
|
+
|
15
|
+
crypto_box_keypair(pk, sk);
|
16
|
+
m_len = (size_t) randombytes_uniform(1000);
|
17
|
+
c_len = crypto_box_SEALBYTES + m_len;
|
18
|
+
m = (unsigned char *) sodium_malloc(m_len);
|
19
|
+
m2 = (unsigned char *) sodium_malloc(m_len);
|
20
|
+
c = (unsigned char *) sodium_malloc(c_len);
|
21
|
+
randombytes_buf(m, m_len);
|
22
|
+
if (crypto_box_seal(c, m, m_len, pk) != 0) {
|
23
|
+
printf("crypto_box_seal() failure\n");
|
24
|
+
return 1;
|
25
|
+
}
|
26
|
+
if (crypto_box_seal_open(m2, c, c_len, pk, sk) != 0) {
|
27
|
+
printf("crypto_box_seal_open() failure\n");
|
28
|
+
return 1;
|
29
|
+
}
|
30
|
+
printf("%d\n", memcmp(m, m2, m_len));
|
31
|
+
|
32
|
+
printf("%d\n", crypto_box_seal_open(m, c, 0U, pk, sk));
|
33
|
+
printf("%d\n", crypto_box_seal_open(m, c, c_len - 1U, pk, sk));
|
34
|
+
printf("%d\n", crypto_box_seal_open(m, c, c_len, sk, pk));
|
35
|
+
|
36
|
+
sodium_free(c);
|
37
|
+
sodium_free(m);
|
38
|
+
sodium_free(m2);
|
39
|
+
|
40
|
+
assert(crypto_box_sealbytes() == crypto_box_SEALBYTES);
|
41
|
+
|
42
|
+
return 0;
|
43
|
+
}
|
@@ -36,6 +36,8 @@ int main(void)
|
|
36
36
|
assert(crypto_hash_sha256_bytes() > 0U);
|
37
37
|
assert(crypto_hash_sha512_bytes() >= crypto_hash_sha256_bytes());
|
38
38
|
assert(crypto_hash_sha512_bytes() == crypto_hash_bytes());
|
39
|
+
assert(crypto_hash_sha256_statebytes() == sizeof(crypto_hash_sha256_state));
|
40
|
+
assert(crypto_hash_sha512_statebytes() == sizeof(crypto_hash_sha512_state));
|
39
41
|
|
40
42
|
return 0;
|
41
43
|
}
|
@@ -6,34 +6,7 @@ try {
|
|
6
6
|
}
|
7
7
|
Module['preRun'] = Module['preRun'] || [];
|
8
8
|
Module['preRun'].push(function(){
|
9
|
-
var randombyte = null;
|
10
|
-
try {
|
11
|
-
function randombyte_standard() {
|
12
|
-
var buf = new Int8Array(1);
|
13
|
-
window.crypto.getRandomValues(buf);
|
14
|
-
return buf[0];
|
15
|
-
}
|
16
|
-
randombyte_standard();
|
17
|
-
randombyte = randombyte_standard;
|
18
|
-
} catch (e) {
|
19
|
-
try {
|
20
|
-
var crypto = require('crypto');
|
21
|
-
function randombyte_node() {
|
22
|
-
return crypto.randomBytes(1)[0];
|
23
|
-
}
|
24
|
-
randombyte_node();
|
25
|
-
randombyte = randombyte_node;
|
26
|
-
} catch(e) {
|
27
|
-
throw 'No secure random number generator found';
|
28
|
-
}
|
29
|
-
}
|
30
9
|
FS.init();
|
31
10
|
FS.mkdir('/test-data');
|
32
11
|
FS.mount(NODEFS, { root: '.' }, '/test-data');
|
33
|
-
FS.analyzePath('/dev/random').exists && FS.unlink('/dev/random');
|
34
|
-
FS.analyzePath('/dev/urandom') && FS.unlink('/dev/urandom');
|
35
|
-
var devFolder = FS.findObject('/dev') ||
|
36
|
-
Module['FS_createFolder']('/', 'dev', true, true);
|
37
|
-
Module['FS_createDevice'](devFolder, 'random', randombyte);
|
38
|
-
Module['FS_createDevice'](devFolder, 'urandom', randombyte);
|
39
12
|
});
|
@@ -276,8 +276,8 @@ static void tv3(void)
|
|
276
276
|
passwd = (char *) sodium_malloc(strlen(tests[i].passwd) + 1U);
|
277
277
|
assert(passwd != NULL);
|
278
278
|
memcpy(passwd, tests[i].passwd, strlen(tests[i].passwd) + 1U);
|
279
|
-
if (crypto_pwhash_scryptsalsa208sha256_str_verify
|
280
|
-
|
279
|
+
if (crypto_pwhash_scryptsalsa208sha256_str_verify
|
280
|
+
(out, passwd, strlen(passwd)) != 0) {
|
281
281
|
printf("pwhash_str failure: [%u]\n", (unsigned int)i);
|
282
282
|
}
|
283
283
|
sodium_free(out);
|
@@ -287,14 +287,22 @@ static void tv3(void)
|
|
287
287
|
|
288
288
|
int main(void)
|
289
289
|
{
|
290
|
-
char
|
291
|
-
char
|
292
|
-
|
290
|
+
char *str_out;
|
291
|
+
char *str_out2;
|
292
|
+
char *salt;
|
293
293
|
const char *passwd = "Correct Horse Battery Staple";
|
294
294
|
|
295
295
|
tv();
|
296
296
|
tv2();
|
297
297
|
tv3();
|
298
|
+
salt = (char *)
|
299
|
+
sodium_malloc(crypto_pwhash_scryptsalsa208sha256_SALTBYTES);
|
300
|
+
str_out = (char *)
|
301
|
+
sodium_malloc(crypto_pwhash_scryptsalsa208sha256_STRBYTES);
|
302
|
+
str_out2 = (char *)
|
303
|
+
sodium_malloc(crypto_pwhash_scryptsalsa208sha256_STRBYTES);
|
304
|
+
memcpy(salt, "[<~A 32-bytes salt for scrypt~>]",
|
305
|
+
crypto_pwhash_scryptsalsa208sha256_SALTBYTES);
|
298
306
|
if (crypto_pwhash_scryptsalsa208sha256_str(str_out, passwd, strlen(passwd),
|
299
307
|
OPSLIMIT, MEMLIMIT) != 0) {
|
300
308
|
printf("pwhash_str failure\n");
|
@@ -321,6 +329,7 @@ int main(void)
|
|
321
329
|
}
|
322
330
|
str_out[14]--;
|
323
331
|
|
332
|
+
assert(str_out[crypto_pwhash_scryptsalsa208sha256_STRBYTES - 1U] == 0);
|
324
333
|
assert(crypto_pwhash_scryptsalsa208sha256_saltbytes() > 0U);
|
325
334
|
assert(crypto_pwhash_scryptsalsa208sha256_strbytes() > 1U);
|
326
335
|
assert(crypto_pwhash_scryptsalsa208sha256_strbytes() >
|
@@ -330,6 +339,10 @@ int main(void)
|
|
330
339
|
assert(crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive() > 0U);
|
331
340
|
assert(crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive() > 0U);
|
332
341
|
|
342
|
+
sodium_free(salt);
|
343
|
+
sodium_free(str_out);
|
344
|
+
sodium_free(str_out2);
|
345
|
+
|
333
346
|
printf("OK\n");
|
334
347
|
|
335
348
|
return 0;
|
@@ -27,11 +27,24 @@ static int compat_tests(void)
|
|
27
27
|
|
28
28
|
static int randombytes_tests(void)
|
29
29
|
{
|
30
|
+
unsigned int f = 0U;
|
30
31
|
unsigned int i;
|
32
|
+
uint32_t n;
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
+
#ifdef __EMSCRIPTEN__
|
35
|
+
assert(strcmp(randombytes_implementation_name(), "sysrandom"));
|
36
|
+
#else
|
37
|
+
assert(strcmp(randombytes_implementation_name(), "js"));
|
38
|
+
#endif
|
34
39
|
randombytes(x, 1U);
|
40
|
+
do {
|
41
|
+
n = randombytes_random();
|
42
|
+
f |= ((n >> 24) > 1);
|
43
|
+
f |= ((n >> 16) > 1) << 1;
|
44
|
+
f |= ((n >> 8) > 1) << 2;
|
45
|
+
f |= ((n ) > 1) << 3;
|
46
|
+
f |= (n > 0x7fffffff) << 4;
|
47
|
+
} while (f != 0x1f);
|
35
48
|
randombytes_close();
|
36
49
|
|
37
50
|
for (i = 0; i < 256; ++i) {
|
@@ -47,8 +60,10 @@ static int randombytes_tests(void)
|
|
47
60
|
}
|
48
61
|
assert(randombytes_uniform(1U) == 0U);
|
49
62
|
randombytes_close();
|
63
|
+
#ifndef __EMSCRIPTEN__
|
50
64
|
randombytes_set_implementation(&randombytes_salsa20_implementation);
|
51
65
|
assert(strcmp(randombytes_implementation_name(), "salsa20") == 0);
|
66
|
+
#endif
|
52
67
|
randombytes_stir();
|
53
68
|
for (i = 0; i < 256; ++i) {
|
54
69
|
freq[i] = 0;
|
@@ -83,10 +98,37 @@ static int randombytes_tests(void)
|
|
83
98
|
return 0;
|
84
99
|
}
|
85
100
|
|
101
|
+
static uint32_t randombytes_uniform_impl(const uint32_t upper_bound)
|
102
|
+
{
|
103
|
+
return upper_bound;
|
104
|
+
}
|
105
|
+
|
106
|
+
static int impl_tests(void)
|
107
|
+
{
|
108
|
+
randombytes_implementation impl = randombytes_sysrandom_implementation;
|
109
|
+
uint32_t v = randombytes_random();
|
110
|
+
|
111
|
+
impl.uniform = randombytes_uniform_impl;
|
112
|
+
randombytes_close();
|
113
|
+
randombytes_set_implementation(&impl);
|
114
|
+
assert(randombytes_uniform(v) == v);
|
115
|
+
assert(randombytes_uniform(v) == v);
|
116
|
+
assert(randombytes_uniform(v) == v);
|
117
|
+
assert(randombytes_uniform(v) == v);
|
118
|
+
randombytes_close();
|
119
|
+
impl.close = NULL;
|
120
|
+
randombytes_close();
|
121
|
+
|
122
|
+
return 0;
|
123
|
+
}
|
124
|
+
|
86
125
|
int main(void)
|
87
126
|
{
|
88
127
|
compat_tests();
|
89
128
|
randombytes_tests();
|
129
|
+
#ifndef __EMSCRIPTEN__
|
130
|
+
impl_tests();
|
131
|
+
#endif
|
90
132
|
printf("OK\n");
|
91
133
|
|
92
134
|
return 0;
|
@@ -8,7 +8,7 @@
|
|
8
8
|
#include "cmptest.h"
|
9
9
|
|
10
10
|
#ifdef __SANITIZE_ADDRESS__
|
11
|
-
#
|
11
|
+
# warning The sodium_utils2 test is expected to fail with address sanitizer
|
12
12
|
#endif
|
13
13
|
|
14
14
|
static void segv_handler(int sig)
|
@@ -39,6 +39,10 @@ int main(void)
|
|
39
39
|
if (sodium_allocarray(SIZE_MAX / 2U + 1U, SIZE_MAX / 2U) != NULL) {
|
40
40
|
return 1;
|
41
41
|
}
|
42
|
+
sodium_free(sodium_allocarray(0U, 0U));
|
43
|
+
sodium_free(sodium_allocarray(0U, 1U));
|
44
|
+
sodium_free(sodium_allocarray(1U, 0U));
|
45
|
+
|
42
46
|
buf = sodium_allocarray(1000U, 50U);
|
43
47
|
memset(buf, 0, 50000U);
|
44
48
|
sodium_free(buf);
|
@@ -19,13 +19,25 @@ int main(void)
|
|
19
19
|
{
|
20
20
|
int i;
|
21
21
|
|
22
|
-
crypto_stream(output,
|
22
|
+
crypto_stream(output, sizeof output, nonce, firstkey);
|
23
23
|
crypto_hash_sha256(h, output, sizeof output);
|
24
24
|
|
25
25
|
for (i = 0; i < 32; ++i)
|
26
26
|
printf("%02x", h[i]);
|
27
27
|
printf("\n");
|
28
28
|
|
29
|
+
assert(sizeof output > 4000);
|
30
|
+
|
31
|
+
crypto_stream_xsalsa20_xor_ic(output, output, 4000, nonce, 0U, firstkey);
|
32
|
+
for (i = 0; i < 4000; ++i)
|
33
|
+
assert(output[i] == 0);
|
34
|
+
|
35
|
+
crypto_stream_xsalsa20_xor_ic(output, output, 4000, nonce, 1U, firstkey);
|
36
|
+
crypto_hash_sha256(h, output, sizeof output);
|
37
|
+
for (i = 0; i < 32; ++i)
|
38
|
+
printf("%02x", h[i]);
|
39
|
+
printf("\n");
|
40
|
+
|
29
41
|
assert(crypto_stream_keybytes() > 0U);
|
30
42
|
assert(crypto_stream_noncebytes() > 0U);
|
31
43
|
assert(strcmp(crypto_stream_primitive(), "xsalsa20") == 0);
|
@@ -17,7 +17,19 @@ unsigned char h[32];
|
|
17
17
|
int main(void)
|
18
18
|
{
|
19
19
|
int i;
|
20
|
-
crypto_stream_salsa20(output,
|
20
|
+
crypto_stream_salsa20(output, sizeof output, 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(sizeof output > 4000);
|
27
|
+
|
28
|
+
crypto_stream_salsa20_xor_ic(output, output, 4000, noncesuffix, 0U, secondkey);
|
29
|
+
for (i = 0; i < 4000; ++i)
|
30
|
+
assert(output[i] == 0);
|
31
|
+
|
32
|
+
crypto_stream_salsa20_xor_ic(output, output, 4000, noncesuffix, 1U, secondkey);
|
21
33
|
crypto_hash_sha256(h, output, sizeof output);
|
22
34
|
for (i = 0; i < 32; ++i)
|
23
35
|
printf("%02x", h[i]);
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
#include <stdlib.h>
|
3
|
+
|
4
|
+
#ifdef __EMSCRIPTEN__
|
5
|
+
# define strcmp(s1, s2) xstrcmp(s1, s2)
|
6
|
+
|
7
|
+
int
|
8
|
+
strcmp(const char *s1, const char *s2) {
|
9
|
+
while (*s1 == *s2++) { if (*s1++ == 0) return 0; }
|
10
|
+
return *(unsigned char *) s1 - *(unsigned char *) --s2;
|
11
|
+
}
|
12
|
+
#endif
|
13
|
+
|
14
|
+
#ifdef _WIN32
|
15
|
+
static void
|
16
|
+
srandom(unsigned seed)
|
17
|
+
{
|
18
|
+
srand(seed);
|
19
|
+
}
|
20
|
+
|
21
|
+
static long
|
22
|
+
random(void)
|
23
|
+
{
|
24
|
+
return (long) rand();
|
25
|
+
}
|
26
|
+
#endif
|