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.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/rbnacl/libsodium/version.rb +1 -1
- data/vendor/libsodium/ChangeLog +13 -0
- data/vendor/libsodium/THANKS +1 -0
- data/vendor/libsodium/autom4te.cache/output.1 +14 -90
- data/vendor/libsodium/autom4te.cache/output.3 +14 -90
- data/vendor/libsodium/autom4te.cache/requests +127 -127
- data/vendor/libsodium/autom4te.cache/traces.1 +224 -224
- data/vendor/libsodium/autom4te.cache/traces.3 +137 -144
- data/vendor/libsodium/builds/msvc/version.h +2 -2
- data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj +3 -0
- data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj.filters +3 -0
- data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj +3 -0
- data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj.filters +3 -0
- data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj +3 -0
- data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj.filters +3 -0
- data/vendor/libsodium/configure +14 -90
- data/vendor/libsodium/configure.ac +5 -12
- data/vendor/libsodium/msvc-scripts/process.bat +2 -2
- data/vendor/libsodium/packaging/nuget/package.config +1 -1
- data/vendor/libsodium/packaging/nuget/package.nuspec +25 -25
- data/vendor/libsodium/packaging/nuget/package.targets +20 -20
- data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +2 -0
- data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_easy.c +7 -0
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2-impl.h +9 -4
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +6 -1
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/generichash_blake2b.c +4 -4
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +2 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +2 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/auth_poly1305_donna.c +2 -1
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c +2 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +13 -13
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.c +28 -27
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +16 -12
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/scrypt_platform.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +3 -3
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sign.c +7 -3
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sign_edwards25519sha512batch.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c +3 -2
- data/vendor/libsodium/src/libsodium/include/sodium/randombytes.h +10 -8
- data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +13 -8
- data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +10 -8
- data/vendor/libsodium/src/libsodium/sodium/core.c +1 -1
- data/vendor/libsodium/src/libsodium/sodium/runtime.c +3 -3
- data/vendor/libsodium/src/libsodium/sodium/utils.c +12 -12
- data/vendor/libsodium/test/default/Makefile.am +9 -1
- data/vendor/libsodium/test/default/Makefile.in +35 -13
- data/vendor/libsodium/test/default/aead_chacha20poly1305.c +37 -31
- data/vendor/libsodium/test/default/auth.c +48 -9
- data/vendor/libsodium/test/default/auth.exp +18 -0
- data/vendor/libsodium/test/default/auth2.c +19 -24
- data/vendor/libsodium/test/default/auth3.c +17 -25
- data/vendor/libsodium/test/default/auth5.c +24 -24
- data/vendor/libsodium/test/default/auth6.c +9 -8
- data/vendor/libsodium/test/default/auth7.c +24 -24
- data/vendor/libsodium/test/default/box.c +74 -51
- data/vendor/libsodium/test/default/box.exp +19 -0
- data/vendor/libsodium/test/default/box2.c +48 -51
- data/vendor/libsodium/test/default/box2.exp +17 -0
- data/vendor/libsodium/test/default/box7.c +20 -18
- data/vendor/libsodium/test/default/box8.c +27 -25
- data/vendor/libsodium/test/default/box_easy.c +32 -42
- data/vendor/libsodium/test/default/box_easy2.c +3 -5
- data/vendor/libsodium/test/default/box_seed.c +20 -20
- data/vendor/libsodium/test/default/chacha20.c +41 -21
- data/vendor/libsodium/test/default/chacha20.exp +8 -5
- data/vendor/libsodium/test/default/cmptest.h +4 -0
- data/vendor/libsodium/test/default/core1.c +26 -19
- data/vendor/libsodium/test/default/core2.c +24 -23
- data/vendor/libsodium/test/default/core3.c +30 -26
- data/vendor/libsodium/test/default/core4.c +22 -23
- data/vendor/libsodium/test/default/core5.c +18 -22
- data/vendor/libsodium/test/default/core6.c +33 -34
- data/vendor/libsodium/test/default/ed25519_convert.c +16 -20
- data/vendor/libsodium/test/default/generichash.c +59 -15
- data/vendor/libsodium/test/default/generichash.exp +2 -0
- data/vendor/libsodium/test/default/generichash2.c +30 -13
- data/vendor/libsodium/test/default/generichash3.c +156 -22
- data/vendor/libsodium/test/default/generichash3.exp +11 -0
- data/vendor/libsodium/test/default/hash.c +31 -6
- data/vendor/libsodium/test/default/hash.exp +3 -0
- data/vendor/libsodium/test/default/hash3.c +10 -7
- data/vendor/libsodium/test/default/onetimeauth.c +46 -34
- data/vendor/libsodium/test/default/onetimeauth.exp +2 -0
- data/vendor/libsodium/test/default/onetimeauth2.c +20 -32
- data/vendor/libsodium/test/default/onetimeauth7.c +24 -24
- data/vendor/libsodium/test/default/pwhash.c +276 -68
- data/vendor/libsodium/test/default/pwhash.exp +20 -0
- data/vendor/libsodium/test/default/pwhash_scrypt_ll.c +31 -37
- data/vendor/libsodium/test/default/randombytes.c +85 -8
- data/vendor/libsodium/test/default/randombytes.exp +1 -0
- data/vendor/libsodium/test/default/scalarmult.c +28 -15
- data/vendor/libsodium/test/default/scalarmult2.c +20 -15
- data/vendor/libsodium/test/default/scalarmult5.c +24 -21
- data/vendor/libsodium/test/default/scalarmult6.c +24 -21
- data/vendor/libsodium/test/default/scalarmult7.c +31 -0
- data/vendor/libsodium/test/default/scalarmult7.exp +1 -0
- data/vendor/libsodium/test/default/secretbox.c +50 -45
- data/vendor/libsodium/test/default/secretbox2.c +32 -45
- data/vendor/libsodium/test/default/secretbox7.c +19 -17
- data/vendor/libsodium/test/default/secretbox8.c +26 -24
- data/vendor/libsodium/test/default/secretbox_easy.c +46 -52
- data/vendor/libsodium/test/default/secretbox_easy2.c +3 -5
- data/vendor/libsodium/test/default/shorthash.c +17 -10
- data/vendor/libsodium/test/default/sign.c +74 -39
- data/vendor/libsodium/test/default/sodium_core.c +6 -3
- data/vendor/libsodium/test/default/sodium_utils.c +57 -28
- data/vendor/libsodium/test/default/sodium_utils.exp +6 -0
- data/vendor/libsodium/test/default/sodium_utils2.c +13 -11
- data/vendor/libsodium/test/default/sodium_utils3.c +5 -10
- data/vendor/libsodium/test/default/sodium_version.c +4 -5
- data/vendor/libsodium/test/default/stream.c +23 -17
- data/vendor/libsodium/test/default/stream2.c +17 -15
- data/vendor/libsodium/test/default/stream3.c +17 -19
- data/vendor/libsodium/test/default/stream4.c +36 -45
- data/vendor/libsodium/test/default/verify1.c +20 -18
- metadata +5 -3
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2s-ref.c +0 -356
@@ -1,6 +1,3 @@
|
|
1
|
-
#include <stdio.h>
|
2
|
-
|
3
|
-
#include "crypto_uint8.h"
|
4
1
|
|
5
2
|
#define TEST_NAME "generichash"
|
6
3
|
#include "cmptest.h"
|
@@ -8,20 +5,67 @@
|
|
8
5
|
int main(void)
|
9
6
|
{
|
10
7
|
#define MAXLEN 64
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
8
|
+
unsigned char in[MAXLEN], out[crypto_generichash_BYTES_MAX],
|
9
|
+
k[crypto_generichash_KEYBYTES_MAX];
|
10
|
+
size_t h, i, j;
|
11
|
+
|
12
|
+
for (h = 0; h < crypto_generichash_KEYBYTES_MAX; ++h)
|
13
|
+
k[h] = h;
|
14
|
+
|
15
|
+
for (i = 0; i < MAXLEN; ++i) {
|
16
|
+
in[i] = i;
|
17
|
+
crypto_generichash(out, 1 + i % crypto_generichash_BYTES_MAX, in, i, k,
|
18
|
+
1 + i % crypto_generichash_KEYBYTES_MAX);
|
19
|
+
for (j = 0; j < 1 + i % crypto_generichash_BYTES_MAX; ++j) {
|
20
|
+
printf("%02x", (unsigned int)out[j]);
|
23
21
|
}
|
24
22
|
printf("\n");
|
25
23
|
}
|
24
|
+
|
25
|
+
memset(out, 0, sizeof out);
|
26
|
+
crypto_generichash(out, crypto_generichash_BYTES_MAX, in, i, k, 0U);
|
27
|
+
for (j = 0; j < crypto_generichash_BYTES_MAX; ++j) {
|
28
|
+
printf("%02x", (unsigned int)out[j]);
|
29
|
+
}
|
30
|
+
printf("\n");
|
31
|
+
|
32
|
+
memset(out, 0, sizeof out);
|
33
|
+
crypto_generichash(out, crypto_generichash_BYTES_MAX, in, i, NULL, 1U);
|
34
|
+
for (j = 0; j < crypto_generichash_BYTES_MAX; ++j) {
|
35
|
+
printf("%02x", (unsigned int)out[j]);
|
36
|
+
}
|
37
|
+
printf("\n");
|
38
|
+
|
39
|
+
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);
|
42
|
+
assert(crypto_generichash(out, sizeof out, in, sizeof in,
|
43
|
+
k, crypto_generichash_KEYBYTES_MAX + 1U) == -1);
|
44
|
+
|
45
|
+
assert(crypto_generichash_bytes_min() > 0U);
|
46
|
+
assert(crypto_generichash_bytes_max() > 0U);
|
47
|
+
assert(crypto_generichash_bytes() > 0U);
|
48
|
+
assert(crypto_generichash_bytes() >= crypto_generichash_bytes_min());
|
49
|
+
assert(crypto_generichash_bytes() <= crypto_generichash_bytes_max());
|
50
|
+
assert(crypto_generichash_keybytes_min() > 0U);
|
51
|
+
assert(crypto_generichash_keybytes_max() > 0U);
|
52
|
+
assert(crypto_generichash_keybytes() > 0U);
|
53
|
+
assert(crypto_generichash_keybytes() >= crypto_generichash_keybytes_min());
|
54
|
+
assert(crypto_generichash_keybytes() <= crypto_generichash_keybytes_max());
|
55
|
+
assert(strcmp(crypto_generichash_primitive(), "blake2b") == 0);
|
56
|
+
assert(crypto_generichash_bytes_min()
|
57
|
+
== crypto_generichash_blake2b_bytes_min());
|
58
|
+
assert(crypto_generichash_bytes_max()
|
59
|
+
== crypto_generichash_blake2b_bytes_max());
|
60
|
+
assert(crypto_generichash_bytes() == crypto_generichash_blake2b_bytes());
|
61
|
+
assert(crypto_generichash_keybytes_min()
|
62
|
+
== crypto_generichash_blake2b_keybytes_min());
|
63
|
+
assert(crypto_generichash_keybytes_max()
|
64
|
+
== crypto_generichash_blake2b_keybytes_max());
|
65
|
+
assert(crypto_generichash_keybytes()
|
66
|
+
== crypto_generichash_blake2b_keybytes());
|
67
|
+
assert(crypto_generichash_blake2b_saltbytes() > 0U);
|
68
|
+
assert(crypto_generichash_blake2b_personalbytes() > 0U);
|
69
|
+
|
26
70
|
return 0;
|
27
71
|
}
|
@@ -62,3 +62,5 @@ cc66a891768e95a2717b040c111996f14942f10f2475c33aa5f1c97476e6f8386733d6b21c16102d
|
|
62
62
|
9ff11c233aaf5e0242b0dbe6e110a42e58b86141ad0ef130fd2bb895700019782de66d435bf0a8d6f5eda5d7d1105e7a6f3ef17a9da8f9c16fc21075431a
|
63
63
|
bdd3d0fafe8ba2b29d1ac0b79aa46e249cc9d3a82d0f772d690637bbdd353722356658d00436ff5dd5239ab747979329345eb8c7ed11b7331456ae87350fcf
|
64
64
|
bd965bf31e87d70327536f2a341cebc4768eca275fa05ef98f7f1b71a0351298de006fba73fe6733ed01d75801b4a928e54231b38e38c562b2e33ea1284992fa
|
65
|
+
2fc6e69fa26a89a5ed269092cb9b2a449a4409a7a44011eecad13d7c4b0456602d402fa5844f1a7a758136ce3d5d8d0e8b86921ffff4f692dd95bdc8e5ff0052
|
66
|
+
2fc6e69fa26a89a5ed269092cb9b2a449a4409a7a44011eecad13d7c4b0456602d402fa5844f1a7a758136ce3d5d8d0e8b86921ffff4f692dd95bdc8e5ff0052
|
@@ -1,6 +1,3 @@
|
|
1
|
-
#include <stdio.h>
|
2
|
-
|
3
|
-
#include "crypto_uint8.h"
|
4
1
|
|
5
2
|
#define TEST_NAME "generichash2"
|
6
3
|
#include "cmptest.h"
|
@@ -9,23 +6,43 @@ int main(void)
|
|
9
6
|
{
|
10
7
|
#define MAXLEN 64
|
11
8
|
crypto_generichash_state st;
|
12
|
-
|
13
|
-
|
9
|
+
unsigned char in[MAXLEN], out[crypto_generichash_BYTES_MAX],
|
10
|
+
k[crypto_generichash_KEYBYTES_MAX];
|
11
|
+
size_t h, i, j;
|
14
12
|
|
15
|
-
for(h = 0; h < crypto_generichash_KEYBYTES_MAX; ++h)
|
13
|
+
for (h = 0; h < crypto_generichash_KEYBYTES_MAX; ++h)
|
14
|
+
k[h] = h;
|
16
15
|
|
17
|
-
for(i = 0; i < MAXLEN; ++i) {
|
18
|
-
in[i]=i;
|
19
|
-
crypto_generichash_init(&st, k,
|
20
|
-
|
16
|
+
for (i = 0; i < MAXLEN; ++i) {
|
17
|
+
in[i] = i;
|
18
|
+
if (crypto_generichash_init(&st, k,
|
19
|
+
1 + i % crypto_generichash_KEYBYTES_MAX,
|
20
|
+
1 + i % crypto_generichash_BYTES_MAX) != 0) {
|
21
|
+
printf("crypto_generichash_init()\n");
|
22
|
+
return 1;
|
23
|
+
}
|
21
24
|
crypto_generichash_update(&st, in, i);
|
22
25
|
crypto_generichash_update(&st, in, i);
|
23
26
|
crypto_generichash_update(&st, in, i);
|
24
|
-
crypto_generichash_final(&st, out,
|
25
|
-
|
26
|
-
|
27
|
+
crypto_generichash_final(&st, out,
|
28
|
+
1 + i % crypto_generichash_BYTES_MAX);
|
29
|
+
for (j = 0; j < 1 + i % crypto_generichash_BYTES_MAX; ++j) {
|
30
|
+
printf("%02x", (unsigned int)out[j]);
|
27
31
|
}
|
28
32
|
printf("\n");
|
29
33
|
}
|
34
|
+
|
35
|
+
assert(crypto_generichash_init(&st, k, sizeof k, 0U) == -1);
|
36
|
+
assert(crypto_generichash_init(&st, k, sizeof k,
|
37
|
+
crypto_generichash_BYTES_MAX + 1U) == -1);
|
38
|
+
assert(crypto_generichash_init(&st, k, crypto_generichash_KEYBYTES_MAX + 1U,
|
39
|
+
sizeof out) == -1);
|
40
|
+
assert(crypto_generichash_init(&st, k, 0U, sizeof out) == 0);
|
41
|
+
assert(crypto_generichash_init(&st, k, 1U, sizeof out) == 0);
|
42
|
+
assert(crypto_generichash_init(&st, NULL, 1U, 0U) == -1);
|
43
|
+
assert(crypto_generichash_init(&st, NULL, crypto_generichash_KEYBYTES,
|
44
|
+
1U) == 0);
|
45
|
+
assert(crypto_generichash_init(&st, NULL, crypto_generichash_KEYBYTES,
|
46
|
+
0U) == -1);
|
30
47
|
return 0;
|
31
48
|
}
|
@@ -1,6 +1,3 @@
|
|
1
|
-
#include <stdio.h>
|
2
|
-
|
3
|
-
#include "crypto_uint8.h"
|
4
1
|
|
5
2
|
#define TEST_NAME "generichash3"
|
6
3
|
#include "cmptest.h"
|
@@ -9,28 +6,165 @@ int main(void)
|
|
9
6
|
{
|
10
7
|
#define MAXLEN 64
|
11
8
|
crypto_generichash_blake2b_state st;
|
12
|
-
|
13
|
-
'5', 'b', '6', 'b', '4', '1', 'e', 'd',
|
14
|
-
|
15
|
-
|
16
|
-
'5', '1', '2', '6', 'f', 'b', '2', 'a',
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
9
|
+
unsigned char salt[crypto_generichash_blake2b_SALTBYTES]
|
10
|
+
= { '5', 'b', '6', 'b', '4', '1', 'e', 'd',
|
11
|
+
'9', 'b', '3', '4', '3', 'f', 'e', '0' };
|
12
|
+
unsigned char personal[crypto_generichash_blake2b_PERSONALBYTES]
|
13
|
+
= { '5', '1', '2', '6', 'f', 'b', '2', 'a',
|
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;
|
21
|
+
|
22
|
+
for (i = 0; i < MAXLEN; ++i) {
|
23
|
+
in[i] = i;
|
24
|
+
crypto_generichash_blake2b_init_salt_personal(
|
25
|
+
&st, k, 1 + i % crypto_generichash_blake2b_KEYBYTES_MAX,
|
26
|
+
1 + i % crypto_generichash_blake2b_BYTES_MAX, salt, personal);
|
28
27
|
crypto_generichash_blake2b_update(&st, in, i);
|
29
|
-
crypto_generichash_blake2b_final(
|
30
|
-
|
31
|
-
|
28
|
+
crypto_generichash_blake2b_final(
|
29
|
+
&st, out, 1 + i % crypto_generichash_blake2b_BYTES_MAX);
|
30
|
+
for (j = 0; j < 1 + i % crypto_generichash_blake2b_BYTES_MAX; ++j) {
|
31
|
+
printf("%02x", (unsigned int)out[j]);
|
32
32
|
}
|
33
33
|
printf("\n");
|
34
34
|
}
|
35
|
+
|
36
|
+
memset(out, 0, sizeof out);
|
37
|
+
crypto_generichash_blake2b_init_salt_personal(
|
38
|
+
&st, k, 0U, crypto_generichash_blake2b_BYTES_MAX, salt, personal);
|
39
|
+
crypto_generichash_blake2b_update(&st, in, MAXLEN);
|
40
|
+
crypto_generichash_blake2b_final(&st, out,
|
41
|
+
crypto_generichash_blake2b_BYTES_MAX);
|
42
|
+
for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
|
43
|
+
printf("%02x", (unsigned int)out[j]);
|
44
|
+
}
|
45
|
+
printf("\n");
|
46
|
+
|
47
|
+
memset(out, 0, sizeof out);
|
48
|
+
crypto_generichash_blake2b_init_salt_personal(
|
49
|
+
&st, NULL, 1U, crypto_generichash_blake2b_BYTES_MAX, salt, personal);
|
50
|
+
crypto_generichash_blake2b_update(&st, in, MAXLEN);
|
51
|
+
crypto_generichash_blake2b_final(&st, out,
|
52
|
+
crypto_generichash_blake2b_BYTES_MAX);
|
53
|
+
for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
|
54
|
+
printf("%02x", (unsigned int)out[j]);
|
55
|
+
}
|
56
|
+
printf("\n");
|
57
|
+
|
58
|
+
memset(out, 0, sizeof out);
|
59
|
+
crypto_generichash_blake2b_init_salt_personal(
|
60
|
+
&st, k, crypto_generichash_blake2b_KEYBYTES_MAX,
|
61
|
+
crypto_generichash_blake2b_BYTES_MAX, NULL, personal);
|
62
|
+
crypto_generichash_blake2b_update(&st, in, MAXLEN);
|
63
|
+
crypto_generichash_blake2b_final(&st, out,
|
64
|
+
crypto_generichash_blake2b_BYTES_MAX);
|
65
|
+
for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
|
66
|
+
printf("%02x", (unsigned int)out[j]);
|
67
|
+
}
|
68
|
+
printf("\n");
|
69
|
+
|
70
|
+
memset(out, 0, sizeof out);
|
71
|
+
crypto_generichash_blake2b_init_salt_personal(
|
72
|
+
&st, k, crypto_generichash_blake2b_KEYBYTES_MAX,
|
73
|
+
crypto_generichash_blake2b_BYTES_MAX, salt, NULL);
|
74
|
+
crypto_generichash_blake2b_update(&st, in, MAXLEN);
|
75
|
+
assert(crypto_generichash_blake2b_final(
|
76
|
+
&st, out, crypto_generichash_blake2b_BYTES_MAX + 1U) == -1);
|
77
|
+
crypto_generichash_blake2b_final(
|
78
|
+
&st, out, crypto_generichash_blake2b_BYTES_MAX);
|
79
|
+
for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
|
80
|
+
printf("%02x", (unsigned int)out[j]);
|
81
|
+
}
|
82
|
+
printf("\n");
|
83
|
+
|
84
|
+
memset(out, 0, sizeof out);
|
85
|
+
crypto_generichash_blake2b_salt_personal(
|
86
|
+
out, crypto_generichash_blake2b_BYTES_MAX, in, MAXLEN,
|
87
|
+
k, 0U, salt, personal);
|
88
|
+
for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
|
89
|
+
printf("%02x", (unsigned int)out[j]);
|
90
|
+
}
|
91
|
+
printf("\n");
|
92
|
+
|
93
|
+
memset(out, 0, sizeof out);
|
94
|
+
crypto_generichash_blake2b_salt_personal(
|
95
|
+
out, crypto_generichash_blake2b_BYTES_MAX, in, MAXLEN,
|
96
|
+
NULL, crypto_generichash_blake2b_KEYBYTES_MAX, salt, personal);
|
97
|
+
for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
|
98
|
+
printf("%02x", (unsigned int)out[j]);
|
99
|
+
}
|
100
|
+
printf("\n");
|
101
|
+
|
102
|
+
memset(out, 0, sizeof out);
|
103
|
+
crypto_generichash_blake2b_salt_personal(
|
104
|
+
out, crypto_generichash_blake2b_BYTES_MAX, in, MAXLEN,
|
105
|
+
k, crypto_generichash_blake2b_KEYBYTES_MAX, salt, personal);
|
106
|
+
for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
|
107
|
+
printf("%02x", (unsigned int)out[j]);
|
108
|
+
}
|
109
|
+
printf("\n");
|
110
|
+
|
111
|
+
memset(out, 0, sizeof out);
|
112
|
+
crypto_generichash_blake2b_salt_personal(
|
113
|
+
out, crypto_generichash_blake2b_BYTES_MAX, in, MAXLEN,
|
114
|
+
k, crypto_generichash_blake2b_KEYBYTES_MAX, NULL, personal);
|
115
|
+
for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
|
116
|
+
printf("%02x", (unsigned int)out[j]);
|
117
|
+
}
|
118
|
+
printf("\n");
|
119
|
+
|
120
|
+
memset(out, 0, sizeof out);
|
121
|
+
crypto_generichash_blake2b_salt_personal(
|
122
|
+
out, crypto_generichash_blake2b_BYTES_MAX, in, MAXLEN,
|
123
|
+
k, crypto_generichash_blake2b_KEYBYTES_MAX, salt, NULL);
|
124
|
+
for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
|
125
|
+
printf("%02x", (unsigned int)out[j]);
|
126
|
+
}
|
127
|
+
printf("\n");
|
128
|
+
|
129
|
+
crypto_generichash_blake2b_init_salt_personal(&st, NULL, 0U, crypto_generichash_BYTES,
|
130
|
+
NULL, personal);
|
131
|
+
crypto_generichash_blake2b_update(&st, in, MAXLEN);
|
132
|
+
crypto_generichash_blake2b_final(&st, out, crypto_generichash_blake2b_BYTES_MAX);
|
133
|
+
for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
|
134
|
+
printf("%02x", (unsigned int)out[j]);
|
135
|
+
}
|
136
|
+
printf("\n");
|
137
|
+
|
138
|
+
crypto_generichash_blake2b_init_salt_personal(&st, NULL, 0U, crypto_generichash_BYTES,
|
139
|
+
salt, NULL);
|
140
|
+
crypto_generichash_blake2b_update(&st, in, MAXLEN);
|
141
|
+
crypto_generichash_blake2b_final(&st, out, crypto_generichash_blake2b_BYTES_MAX);
|
142
|
+
for (j = 0; j < crypto_generichash_blake2b_BYTES_MAX; ++j) {
|
143
|
+
printf("%02x", (unsigned int)out[j]);
|
144
|
+
}
|
145
|
+
printf("\n");
|
146
|
+
|
147
|
+
assert(crypto_generichash_blake2b_init_salt_personal(&st, k, sizeof k, 0U,
|
148
|
+
salt, personal) == -1);
|
149
|
+
assert(crypto_generichash_blake2b_init_salt_personal(&st, k, sizeof k,
|
150
|
+
crypto_generichash_BYTES_MAX + 1U,
|
151
|
+
salt, personal) == -1);
|
152
|
+
assert(crypto_generichash_blake2b_init_salt_personal(&st, k,
|
153
|
+
crypto_generichash_KEYBYTES_MAX + 1U,
|
154
|
+
sizeof out, salt, personal) == -1);
|
155
|
+
|
156
|
+
assert(crypto_generichash_blake2b_salt_personal(out, 0U, in, MAXLEN,
|
157
|
+
k, sizeof k,
|
158
|
+
salt, personal) == -1);
|
159
|
+
assert(crypto_generichash_blake2b_salt_personal(out, crypto_generichash_BYTES_MAX + 1U,
|
160
|
+
in, MAXLEN, k, sizeof k,
|
161
|
+
salt, personal) == -1);
|
162
|
+
assert(crypto_generichash_blake2b_salt_personal(out, sizeof out, in, MAXLEN,
|
163
|
+
k, crypto_generichash_KEYBYTES_MAX + 1U,
|
164
|
+
salt, personal) == -1);
|
165
|
+
assert(crypto_generichash_blake2b_init_salt_personal(&st, k, sizeof k, crypto_generichash_BYTES,
|
166
|
+
NULL, personal) == 0);
|
167
|
+
assert(crypto_generichash_blake2b_init_salt_personal(&st, k, sizeof k, crypto_generichash_BYTES,
|
168
|
+
salt, NULL) == 0);
|
35
169
|
return 0;
|
36
170
|
}
|
@@ -62,3 +62,14 @@ c6d6722a916651a8671383d8260873347d9c248696b4cb3dac4dea9ba57ed971127cb18e44211d7e
|
|
62
62
|
5dd258a3e7505bc6b9776b0df25676a1c19e2c8258c7b5f2e361423523d96299eb6827bc7c27e7bca2d2b59d717c2ebcb05e6dcaa32289d96fae9a4077ef
|
63
63
|
19c14de35fe19c92cc0e624280e4136355d4cfa9a0a98b090c4b06f5665021920725852ff1f566b0c8c37157b25fb9f947a2e70b40577a17860a0732c170ac
|
64
64
|
5fcdcc02be7714a0dbc77df498bf999ea9225d564adca1c121c9af03af92cac8177b9b4a86bcc47c79aa32aac58a3fef967b2132e9352d4613fe890beed2571b
|
65
|
+
1afc8ec818bef0a479d2b4cac81d40a52cafa27f6d80c42fc23cbaf4141882ab59ab1101922fcb6e707ef2f61efd07cce5d09094e6bee420b1b96998c7cee96d
|
66
|
+
1afc8ec818bef0a479d2b4cac81d40a52cafa27f6d80c42fc23cbaf4141882ab59ab1101922fcb6e707ef2f61efd07cce5d09094e6bee420b1b96998c7cee96d
|
67
|
+
5789f474edd5206ededaccfc35e7dd3ed730748125b5395abf802b2601126b19b109a1db67556945bc79bb25e1ab59610599d155070e0e04354f11a6a5d6f3ac
|
68
|
+
e78efc663a5547c089f2b3b08973c974c4bfd365eac18b80c68bdb3b1ba4554b54d6b8465a68a3b9aa0bc020621f16efd5b8dd8c7c01ed9ee3ec5544aae465ff
|
69
|
+
1afc8ec818bef0a479d2b4cac81d40a52cafa27f6d80c42fc23cbaf4141882ab59ab1101922fcb6e707ef2f61efd07cce5d09094e6bee420b1b96998c7cee96d
|
70
|
+
1afc8ec818bef0a479d2b4cac81d40a52cafa27f6d80c42fc23cbaf4141882ab59ab1101922fcb6e707ef2f61efd07cce5d09094e6bee420b1b96998c7cee96d
|
71
|
+
fb4e2ad6b7fe6afd2ba06d5c1d79379c5bf10e336a35c89a1aaf408a805171716e0635a5b1d18190131e15b6888510bcb3e3752b050f892a09dbbde60b051495
|
72
|
+
5789f474edd5206ededaccfc35e7dd3ed730748125b5395abf802b2601126b19b109a1db67556945bc79bb25e1ab59610599d155070e0e04354f11a6a5d6f3ac
|
73
|
+
e78efc663a5547c089f2b3b08973c974c4bfd365eac18b80c68bdb3b1ba4554b54d6b8465a68a3b9aa0bc020621f16efd5b8dd8c7c01ed9ee3ec5544aae465ff
|
74
|
+
4f9875a42ba0da8ae3448d2d62b1ff51be672eb1b8a1b0fa5bcd5334c861eff06b5903d672d318fd04e0ef94ddd37eca6d4ad2051a36a0236dc4cc09a5a44358
|
75
|
+
ec9f272db92d1fa99324115f34cda8b4690ad029c1df36986cf9e1f844d8fdeca8e8e8311620ad24cbbfa12eccb676b979565405c8e2e20a2e4f18fb27c93d76
|
@@ -1,16 +1,41 @@
|
|
1
|
-
#include <stdio.h>
|
2
1
|
|
3
2
|
#define TEST_NAME "hash"
|
4
3
|
#include "cmptest.h"
|
5
4
|
|
6
5
|
unsigned char x[] = "testing\n";
|
6
|
+
unsigned char x2[] = "The Conscience of a Hacker is a small essay written January 8, 1986 by a computer security hacker who went by the handle of The Mentor, who belonged to the 2nd generation of Legion of Doom.";
|
7
7
|
unsigned char h[crypto_hash_BYTES];
|
8
8
|
|
9
9
|
int main(void)
|
10
10
|
{
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
size_t i;
|
12
|
+
|
13
|
+
crypto_hash(h, x, sizeof x - 1U);
|
14
|
+
for (i = 0; i < crypto_hash_BYTES; ++i) {
|
15
|
+
printf("%02x", (unsigned int)h[i]);
|
16
|
+
}
|
17
|
+
printf("\n");
|
18
|
+
crypto_hash(h, x2, sizeof x2 - 1U);
|
19
|
+
for (i = 0; i < crypto_hash_BYTES; ++i) {
|
20
|
+
printf("%02x", (unsigned int)h[i]);
|
21
|
+
}
|
22
|
+
printf("\n");
|
23
|
+
crypto_hash_sha256(h, x, sizeof x - 1U);
|
24
|
+
for (i = 0; i < crypto_hash_sha256_BYTES; ++i) {
|
25
|
+
printf("%02x", (unsigned int)h[i]);
|
26
|
+
}
|
27
|
+
printf("\n");
|
28
|
+
crypto_hash_sha256(h, x2, sizeof x2 - 1U);
|
29
|
+
for (i = 0; i < crypto_hash_sha256_BYTES; ++i) {
|
30
|
+
printf("%02x", (unsigned int)h[i]);
|
31
|
+
}
|
32
|
+
printf("\n");
|
33
|
+
|
34
|
+
assert(crypto_hash_bytes() > 0U);
|
35
|
+
assert(strcmp(crypto_hash_primitive(), "sha512") == 0);
|
36
|
+
assert(crypto_hash_sha256_bytes() > 0U);
|
37
|
+
assert(crypto_hash_sha512_bytes() >= crypto_hash_sha256_bytes());
|
38
|
+
assert(crypto_hash_sha512_bytes() == crypto_hash_bytes());
|
39
|
+
|
40
|
+
return 0;
|
16
41
|
}
|
@@ -1 +1,4 @@
|
|
1
1
|
24f950aac7b9ea9b3cb728228a0c82b67c39e96b4b344798870d5daee93e3ae5931baae8c7cacfea4b629452c38026a81d138bc7aad1af3ef7bfd5ec646d6c28
|
2
|
+
a77abe1ccf8f5497e228fbc0acd73a521ededb21b89726684a6ebbc3baa32361aca5a244daa84f24bf19c68baf78e6907625a659b15479eb7bd426fc62aafa73
|
3
|
+
12a61f4e173fb3a11c05d6471f74728f76231b4a5fcd9667cef3af87a3ae4dc2
|
4
|
+
71cc8123fef8c236e451d3c3ddf1adae9aa6cd9521e7041769d737024900a03a
|
@@ -1,16 +1,19 @@
|
|
1
|
-
#include <stdio.h>
|
2
1
|
|
3
2
|
#define TEST_NAME "hash3"
|
4
3
|
#include "cmptest.h"
|
5
4
|
|
6
5
|
unsigned char x[] = "testing\n";
|
7
|
-
unsigned char h[
|
6
|
+
unsigned char h[crypto_hash_BYTES];
|
8
7
|
|
9
8
|
int main(void)
|
10
9
|
{
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
size_t i;
|
11
|
+
|
12
|
+
crypto_hash(h, x, sizeof x - 1U);
|
13
|
+
for (i = 0; i < crypto_hash_BYTES; ++i) {
|
14
|
+
printf("%02x", (unsigned int)h[i]);
|
15
|
+
}
|
16
|
+
printf("\n");
|
17
|
+
|
18
|
+
return 0;
|
16
19
|
}
|
@@ -1,44 +1,56 @@
|
|
1
|
-
#include <stdio.h>
|
2
1
|
|
3
2
|
#define TEST_NAME "onetimeauth"
|
4
3
|
#include "cmptest.h"
|
5
4
|
|
6
|
-
unsigned char rs[32]
|
7
|
-
0xee,0xa6,0xa7,0x25,0x1c,0x1e,0x72,0x91
|
8
|
-
|
9
|
-
,
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
,
|
16
|
-
,
|
17
|
-
,
|
18
|
-
,
|
19
|
-
,
|
20
|
-
,
|
21
|
-
,
|
22
|
-
,0xb4,
|
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
|
-
} ;
|
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 };
|
9
|
+
|
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
23
|
unsigned char a[16];
|
34
24
|
|
35
25
|
int main(void)
|
36
26
|
{
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
27
|
+
crypto_onetimeauth_state st;
|
28
|
+
int i;
|
29
|
+
|
30
|
+
crypto_onetimeauth(a, c, 131, rs);
|
31
|
+
for (i = 0; i < 16; ++i) {
|
32
|
+
printf(",0x%02x", (unsigned int)a[i]);
|
33
|
+
if (i % 8 == 7)
|
34
|
+
printf("\n");
|
35
|
+
}
|
36
|
+
|
37
|
+
memset(a, 0, sizeof a);
|
38
|
+
crypto_onetimeauth_init(&st, rs);
|
39
|
+
crypto_onetimeauth_update(&st, c, 100);
|
40
|
+
crypto_onetimeauth_update(&st, c + 100, 31);
|
41
|
+
crypto_onetimeauth_final(&st, a);
|
42
|
+
for (i = 0; i < 16; ++i) {
|
43
|
+
printf(",0x%02x", (unsigned int)a[i]);
|
44
|
+
if (i % 8 == 7)
|
45
|
+
printf("\n");
|
46
|
+
}
|
47
|
+
|
48
|
+
assert(crypto_onetimeauth_bytes() > 0U);
|
49
|
+
assert(crypto_onetimeauth_keybytes() > 0U);
|
50
|
+
assert(strcmp(crypto_onetimeauth_primitive(), "poly1305") == 0);
|
51
|
+
assert(crypto_onetimeauth_poly1305_bytes() == crypto_onetimeauth_bytes());
|
52
|
+
assert(crypto_onetimeauth_poly1305_keybytes()
|
53
|
+
== crypto_onetimeauth_keybytes());
|
54
|
+
|
55
|
+
return 0;
|
44
56
|
}
|