rbnacl-libsodium 1.0.13 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +5 -0
- data/lib/rbnacl/libsodium.rb +1 -0
- data/lib/rbnacl/libsodium/version.rb +1 -1
- data/vendor/libsodium/AUTHORS +2 -2
- data/vendor/libsodium/ChangeLog +64 -0
- data/vendor/libsodium/Makefile.am +1 -0
- data/vendor/libsodium/README.markdown +1 -3
- data/vendor/libsodium/THANKS +13 -3
- data/vendor/libsodium/builds/Makefile.am +65 -0
- data/vendor/libsodium/builds/msvc/resource.rc +2 -2
- data/vendor/libsodium/builds/msvc/version.h +3 -3
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +168 -173
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +382 -394
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +168 -173
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +382 -394
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +168 -173
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +382 -394
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +168 -173
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +382 -394
- data/vendor/libsodium/builds/msvc/vs2017/libsodium/libsodium.vcxproj +168 -173
- data/vendor/libsodium/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters +382 -394
- data/vendor/libsodium/configure.ac +59 -10
- data/vendor/libsodium/contrib/Findsodium.cmake +2 -0
- data/vendor/libsodium/dist-build/emscripten-symbols.def +72 -32
- data/vendor/libsodium/dist-build/emscripten.sh +33 -6
- data/vendor/libsodium/dist-build/generate-emscripten-symbols.sh +52 -38
- data/vendor/libsodium/dist-build/ios.sh +2 -2
- data/vendor/libsodium/libsodium.vcxproj +168 -173
- data/vendor/libsodium/libsodium.vcxproj.filters +220 -235
- data/vendor/libsodium/m4/ax_check_catchable_abrt.m4 +57 -0
- data/vendor/libsodium/m4/ax_check_gnu_make.m4 +2 -2
- data/vendor/libsodium/m4/ax_pthread.m4 +2 -2
- data/vendor/libsodium/msvc-scripts/process.bat +3 -3
- data/vendor/libsodium/packaging/dotnet-core/README.md +5 -5
- data/vendor/libsodium/packaging/dotnet-core/libsodium.props +5 -2
- data/vendor/libsodium/packaging/dotnet-core/prepare.py +13 -31
- data/vendor/libsodium/packaging/dotnet-core/recipes/linux-x64 +4 -0
- data/vendor/libsodium/packaging/nuget/package.config +1 -1
- data/vendor/libsodium/src/libsodium/Makefile.am +11 -12
- data/vendor/libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +11 -4
- data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +17 -4
- data/vendor/libsodium/src/libsodium/crypto_aead/xchacha20poly1305/sodium/aead_xchacha20poly1305.c +8 -1
- data/vendor/libsodium/src/libsodium/crypto_box/crypto_box.c +6 -0
- data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_easy.c +5 -4
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xchacha20poly1305/box_curve25519xchacha20poly1305.c +11 -4
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305.c +6 -0
- data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.c +78 -17
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-ref.c +74 -64
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512_cp.c +2 -0
- data/vendor/libsodium/src/libsodium/crypto_kx/crypto_kx.c +7 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +1 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c +17 -17
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.c +53 -48
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.h +37 -11
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c +23 -179
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-avx2.c +4 -12
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-avx512f.c +244 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ref.c +3 -12
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ssse3.c +4 -12
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.c +1 -5
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blamka-round-avx512f.h +145 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/pwhash_argon2i.c +91 -14
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/pwhash_argon2id.c +35 -14
- data/vendor/libsodium/src/libsodium/crypto_pwhash/crypto_pwhash.c +41 -4
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +31 -17
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +4 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.c +5 -1
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +30 -1
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +8 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519.c +3 -3
- data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox.c +6 -0
- data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +5 -4
- data/vendor/libsodium/src/libsodium/crypto_secretbox/xchacha20poly1305/secretbox_xchacha20poly1305.c +11 -4
- data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305.c +6 -0
- data/vendor/libsodium/src/libsodium/crypto_secretstream/xchacha20poly1305/secretstream_xchacha20poly1305.c +311 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/crypto_sign.c +6 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ed25519_ref10.h +3 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +9 -2
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/obsolete.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +6 -5
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/sign_ed25519.c +6 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/chacha20_dolbeau-avx2.c +3 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/chacha20_dolbeau-ssse3.c +3 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/u0.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/chacha20_ref.c +3 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/stream_chacha20.c +12 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/crypto_stream.c +6 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20.c +7 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/u0.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/stream_salsa2012.c +6 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/stream_salsa208.c +6 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/xchacha20/stream_xchacha20.c +6 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/stream_xsalsa20.c +6 -0
- data/vendor/libsodium/src/libsodium/crypto_verify/sodium/verify.c +66 -29
- data/vendor/libsodium/src/libsodium/include/Makefile.am +1 -1
- data/vendor/libsodium/src/libsodium/include/sodium.h +2 -2
- data/vendor/libsodium/src/libsodium/include/sodium/core.h +9 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_aes256gcm.h +26 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h +16 -4
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_xchacha20poly1305.h +10 -4
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_box.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xchacha20poly1305.h +6 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +24 -15
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_salsa208.h +8 -4
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash.h +40 -18
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_argon2i.h +8 -2
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_argon2id.h +8 -2
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h +11 -3
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xchacha20poly1305.h +6 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h +17 -8
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretstream_xchacha20poly1305.h +102 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_ed25519.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h +1 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_chacha20.h +10 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa20.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa2012.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa208.h +15 -5
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_xchacha20.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_xsalsa20.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/export.h +9 -0
- data/vendor/libsodium/src/libsodium/include/sodium/private/common.h +11 -0
- data/vendor/libsodium/src/libsodium/include/sodium/private/curve25519_ref10.h +2 -30
- data/vendor/libsodium/src/libsodium/include/sodium/randombytes.h +2 -0
- data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +12 -9
- data/vendor/libsodium/src/libsodium/include/sodium/utils.h +36 -0
- data/vendor/libsodium/src/libsodium/randombytes/nativeclient/randombytes_nativeclient.c +3 -2
- data/vendor/libsodium/src/libsodium/randombytes/randombytes.c +18 -14
- data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +11 -10
- data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +20 -8
- data/vendor/libsodium/src/libsodium/sodium/codecs.c +333 -0
- data/vendor/libsodium/src/libsodium/sodium/core.c +36 -4
- data/vendor/libsodium/src/libsodium/sodium/runtime.c +18 -0
- data/vendor/libsodium/src/libsodium/sodium/utils.c +87 -100
- data/vendor/libsodium/test/constcheck.sh +19 -0
- data/vendor/libsodium/test/default/Makefile.am +39 -7
- data/vendor/libsodium/test/default/aead_aes256gcm.c +6 -0
- data/vendor/libsodium/test/default/aead_chacha20poly1305.c +16 -0
- data/vendor/libsodium/test/default/aead_xchacha20poly1305.c +25 -15
- data/vendor/libsodium/test/default/auth.c +13 -0
- data/vendor/libsodium/test/default/auth.exp +8 -0
- data/vendor/libsodium/test/default/box.c +3 -0
- data/vendor/libsodium/test/default/box2.c +2 -0
- data/vendor/libsodium/test/default/box_easy.c +1 -4
- data/vendor/libsodium/test/default/box_easy2.c +7 -3
- data/vendor/libsodium/test/default/chacha20.c +9 -2
- data/vendor/libsodium/test/default/cmptest.h +47 -1
- data/vendor/libsodium/test/default/codecs.c +226 -0
- data/vendor/libsodium/test/default/codecs.exp +28 -0
- data/vendor/libsodium/test/default/core3.c +42 -15
- data/vendor/libsodium/test/default/ed25519_convert.c +17 -0
- data/vendor/libsodium/test/default/kdf.c +8 -4
- data/vendor/libsodium/test/default/keygen.c +5 -2
- data/vendor/libsodium/test/default/kx.c +30 -0
- data/vendor/libsodium/test/default/metamorphic.c +187 -0
- data/vendor/libsodium/test/default/metamorphic.exp +1 -0
- data/vendor/libsodium/test/default/misuse.c +145 -0
- data/vendor/libsodium/test/default/misuse.exp +0 -0
- data/vendor/libsodium/test/default/onetimeauth.c +2 -0
- data/vendor/libsodium/test/default/{pwhash.c → pwhash_argon2i.c} +133 -106
- data/vendor/libsodium/test/default/{pwhash.exp → pwhash_argon2i.exp} +0 -1
- data/vendor/libsodium/test/default/pwhash_argon2id.c +254 -144
- data/vendor/libsodium/test/default/pwhash_argon2id.exp +2 -3
- data/vendor/libsodium/test/default/pwhash_scrypt.c +61 -18
- data/vendor/libsodium/test/default/pwhash_scrypt.exp +6 -0
- data/vendor/libsodium/test/default/randombytes.c +8 -3
- data/vendor/libsodium/test/default/secretbox.c +8 -0
- data/vendor/libsodium/test/default/secretbox2.c +5 -0
- data/vendor/libsodium/test/default/secretbox_easy.c +19 -1
- data/vendor/libsodium/test/default/secretbox_easy.exp +2 -0
- data/vendor/libsodium/test/default/secretbox_easy2.c +4 -0
- data/vendor/libsodium/test/default/secretstream.c +280 -0
- data/vendor/libsodium/test/default/secretstream.exp +1 -0
- data/vendor/libsodium/test/default/sign.c +31 -0
- data/vendor/libsodium/test/default/sodium_core.c +23 -1
- data/vendor/libsodium/test/default/sodium_core.exp +1 -1
- data/vendor/libsodium/test/default/sodium_utils.c +45 -56
- data/vendor/libsodium/test/default/sodium_utils.exp +0 -8
- data/vendor/libsodium/test/default/stream.c +2 -0
- data/vendor/libsodium/test/default/stream2.c +1 -0
- data/vendor/libsodium/test/default/xchacha20.c +58 -7
- metadata +21 -18
- data/vendor/libsodium/dist-build/emscripten-wasm.sh +0 -132
- data/vendor/libsodium/m4/pkg.m4 +0 -214
- data/vendor/libsodium/packaging/dotnet-core/desktop.targets +0 -16
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/afternm_aes128ctr.c +0 -174
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/beforenm_aes128ctr.c +0 -66
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/common.h +0 -766
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/consts.h +0 -28
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/consts_aes128ctr.c +0 -28
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/int128.h +0 -50
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/int128_aes128ctr.c +0 -149
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/stream_aes128ctr_nacl.c +0 -31
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/xor_afternm_aes128ctr.c +0 -195
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/stream_aes128ctr.c +0 -19
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes128ctr.h +0 -65
@@ -8,6 +8,7 @@
|
|
8
8
|
#include "argon2-core.h"
|
9
9
|
#include "argon2.h"
|
10
10
|
#include "crypto_pwhash_argon2id.h"
|
11
|
+
#include "private/common.h"
|
11
12
|
#include "randombytes.h"
|
12
13
|
#include "utils.h"
|
13
14
|
|
@@ -22,30 +23,36 @@ crypto_pwhash_argon2id_alg_argon2id13(void)
|
|
22
23
|
size_t
|
23
24
|
crypto_pwhash_argon2id_bytes_min(void)
|
24
25
|
{
|
26
|
+
COMPILER_ASSERT(crypto_pwhash_argon2id_BYTES_MIN >= ARGON2_MIN_OUTLEN);
|
25
27
|
return crypto_pwhash_argon2id_BYTES_MIN;
|
26
28
|
}
|
27
29
|
|
28
30
|
size_t
|
29
31
|
crypto_pwhash_argon2id_bytes_max(void)
|
30
32
|
{
|
33
|
+
COMPILER_ASSERT(crypto_pwhash_argon2id_BYTES_MAX <= ARGON2_MAX_OUTLEN);
|
31
34
|
return crypto_pwhash_argon2id_BYTES_MAX;
|
32
35
|
}
|
33
36
|
|
34
37
|
size_t
|
35
38
|
crypto_pwhash_argon2id_passwd_min(void)
|
36
39
|
{
|
40
|
+
COMPILER_ASSERT(crypto_pwhash_argon2id_PASSWD_MIN >= ARGON2_MIN_PWD_LENGTH);
|
37
41
|
return crypto_pwhash_argon2id_PASSWD_MIN;
|
38
42
|
}
|
39
43
|
|
40
44
|
size_t
|
41
45
|
crypto_pwhash_argon2id_passwd_max(void)
|
42
46
|
{
|
47
|
+
COMPILER_ASSERT(crypto_pwhash_argon2id_PASSWD_MAX <= ARGON2_MAX_PWD_LENGTH);
|
43
48
|
return crypto_pwhash_argon2id_PASSWD_MAX;
|
44
49
|
}
|
45
50
|
|
46
51
|
size_t
|
47
52
|
crypto_pwhash_argon2id_saltbytes(void)
|
48
53
|
{
|
54
|
+
COMPILER_ASSERT(crypto_pwhash_argon2id_SALTBYTES >= ARGON2_MIN_SALT_LENGTH);
|
55
|
+
COMPILER_ASSERT(crypto_pwhash_argon2id_SALTBYTES <= ARGON2_MAX_SALT_LENGTH);
|
49
56
|
return crypto_pwhash_argon2id_SALTBYTES;
|
50
57
|
}
|
51
58
|
|
@@ -64,24 +71,28 @@ crypto_pwhash_argon2id_strprefix(void)
|
|
64
71
|
size_t
|
65
72
|
crypto_pwhash_argon2id_opslimit_min(void)
|
66
73
|
{
|
74
|
+
COMPILER_ASSERT(crypto_pwhash_argon2id_OPSLIMIT_MIN >= ARGON2_MIN_TIME);
|
67
75
|
return crypto_pwhash_argon2id_OPSLIMIT_MIN;
|
68
76
|
}
|
69
77
|
|
70
78
|
size_t
|
71
79
|
crypto_pwhash_argon2id_opslimit_max(void)
|
72
80
|
{
|
81
|
+
COMPILER_ASSERT(crypto_pwhash_argon2id_OPSLIMIT_MAX <= ARGON2_MAX_TIME);
|
73
82
|
return crypto_pwhash_argon2id_OPSLIMIT_MAX;
|
74
83
|
}
|
75
84
|
|
76
85
|
size_t
|
77
86
|
crypto_pwhash_argon2id_memlimit_min(void)
|
78
87
|
{
|
88
|
+
COMPILER_ASSERT((crypto_pwhash_argon2id_MEMLIMIT_MIN / 1024U) >= ARGON2_MIN_MEMORY);
|
79
89
|
return crypto_pwhash_argon2id_MEMLIMIT_MIN;
|
80
90
|
}
|
81
91
|
|
82
92
|
size_t
|
83
93
|
crypto_pwhash_argon2id_memlimit_max(void)
|
84
94
|
{
|
95
|
+
COMPILER_ASSERT((crypto_pwhash_argon2id_MEMLIMIT_MAX / 1024U) <= ARGON2_MAX_MEMORY);
|
85
96
|
return crypto_pwhash_argon2id_MEMLIMIT_MAX;
|
86
97
|
}
|
87
98
|
|
@@ -128,20 +139,29 @@ crypto_pwhash_argon2id(unsigned char *const out, unsigned long long outlen,
|
|
128
139
|
unsigned long long opslimit, size_t memlimit, int alg)
|
129
140
|
{
|
130
141
|
memset(out, 0, outlen);
|
131
|
-
|
132
|
-
if (outlen > ARGON2_MAX_OUTLEN || passwdlen > ARGON2_MAX_PWD_LENGTH ||
|
133
|
-
opslimit > ARGON2_MAX_TIME || memlimit > ARGON2_MAX_MEMORY) {
|
142
|
+
if (outlen > crypto_pwhash_argon2id_BYTES_MAX) {
|
134
143
|
errno = EFBIG;
|
135
144
|
return -1;
|
136
145
|
}
|
137
|
-
if (outlen <
|
138
|
-
|
146
|
+
if (outlen < crypto_pwhash_argon2id_BYTES_MIN) {
|
147
|
+
errno = EINVAL;
|
148
|
+
return -1;
|
149
|
+
}
|
150
|
+
if (passwdlen > crypto_pwhash_argon2id_PASSWD_MAX ||
|
151
|
+
opslimit > crypto_pwhash_argon2id_OPSLIMIT_MAX ||
|
152
|
+
memlimit > crypto_pwhash_argon2id_MEMLIMIT_MAX) {
|
153
|
+
errno = EFBIG;
|
154
|
+
return -1;
|
155
|
+
}
|
156
|
+
if (passwdlen < crypto_pwhash_argon2id_PASSWD_MIN ||
|
157
|
+
opslimit < crypto_pwhash_argon2id_OPSLIMIT_MIN ||
|
158
|
+
memlimit < crypto_pwhash_argon2id_MEMLIMIT_MIN) {
|
139
159
|
errno = EINVAL;
|
140
160
|
return -1;
|
141
161
|
}
|
142
162
|
switch (alg) {
|
143
163
|
case crypto_pwhash_argon2id_ALG_ARGON2ID13:
|
144
|
-
if (argon2id_hash_raw((uint32_t) opslimit, (uint32_t) memlimit,
|
164
|
+
if (argon2id_hash_raw((uint32_t) opslimit, (uint32_t) (memlimit / 1024U),
|
145
165
|
(uint32_t) 1U, passwd, (size_t) passwdlen, salt,
|
146
166
|
(size_t) crypto_pwhash_argon2id_SALTBYTES, out,
|
147
167
|
(size_t) outlen) != ARGON2_OK) {
|
@@ -163,19 +183,20 @@ crypto_pwhash_argon2id_str(char out[crypto_pwhash_argon2id_STRBYTES],
|
|
163
183
|
unsigned char salt[crypto_pwhash_argon2id_SALTBYTES];
|
164
184
|
|
165
185
|
memset(out, 0, crypto_pwhash_argon2id_STRBYTES);
|
166
|
-
|
167
|
-
|
168
|
-
memlimit >
|
186
|
+
if (passwdlen > crypto_pwhash_argon2id_PASSWD_MAX ||
|
187
|
+
opslimit > crypto_pwhash_argon2id_OPSLIMIT_MAX ||
|
188
|
+
memlimit > crypto_pwhash_argon2id_MEMLIMIT_MAX) {
|
169
189
|
errno = EFBIG;
|
170
190
|
return -1;
|
171
191
|
}
|
172
|
-
if (passwdlen <
|
173
|
-
|
192
|
+
if (passwdlen < crypto_pwhash_argon2id_PASSWD_MIN ||
|
193
|
+
opslimit < crypto_pwhash_argon2id_OPSLIMIT_MIN ||
|
194
|
+
memlimit < crypto_pwhash_argon2id_MEMLIMIT_MIN) {
|
174
195
|
errno = EINVAL;
|
175
196
|
return -1;
|
176
197
|
}
|
177
198
|
randombytes_buf(salt, sizeof salt);
|
178
|
-
if (argon2id_hash_encoded((uint32_t) opslimit, (uint32_t) memlimit,
|
199
|
+
if (argon2id_hash_encoded((uint32_t) opslimit, (uint32_t) (memlimit / 1024U),
|
179
200
|
(uint32_t) 1U, passwd, (size_t) passwdlen, salt,
|
180
201
|
sizeof salt, STR_HASHBYTES, out,
|
181
202
|
crypto_pwhash_argon2id_STRBYTES) != ARGON2_OK) {
|
@@ -191,12 +212,12 @@ crypto_pwhash_argon2id_str_verify(const char str[crypto_pwhash_argon2id_STRBYTES
|
|
191
212
|
{
|
192
213
|
int verify_ret;
|
193
214
|
|
194
|
-
if (passwdlen >
|
215
|
+
if (passwdlen > crypto_pwhash_argon2id_PASSWD_MAX) {
|
195
216
|
errno = EFBIG;
|
196
217
|
return -1;
|
197
218
|
}
|
198
219
|
/* LCOV_EXCL_START */
|
199
|
-
if (passwdlen <
|
220
|
+
if (passwdlen < crypto_pwhash_argon2id_PASSWD_MIN) {
|
200
221
|
errno = EINVAL;
|
201
222
|
return -1;
|
202
223
|
}
|
@@ -2,6 +2,7 @@
|
|
2
2
|
#include <errno.h>
|
3
3
|
#include <string.h>
|
4
4
|
|
5
|
+
#include "core.h"
|
5
6
|
#include "crypto_pwhash.h"
|
6
7
|
|
7
8
|
int
|
@@ -19,7 +20,7 @@ crypto_pwhash_alg_argon2id13(void)
|
|
19
20
|
int
|
20
21
|
crypto_pwhash_alg_default(void)
|
21
22
|
{
|
22
|
-
return
|
23
|
+
return crypto_pwhash_ALG_DEFAULT;
|
23
24
|
}
|
24
25
|
|
25
26
|
size_t
|
@@ -131,10 +132,12 @@ crypto_pwhash(unsigned char * const out, unsigned long long outlen,
|
|
131
132
|
unsigned long long opslimit, size_t memlimit, int alg)
|
132
133
|
{
|
133
134
|
switch (alg) {
|
134
|
-
case crypto_pwhash_ALG_ARGON2ID13:
|
135
135
|
case crypto_pwhash_ALG_ARGON2I13:
|
136
136
|
return crypto_pwhash_argon2i(out, outlen, passwd, passwdlen, salt,
|
137
137
|
opslimit, memlimit, alg);
|
138
|
+
case crypto_pwhash_ALG_ARGON2ID13:
|
139
|
+
return crypto_pwhash_argon2id(out, outlen, passwd, passwdlen, salt,
|
140
|
+
opslimit, memlimit, alg);
|
138
141
|
default:
|
139
142
|
errno = EINVAL;
|
140
143
|
return -1;
|
@@ -146,8 +149,25 @@ crypto_pwhash_str(char out[crypto_pwhash_STRBYTES],
|
|
146
149
|
const char * const passwd, unsigned long long passwdlen,
|
147
150
|
unsigned long long opslimit, size_t memlimit)
|
148
151
|
{
|
149
|
-
return
|
150
|
-
|
152
|
+
return crypto_pwhash_argon2id_str(out, passwd, passwdlen,
|
153
|
+
opslimit, memlimit);
|
154
|
+
}
|
155
|
+
|
156
|
+
int
|
157
|
+
crypto_pwhash_str_alg(char out[crypto_pwhash_STRBYTES],
|
158
|
+
const char * const passwd, unsigned long long passwdlen,
|
159
|
+
unsigned long long opslimit, size_t memlimit, int alg)
|
160
|
+
{
|
161
|
+
switch (alg) {
|
162
|
+
case crypto_pwhash_ALG_ARGON2I13:
|
163
|
+
return crypto_pwhash_argon2i_str(out, passwd, passwdlen,
|
164
|
+
opslimit, memlimit);
|
165
|
+
case crypto_pwhash_ALG_ARGON2ID13:
|
166
|
+
return crypto_pwhash_argon2id_str(out, passwd, passwdlen,
|
167
|
+
opslimit, memlimit);
|
168
|
+
}
|
169
|
+
sodium_misuse();
|
170
|
+
/* NOTREACHED */
|
151
171
|
}
|
152
172
|
|
153
173
|
int
|
@@ -168,6 +188,23 @@ crypto_pwhash_str_verify(const char str[crypto_pwhash_STRBYTES],
|
|
168
188
|
return -1;
|
169
189
|
}
|
170
190
|
|
191
|
+
int
|
192
|
+
crypto_pwhash_str_needs_rehash(const char str[crypto_pwhash_STRBYTES],
|
193
|
+
unsigned long long opslimit, size_t memlimit)
|
194
|
+
{
|
195
|
+
if (strncmp(str, crypto_pwhash_argon2id_STRPREFIX,
|
196
|
+
sizeof crypto_pwhash_argon2id_STRPREFIX - 1) == 0) {
|
197
|
+
return crypto_pwhash_argon2id_str_needs_rehash(str, opslimit, memlimit);
|
198
|
+
}
|
199
|
+
if (strncmp(str, crypto_pwhash_argon2i_STRPREFIX,
|
200
|
+
sizeof crypto_pwhash_argon2i_STRPREFIX - 1) == 0) {
|
201
|
+
return crypto_pwhash_argon2i_str_needs_rehash(str, opslimit, memlimit);
|
202
|
+
}
|
203
|
+
errno = EINVAL;
|
204
|
+
|
205
|
+
return -1;
|
206
|
+
}
|
207
|
+
|
171
208
|
const char *
|
172
209
|
crypto_pwhash_primitive(void) {
|
173
210
|
return crypto_pwhash_PRIMITIVE;
|
data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c
CHANGED
@@ -105,6 +105,34 @@ decode64_uint32(uint32_t *dst, uint32_t dstbits, const uint8_t *src)
|
|
105
105
|
return src;
|
106
106
|
}
|
107
107
|
|
108
|
+
const uint8_t *
|
109
|
+
escrypt_parse_setting(const uint8_t *setting,
|
110
|
+
uint32_t *N_log2_p, uint32_t *r_p, uint32_t *p_p)
|
111
|
+
{
|
112
|
+
const uint8_t *src;
|
113
|
+
|
114
|
+
if (setting[0] != '$' || setting[1] != '7' || setting[2] != '$') {
|
115
|
+
return NULL;
|
116
|
+
}
|
117
|
+
src = setting + 3;
|
118
|
+
|
119
|
+
if (decode64_one(N_log2_p, *src)) {
|
120
|
+
return NULL;
|
121
|
+
}
|
122
|
+
src++;
|
123
|
+
|
124
|
+
src = decode64_uint32(r_p, 30, src);
|
125
|
+
if (!src) {
|
126
|
+
return NULL;
|
127
|
+
}
|
128
|
+
|
129
|
+
src = decode64_uint32(p_p, 30, src);
|
130
|
+
if (!src) {
|
131
|
+
return NULL;
|
132
|
+
}
|
133
|
+
return src;
|
134
|
+
}
|
135
|
+
|
108
136
|
uint8_t *
|
109
137
|
escrypt_r(escrypt_local_t *local, const uint8_t *passwd, size_t passwdlen,
|
110
138
|
const uint8_t *setting, uint8_t *buf, size_t buflen)
|
@@ -122,25 +150,11 @@ escrypt_r(escrypt_local_t *local, const uint8_t *passwd, size_t passwdlen,
|
|
122
150
|
uint32_t r;
|
123
151
|
uint32_t p;
|
124
152
|
|
125
|
-
|
126
|
-
return NULL;
|
127
|
-
}
|
128
|
-
src = setting + 3;
|
129
|
-
|
130
|
-
if (decode64_one(&N_log2, *src)) {
|
131
|
-
return NULL;
|
132
|
-
}
|
133
|
-
src++;
|
134
|
-
N = (uint64_t) 1 << N_log2;
|
135
|
-
|
136
|
-
src = decode64_uint32(&r, 30, src);
|
137
|
-
if (!src) {
|
138
|
-
return NULL;
|
139
|
-
}
|
140
|
-
src = decode64_uint32(&p, 30, src);
|
153
|
+
src = escrypt_parse_setting(setting, &N_log2, &r, &p);
|
141
154
|
if (!src) {
|
142
155
|
return NULL;
|
143
156
|
}
|
157
|
+
N = (uint64_t) 1 << N_log2;
|
144
158
|
prefixlen = src - setting;
|
145
159
|
|
146
160
|
salt = src;
|
@@ -195,7 +209,7 @@ escrypt_gensalt_r(uint32_t N_log2, uint32_t r, uint32_t p, const uint8_t *src,
|
|
195
209
|
return NULL; /* LCOV_EXCL_LINE */
|
196
210
|
}
|
197
211
|
if (N_log2 > 63 || ((uint64_t) r * (uint64_t) p >= (1U << 30))) {
|
198
|
-
return NULL;
|
212
|
+
return NULL; /* LCOV_EXCL_LINE */
|
199
213
|
}
|
200
214
|
dst = buf;
|
201
215
|
*dst++ = '$';
|
@@ -91,4 +91,8 @@ extern uint8_t *escrypt_gensalt_r(uint32_t __N_log2, uint32_t __r, uint32_t __p,
|
|
91
91
|
const uint8_t *__src, size_t __srclen,
|
92
92
|
uint8_t *__buf, size_t __buflen);
|
93
93
|
|
94
|
+
extern const uint8_t *escrypt_parse_setting(const uint8_t *setting,
|
95
|
+
uint32_t *N_log2_p, uint32_t *r_p,
|
96
|
+
uint32_t *p_p);
|
97
|
+
|
94
98
|
#endif /* !_CRYPTO_SCRYPT_H_ */
|
@@ -31,7 +31,9 @@
|
|
31
31
|
|
32
32
|
#include <sys/types.h>
|
33
33
|
|
34
|
+
#include "core.h"
|
34
35
|
#include "crypto_auth_hmacsha256.h"
|
36
|
+
#include "crypto_pwhash_scryptsalsa208sha256.h"
|
35
37
|
#include "pbkdf2-sha256.h"
|
36
38
|
#include "private/common.h"
|
37
39
|
#include "utils.h"
|
@@ -55,8 +57,10 @@ PBKDF2_SHA256(const uint8_t *passwd, size_t passwdlen, const uint8_t *salt,
|
|
55
57
|
size_t clen;
|
56
58
|
|
57
59
|
#if SIZE_MAX > 0x1fffffffe0ULL
|
60
|
+
COMPILER_ASSERT(crypto_pwhash_scryptsalsa208sha256_BYTES_MAX
|
61
|
+
<= 0x1fffffffe0ULL);
|
58
62
|
if (dkLen > 0x1fffffffe0ULL) {
|
59
|
-
|
63
|
+
sodium_misuse(); /* LCOV_EXCL_LINE */
|
60
64
|
}
|
61
65
|
#endif
|
62
66
|
crypto_auth_hmacsha256_init(&PShctx, passwd, passwdlen);
|
data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c
CHANGED
@@ -27,7 +27,7 @@ pickparams(unsigned long long opslimit, const size_t memlimit,
|
|
27
27
|
}
|
28
28
|
*r = 8;
|
29
29
|
if (opslimit < memlimit / 32) {
|
30
|
-
*p
|
30
|
+
*p = 1;
|
31
31
|
maxN = opslimit / (*r * 4);
|
32
32
|
for (*N_log2 = 1; *N_log2 < 63; *N_log2 += 1) {
|
33
33
|
if ((uint64_t)(1) << *N_log2 > maxN / 2) {
|
@@ -254,3 +254,32 @@ crypto_pwhash_scryptsalsa208sha256_str_verify(
|
|
254
254
|
|
255
255
|
return ret;
|
256
256
|
}
|
257
|
+
|
258
|
+
int
|
259
|
+
crypto_pwhash_scryptsalsa208sha256_str_needs_rehash(
|
260
|
+
const char str[crypto_pwhash_scryptsalsa208sha256_STRBYTES],
|
261
|
+
unsigned long long opslimit, size_t memlimit)
|
262
|
+
{
|
263
|
+
uint32_t N_log2, N_log2_;
|
264
|
+
uint32_t p, p_;
|
265
|
+
uint32_t r, r_;
|
266
|
+
|
267
|
+
if (pickparams(opslimit, memlimit, &N_log2, &p, &r) != 0) {
|
268
|
+
errno = EINVAL;
|
269
|
+
return -1;
|
270
|
+
}
|
271
|
+
if (memchr(str, 0, crypto_pwhash_scryptsalsa208sha256_STRBYTES) !=
|
272
|
+
&str[crypto_pwhash_scryptsalsa208sha256_STRBYTES - 1U]) {
|
273
|
+
errno = EINVAL;
|
274
|
+
return -1;
|
275
|
+
}
|
276
|
+
if (escrypt_parse_setting((const uint8_t *) str,
|
277
|
+
&N_log2_, &r_, &p_) == NULL) {
|
278
|
+
errno = EINVAL;
|
279
|
+
return -1;
|
280
|
+
}
|
281
|
+
if (N_log2 != N_log2_ || r != r_ || p != p_) {
|
282
|
+
return 1;
|
283
|
+
}
|
284
|
+
return 0;
|
285
|
+
}
|
@@ -318,10 +318,12 @@ escrypt_kdf_sse(escrypt_local_t *local, const uint8_t *passwd, size_t passwdlen,
|
|
318
318
|
|
319
319
|
/* Sanity-check parameters. */
|
320
320
|
# if SIZE_MAX > UINT32_MAX
|
321
|
+
/* LCOV_EXCL_START */
|
321
322
|
if (buflen > (((uint64_t)(1) << 32) - 1) * 32) {
|
322
323
|
errno = EFBIG;
|
323
324
|
return -1;
|
324
325
|
}
|
326
|
+
/* LCOV_EXCL_END */
|
325
327
|
# endif
|
326
328
|
if ((uint64_t)(r) * (uint64_t)(p) >= ((uint64_t) 1 << 30)) {
|
327
329
|
errno = EFBIG;
|
@@ -339,6 +341,7 @@ escrypt_kdf_sse(escrypt_local_t *local, const uint8_t *passwd, size_t passwdlen,
|
|
339
341
|
errno = EINVAL;
|
340
342
|
return -1;
|
341
343
|
}
|
344
|
+
/* LCOV_EXCL_START */
|
342
345
|
if ((r > SIZE_MAX / 128 / p) ||
|
343
346
|
# if SIZE_MAX / 256 <= UINT32_MAX
|
344
347
|
(r > SIZE_MAX / 256) ||
|
@@ -347,21 +350,26 @@ escrypt_kdf_sse(escrypt_local_t *local, const uint8_t *passwd, size_t passwdlen,
|
|
347
350
|
errno = ENOMEM;
|
348
351
|
return -1;
|
349
352
|
}
|
353
|
+
/* LCOV_EXCL_END */
|
350
354
|
|
351
355
|
/* Allocate memory. */
|
352
356
|
B_size = (size_t) 128 * r * p;
|
353
357
|
V_size = (size_t) 128 * r * N;
|
354
358
|
need = B_size + V_size;
|
359
|
+
/* LCOV_EXCL_START */
|
355
360
|
if (need < V_size) {
|
356
361
|
errno = ENOMEM;
|
357
362
|
return -1;
|
358
363
|
}
|
364
|
+
/* LCOV_EXCL_END */
|
359
365
|
XY_size = (size_t) 256 * r + 64;
|
360
366
|
need += XY_size;
|
367
|
+
/* LCOV_EXCL_START */
|
361
368
|
if (need < XY_size) {
|
362
369
|
errno = ENOMEM;
|
363
370
|
return -1;
|
364
371
|
}
|
372
|
+
/* LCOV_EXCL_END */
|
365
373
|
if (local->size < need) {
|
366
374
|
if (free_region(local)) {
|
367
375
|
return -1; /* LCOV_EXCL_LINE */
|
@@ -20,11 +20,11 @@ int
|
|
20
20
|
crypto_scalarmult_curve25519(unsigned char *q, const unsigned char *n,
|
21
21
|
const unsigned char *p)
|
22
22
|
{
|
23
|
-
size_t
|
24
|
-
unsigned char d = 0;
|
23
|
+
size_t i;
|
24
|
+
volatile unsigned char d = 0;
|
25
25
|
|
26
26
|
if (implementation->mult(q, n, p) != 0) {
|
27
|
-
return -1;
|
27
|
+
return -1; /* LCOV_EXCL_LINE */
|
28
28
|
}
|
29
29
|
for (i = 0; i < crypto_scalarmult_curve25519_BYTES; i++) {
|
30
30
|
d |= q[i];
|