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
@@ -8,4 +8,24 @@ ca9216d4127e2e4a6ee3584b49be106217bb61cc807016d46d0cfbb1fd722e2bbac33541386bdfea
|
|
8
8
|
2732a7566023c8db90a5fdd08dbe6c1b5e70c046d50c5735c8d86a589ba177f69db12d6cc3596319fa27c9e063ed05b8a31970a07dc905
|
9
9
|
d7b1ef464be03ce9050b5108e25f0b8e821299986fe0ff89e17fbae65ba9fad167fbd265866ac03efc86ab0b50d46d6740a59adf5949b44f7f9f3ac3f3d4cc9f128966db9099deb1b6b78505242b2401a193820408eb0780b27162ebafb7c505b0e7c32ce66c6efc0be487008c1201454680498a2fc06e00b454e0b20933906bbb0e43b399b9ee46d882f107df1ebdd1e7cd867c9cdba6015b7e80064ae8b3417d969524bec046e782a13b125f058cd36b5d1ae65886ae7caab45a6d98651ada435b8ee11d5c1224232f5f515df974138dd6cf347b730481d4b073af8ff0394fe9f0b8cdfd99f5
|
10
10
|
1839be14287053bfcd4ea60db82777fad1a6e9535c388b770743e61235449e668717199defd516c438b3ebd79b3529eb32482ef414525292ea1bbec09da10790a2330a4399f2fe6dd63d80954e3c547a5f1c619db5a30bde495b23f2214b4fa7572851d75246f2817775f0b521acc6efbc7832c9a76de7465e3c65cade88e86c973f85a882bb54f92b983977c6e937c88f083ba68c70fb49497065b158e2e789809b1d4cc9ec2d
|
11
|
+
d54916748076b9d9f72198c8fbef563462dc8c706e1ad38abd1fac570016721acd0a7659ab49a47299a996b43597690c0c947143069f35d83e606273dbf2d622321393949b8ed5a68315362c4f84804384d05e0e0e86bc00e3641233f9f975ab46b60ba185c5e5fe47f78efd207e69fd8f6390730828b93b9b3763ea1283caa03bc36726763715de811915681dd214524f5ad4dd386608cac6c7f2
|
12
|
+
d54916748076b9d9f72198c8fbef563462dc8c706e1ad38abd1fac570016721acd0a7659ab49a47299a996b43597690c0c947143069f35d83e606273dbf2d622321393949b8ed5a68315362c4f84804384d05e0e0e86bc00e3641233f9f975ab46b60ba185c5e5fe47f78efd207e69fd8f6390730828b93b9b3763ea1283caa03bc36726763715de811915681dd214524f5ad4dd386608cac6c7f2
|
13
|
+
pwhash_str failure: [10]
|
14
|
+
pwhash_str failure: [11]
|
15
|
+
pwhash_str failure: [12]
|
16
|
+
pwhash_str failure: [13]
|
17
|
+
pwhash_str failure: [14]
|
18
|
+
pwhash_str failure: [15]
|
19
|
+
pwhash_str failure: [16]
|
20
|
+
pwhash_str failure: [17]
|
21
|
+
pwhash_str failure: [18]
|
22
|
+
pwhash_str failure: [19]
|
23
|
+
pwhash_str failure: [20]
|
24
|
+
pwhash_str failure: [21]
|
25
|
+
pwhash_str failure: [22]
|
26
|
+
pwhash_str failure: [23]
|
27
|
+
pwhash_str failure: [24]
|
28
|
+
pwhash_str failure: [25]
|
29
|
+
pwhash_str failure: [26]
|
30
|
+
pwhash_str failure: [27]
|
11
31
|
OK
|
@@ -1,6 +1,3 @@
|
|
1
|
-
#include <stdio.h>
|
2
|
-
#include <stdint.h>
|
3
|
-
#include <string.h>
|
4
1
|
|
5
2
|
#define TEST_NAME "pwhash_scrypt_ll"
|
6
3
|
#include "cmptest.h"
|
@@ -9,47 +6,44 @@
|
|
9
6
|
|
10
7
|
static const char *password1 = "";
|
11
8
|
static const char *salt1 = "";
|
12
|
-
static uint64_t
|
13
|
-
static uint32_t
|
14
|
-
static uint32_t
|
9
|
+
static uint64_t N1 = 16U;
|
10
|
+
static uint32_t r1 = 1U;
|
11
|
+
static uint32_t p1 = 1U;
|
15
12
|
|
16
13
|
static const char *password2 = "password";
|
17
14
|
static const char *salt2 = "NaCl";
|
18
|
-
static uint64_t
|
19
|
-
static uint32_t
|
20
|
-
static uint32_t
|
15
|
+
static uint64_t N2 = 1024U;
|
16
|
+
static uint32_t r2 = 8U;
|
17
|
+
static uint32_t p2 = 16U;
|
21
18
|
|
22
19
|
static const char *password3 = "pleaseletmein";
|
23
|
-
static const char *salt3
|
24
|
-
static uint64_t
|
25
|
-
static uint32_t
|
26
|
-
static uint32_t
|
20
|
+
static const char *salt3 = "SodiumChloride";
|
21
|
+
static uint64_t N3 = 16384U;
|
22
|
+
static uint32_t r3 = 8U;
|
23
|
+
static uint32_t p3 = 1U;
|
27
24
|
|
28
|
-
static void test_vector(const char *password, const char *salt,
|
29
|
-
|
25
|
+
static void test_vector(const char *password, const char *salt, uint64_t N,
|
26
|
+
uint32_t r, uint32_t p)
|
30
27
|
{
|
31
28
|
uint8_t data[64];
|
32
|
-
size_t
|
33
|
-
size_t
|
34
|
-
size_t
|
35
|
-
size_t
|
36
|
-
int
|
37
|
-
int
|
38
|
-
|
39
|
-
if (crypto_pwhash_scryptsalsa208sha256_ll(
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
printf("pwhash_scryptsalsa208sha256_ll([%s],[%s]) failure\n",
|
45
|
-
password, salt);
|
29
|
+
size_t i;
|
30
|
+
size_t olen = (sizeof data / sizeof data[0]);
|
31
|
+
size_t passwordLength = strlen(password);
|
32
|
+
size_t saltLenght = strlen(salt);
|
33
|
+
int lineitems = 0;
|
34
|
+
int lineitemsLimit = 15;
|
35
|
+
|
36
|
+
if (crypto_pwhash_scryptsalsa208sha256_ll(
|
37
|
+
(const uint8_t *)password, passwordLength, (const uint8_t *)salt,
|
38
|
+
saltLenght, N, r, p, data, olen) != 0) {
|
39
|
+
printf("pwhash_scryptsalsa208sha256_ll([%s],[%s]) failure\n", password,
|
40
|
+
salt);
|
46
41
|
return;
|
47
42
|
}
|
48
43
|
|
49
|
-
printf("scrypt('%s', '%s', %llu, %lu, %lu, %lu) =\n",
|
50
|
-
|
51
|
-
(unsigned long
|
52
|
-
(unsigned long) olen);
|
44
|
+
printf("scrypt('%s', '%s', %llu, %lu, %lu, %lu) =\n", password, salt,
|
45
|
+
(unsigned long long)N, (unsigned long)r, (unsigned long)p,
|
46
|
+
(unsigned long)olen);
|
53
47
|
|
54
48
|
for (i = 0; i < olen; ++i) {
|
55
49
|
printf("%02x%c", data[i], lineitems < lineitemsLimit ? ' ' : '\n');
|
@@ -59,9 +53,9 @@ static void test_vector(const char *password, const char *salt,
|
|
59
53
|
|
60
54
|
int main(void)
|
61
55
|
{
|
62
|
-
|
63
|
-
|
64
|
-
|
56
|
+
test_vector(password1, salt1, N1, r1, p1);
|
57
|
+
test_vector(password2, salt2, N2, r2, p2);
|
58
|
+
test_vector(password3, salt3, N3, r3, p3);
|
65
59
|
|
66
|
-
|
60
|
+
return 0;
|
67
61
|
}
|
@@ -1,16 +1,93 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
#define TEST_NAME "randombytes"
|
3
|
+
#include "cmptest.h"
|
2
4
|
|
3
5
|
unsigned char x[65536];
|
4
6
|
unsigned long long freq[256];
|
5
7
|
|
6
|
-
int
|
8
|
+
static int compat_tests(void)
|
7
9
|
{
|
8
|
-
|
10
|
+
size_t i;
|
11
|
+
|
12
|
+
memset(x, 0, sizeof x);
|
13
|
+
randombytes(x, sizeof x);
|
14
|
+
for (i = 0; i < 256; ++i) {
|
15
|
+
freq[i] = 0;
|
16
|
+
}
|
17
|
+
for (i = 0; i < sizeof x; ++i) {
|
18
|
+
++freq[255 & (int)x[i]];
|
19
|
+
}
|
20
|
+
for (i = 0; i < 256; ++i) {
|
21
|
+
if (!freq[i]) {
|
22
|
+
printf("nacl_tests failed\n");
|
23
|
+
}
|
24
|
+
}
|
25
|
+
return 0;
|
26
|
+
}
|
27
|
+
|
28
|
+
static int randombytes_tests(void)
|
29
|
+
{
|
30
|
+
unsigned int i;
|
31
|
+
|
32
|
+
assert(strcmp(randombytes_implementation_name(), "sysrandom") == 0);
|
9
33
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
34
|
+
randombytes(x, 1U);
|
35
|
+
randombytes_close();
|
36
|
+
|
37
|
+
for (i = 0; i < 256; ++i) {
|
38
|
+
freq[i] = 0;
|
39
|
+
}
|
40
|
+
for (i = 0; i < 65536; ++i) {
|
41
|
+
++freq[randombytes_uniform(256)];
|
42
|
+
}
|
43
|
+
for (i = 0; i < 256; ++i) {
|
44
|
+
if (!freq[i]) {
|
45
|
+
printf("randombytes_uniform() test failed\n");
|
46
|
+
}
|
47
|
+
}
|
48
|
+
assert(randombytes_uniform(1U) == 0U);
|
49
|
+
randombytes_close();
|
50
|
+
randombytes_set_implementation(&randombytes_salsa20_implementation);
|
51
|
+
assert(strcmp(randombytes_implementation_name(), "salsa20") == 0);
|
52
|
+
randombytes_stir();
|
53
|
+
for (i = 0; i < 256; ++i) {
|
54
|
+
freq[i] = 0;
|
55
|
+
}
|
56
|
+
for (i = 0; i < 65536; ++i) {
|
57
|
+
++freq[randombytes_uniform(256)];
|
58
|
+
}
|
59
|
+
for (i = 0; i < 256; ++i) {
|
60
|
+
if (!freq[i]) {
|
61
|
+
printf("randombytes_uniform() test failed\n");
|
62
|
+
}
|
63
|
+
}
|
64
|
+
memset(x, 0, sizeof x);
|
65
|
+
randombytes_buf(x, sizeof x);
|
66
|
+
for (i = 0; i < 256; ++i) {
|
67
|
+
freq[i] = 0;
|
68
|
+
}
|
69
|
+
for (i = 0; i < sizeof x; ++i) {
|
70
|
+
++freq[255 & (int)x[i]];
|
71
|
+
}
|
72
|
+
for (i = 0; i < 256; ++i) {
|
73
|
+
if (!freq[i]) {
|
74
|
+
printf("randombytes_buf() test failed\n");
|
75
|
+
}
|
76
|
+
}
|
77
|
+
assert(randombytes_uniform(1U) == 0U);
|
78
|
+
randombytes_close();
|
79
|
+
|
80
|
+
randombytes(x, 1U);
|
81
|
+
randombytes_close();
|
82
|
+
|
83
|
+
return 0;
|
84
|
+
}
|
85
|
+
|
86
|
+
int main(void)
|
87
|
+
{
|
88
|
+
compat_tests();
|
89
|
+
randombytes_tests();
|
90
|
+
printf("OK\n");
|
14
91
|
|
15
|
-
|
92
|
+
return 0;
|
16
93
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
OK
|
@@ -1,25 +1,38 @@
|
|
1
|
-
#include <stdio.h>
|
2
1
|
|
3
2
|
#define TEST_NAME "scalarmult"
|
4
3
|
#include "cmptest.h"
|
5
4
|
|
6
|
-
unsigned char alicesk[32]
|
7
|
-
0x77,0x07,0x6d,0x0a,0x73,0x18,0xa5,0x7d
|
8
|
-
|
9
|
-
,
|
10
|
-
,0xb1,0x77,0xfb,0xa5,0x1d,0xb9,0x2c,0x2a
|
11
|
-
} ;
|
5
|
+
unsigned char alicesk[32]
|
6
|
+
= { 0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d, 0x3c, 0x16, 0xc1,
|
7
|
+
0x72, 0x51, 0xb2, 0x66, 0x45, 0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0,
|
8
|
+
0x99, 0x2a, 0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a };
|
12
9
|
|
13
10
|
unsigned char alicepk[32];
|
14
11
|
|
15
12
|
int main(void)
|
16
13
|
{
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
14
|
+
int i;
|
15
|
+
|
16
|
+
crypto_scalarmult_base(alicepk, alicesk);
|
17
|
+
|
18
|
+
for (i = 0; i < 32; ++i) {
|
19
|
+
if (i > 0) {
|
20
|
+
printf(",");
|
21
|
+
} else {
|
22
|
+
printf(" ");
|
23
|
+
}
|
24
|
+
printf("0x%02x", (unsigned int)alicepk[i]);
|
25
|
+
if (i % 8 == 7) {
|
26
|
+
printf("\n");
|
27
|
+
}
|
28
|
+
}
|
29
|
+
assert(crypto_scalarmult_bytes() > 0U);
|
30
|
+
assert(crypto_scalarmult_scalarbytes() > 0U);
|
31
|
+
assert(strcmp(crypto_scalarmult_primitive(), "curve25519") == 0);
|
32
|
+
assert(crypto_scalarmult_bytes() == crypto_scalarmult_curve25519_bytes());
|
33
|
+
assert(crypto_scalarmult_scalarbytes()
|
34
|
+
== crypto_scalarmult_curve25519_scalarbytes());
|
35
|
+
assert(crypto_scalarmult_bytes() == crypto_scalarmult_scalarbytes());
|
36
|
+
|
37
|
+
return 0;
|
25
38
|
}
|
@@ -1,25 +1,30 @@
|
|
1
|
-
#include <stdio.h>
|
2
1
|
|
3
2
|
#define TEST_NAME "scalarmult2"
|
4
3
|
#include "cmptest.h"
|
5
4
|
|
6
|
-
unsigned char bobsk[32]
|
7
|
-
0x5d,0xab,0x08,0x7e,0x62,0x4a,0x8a,0x4b
|
8
|
-
|
9
|
-
,
|
10
|
-
,0x1c,0x2f,0x8b,0x27,0xff,0x88,0xe0,0xeb
|
11
|
-
} ;
|
5
|
+
unsigned char bobsk[32]
|
6
|
+
= { 0x5d, 0xab, 0x08, 0x7e, 0x62, 0x4a, 0x8a, 0x4b, 0x79, 0xe1, 0x7f,
|
7
|
+
0x8b, 0x83, 0x80, 0x0e, 0xe6, 0x6f, 0x3b, 0xb1, 0x29, 0x26, 0x18,
|
8
|
+
0xb6, 0xfd, 0x1c, 0x2f, 0x8b, 0x27, 0xff, 0x88, 0xe0, 0xeb };
|
12
9
|
|
13
10
|
unsigned char bobpk[32];
|
14
11
|
|
15
12
|
int main(void)
|
16
13
|
{
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
14
|
+
int i;
|
15
|
+
|
16
|
+
crypto_scalarmult_base(bobpk, bobsk);
|
17
|
+
|
18
|
+
for (i = 0; i < 32; ++i) {
|
19
|
+
if (i > 0) {
|
20
|
+
printf(",");
|
21
|
+
} else {
|
22
|
+
printf(" ");
|
23
|
+
}
|
24
|
+
printf("0x%02x", (unsigned int)bobpk[i]);
|
25
|
+
if (i % 8 == 7) {
|
26
|
+
printf("\n");
|
27
|
+
}
|
28
|
+
}
|
29
|
+
return 0;
|
25
30
|
}
|
@@ -1,32 +1,35 @@
|
|
1
|
-
#include <stdio.h>
|
2
1
|
|
3
2
|
#define TEST_NAME "scalarmult5"
|
4
3
|
#include "cmptest.h"
|
5
4
|
|
6
|
-
unsigned char alicesk[32]
|
7
|
-
0x77,0x07,0x6d,0x0a,0x73,0x18,0xa5,0x7d
|
8
|
-
|
9
|
-
,
|
10
|
-
,0xb1,0x77,0xfb,0xa5,0x1d,0xb9,0x2c,0x2a
|
11
|
-
} ;
|
5
|
+
unsigned char alicesk[32]
|
6
|
+
= { 0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d, 0x3c, 0x16, 0xc1,
|
7
|
+
0x72, 0x51, 0xb2, 0x66, 0x45, 0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0,
|
8
|
+
0x99, 0x2a, 0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a };
|
12
9
|
|
13
|
-
unsigned char bobpk[32]
|
14
|
-
0xde,0x9e,0xdb,0x7d,0x7b,0x7d,0xc1,0xb4
|
15
|
-
|
16
|
-
,
|
17
|
-
,0xad,0xfc,0x7e,0x14,0x6f,0x88,0x2b,0x4f
|
18
|
-
} ;
|
10
|
+
unsigned char bobpk[32]
|
11
|
+
= { 0xde, 0x9e, 0xdb, 0x7d, 0x7b, 0x7d, 0xc1, 0xb4, 0xd3, 0x5b, 0x61,
|
12
|
+
0xc2, 0xec, 0xe4, 0x35, 0x37, 0x3f, 0x83, 0x43, 0xc8, 0x5b, 0x78,
|
13
|
+
0x67, 0x4d, 0xad, 0xfc, 0x7e, 0x14, 0x6f, 0x88, 0x2b, 0x4f };
|
19
14
|
|
20
15
|
unsigned char k[32];
|
21
16
|
|
22
17
|
int main(void)
|
23
18
|
{
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
19
|
+
int i;
|
20
|
+
|
21
|
+
crypto_scalarmult(k, alicesk, bobpk);
|
22
|
+
|
23
|
+
for (i = 0; i < 32; ++i) {
|
24
|
+
if (i > 0) {
|
25
|
+
printf(",");
|
26
|
+
} else {
|
27
|
+
printf(" ");
|
28
|
+
}
|
29
|
+
printf("0x%02x", (unsigned int)k[i]);
|
30
|
+
if (i % 8 == 7) {
|
31
|
+
printf("\n");
|
32
|
+
}
|
33
|
+
}
|
34
|
+
return 0;
|
32
35
|
}
|
@@ -1,32 +1,35 @@
|
|
1
|
-
#include <stdio.h>
|
2
1
|
|
3
2
|
#define TEST_NAME "scalarmult6"
|
4
3
|
#include "cmptest.h"
|
5
4
|
|
6
|
-
unsigned char bobsk[32]
|
7
|
-
0x5d,0xab,0x08,0x7e,0x62,0x4a,0x8a,0x4b
|
8
|
-
|
9
|
-
,
|
10
|
-
,0x1c,0x2f,0x8b,0x27,0xff,0x88,0xe0,0xeb
|
11
|
-
} ;
|
5
|
+
unsigned char bobsk[32]
|
6
|
+
= { 0x5d, 0xab, 0x08, 0x7e, 0x62, 0x4a, 0x8a, 0x4b, 0x79, 0xe1, 0x7f,
|
7
|
+
0x8b, 0x83, 0x80, 0x0e, 0xe6, 0x6f, 0x3b, 0xb1, 0x29, 0x26, 0x18,
|
8
|
+
0xb6, 0xfd, 0x1c, 0x2f, 0x8b, 0x27, 0xff, 0x88, 0xe0, 0xeb };
|
12
9
|
|
13
|
-
unsigned char alicepk[32]
|
14
|
-
0x85,0x20,0xf0,0x09,0x89,0x30,0xa7,0x54
|
15
|
-
|
16
|
-
,
|
17
|
-
,0xeb,0xa4,0xa9,0x8e,0xaa,0x9b,0x4e,0x6a
|
18
|
-
} ;
|
10
|
+
unsigned char alicepk[32]
|
11
|
+
= { 0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 0x74, 0x8b, 0x7d,
|
12
|
+
0xdc, 0xb4, 0x3e, 0xf7, 0x5a, 0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38,
|
13
|
+
0x1a, 0xf4, 0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a };
|
19
14
|
|
20
15
|
unsigned char k[32];
|
21
16
|
|
22
17
|
int main(void)
|
23
18
|
{
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
19
|
+
int i;
|
20
|
+
|
21
|
+
crypto_scalarmult(k, bobsk, alicepk);
|
22
|
+
|
23
|
+
for (i = 0; i < 32; ++i) {
|
24
|
+
if (i > 0) {
|
25
|
+
printf(",");
|
26
|
+
} else {
|
27
|
+
printf(" ");
|
28
|
+
}
|
29
|
+
printf("0x%02x", (unsigned int)k[i]);
|
30
|
+
if (i % 8 == 7) {
|
31
|
+
printf("\n");
|
32
|
+
}
|
33
|
+
}
|
34
|
+
return 0;
|
32
35
|
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
#define TEST_NAME "scalarmult7"
|
3
|
+
#include "cmptest.h"
|
4
|
+
|
5
|
+
unsigned char p1[32] = {
|
6
|
+
0x72, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54,
|
7
|
+
0x74, 0x8b, 0x7d, 0xdc, 0xb4, 0x3e, 0xf7, 0x5a,
|
8
|
+
0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38, 0x1a, 0xf4,
|
9
|
+
0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0xea
|
10
|
+
};
|
11
|
+
|
12
|
+
unsigned char p2[32] = {
|
13
|
+
0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54,
|
14
|
+
0x74, 0x8b, 0x7d, 0xdc, 0xb4, 0x3e, 0xf7, 0x5a,
|
15
|
+
0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38, 0x1a, 0xf4,
|
16
|
+
0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a
|
17
|
+
};
|
18
|
+
|
19
|
+
unsigned char scalar[32];
|
20
|
+
unsigned char out1[32];
|
21
|
+
unsigned char out2[32];
|
22
|
+
|
23
|
+
int main(void)
|
24
|
+
{
|
25
|
+
scalar[0] = 1U;
|
26
|
+
crypto_scalarmult_curve25519(out1, scalar, p1);
|
27
|
+
crypto_scalarmult_curve25519(out2, scalar, p2);
|
28
|
+
printf("%d\n", !!memcmp(out1, out2, 32));
|
29
|
+
|
30
|
+
return 0;
|
31
|
+
}
|