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
@@ -0,0 +1 @@
|
|
1
|
+
1
|
@@ -1,58 +1,63 @@
|
|
1
|
-
#include <stdio.h>
|
2
1
|
|
3
2
|
#define TEST_NAME "secretbox"
|
4
3
|
#include "cmptest.h"
|
5
4
|
|
6
|
-
unsigned char firstkey[32]
|
7
|
-
0x1b,0x27,0x55,0x64,0x73,0xe9,0x85,0xd4
|
8
|
-
|
9
|
-
,
|
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
|
-
|
15
|
-
,
|
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
|
// API requires first 32 bytes to be 0
|
20
|
-
unsigned char m[163]
|
21
|
-
0,
|
22
|
-
,
|
23
|
-
,
|
24
|
-
,
|
25
|
-
,
|
26
|
-
,
|
27
|
-
,
|
28
|
-
,
|
29
|
-
,
|
30
|
-
,
|
31
|
-
,
|
32
|
-
,
|
33
|
-
,
|
34
|
-
,
|
35
|
-
,0xe2,0xf6,0x55,0x6a,0xd6,0xb1,0x31,0x8a
|
36
|
-
,0x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 0x9f, 0xfd, 0x49, 0x24, 0xca, 0x1c, 0x60, 0x90, 0x2e, 0x52,
|
28
|
+
0xf0, 0xa0, 0x89, 0xbc, 0x76, 0x89, 0x70, 0x40, 0xe0, 0x82, 0xf9, 0x37,
|
29
|
+
0x76, 0x38, 0x48, 0x64, 0x5e, 0x07, 0x05 };
|
43
30
|
|
44
31
|
unsigned char c[163];
|
45
32
|
|
46
33
|
int main(void)
|
47
34
|
{
|
48
|
-
|
49
|
-
|
50
|
-
c,m,163,nonce,firstkey
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
35
|
+
int i;
|
36
|
+
|
37
|
+
crypto_secretbox(c, m, 163, nonce, firstkey);
|
38
|
+
for (i = 16; 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
|
+
assert(crypto_secretbox_keybytes() > 0U);
|
46
|
+
assert(crypto_secretbox_noncebytes() > 0U);
|
47
|
+
assert(crypto_secretbox_zerobytes() > 0U);
|
48
|
+
assert(crypto_secretbox_boxzerobytes() > 0U);
|
49
|
+
assert(crypto_secretbox_macbytes() > 0U);
|
50
|
+
assert(strcmp(crypto_secretbox_primitive(), "xsalsa20poly1305") == 0);
|
51
|
+
assert(crypto_secretbox_keybytes()
|
52
|
+
== crypto_secretbox_xsalsa20poly1305_keybytes());
|
53
|
+
assert(crypto_secretbox_noncebytes()
|
54
|
+
== crypto_secretbox_xsalsa20poly1305_noncebytes());
|
55
|
+
assert(crypto_secretbox_zerobytes()
|
56
|
+
== crypto_secretbox_xsalsa20poly1305_zerobytes());
|
57
|
+
assert(crypto_secretbox_boxzerobytes()
|
58
|
+
== crypto_secretbox_xsalsa20poly1305_boxzerobytes());
|
59
|
+
assert(crypto_secretbox_macbytes()
|
60
|
+
== crypto_secretbox_xsalsa20poly1305_macbytes());
|
61
|
+
|
62
|
+
return 0;
|
58
63
|
}
|
@@ -1,59 +1,46 @@
|
|
1
|
-
#include <stdio.h>
|
2
1
|
|
3
2
|
#define TEST_NAME "secretbox2"
|
4
3
|
#include "cmptest.h"
|
5
4
|
|
6
|
-
unsigned char firstkey[32]
|
7
|
-
0x1b,0x27,0x55,0x64,0x73,0xe9,0x85,0xd4
|
8
|
-
|
9
|
-
,
|
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
|
-
|
15
|
-
,
|
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
|
// API requires first 16 bytes to be 0
|
20
|
-
unsigned char c[163]
|
21
|
-
0,
|
22
|
-
|
23
|
-
,
|
24
|
-
,
|
25
|
-
,
|
26
|
-
,
|
27
|
-
,0x48,
|
28
|
-
,
|
29
|
-
,
|
30
|
-
,
|
31
|
-
,
|
32
|
-
,
|
33
|
-
,
|
34
|
-
,
|
35
|
-
,0x90,0x22,0x43,0x68,0x51,0x7a,0xcf,0xea
|
36
|
-
,0xbd,0x6b,0xb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x83, 0x2b, 0x61,
|
27
|
+
0xca, 0x01, 0xb6, 0xde, 0x56, 0x24, 0x4a, 0x9e, 0x88, 0xd5, 0xf9, 0xb3,
|
28
|
+
0x79, 0x73, 0xf6, 0x22, 0xa4, 0x3d, 0x14, 0xa6, 0x59, 0x9b, 0x1f, 0x65,
|
29
|
+
0x4c, 0xb4, 0x5a, 0x74, 0xe3, 0x55, 0xa5 };
|
43
30
|
|
44
31
|
unsigned char m[163];
|
45
32
|
|
46
33
|
int main(void)
|
47
34
|
{
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
35
|
+
int i;
|
36
|
+
|
37
|
+
if (crypto_secretbox_open(m, c, 163, nonce, firstkey) == 0) {
|
38
|
+
for (i = 32; i < 163; ++i) {
|
39
|
+
printf(",0x%02x", (unsigned int)m[i]);
|
40
|
+
if (i % 8 == 7)
|
41
|
+
printf("\n");
|
42
|
+
}
|
43
|
+
printf("\n");
|
55
44
|
}
|
56
|
-
|
57
|
-
}
|
58
|
-
return 0;
|
45
|
+
return 0;
|
59
46
|
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
#include <stdio.h>
|
2
1
|
|
3
2
|
#define TEST_NAME "secretbox7"
|
4
3
|
#include "cmptest.h"
|
@@ -11,23 +10,26 @@ unsigned char m2[10000];
|
|
11
10
|
|
12
11
|
int main(void)
|
13
12
|
{
|
14
|
-
|
15
|
-
|
13
|
+
size_t mlen;
|
14
|
+
size_t i;
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
16
|
+
for (mlen = 0; mlen < 1000 && mlen + crypto_secretbox_ZEROBYTES < sizeof m;
|
17
|
+
++mlen) {
|
18
|
+
randombytes_buf(k, crypto_secretbox_KEYBYTES);
|
19
|
+
randombytes_buf(n, crypto_secretbox_NONCEBYTES);
|
20
|
+
randombytes_buf(m + crypto_secretbox_ZEROBYTES, mlen);
|
21
|
+
crypto_secretbox(c, m, mlen + crypto_secretbox_ZEROBYTES, n, k);
|
22
|
+
if (crypto_secretbox_open(m2, c, mlen + crypto_secretbox_ZEROBYTES, n,
|
23
|
+
k) == 0) {
|
24
|
+
for (i = 0; i < mlen + crypto_secretbox_ZEROBYTES; ++i) {
|
25
|
+
if (m2[i] != m[i]) {
|
26
|
+
printf("bad decryption\n");
|
27
|
+
break;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
} else {
|
31
|
+
printf("ciphertext fails verification\n");
|
27
32
|
}
|
28
|
-
} else {
|
29
|
-
printf("ciphertext fails verification\n");
|
30
33
|
}
|
31
|
-
|
32
|
-
return 0;
|
34
|
+
return 0;
|
33
35
|
}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
#include <stdlib.h>
|
1
|
+
|
3
2
|
#include "windows/windows-quirks.h"
|
4
3
|
|
5
4
|
#define TEST_NAME "secretbox8"
|
@@ -13,28 +12,31 @@ unsigned char m2[10000];
|
|
13
12
|
|
14
13
|
int main(void)
|
15
14
|
{
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
size_t mlen;
|
16
|
+
size_t i;
|
17
|
+
int caught;
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
19
|
+
for (mlen = 0; mlen < 1000 && mlen + crypto_secretbox_ZEROBYTES < sizeof m;
|
20
|
+
++mlen) {
|
21
|
+
randombytes_buf(k, crypto_secretbox_KEYBYTES);
|
22
|
+
randombytes_buf(n, crypto_secretbox_NONCEBYTES);
|
23
|
+
randombytes_buf(m + crypto_secretbox_ZEROBYTES, mlen);
|
24
|
+
crypto_secretbox(c, m, mlen + crypto_secretbox_ZEROBYTES, n, k);
|
25
|
+
caught = 0;
|
26
|
+
while (caught < 10) {
|
27
|
+
c[rand() % (mlen + crypto_secretbox_ZEROBYTES)] = rand();
|
28
|
+
if (crypto_secretbox_open(m2, c, mlen + crypto_secretbox_ZEROBYTES,
|
29
|
+
n, k) == 0) {
|
30
|
+
for (i = 0; i < mlen + crypto_secretbox_ZEROBYTES; ++i) {
|
31
|
+
if (m2[i] != m[i]) {
|
32
|
+
printf("forgery\n");
|
33
|
+
return 100;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
} else {
|
37
|
+
++caught;
|
38
|
+
}
|
39
|
+
}
|
37
40
|
}
|
38
|
-
|
39
|
-
return 0;
|
41
|
+
return 0;
|
40
42
|
}
|
@@ -1,63 +1,57 @@
|
|
1
|
-
#include <stdio.h>
|
2
1
|
|
3
2
|
#define TEST_NAME "secretbox_easy"
|
4
3
|
#include "cmptest.h"
|
5
4
|
|
6
|
-
unsigned char firstkey[32]
|
7
|
-
0x1b,0x27,0x55,0x64,0x73,0xe9,0x85,0xd4
|
8
|
-
|
9
|
-
,
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
,
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
,
|
22
|
-
,
|
23
|
-
,
|
24
|
-
,
|
25
|
-
,
|
26
|
-
,
|
27
|
-
,0x1d,0xb6,0x6c,0xce,0x31,0x4a,0xdb,0x31
|
28
|
-
,0x0e,0x3b,0xe8,0x25,0x0c,0x46,0xf0,0x6d
|
29
|
-
,0xce,0xea,0x3a,0x7f,0xa1,0x34,0x80,0x57
|
30
|
-
,0xe2,0xf6,0x55,0x6a,0xd6,0xb1,0x31,0x8a
|
31
|
-
,0x02,0x4a,0x83,0x8f,0x21,0xaf,0x1f,0xde
|
32
|
-
,0x04,0x89,0x77,0xeb,0x48,0xf5,0x9f,0xfd
|
33
|
-
,0x49,0x24,0xca,0x1c,0x60,0x90,0x2e,0x52
|
34
|
-
,0xf0,0xa0,0x89,0xbc,0x76,0x89,0x70,0x40
|
35
|
-
,0xe0,0x82,0xf9,0x37,0x76,0x38,0x48,0x64
|
36
|
-
,0x5e,0x07,0x05
|
37
|
-
} ;
|
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[131]
|
15
|
+
= { 0xbe, 0x07, 0x5f, 0xc5, 0x3c, 0x81, 0xf2, 0xd5, 0xcf, 0x14, 0x13, 0x16,
|
16
|
+
0xeb, 0xeb, 0x0c, 0x7b, 0x52, 0x28, 0xc5, 0x2a, 0x4c, 0x62, 0xcb, 0xd4,
|
17
|
+
0x4b, 0x66, 0x84, 0x9b, 0x64, 0x24, 0x4f, 0xfc, 0xe5, 0xec, 0xba, 0xaf,
|
18
|
+
0x33, 0xbd, 0x75, 0x1a, 0x1a, 0xc7, 0x28, 0xd4, 0x5e, 0x6c, 0x61, 0x29,
|
19
|
+
0x6c, 0xdc, 0x3c, 0x01, 0x23, 0x35, 0x61, 0xf4, 0x1d, 0xb6, 0x6c, 0xce,
|
20
|
+
0x31, 0x4a, 0xdb, 0x31, 0x0e, 0x3b, 0xe8, 0x25, 0x0c, 0x46, 0xf0, 0x6d,
|
21
|
+
0xce, 0xea, 0x3a, 0x7f, 0xa1, 0x34, 0x80, 0x57, 0xe2, 0xf6, 0x55, 0x6a,
|
22
|
+
0xd6, 0xb1, 0x31, 0x8a, 0x02, 0x4a, 0x83, 0x8f, 0x21, 0xaf, 0x1f, 0xde,
|
23
|
+
0x04, 0x89, 0x77, 0xeb, 0x48, 0xf5, 0x9f, 0xfd, 0x49, 0x24, 0xca, 0x1c,
|
24
|
+
0x60, 0x90, 0x2e, 0x52, 0xf0, 0xa0, 0x89, 0xbc, 0x76, 0x89, 0x70, 0x40,
|
25
|
+
0xe0, 0x82, 0xf9, 0x37, 0x76, 0x38, 0x48, 0x64, 0x5e, 0x07, 0x05 };
|
38
26
|
|
39
27
|
unsigned char c[147 + crypto_secretbox_MACBYTES];
|
40
28
|
unsigned char mac[crypto_secretbox_MACBYTES];
|
41
29
|
|
42
30
|
int main(void)
|
43
31
|
{
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
32
|
+
size_t i;
|
33
|
+
|
34
|
+
crypto_secretbox_easy(c, m, 131, nonce, firstkey);
|
35
|
+
for (i = 0; i < 131 + crypto_secretbox_MACBYTES; ++i) {
|
36
|
+
printf(",0x%02x", (unsigned int)c[i]);
|
37
|
+
if (i % 8 == 7)
|
38
|
+
printf("\n");
|
39
|
+
}
|
40
|
+
printf("\n");
|
41
|
+
|
42
|
+
crypto_secretbox_detached(c, mac, m, 131, nonce, firstkey);
|
43
|
+
for (i = 0; i < crypto_secretbox_MACBYTES; ++i) {
|
44
|
+
printf(",0x%02x", (unsigned int)mac[i]);
|
45
|
+
if (i % 8 == 7)
|
46
|
+
printf("\n");
|
47
|
+
}
|
48
|
+
for (i = 0; i < 131; ++i) {
|
49
|
+
printf(",0x%02x", (unsigned int)c[i]);
|
50
|
+
if (i % 8 == 7)
|
51
|
+
printf("\n");
|
52
|
+
}
|
53
|
+
|
54
|
+
assert(crypto_secretbox_easy(c, m, SIZE_MAX - 1U, nonce, firstkey) == -1);
|
55
|
+
|
56
|
+
return 0;
|
63
57
|
}
|
@@ -1,5 +1,3 @@
|
|
1
|
-
#include <stdio.h>
|
2
|
-
#include <string.h>
|
3
1
|
|
4
2
|
#define TEST_NAME "secretbox_easy2"
|
5
3
|
#include "cmptest.h"
|
@@ -17,12 +15,12 @@ int main(void)
|
|
17
15
|
unsigned long long i;
|
18
16
|
|
19
17
|
randombytes_buf(k, sizeof k);
|
20
|
-
mlen = (unsigned long long)
|
18
|
+
mlen = (unsigned long long)randombytes_uniform((uint32_t)sizeof m);
|
21
19
|
randombytes_buf(m, mlen);
|
22
20
|
randombytes_buf(nonce, sizeof nonce);
|
23
21
|
crypto_secretbox_easy(c, m, mlen, nonce, k);
|
24
|
-
crypto_secretbox_open_easy(m2, c, mlen + crypto_secretbox_MACBYTES,
|
25
|
-
|
22
|
+
crypto_secretbox_open_easy(m2, c, mlen + crypto_secretbox_MACBYTES, nonce,
|
23
|
+
k);
|
26
24
|
printf("%d\n", memcmp(m, m2, mlen));
|
27
25
|
|
28
26
|
for (i = 0; i < mlen + crypto_secretbox_MACBYTES - 1; i++) {
|
@@ -1,6 +1,3 @@
|
|
1
|
-
#include <stdio.h>
|
2
|
-
|
3
|
-
#include "crypto_uint8.h"
|
4
1
|
|
5
2
|
#define TEST_NAME "shorthash"
|
6
3
|
#include "cmptest.h"
|
@@ -8,16 +5,26 @@
|
|
8
5
|
int main(void)
|
9
6
|
{
|
10
7
|
#define MAXLEN 64
|
11
|
-
|
12
|
-
|
8
|
+
unsigned char in[MAXLEN], out[crypto_shorthash_BYTES],
|
9
|
+
k[crypto_shorthash_KEYBYTES];
|
10
|
+
size_t i, j;
|
13
11
|
|
14
|
-
for(
|
12
|
+
for (i = 0; i < crypto_shorthash_KEYBYTES; ++i)
|
13
|
+
k[i] = i;
|
15
14
|
|
16
|
-
for(i=0;i<MAXLEN
|
17
|
-
in[i]=i;
|
18
|
-
crypto_shorthash(
|
19
|
-
for (j = 0;j < crypto_shorthash_BYTES
|
15
|
+
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
20
|
printf("\n");
|
21
21
|
}
|
22
|
+
assert(crypto_shorthash_bytes() > 0);
|
23
|
+
assert(crypto_shorthash_keybytes() > 0);
|
24
|
+
assert(strcmp(crypto_shorthash_primitive(), "siphash24") == 0);
|
25
|
+
assert(crypto_shorthash_bytes() == crypto_shorthash_siphash24_bytes());
|
26
|
+
assert(crypto_shorthash_keybytes()
|
27
|
+
== crypto_shorthash_siphash24_keybytes());
|
28
|
+
|
22
29
|
return 0;
|
23
30
|
}
|