rbnacl-libsodium 1.0.15.1 → 1.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -6
- data/CHANGES.md +50 -42
- data/Gemfile +1 -1
- data/README.md +3 -1
- data/Rakefile +46 -0
- data/ext/rbnacl/extconf.rb +16 -1
- data/lib/rbnacl/libsodium.rb +16 -8
- data/lib/rbnacl/libsodium/version.rb +1 -1
- data/rbnacl-libsodium.gemspec +3 -0
- data/vendor/libsodium/AUTHORS +20 -5
- data/vendor/libsodium/ChangeLog +25 -0
- data/vendor/libsodium/Makefile.in +3 -1
- data/vendor/libsodium/README.markdown +2 -1
- data/vendor/libsodium/aclocal.m4 +1 -0
- data/vendor/libsodium/autom4te.cache/output.1 +836 -123
- data/vendor/libsodium/autom4te.cache/output.4 +21342 -0
- data/vendor/libsodium/autom4te.cache/requests +801 -554
- data/vendor/libsodium/autom4te.cache/traces.1 +717 -596
- data/vendor/libsodium/autom4te.cache/traces.4 +4355 -0
- data/vendor/libsodium/builds/Makefile.in +3 -1
- data/vendor/libsodium/builds/msvc/resource.h +1 -1
- data/vendor/libsodium/builds/msvc/resource.rc +2 -2
- data/vendor/libsodium/builds/msvc/version.h +2 -2
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +17 -8
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +60 -24
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +17 -8
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +60 -24
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +17 -8
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +60 -24
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +17 -8
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +60 -24
- data/vendor/libsodium/builds/msvc/vs2017/libsodium/libsodium.vcxproj +17 -8
- data/vendor/libsodium/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters +60 -24
- data/vendor/libsodium/configure +834 -121
- data/vendor/libsodium/configure.ac +55 -13
- data/vendor/libsodium/contrib/Findsodium.cmake +22 -3
- data/vendor/libsodium/contrib/Makefile.in +3 -1
- data/vendor/libsodium/dist-build/Makefile.in +3 -1
- data/vendor/libsodium/dist-build/android-build.sh +2 -2
- data/vendor/libsodium/dist-build/emscripten-symbols.def +38 -26
- data/vendor/libsodium/dist-build/emscripten.sh +23 -8
- data/vendor/libsodium/dist-build/msys2-win32.sh +1 -1
- data/vendor/libsodium/dist-build/msys2-win64.sh +1 -1
- data/vendor/libsodium/libsodium.vcxproj +17 -8
- data/vendor/libsodium/libsodium.vcxproj.filters +41 -14
- data/vendor/libsodium/m4/ax_tls.m4 +74 -0
- data/vendor/libsodium/msvc-scripts/Makefile.in +3 -1
- data/vendor/libsodium/msvc-scripts/process.bat +2 -2
- data/vendor/libsodium/packaging/dotnet-core/README.md +5 -5
- data/vendor/libsodium/packaging/dotnet-core/prepare.py +7 -7
- data/vendor/libsodium/packaging/nuget/package.config +1 -1
- data/vendor/libsodium/regen-msvc/libsodium.vcxproj +326 -0
- data/vendor/libsodium/regen-msvc/libsodium.vcxproj.filters +23 -0
- data/vendor/libsodium/regen-msvc/libsodium.vcxproj.filters.tpl +35 -0
- data/vendor/libsodium/regen-msvc/libsodium.vcxproj.tpl +93 -0
- data/vendor/libsodium/regen-msvc/regen-msvc.py +136 -0
- data/vendor/libsodium/regen-msvc/tl_libsodium.vcxproj.filters.tpl +23 -0
- data/vendor/libsodium/regen-msvc/tl_libsodium.vcxproj.tpl +331 -0
- data/vendor/libsodium/src/Makefile.in +3 -1
- data/vendor/libsodium/src/libsodium/Makefile.am +40 -24
- data/vendor/libsodium/src/libsodium/Makefile.in +238 -180
- data/vendor/libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +10 -2
- data/vendor/libsodium/src/libsodium/crypto_core/ed25519/core_ed25519.c +79 -0
- data/vendor/libsodium/src/libsodium/crypto_core/ed25519/ref10/ed25519_ref10.c +2031 -0
- data/vendor/libsodium/src/libsodium/crypto_core/ed25519/ref10/fe_25_5/base.h +1344 -0
- data/vendor/libsodium/src/libsodium/crypto_core/ed25519/ref10/fe_25_5/base2.h +40 -0
- data/vendor/libsodium/src/libsodium/crypto_core/ed25519/ref10/fe_25_5/constants.h +20 -0
- data/vendor/libsodium/src/libsodium/crypto_core/ed25519/ref10/fe_25_5/fe.h +220 -0
- data/vendor/libsodium/src/libsodium/crypto_core/ed25519/ref10/fe_51/base.h +1344 -0
- data/vendor/libsodium/src/libsodium/crypto_core/ed25519/ref10/fe_51/base2.h +40 -0
- data/vendor/libsodium/src/libsodium/crypto_core/ed25519/ref10/fe_51/constants.h +21 -0
- data/vendor/libsodium/src/libsodium/crypto_core/ed25519/ref10/fe_51/fe.h +116 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ref.c +2 -1
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-ref.c +14 -82
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/generichash_blake2b.c +1 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256_cp.c +3 -3
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512_cp.c +3 -3
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +1 -7
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c +1 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c +0 -6
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.c +19 -92
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.h +72 -4
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.c +5 -1
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/scrypt_platform.c +10 -7
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.c +108 -231
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/curve25519_sandy2x.c +27 -27
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_invert.c +2 -1
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe_frombytes_sandy2x.c +6 -3
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519.c +3 -11
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/ed25519/ref10/scalarmult_ed25519_ref10.c +86 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +28 -26
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/obsolete.c +32 -30
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +14 -115
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sign.c +56 -13
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/{ed25519_ref10.h → sign_ed25519_ref10.h} +2 -5
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/sign_ed25519.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/stream_chacha20.c +1 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20.c +1 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/u8.h +1 -1
- data/vendor/libsodium/src/libsodium/include/Makefile.am +2 -0
- data/vendor/libsodium/src/libsodium/include/Makefile.in +13 -9
- data/vendor/libsodium/src/libsodium/include/sodium.h +2 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_ed25519.h +37 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult.h +8 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h +8 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult_ed25519.h +41 -0
- data/vendor/libsodium/src/libsodium/include/sodium/private/common.h +18 -0
- data/vendor/libsodium/src/libsodium/include/sodium/private/ed25519_ref10.h +125 -0
- data/vendor/libsodium/src/libsodium/include/sodium/private/ed25519_ref10_fe_25_5.h +1050 -0
- data/vendor/libsodium/src/libsodium/include/sodium/private/ed25519_ref10_fe_51.h +518 -0
- data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/utils.h +3 -0
- data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +182 -102
- data/vendor/libsodium/src/libsodium/sodium/core.c +30 -2
- data/vendor/libsodium/src/libsodium/sodium/runtime.c +14 -0
- data/vendor/libsodium/src/libsodium/sodium/utils.c +46 -0
- data/vendor/libsodium/test/Makefile.in +3 -1
- data/vendor/libsodium/test/default/Makefile.am +16 -0
- data/vendor/libsodium/test/default/Makefile.in +71 -23
- data/vendor/libsodium/test/default/aead_aes256gcm.c +1 -1
- data/vendor/libsodium/test/default/cmptest.h +4 -0
- data/vendor/libsodium/test/default/core3.c +44 -4
- data/vendor/libsodium/test/default/core3.exp +2 -0
- data/vendor/libsodium/test/default/core4.c +1 -1
- data/vendor/libsodium/test/default/core_ed25519.c +151 -0
- data/vendor/libsodium/test/default/core_ed25519.exp +1 -0
- data/vendor/libsodium/test/default/ed25519_convert.c +9 -1
- data/vendor/libsodium/test/default/index.html.tpl +17 -3
- data/vendor/libsodium/test/default/kdf.c +4 -2
- data/vendor/libsodium/test/default/metamorphic.c +8 -8
- data/vendor/libsodium/test/default/misuse.c +29 -1
- data/vendor/libsodium/test/default/pwhash_argon2i.c +9 -3
- data/vendor/libsodium/test/default/pwhash_argon2i.exp +2 -2
- data/vendor/libsodium/test/default/pwhash_argon2id.c +7 -2
- data/vendor/libsodium/test/default/pwhash_argon2id.exp +2 -2
- data/vendor/libsodium/test/default/scalarmult.c +0 -2
- data/vendor/libsodium/test/default/scalarmult.exp +0 -1
- data/vendor/libsodium/test/default/scalarmult_ed25519.c +90 -0
- data/vendor/libsodium/test/default/scalarmult_ed25519.exp +1 -0
- data/vendor/libsodium/test/default/secretbox_easy2.c +1 -1
- data/vendor/libsodium/test/default/secretstream.c +52 -3
- data/vendor/libsodium/test/default/sign.c +16 -0
- data/vendor/libsodium/test/default/sodium_core.c +1 -0
- data/vendor/libsodium/test/default/sodium_utils.c +2 -1
- data/vendor/libsodium/test/default/xchacha20.c +2 -1
- metadata +63 -12
- data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/base.h +0 -1344
- data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/base2.h +0 -40
- data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.c +0 -2797
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.c +0 -545
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.h +0 -10
- data/vendor/libsodium/src/libsodium/include/sodium/private/curve25519_ref10.h +0 -132
- data/vendor/libsodium/test/default/index-wasm.html.tpl +0 -118
@@ -0,0 +1,40 @@
|
|
1
|
+
{
|
2
|
+
{ 1288382639258501, 245678601348599, 269427782077623, 1462984067271730, 137412439391563 },
|
3
|
+
{ 62697248952638, 204681361388450, 631292143396476, 338455783676468, 1213667448819585 },
|
4
|
+
{ 301289933810280, 1259582250014073, 1422107436869536, 796239922652654, 1953934009299142 }
|
5
|
+
},
|
6
|
+
{
|
7
|
+
{ 1601611775252272, 1720807796594148, 1132070835939856, 1260455018889551, 2147779492816911 },
|
8
|
+
{ 316559037616741, 2177824224946892, 1459442586438991, 1461528397712656, 751590696113597 },
|
9
|
+
{ 1850748884277385, 1200145853858453, 1068094770532492, 672251375690438, 1586055907191707 }
|
10
|
+
},
|
11
|
+
{
|
12
|
+
{ 769950342298419, 132954430919746, 844085933195555, 974092374476333, 726076285546016 },
|
13
|
+
{ 425251763115706, 608463272472562, 442562545713235, 837766094556764, 374555092627893 },
|
14
|
+
{ 1086255230780037, 274979815921559, 1960002765731872, 929474102396301, 1190409889297339 }
|
15
|
+
},
|
16
|
+
{
|
17
|
+
{ 665000864555967, 2065379846933859, 370231110385876, 350988370788628, 1233371373142985 },
|
18
|
+
{ 2019367628972465, 676711900706637, 110710997811333, 1108646842542025, 517791959672113 },
|
19
|
+
{ 965130719900578, 247011430587952, 526356006571389, 91986625355052, 2157223321444601 }
|
20
|
+
},
|
21
|
+
{
|
22
|
+
{ 1802695059465007, 1664899123557221, 593559490740857, 2160434469266659, 927570450755031 },
|
23
|
+
{ 1725674970513508, 1933645953859181, 1542344539275782, 1767788773573747, 1297447965928905 },
|
24
|
+
{ 1381809363726107, 1430341051343062, 2061843536018959, 1551778050872521, 2036394857967624 }
|
25
|
+
},
|
26
|
+
{
|
27
|
+
{ 1970894096313054, 528066325833207, 1619374932191227, 2207306624415883, 1169170329061080 },
|
28
|
+
{ 2070390218572616, 1458919061857835, 624171843017421, 1055332792707765, 433987520732508 },
|
29
|
+
{ 893653801273833, 1168026499324677, 1242553501121234, 1306366254304474, 1086752658510815 }
|
30
|
+
},
|
31
|
+
{
|
32
|
+
{ 213454002618221, 939771523987438, 1159882208056014, 317388369627517, 621213314200687 },
|
33
|
+
{ 1971678598905747, 338026507889165, 762398079972271, 655096486107477, 42299032696322 },
|
34
|
+
{ 177130678690680, 1754759263300204, 1864311296286618, 1180675631479880, 1292726903152791 }
|
35
|
+
},
|
36
|
+
{
|
37
|
+
{ 1913163449625248, 460779200291993, 2193883288642314, 1008900146920800, 1721983679009502 },
|
38
|
+
{ 1070401523076875, 1272492007800961, 1910153608563310, 2075579521696771, 1191169788841221 },
|
39
|
+
{ 692896803108118, 500174642072499, 2068223309439677, 1162190621851337, 1426986007309901 }
|
40
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/* 37095705934669439343138083508754565189542113879843219016388785533085940283555 */
|
2
|
+
static const fe25519 d = {
|
3
|
+
929955233495203, 466365720129213, 1662059464998953, 2033849074728123, 1442794654840575
|
4
|
+
};
|
5
|
+
|
6
|
+
/* 2 * d =
|
7
|
+
* 16295367250680780974490674513165176452449235426866156013048779062215315747161
|
8
|
+
*/
|
9
|
+
static const fe25519 d2 = {
|
10
|
+
1859910466990425, 932731440258426, 1072319116312658, 1815898335770999, 633789495995903
|
11
|
+
};
|
12
|
+
|
13
|
+
/* sqrt(-1) */
|
14
|
+
static const fe25519 sqrtm1 = {
|
15
|
+
1718705420411056, 234908883556509, 2233514472574048, 2117202627021982, 765476049583133
|
16
|
+
};
|
17
|
+
|
18
|
+
/* A = 486662 */
|
19
|
+
static const fe25519 curve25519_A = {
|
20
|
+
486662, 0, 0, 0, 0
|
21
|
+
};
|
@@ -0,0 +1,116 @@
|
|
1
|
+
/*
|
2
|
+
Ignores top bit of h.
|
3
|
+
*/
|
4
|
+
|
5
|
+
void
|
6
|
+
fe25519_frombytes(fe25519 h, const unsigned char *s)
|
7
|
+
{
|
8
|
+
const uint64_t mask = 0x7ffffffffffffULL;
|
9
|
+
uint64_t h0, h1, h2, h3, h4;
|
10
|
+
|
11
|
+
h0 = (LOAD64_LE(s ) ) & mask;
|
12
|
+
h1 = (LOAD64_LE(s + 6) >> 3) & mask;
|
13
|
+
h2 = (LOAD64_LE(s + 12) >> 6) & mask;
|
14
|
+
h3 = (LOAD64_LE(s + 19) >> 1) & mask;
|
15
|
+
h4 = (LOAD64_LE(s + 24) >> 12) & mask;
|
16
|
+
|
17
|
+
h[0] = h0;
|
18
|
+
h[1] = h1;
|
19
|
+
h[2] = h2;
|
20
|
+
h[3] = h3;
|
21
|
+
h[4] = h4;
|
22
|
+
}
|
23
|
+
|
24
|
+
static void
|
25
|
+
fe25519_reduce(fe25519 h, const fe25519 f)
|
26
|
+
{
|
27
|
+
const uint64_t mask = 0x7ffffffffffffULL;
|
28
|
+
uint128_t t[5];
|
29
|
+
|
30
|
+
t[0] = f[0];
|
31
|
+
t[1] = f[1];
|
32
|
+
t[2] = f[2];
|
33
|
+
t[3] = f[3];
|
34
|
+
t[4] = f[4];
|
35
|
+
|
36
|
+
t[1] += t[0] >> 51;
|
37
|
+
t[0] &= mask;
|
38
|
+
t[2] += t[1] >> 51;
|
39
|
+
t[1] &= mask;
|
40
|
+
t[3] += t[2] >> 51;
|
41
|
+
t[2] &= mask;
|
42
|
+
t[4] += t[3] >> 51;
|
43
|
+
t[3] &= mask;
|
44
|
+
t[0] += 19 * (t[4] >> 51);
|
45
|
+
t[4] &= mask;
|
46
|
+
|
47
|
+
t[1] += t[0] >> 51;
|
48
|
+
t[0] &= mask;
|
49
|
+
t[2] += t[1] >> 51;
|
50
|
+
t[1] &= mask;
|
51
|
+
t[3] += t[2] >> 51;
|
52
|
+
t[2] &= mask;
|
53
|
+
t[4] += t[3] >> 51;
|
54
|
+
t[3] &= mask;
|
55
|
+
t[0] += 19 * (t[4] >> 51);
|
56
|
+
t[4] &= mask;
|
57
|
+
|
58
|
+
/* now t is between 0 and 2^255-1, properly carried. */
|
59
|
+
/* case 1: between 0 and 2^255-20. case 2: between 2^255-19 and 2^255-1. */
|
60
|
+
|
61
|
+
t[0] += 19ULL;
|
62
|
+
|
63
|
+
t[1] += t[0] >> 51;
|
64
|
+
t[0] &= mask;
|
65
|
+
t[2] += t[1] >> 51;
|
66
|
+
t[1] &= mask;
|
67
|
+
t[3] += t[2] >> 51;
|
68
|
+
t[2] &= mask;
|
69
|
+
t[4] += t[3] >> 51;
|
70
|
+
t[3] &= mask;
|
71
|
+
t[0] += 19ULL * (t[4] >> 51);
|
72
|
+
t[4] &= mask;
|
73
|
+
|
74
|
+
/* now between 19 and 2^255-1 in both cases, and offset by 19. */
|
75
|
+
|
76
|
+
t[0] += 0x8000000000000 - 19ULL;
|
77
|
+
t[1] += 0x8000000000000 - 1ULL;
|
78
|
+
t[2] += 0x8000000000000 - 1ULL;
|
79
|
+
t[3] += 0x8000000000000 - 1ULL;
|
80
|
+
t[4] += 0x8000000000000 - 1ULL;
|
81
|
+
|
82
|
+
/* now between 2^255 and 2^256-20, and offset by 2^255. */
|
83
|
+
|
84
|
+
t[1] += t[0] >> 51;
|
85
|
+
t[0] &= mask;
|
86
|
+
t[2] += t[1] >> 51;
|
87
|
+
t[1] &= mask;
|
88
|
+
t[3] += t[2] >> 51;
|
89
|
+
t[2] &= mask;
|
90
|
+
t[4] += t[3] >> 51;
|
91
|
+
t[3] &= mask;
|
92
|
+
t[4] &= mask;
|
93
|
+
|
94
|
+
h[0] = t[0];
|
95
|
+
h[1] = t[1];
|
96
|
+
h[2] = t[2];
|
97
|
+
h[3] = t[3];
|
98
|
+
h[4] = t[4];
|
99
|
+
}
|
100
|
+
|
101
|
+
void
|
102
|
+
fe25519_tobytes(unsigned char *s, const fe25519 h)
|
103
|
+
{
|
104
|
+
fe25519 t;
|
105
|
+
uint64_t t0, t1, t2, t3;
|
106
|
+
|
107
|
+
fe25519_reduce(t, h);
|
108
|
+
t0 = t[0] | (t[1] << 51);
|
109
|
+
t1 = (t[1] >> 13) | (t[2] << 38);
|
110
|
+
t2 = (t[2] >> 26) | (t[3] << 25);
|
111
|
+
t3 = (t[3] >> 39) | (t[4] << 12);
|
112
|
+
STORE64_LE(s + 0, t0);
|
113
|
+
STORE64_LE(s + 8, t1);
|
114
|
+
STORE64_LE(s + 16, t2);
|
115
|
+
STORE64_LE(s + 24, t3);
|
116
|
+
}
|
@@ -76,7 +76,7 @@ typedef crypto_generichash_blake2b_state blake2b_state;
|
|
76
76
|
/* Streaming API */
|
77
77
|
int blake2b_init(blake2b_state *S, const uint8_t outlen);
|
78
78
|
int blake2b_init_salt_personal(blake2b_state *S, const uint8_t outlen,
|
79
|
-
const void *
|
79
|
+
const void *salt, const void *personal);
|
80
80
|
int blake2b_init_key(blake2b_state *S, const uint8_t outlen, const void *key,
|
81
81
|
const uint8_t keylen);
|
82
82
|
int blake2b_init_key_salt_personal(blake2b_state *S, const uint8_t outlen,
|
@@ -25,14 +25,6 @@
|
|
25
25
|
#include "runtime.h"
|
26
26
|
#include "utils.h"
|
27
27
|
|
28
|
-
#ifdef HAVE_TI_MODE
|
29
|
-
# if defined(__SIZEOF_INT128__)
|
30
|
-
typedef unsigned __int128 uint128_t;
|
31
|
-
# else
|
32
|
-
typedef unsigned uint128_t __attribute__((mode(TI)));
|
33
|
-
# endif
|
34
|
-
#endif
|
35
|
-
|
36
28
|
static blake2b_compress_fn blake2b_compress = blake2b_compress_ref;
|
37
29
|
|
38
30
|
static const uint64_t blake2b_IV[8] = {
|
@@ -49,13 +41,6 @@ blake2b_set_lastnode(blake2b_state *S)
|
|
49
41
|
return 0;
|
50
42
|
}
|
51
43
|
/* LCOV_EXCL_STOP */
|
52
|
-
#if 0
|
53
|
-
static inline int blake2b_clear_lastnode( blake2b_state *S )
|
54
|
-
{
|
55
|
-
S->f[1] = 0;
|
56
|
-
return 0;
|
57
|
-
}
|
58
|
-
#endif
|
59
44
|
|
60
45
|
static inline int
|
61
46
|
blake2b_is_lastblock(const blake2b_state *S)
|
@@ -72,15 +57,7 @@ blake2b_set_lastblock(blake2b_state *S)
|
|
72
57
|
S->f[0] = -1;
|
73
58
|
return 0;
|
74
59
|
}
|
75
|
-
#if 0
|
76
|
-
static inline int blake2b_clear_lastblock( blake2b_state *S )
|
77
|
-
{
|
78
|
-
if( S->last_node ) blake2b_clear_lastnode( S );
|
79
60
|
|
80
|
-
S->f[0] = 0;
|
81
|
-
return 0;
|
82
|
-
}
|
83
|
-
#endif
|
84
61
|
static inline int
|
85
62
|
blake2b_increment_counter(blake2b_state *S, const uint64_t inc)
|
86
63
|
{
|
@@ -97,51 +74,6 @@ blake2b_increment_counter(blake2b_state *S, const uint64_t inc)
|
|
97
74
|
}
|
98
75
|
|
99
76
|
/* Parameter-related functions */
|
100
|
-
#if 0
|
101
|
-
/* Redundant: digest length is directly set in blake2b_init(), blake2b_init_salt_personal(),
|
102
|
-
* blake2b_init_key() and blake2b_init_key_salt_personal() */
|
103
|
-
static inline int blake2b_param_set_digest_length( blake2b_param *P, const uint8_t digest_length )
|
104
|
-
{
|
105
|
-
P->digest_length = digest_length;
|
106
|
-
return 0;
|
107
|
-
}
|
108
|
-
|
109
|
-
static inline int blake2b_param_set_fanout( blake2b_param *P, const uint8_t fanout )
|
110
|
-
{
|
111
|
-
P->fanout = fanout;
|
112
|
-
return 0;
|
113
|
-
}
|
114
|
-
|
115
|
-
static inline int blake2b_param_set_max_depth( blake2b_param *P, const uint8_t depth )
|
116
|
-
{
|
117
|
-
P->depth = depth;
|
118
|
-
return 0;
|
119
|
-
}
|
120
|
-
|
121
|
-
static inline int blake2b_param_set_leaf_length( blake2b_param *P, const uint32_t leaf_length )
|
122
|
-
{
|
123
|
-
STORE32_LE( P->leaf_length, leaf_length );
|
124
|
-
return 0;
|
125
|
-
}
|
126
|
-
|
127
|
-
static inline int blake2b_param_set_node_offset( blake2b_param *P, const uint64_t node_offset )
|
128
|
-
{
|
129
|
-
STORE64_LE( P->node_offset, node_offset );
|
130
|
-
return 0;
|
131
|
-
}
|
132
|
-
|
133
|
-
static inline int blake2b_param_set_node_depth( blake2b_param *P, const uint8_t node_depth )
|
134
|
-
{
|
135
|
-
P->node_depth = node_depth;
|
136
|
-
return 0;
|
137
|
-
}
|
138
|
-
|
139
|
-
static inline int blake2b_param_set_inner_length( blake2b_param *P, const uint8_t inner_length )
|
140
|
-
{
|
141
|
-
P->inner_length = inner_length;
|
142
|
-
return 0;
|
143
|
-
}
|
144
|
-
#endif
|
145
77
|
static inline int
|
146
78
|
blake2b_param_set_salt(blake2b_param *P, const uint8_t salt[BLAKE2B_SALTBYTES])
|
147
79
|
{
|
@@ -271,7 +203,7 @@ blake2b_init_key(blake2b_state *S, const uint8_t outlen, const void *key,
|
|
271
203
|
{
|
272
204
|
uint8_t block[BLAKE2B_BLOCKBYTES];
|
273
205
|
memset(block, 0, BLAKE2B_BLOCKBYTES);
|
274
|
-
memcpy(block, key, keylen);
|
206
|
+
memcpy(block, key, keylen); /* keylen cannot be 0 */
|
275
207
|
blake2b_update(S, block, BLAKE2B_BLOCKBYTES);
|
276
208
|
sodium_memzero(block, BLAKE2B_BLOCKBYTES); /* Burn the key from stack */
|
277
209
|
}
|
@@ -317,7 +249,7 @@ blake2b_init_key_salt_personal(blake2b_state *S, const uint8_t outlen,
|
|
317
249
|
{
|
318
250
|
uint8_t block[BLAKE2B_BLOCKBYTES];
|
319
251
|
memset(block, 0, BLAKE2B_BLOCKBYTES);
|
320
|
-
memcpy(block, key, keylen);
|
252
|
+
memcpy(block, key, keylen); /* keylen cannot be 0 */
|
321
253
|
blake2b_update(S, block, BLAKE2B_BLOCKBYTES);
|
322
254
|
sodium_memzero(block, BLAKE2B_BLOCKBYTES); /* Burn the key from stack */
|
323
255
|
}
|
@@ -357,6 +289,8 @@ blake2b_update(blake2b_state *S, const uint8_t *in, uint64_t inlen)
|
|
357
289
|
int
|
358
290
|
blake2b_final(blake2b_state *S, uint8_t *out, uint8_t outlen)
|
359
291
|
{
|
292
|
+
unsigned char buffer[BLAKE2B_OUTBYTES];
|
293
|
+
|
360
294
|
if (!outlen || outlen > BLAKE2B_OUTBYTES) {
|
361
295
|
sodium_misuse();
|
362
296
|
}
|
@@ -377,19 +311,17 @@ blake2b_final(blake2b_state *S, uint8_t *out, uint8_t outlen)
|
|
377
311
|
2 * BLAKE2B_BLOCKBYTES - S->buflen); /* Padding */
|
378
312
|
blake2b_compress(S, S->buf);
|
379
313
|
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
314
|
+
COMPILER_ASSERT(sizeof buffer == 64U);
|
315
|
+
STORE64_LE(buffer + 8 * 0, S->h[0]);
|
316
|
+
STORE64_LE(buffer + 8 * 1, S->h[1]);
|
317
|
+
STORE64_LE(buffer + 8 * 2, S->h[2]);
|
318
|
+
STORE64_LE(buffer + 8 * 3, S->h[3]);
|
319
|
+
STORE64_LE(buffer + 8 * 4, S->h[4]);
|
320
|
+
STORE64_LE(buffer + 8 * 5, S->h[5]);
|
321
|
+
STORE64_LE(buffer + 8 * 6, S->h[6]);
|
322
|
+
STORE64_LE(buffer + 8 * 7, S->h[7]);
|
323
|
+
memcpy(out, buffer, outlen); /* outlen <= BLAKE2B_OUTBYTES (64) */
|
386
324
|
|
387
|
-
for (i = 0; i < 8; i++) { /* Output full hash to temp buffer */
|
388
|
-
STORE64_LE(buffer + sizeof(S->h[i]) * i, S->h[i]);
|
389
|
-
}
|
390
|
-
memcpy(out, buffer, outlen);
|
391
|
-
}
|
392
|
-
#endif
|
393
325
|
sodium_memzero(S->h, sizeof S->h);
|
394
326
|
sodium_memzero(S->buf, sizeof S->buf);
|
395
327
|
|
@@ -153,10 +153,10 @@ static const uint8_t PAD[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
153
153
|
static void
|
154
154
|
SHA256_Pad(crypto_hash_sha256_state *state, uint32_t tmp32[64 + 8])
|
155
155
|
{
|
156
|
-
|
157
|
-
|
156
|
+
unsigned int r;
|
157
|
+
unsigned int i;
|
158
158
|
|
159
|
-
r = (state->count >> 3) & 0x3f;
|
159
|
+
r = (unsigned int) ((state->count >> 3) & 0x3f);
|
160
160
|
if (r < 56) {
|
161
161
|
for (i = 0; i < 56 - r; i++) {
|
162
162
|
state->buf[r + i] = PAD[i];
|
@@ -172,10 +172,10 @@ static const uint8_t PAD[128] = {
|
|
172
172
|
static void
|
173
173
|
SHA512_Pad(crypto_hash_sha512_state *state, uint64_t tmp64[80 + 8])
|
174
174
|
{
|
175
|
-
|
176
|
-
|
175
|
+
unsigned int r;
|
176
|
+
unsigned int i;
|
177
177
|
|
178
|
-
r = (state->count[1] >> 3) & 0x7f;
|
178
|
+
r = (unsigned int) ((state->count[1] >> 3) & 0x7f);
|
179
179
|
if (r < 112) {
|
180
180
|
for (i = 0; i < 112 - r; i++) {
|
181
181
|
state->buf[r + i] = PAD[i];
|
@@ -3,11 +3,7 @@
|
|
3
3
|
and 128 bit addition
|
4
4
|
*/
|
5
5
|
|
6
|
-
#
|
7
|
-
typedef unsigned __int128 uint128_t;
|
8
|
-
#else
|
9
|
-
typedef unsigned uint128_t __attribute__((mode(TI)));
|
10
|
-
#endif
|
6
|
+
#include "private/common.h"
|
11
7
|
|
12
8
|
#define MUL(out, x, y) out = ((uint128_t) x * y)
|
13
9
|
#define ADD(out, in) out += in
|
@@ -23,8 +19,6 @@ typedef unsigned uint128_t __attribute__((mode(TI)));
|
|
23
19
|
# define POLY1305_NOINLINE
|
24
20
|
#endif
|
25
21
|
|
26
|
-
#include "private/common.h"
|
27
|
-
|
28
22
|
#define poly1305_block_size 16
|
29
23
|
|
30
24
|
/* 17 + sizeof(unsigned long long) + 8*sizeof(unsigned long long) */
|
@@ -19,12 +19,6 @@
|
|
19
19
|
|
20
20
|
typedef __m128i xmmi;
|
21
21
|
|
22
|
-
# if defined(__SIZEOF_INT128__)
|
23
|
-
typedef unsigned __int128 uint128_t;
|
24
|
-
# else
|
25
|
-
typedef unsigned uint128_t __attribute__((mode(TI)));
|
26
|
-
# endif
|
27
|
-
|
28
22
|
# if defined(_MSC_VER)
|
29
23
|
# define POLY1305_NOINLINE __declspec(noinline)
|
30
24
|
# elif defined(__GNUC__)
|
@@ -24,6 +24,7 @@
|
|
24
24
|
|
25
25
|
#include "crypto_generichash_blake2b.h"
|
26
26
|
#include "private/common.h"
|
27
|
+
#include "private/implementations.h"
|
27
28
|
#include "runtime.h"
|
28
29
|
#include "utils.h"
|
29
30
|
|
@@ -33,6 +34,12 @@
|
|
33
34
|
#if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
|
34
35
|
# define MAP_ANON MAP_ANONYMOUS
|
35
36
|
#endif
|
37
|
+
#ifndef MAP_NOCORE
|
38
|
+
# define MAP_NOCORE 0
|
39
|
+
#endif
|
40
|
+
#ifndef MAP_POPULATE
|
41
|
+
# define MAP_POPULATE 0
|
42
|
+
#endif
|
36
43
|
|
37
44
|
static fill_segment_fn fill_segment = fill_segment_ref;
|
38
45
|
|
@@ -87,11 +94,7 @@ allocate_memory(block_region **region, uint32_t m_cost)
|
|
87
94
|
|
88
95
|
#if defined(MAP_ANON) && defined(HAVE_MMAP)
|
89
96
|
if ((base = mmap(NULL, memory_size, PROT_READ | PROT_WRITE,
|
90
|
-
|
91
|
-
MAP_ANON | MAP_PRIVATE | MAP_NOCORE,
|
92
|
-
#else
|
93
|
-
MAP_ANON | MAP_PRIVATE,
|
94
|
-
#endif
|
97
|
+
MAP_ANON | MAP_PRIVATE | MAP_NOCORE | MAP_POPULATE,
|
95
98
|
-1, 0)) == MAP_FAILED) {
|
96
99
|
base = NULL; /* LCOV_EXCL_LINE */
|
97
100
|
} /* LCOV_EXCL_LINE */
|
@@ -214,100 +217,24 @@ finalize(const argon2_context *context, argon2_instance_t *instance)
|
|
214
217
|
}
|
215
218
|
}
|
216
219
|
|
217
|
-
uint32_t
|
218
|
-
index_alpha(const argon2_instance_t *instance,
|
219
|
-
const argon2_position_t *position, uint32_t pseudo_rand,
|
220
|
-
int same_lane)
|
221
|
-
{
|
222
|
-
/*
|
223
|
-
* Pass 0:
|
224
|
-
* This lane : all already finished segments plus already constructed
|
225
|
-
* blocks in this segment
|
226
|
-
* Other lanes : all already finished segments
|
227
|
-
* Pass 1+:
|
228
|
-
* This lane : (SYNC_POINTS - 1) last segments plus already constructed
|
229
|
-
* blocks in this segment
|
230
|
-
* Other lanes : (SYNC_POINTS - 1) last segments
|
231
|
-
*/
|
232
|
-
uint32_t reference_area_size;
|
233
|
-
uint64_t relative_position;
|
234
|
-
uint32_t start_position, absolute_position;
|
235
|
-
|
236
|
-
if (position->pass == 0) {
|
237
|
-
/* First pass */
|
238
|
-
if (position->slice == 0) {
|
239
|
-
/* First slice */
|
240
|
-
reference_area_size =
|
241
|
-
position->index - 1; /* all but the previous */
|
242
|
-
} else {
|
243
|
-
if (same_lane) {
|
244
|
-
/* The same lane => add current segment */
|
245
|
-
reference_area_size =
|
246
|
-
position->slice * instance->segment_length +
|
247
|
-
position->index - 1;
|
248
|
-
} else {
|
249
|
-
reference_area_size =
|
250
|
-
position->slice * instance->segment_length +
|
251
|
-
((position->index == 0) ? (-1) : 0);
|
252
|
-
}
|
253
|
-
}
|
254
|
-
} else {
|
255
|
-
/* Second pass */
|
256
|
-
if (same_lane) {
|
257
|
-
reference_area_size = instance->lane_length -
|
258
|
-
instance->segment_length + position->index -
|
259
|
-
1;
|
260
|
-
} else {
|
261
|
-
reference_area_size = instance->lane_length -
|
262
|
-
instance->segment_length +
|
263
|
-
((position->index == 0) ? (-1) : 0);
|
264
|
-
}
|
265
|
-
}
|
266
|
-
|
267
|
-
/* 1.2.4. Mapping pseudo_rand to 0..<reference_area_size-1> and produce
|
268
|
-
* relative position */
|
269
|
-
relative_position = pseudo_rand;
|
270
|
-
relative_position = relative_position * relative_position >> 32;
|
271
|
-
relative_position = reference_area_size - 1 -
|
272
|
-
(reference_area_size * relative_position >> 32);
|
273
|
-
|
274
|
-
/* 1.2.5 Computing starting position */
|
275
|
-
start_position = 0;
|
276
|
-
|
277
|
-
if (position->pass != 0) {
|
278
|
-
start_position = (position->slice == ARGON2_SYNC_POINTS - 1)
|
279
|
-
? 0
|
280
|
-
: (position->slice + 1) * instance->segment_length;
|
281
|
-
}
|
282
|
-
|
283
|
-
/* 1.2.6. Computing absolute position */
|
284
|
-
absolute_position = (start_position + relative_position) %
|
285
|
-
instance->lane_length; /* absolute position */
|
286
|
-
return absolute_position;
|
287
|
-
}
|
288
|
-
|
289
220
|
void
|
290
|
-
fill_memory_blocks(argon2_instance_t *instance)
|
221
|
+
fill_memory_blocks(argon2_instance_t *instance, uint32_t pass)
|
291
222
|
{
|
292
|
-
|
223
|
+
argon2_position_t position;
|
224
|
+
uint32_t l;
|
225
|
+
uint32_t s;
|
293
226
|
|
294
227
|
if (instance == NULL || instance->lanes == 0) {
|
295
228
|
return; /* LCOV_EXCL_LINE */
|
296
229
|
}
|
297
230
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
position.pass = r;
|
306
|
-
position.lane = l;
|
307
|
-
position.slice = (uint8_t) s;
|
308
|
-
position.index = 0;
|
309
|
-
fill_segment(instance, position);
|
310
|
-
}
|
231
|
+
position.pass = pass;
|
232
|
+
for (s = 0; s < ARGON2_SYNC_POINTS; ++s) {
|
233
|
+
position.slice = (uint8_t) s;
|
234
|
+
for (l = 0; l < instance->lanes; ++l) {
|
235
|
+
position.lane = l;
|
236
|
+
position.index = 0;
|
237
|
+
fill_segment(instance, position);
|
311
238
|
}
|
312
239
|
}
|
313
240
|
}
|