rbnacl-libsodium 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +23 -0
- data/CHANGES.md +5 -0
- data/Gemfile +5 -2
- data/Rakefile +5 -0
- data/ext/rbnacl/extconf.rb +2 -1
- data/lib/rbnacl/libsodium.rb +8 -2
- data/lib/rbnacl/libsodium/version.rb +1 -1
- data/vendor/libsodium/AUTHORS +14 -0
- data/vendor/libsodium/ChangeLog +26 -0
- data/vendor/libsodium/LICENSE +1 -1
- data/vendor/libsodium/Makefile.am +1 -0
- data/vendor/libsodium/Makefile.in +9 -0
- data/vendor/libsodium/README.markdown +7 -0
- data/vendor/libsodium/aclocal.m4 +1 -0
- data/vendor/libsodium/appveyor.yml +25 -0
- data/vendor/libsodium/autom4te.cache/output.1 +640 -126
- data/vendor/libsodium/autom4te.cache/output.6 +19049 -0
- data/vendor/libsodium/autom4te.cache/requests +1151 -914
- data/vendor/libsodium/autom4te.cache/traces.1 +472 -426
- data/vendor/libsodium/autom4te.cache/traces.6 +3193 -0
- data/vendor/libsodium/builds/msvc/version.h +2 -2
- data/vendor/libsodium/builds/msvc/vs2010/libsodium.sln +50 -79
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +20 -8
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +208 -166
- data/vendor/libsodium/builds/msvc/vs2012/libsodium.sln +50 -79
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +20 -8
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +206 -164
- data/vendor/libsodium/builds/msvc/vs2013/libsodium.sln +52 -81
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +20 -8
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +206 -164
- data/vendor/libsodium/builds/msvc/vs2015/libsodium.sln +52 -81
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +20 -8
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +206 -164
- data/vendor/libsodium/configure +639 -125
- data/vendor/libsodium/configure.ac +94 -16
- data/vendor/libsodium/dist-build/Makefile.in +9 -0
- data/vendor/libsodium/dist-build/emscripten-symbols.def +370 -0
- data/vendor/libsodium/dist-build/emscripten.sh +9 -3
- data/vendor/libsodium/dist-build/generate-emscripten-symbols.sh +43 -0
- data/vendor/libsodium/libsodium-uninstalled.pc.in +1 -1
- data/vendor/libsodium/libsodium.pc.in +1 -1
- data/vendor/libsodium/libsodium.vcxproj +70 -66
- data/vendor/libsodium/libsodium.vcxproj.filters +204 -192
- data/vendor/libsodium/m4/ax_valgrind_check.m4 +190 -0
- data/vendor/libsodium/msvc-scripts/Makefile.in +9 -0
- data/vendor/libsodium/msvc-scripts/process.bat +2 -2
- data/vendor/libsodium/src/Makefile.in +9 -0
- data/vendor/libsodium/src/libsodium/Makefile.am +31 -6
- data/vendor/libsodium/src/libsodium/Makefile.in +238 -42
- data/vendor/libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +234 -38
- data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +208 -118
- data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_seal.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c +1 -4
- data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.c +1799 -1790
- data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.h +39 -39
- data/vendor/libsodium/src/libsodium/crypto_core/hchacha20/core_hchacha20.c +86 -0
- data/vendor/libsodium/src/libsodium/crypto_core/hchacha20/core_hchacha20.h +28 -0
- data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20.c +38 -46
- data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/core_salsa20.c +47 -55
- data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/core_salsa2012.c +47 -55
- data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/core_salsa208.c +47 -55
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c +7 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2-impl.h +0 -89
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h +50 -141
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-avx2.c +45 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-avx2.h +123 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ref.c +3 -2
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-sse41.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/{blake2b-round.h → blake2b-compress-sse41.h} +2 -28
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ssse3.c +2 -4
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ssse3.h +97 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-avx2.h +339 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-sse2.h +0 -2
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-sse41.h +0 -2
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +29 -18
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +4 -43
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +3 -32
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +1 -20
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +22 -41
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +12 -39
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c +2 -4
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.h +1 -20
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.c +570 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.h +198 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c +444 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-encoding.h +32 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ref.c +229 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ssse3.c +222 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-impl.h +40 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.c +238 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.h +251 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blake2b-long.c +80 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blake2b-long.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blamka-round-ref.h +38 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blamka-round-ssse3.h +117 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/pwhash_argon2i.c +164 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/crypto_pwhash.c +106 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +4 -4
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c +186 -186
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +3 -2
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/scrypt_platform.c +33 -33
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +253 -254
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.c +16 -17
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.h +1 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.c +11 -11
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.h +1 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/consts_namespace.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe.h +3 -2
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51.h +5 -3
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_invert.c +41 -41
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_mul.S +10 -2
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_namespace.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_nsquare.S +4 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_pack.S +4 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe_frombytes_sandy2x.c +31 -32
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder.S +4 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base.S +4 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base_namespace.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_namespace.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +2 -6
- data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash24.c +8 -28
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +75 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/afternm_aes128ctr.c +6 -6
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/common.h +1 -18
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128_aes128ctr.c +20 -20
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/types.h +4 -4
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/xor_afternm_aes128ctr.c +6 -6
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c +56 -77
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.h +1 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/vec/stream_chacha20_vec.h +1 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20_ref.c +2 -8
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c +2 -8
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c +2 -8
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c +2 -8
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c +2 -8
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c +2 -8
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c +1 -5
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c +1 -5
- data/vendor/libsodium/src/libsodium/include/Makefile.am +3 -0
- data/vendor/libsodium/src/libsodium/include/Makefile.in +19 -8
- data/vendor/libsodium/src/libsodium/include/sodium.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_aes256gcm.h +50 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h +94 -22
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +6 -6
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_hchacha20.h +35 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash.h +89 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_argon2i.h +86 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h +6 -6
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h +0 -11
- data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +3 -0
- data/vendor/libsodium/src/libsodium/randombytes/randombytes.c +3 -0
- data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +5 -1
- data/vendor/libsodium/src/libsodium/sodium/common.h +150 -0
- data/vendor/libsodium/src/libsodium/sodium/core.c +3 -1
- data/vendor/libsodium/src/libsodium/sodium/runtime.c +37 -19
- data/vendor/libsodium/src/libsodium/sodium/utils.c +18 -9
- data/vendor/libsodium/test/Makefile.in +9 -0
- data/vendor/libsodium/test/default/Makefile.am +10 -0
- data/vendor/libsodium/test/default/Makefile.in +53 -20
- data/vendor/libsodium/test/default/aead_aes256gcm.c +43 -17
- data/vendor/libsodium/test/default/aead_chacha20poly1305.c +179 -86
- data/vendor/libsodium/test/default/auth7.c +5 -5
- data/vendor/libsodium/test/default/box.c +4 -4
- data/vendor/libsodium/test/default/box2.c +1 -1
- data/vendor/libsodium/test/default/core6.c +1 -1
- data/vendor/libsodium/test/default/generichash.c +12 -1
- data/vendor/libsodium/test/default/generichash2.c +2 -2
- data/vendor/libsodium/test/default/generichash3.c +21 -0
- data/vendor/libsodium/test/default/pwhash.c +186 -168
- data/vendor/libsodium/test/default/pwhash.exp +11 -30
- data/vendor/libsodium/test/default/pwhash_scrypt.c +349 -0
- data/vendor/libsodium/test/default/pwhash_scrypt.exp +31 -0
- data/vendor/libsodium/test/default/secretbox.c +1 -1
- data/vendor/libsodium/test/default/secretbox2.c +1 -1
- data/vendor/libsodium/test/default/sign.c +15 -0
- data/vendor/libsodium/test/default/sodium_utils2.c +8 -3
- data/vendor/libsodium/test/default/sodium_utils3.c +4 -2
- data/vendor/libsodium/test/default/verify1.c +0 -4
- data/vendor/libsodium/test/quirks/quirks.h +3 -0
- metadata +37 -22
- data/vendor/libsodium/builds/msvc/vs2010/test/test.props +0 -43
- data/vendor/libsodium/builds/msvc/vs2010/test/test.runner.bat +0 -78
- data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj +0 -244
- data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj.filters +0 -192
- data/vendor/libsodium/builds/msvc/vs2012/test/test.props +0 -43
- data/vendor/libsodium/builds/msvc/vs2012/test/test.runner.bat +0 -78
- data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj +0 -244
- data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj.filters +0 -192
- data/vendor/libsodium/builds/msvc/vs2013/test/test.props +0 -43
- data/vendor/libsodium/builds/msvc/vs2013/test/test.runner.bat +0 -78
- data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj +0 -244
- data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj.filters +0 -192
- data/vendor/libsodium/builds/msvc/vs2015/test/test.props +0 -43
- data/vendor/libsodium/builds/msvc/vs2015/test/test.runner.bat +0 -78
- data/vendor/libsodium/builds/msvc/vs2015/test/test.vcxproj +0 -244
- data/vendor/libsodium/builds/msvc/vs2015/test/test.vcxproj.filters +0 -192
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sysendian.h +0 -146
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/common_aes128ctr.c +0 -64
@@ -32,8 +32,8 @@
|
|
32
32
|
|
33
33
|
#include "crypto_auth_hmacsha256.h"
|
34
34
|
#include "pbkdf2-sha256.h"
|
35
|
-
#include "sysendian.h"
|
36
35
|
#include "utils.h"
|
36
|
+
#include "../../sodium/common.h"
|
37
37
|
|
38
38
|
/**
|
39
39
|
* PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen):
|
@@ -60,7 +60,7 @@ PBKDF2_SHA256(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt,
|
|
60
60
|
crypto_auth_hmacsha256_update(&PShctx, salt, saltlen);
|
61
61
|
|
62
62
|
for (i = 0; i * 32 < dkLen; i++) {
|
63
|
-
|
63
|
+
STORE32_BE(ivec, (uint32_t)(i + 1));
|
64
64
|
memcpy(&hctx, &PShctx, sizeof(crypto_auth_hmacsha256_state));
|
65
65
|
crypto_auth_hmacsha256_update(&hctx, ivec, 4);
|
66
66
|
crypto_auth_hmacsha256_final(&hctx, U);
|
data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c
CHANGED
@@ -11,8 +11,8 @@
|
|
11
11
|
#include "utils.h"
|
12
12
|
|
13
13
|
#define SETTING_SIZE(saltbytes) \
|
14
|
-
(sizeof "$7$" - 1U) + \
|
15
|
-
|
14
|
+
((sizeof "$7$" - 1U) + \
|
15
|
+
(1U /* N_log2 */) + (5U /* r */) + (5U /* p */) + BYTES2CHARS(saltbytes))
|
16
16
|
|
17
17
|
static int
|
18
18
|
pickparams(unsigned long long opslimit, const size_t memlimit,
|
@@ -193,6 +193,7 @@ crypto_pwhash_scryptsalsa208sha256_str_verify(const char str[crypto_pwhash_scryp
|
|
193
193
|
if (escrypt_init_local(&escrypt_local) != 0) {
|
194
194
|
return -1; /* LCOV_EXCL_LINE */
|
195
195
|
}
|
196
|
+
memset(wanted, 0, sizeof wanted);
|
196
197
|
if (escrypt_r(&escrypt_local, (const uint8_t *) passwd, (size_t) passwdlen,
|
197
198
|
(const uint8_t *) str, (uint8_t *) wanted,
|
198
199
|
sizeof wanted) == NULL) {
|
@@ -34,67 +34,67 @@
|
|
34
34
|
void *
|
35
35
|
alloc_region(escrypt_region_t * region, size_t size)
|
36
36
|
{
|
37
|
-
|
37
|
+
uint8_t * base, * aligned;
|
38
38
|
#if defined(MAP_ANON) && defined(HAVE_MMAP)
|
39
|
-
|
39
|
+
if ((base = (uint8_t *) mmap(NULL, size, PROT_READ | PROT_WRITE,
|
40
40
|
#ifdef MAP_NOCORE
|
41
|
-
|
41
|
+
MAP_ANON | MAP_PRIVATE | MAP_NOCORE,
|
42
42
|
#else
|
43
|
-
|
43
|
+
MAP_ANON | MAP_PRIVATE,
|
44
44
|
#endif
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
-1, 0)) == MAP_FAILED)
|
46
|
+
base = NULL; /* LCOV_EXCL_LINE */
|
47
|
+
aligned = base;
|
48
48
|
#elif defined(HAVE_POSIX_MEMALIGN)
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
if ((errno = posix_memalign((void **) &base, 64, size)) != 0)
|
50
|
+
base = NULL;
|
51
|
+
aligned = base;
|
52
52
|
#else
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
53
|
+
base = aligned = NULL;
|
54
|
+
if (size + 63 < size)
|
55
|
+
errno = ENOMEM;
|
56
|
+
else if ((base = (uint8_t *) malloc(size + 63)) != NULL) {
|
57
|
+
aligned = base + 63;
|
58
|
+
aligned -= (uintptr_t)aligned & 63;
|
59
|
+
}
|
60
60
|
#endif
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
region->base = base;
|
62
|
+
region->aligned = aligned;
|
63
|
+
region->size = base ? size : 0;
|
64
|
+
return aligned;
|
65
65
|
}
|
66
66
|
|
67
67
|
static inline void
|
68
68
|
init_region(escrypt_region_t * region)
|
69
69
|
{
|
70
|
-
|
71
|
-
|
70
|
+
region->base = region->aligned = NULL;
|
71
|
+
region->size = 0;
|
72
72
|
}
|
73
73
|
|
74
74
|
int
|
75
75
|
free_region(escrypt_region_t * region)
|
76
76
|
{
|
77
|
-
|
77
|
+
if (region->base) {
|
78
78
|
#if defined(MAP_ANON) && defined(HAVE_MMAP)
|
79
|
-
|
80
|
-
|
79
|
+
if (munmap(region->base, region->size))
|
80
|
+
return -1; /* LCOV_EXCL_LINE */
|
81
81
|
#else
|
82
|
-
|
82
|
+
free(region->base);
|
83
83
|
#endif
|
84
|
-
|
85
|
-
|
86
|
-
|
84
|
+
}
|
85
|
+
init_region(region);
|
86
|
+
return 0;
|
87
87
|
}
|
88
88
|
|
89
89
|
int
|
90
90
|
escrypt_init_local(escrypt_local_t * local)
|
91
91
|
{
|
92
|
-
|
93
|
-
|
92
|
+
init_region(local);
|
93
|
+
return 0;
|
94
94
|
}
|
95
95
|
|
96
96
|
int
|
97
97
|
escrypt_free_local(escrypt_local_t * local)
|
98
98
|
{
|
99
|
-
|
99
|
+
return free_region(local);
|
100
100
|
}
|
@@ -45,62 +45,62 @@
|
|
45
45
|
#include <string.h>
|
46
46
|
|
47
47
|
#include "../pbkdf2-sha256.h"
|
48
|
-
#include "../sysendian.h"
|
49
48
|
#include "../crypto_scrypt.h"
|
49
|
+
#include "../../../sodium/common.h"
|
50
50
|
|
51
51
|
#if defined(__XOP__) && defined(DISABLED)
|
52
52
|
#define ARX(out, in1, in2, s) \
|
53
|
-
|
53
|
+
out = _mm_xor_si128(out, _mm_roti_epi32(_mm_add_epi32(in1, in2), s));
|
54
54
|
#else
|
55
55
|
#define ARX(out, in1, in2, s) \
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
56
|
+
{ \
|
57
|
+
__m128i T = _mm_add_epi32(in1, in2); \
|
58
|
+
out = _mm_xor_si128(out, _mm_slli_epi32(T, s)); \
|
59
|
+
out = _mm_xor_si128(out, _mm_srli_epi32(T, 32-s)); \
|
60
|
+
}
|
61
61
|
#endif
|
62
62
|
|
63
63
|
#define SALSA20_2ROUNDS \
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
/* Operate on "columns". */ \
|
65
|
+
ARX(X1, X0, X3, 7) \
|
66
|
+
ARX(X2, X1, X0, 9) \
|
67
|
+
ARX(X3, X2, X1, 13) \
|
68
|
+
ARX(X0, X3, X2, 18) \
|
69
69
|
\
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
/* Rearrange data. */ \
|
71
|
+
X1 = _mm_shuffle_epi32(X1, 0x93); \
|
72
|
+
X2 = _mm_shuffle_epi32(X2, 0x4E); \
|
73
|
+
X3 = _mm_shuffle_epi32(X3, 0x39); \
|
74
74
|
\
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
75
|
+
/* Operate on "rows". */ \
|
76
|
+
ARX(X3, X0, X1, 7) \
|
77
|
+
ARX(X2, X3, X0, 9) \
|
78
|
+
ARX(X1, X2, X3, 13) \
|
79
|
+
ARX(X0, X1, X2, 18) \
|
80
80
|
\
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
81
|
+
/* Rearrange data. */ \
|
82
|
+
X1 = _mm_shuffle_epi32(X1, 0x39); \
|
83
|
+
X2 = _mm_shuffle_epi32(X2, 0x4E); \
|
84
|
+
X3 = _mm_shuffle_epi32(X3, 0x93);
|
85
85
|
|
86
86
|
/**
|
87
87
|
* Apply the salsa20/8 core to the block provided in (X0 ... X3) ^ (Z0 ... Z3).
|
88
88
|
*/
|
89
89
|
#define SALSA20_8_XOR(in, out) \
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
90
|
+
{ \
|
91
|
+
__m128i Y0 = X0 = _mm_xor_si128(X0, (in)[0]); \
|
92
|
+
__m128i Y1 = X1 = _mm_xor_si128(X1, (in)[1]); \
|
93
|
+
__m128i Y2 = X2 = _mm_xor_si128(X2, (in)[2]); \
|
94
|
+
__m128i Y3 = X3 = _mm_xor_si128(X3, (in)[3]); \
|
95
|
+
SALSA20_2ROUNDS \
|
96
|
+
SALSA20_2ROUNDS \
|
97
|
+
SALSA20_2ROUNDS \
|
98
|
+
SALSA20_2ROUNDS \
|
99
|
+
(out)[0] = X0 = _mm_add_epi32(X0, Y0); \
|
100
|
+
(out)[1] = X1 = _mm_add_epi32(X1, Y1); \
|
101
|
+
(out)[2] = X2 = _mm_add_epi32(X2, Y2); \
|
102
|
+
(out)[3] = X3 = _mm_add_epi32(X3, Y3); \
|
103
|
+
}
|
104
104
|
|
105
105
|
/**
|
106
106
|
* blockmix_salsa8(Bin, Bout, r):
|
@@ -110,95 +110,95 @@
|
|
110
110
|
static inline void
|
111
111
|
blockmix_salsa8(const __m128i * Bin, __m128i * Bout, size_t r)
|
112
112
|
{
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
113
|
+
__m128i X0, X1, X2, X3;
|
114
|
+
size_t i;
|
115
|
+
|
116
|
+
/* 1: X <-- B_{2r - 1} */
|
117
|
+
X0 = Bin[8 * r - 4];
|
118
|
+
X1 = Bin[8 * r - 3];
|
119
|
+
X2 = Bin[8 * r - 2];
|
120
|
+
X3 = Bin[8 * r - 1];
|
121
|
+
|
122
|
+
/* 3: X <-- H(X \xor B_i) */
|
123
|
+
/* 4: Y_i <-- X */
|
124
|
+
/* 6: B' <-- (Y_0, Y_2 ... Y_{2r-2}, Y_1, Y_3 ... Y_{2r-1}) */
|
125
|
+
SALSA20_8_XOR(Bin, Bout)
|
126
|
+
|
127
|
+
/* 2: for i = 0 to 2r - 1 do */
|
128
|
+
r--;
|
129
|
+
for (i = 0; i < r;) {
|
130
|
+
/* 3: X <-- H(X \xor B_i) */
|
131
|
+
/* 4: Y_i <-- X */
|
132
|
+
/* 6: B' <-- (Y_0, Y_2 ... Y_{2r-2}, Y_1, Y_3 ... Y_{2r-1}) */
|
133
|
+
SALSA20_8_XOR(&Bin[i * 8 + 4], &Bout[(r + i) * 4 + 4])
|
134
|
+
|
135
|
+
i++;
|
136
|
+
|
137
|
+
/* 3: X <-- H(X \xor B_i) */
|
138
|
+
/* 4: Y_i <-- X */
|
139
|
+
/* 6: B' <-- (Y_0, Y_2 ... Y_{2r-2}, Y_1, Y_3 ... Y_{2r-1}) */
|
140
|
+
SALSA20_8_XOR(&Bin[i * 8], &Bout[i * 4])
|
141
|
+
}
|
142
|
+
|
143
|
+
/* 3: X <-- H(X \xor B_i) */
|
144
|
+
/* 4: Y_i <-- X */
|
145
|
+
/* 6: B' <-- (Y_0, Y_2 ... Y_{2r-2}, Y_1, Y_3 ... Y_{2r-1}) */
|
146
|
+
SALSA20_8_XOR(&Bin[i * 8 + 4], &Bout[(r + i) * 4 + 4])
|
147
147
|
}
|
148
148
|
|
149
149
|
#define XOR4(in) \
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
150
|
+
X0 = _mm_xor_si128(X0, (in)[0]); \
|
151
|
+
X1 = _mm_xor_si128(X1, (in)[1]); \
|
152
|
+
X2 = _mm_xor_si128(X2, (in)[2]); \
|
153
|
+
X3 = _mm_xor_si128(X3, (in)[3]);
|
154
154
|
|
155
155
|
#define XOR4_2(in1, in2) \
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
156
|
+
X0 = _mm_xor_si128((in1)[0], (in2)[0]); \
|
157
|
+
X1 = _mm_xor_si128((in1)[1], (in2)[1]); \
|
158
|
+
X2 = _mm_xor_si128((in1)[2], (in2)[2]); \
|
159
|
+
X3 = _mm_xor_si128((in1)[3], (in2)[3]);
|
160
160
|
|
161
161
|
static inline uint32_t
|
162
162
|
blockmix_salsa8_xor(const __m128i * Bin1, const __m128i * Bin2, __m128i * Bout,
|
163
163
|
size_t r)
|
164
164
|
{
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
165
|
+
__m128i X0, X1, X2, X3;
|
166
|
+
size_t i;
|
167
|
+
|
168
|
+
/* 1: X <-- B_{2r - 1} */
|
169
|
+
XOR4_2(&Bin1[8 * r - 4], &Bin2[8 * r - 4])
|
170
|
+
|
171
|
+
/* 3: X <-- H(X \xor B_i) */
|
172
|
+
/* 4: Y_i <-- X */
|
173
|
+
/* 6: B' <-- (Y_0, Y_2 ... Y_{2r-2}, Y_1, Y_3 ... Y_{2r-1}) */
|
174
|
+
XOR4(Bin1)
|
175
|
+
SALSA20_8_XOR(Bin2, Bout)
|
176
|
+
|
177
|
+
/* 2: for i = 0 to 2r - 1 do */
|
178
|
+
r--;
|
179
|
+
for (i = 0; i < r;) {
|
180
|
+
/* 3: X <-- H(X \xor B_i) */
|
181
|
+
/* 4: Y_i <-- X */
|
182
|
+
/* 6: B' <-- (Y_0, Y_2 ... Y_{2r-2}, Y_1, Y_3 ... Y_{2r-1}) */
|
183
|
+
XOR4(&Bin1[i * 8 + 4])
|
184
|
+
SALSA20_8_XOR(&Bin2[i * 8 + 4], &Bout[(r + i) * 4 + 4])
|
185
|
+
|
186
|
+
i++;
|
187
|
+
|
188
|
+
/* 3: X <-- H(X \xor B_i) */
|
189
|
+
/* 4: Y_i <-- X */
|
190
|
+
/* 6: B' <-- (Y_0, Y_2 ... Y_{2r-2}, Y_1, Y_3 ... Y_{2r-1}) */
|
191
|
+
XOR4(&Bin1[i * 8])
|
192
|
+
SALSA20_8_XOR(&Bin2[i * 8], &Bout[i * 4])
|
193
|
+
}
|
194
|
+
|
195
|
+
/* 3: X <-- H(X \xor B_i) */
|
196
|
+
/* 4: Y_i <-- X */
|
197
|
+
/* 6: B' <-- (Y_0, Y_2 ... Y_{2r-2}, Y_1, Y_3 ... Y_{2r-1}) */
|
198
|
+
XOR4(&Bin1[i * 8 + 4])
|
199
|
+
SALSA20_8_XOR(&Bin2[i * 8 + 4], &Bout[(r + i) * 4 + 4])
|
200
|
+
|
201
|
+
return _mm_cvtsi128_si32(X0);
|
202
202
|
}
|
203
203
|
|
204
204
|
#undef ARX
|
@@ -214,7 +214,7 @@ blockmix_salsa8_xor(const __m128i * Bin1, const __m128i * Bin2, __m128i * Bout,
|
|
214
214
|
static inline uint32_t
|
215
215
|
integerify(const void * B, size_t r)
|
216
216
|
{
|
217
|
-
|
217
|
+
return *(const uint32_t *)((uintptr_t)(B) + (2 * r - 1) * 64);
|
218
218
|
}
|
219
219
|
|
220
220
|
/**
|
@@ -228,71 +228,70 @@ integerify(const void * B, size_t r)
|
|
228
228
|
static void
|
229
229
|
smix(uint8_t * B, size_t r, uint32_t N, void * V, void * XY)
|
230
230
|
{
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
}
|
231
|
+
size_t s = 128 * r;
|
232
|
+
__m128i * X = (__m128i *) V, * Y;
|
233
|
+
uint32_t * X32 = (uint32_t *) V;
|
234
|
+
uint32_t i, j;
|
235
|
+
size_t k;
|
236
|
+
|
237
|
+
/* 1: X <-- B */
|
238
|
+
/* 3: V_i <-- X */
|
239
|
+
for (k = 0; k < 2 * r; k++) {
|
240
|
+
for (i = 0; i < 16; i++) {
|
241
|
+
X32[k * 16 + i] =
|
242
|
+
LOAD32_LE(&B[(k * 16 + (i * 5 % 16)) * 4]);
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
/* 2: for i = 0 to N - 1 do */
|
247
|
+
for (i = 1; i < N - 1; i += 2) {
|
248
|
+
/* 4: X <-- H(X) */
|
249
|
+
/* 3: V_i <-- X */
|
250
|
+
Y = (__m128i *)((uintptr_t)(V) + i * s);
|
251
|
+
blockmix_salsa8(X, Y, r);
|
252
|
+
|
253
|
+
/* 4: X <-- H(X) */
|
254
|
+
/* 3: V_i <-- X */
|
255
|
+
X = (__m128i *)((uintptr_t)(V) + (i + 1) * s);
|
256
|
+
blockmix_salsa8(Y, X, r);
|
257
|
+
}
|
258
|
+
|
259
|
+
/* 4: X <-- H(X) */
|
260
|
+
/* 3: V_i <-- X */
|
261
|
+
Y = (__m128i *)((uintptr_t)(V) + i * s);
|
262
|
+
blockmix_salsa8(X, Y, r);
|
263
|
+
|
264
|
+
/* 4: X <-- H(X) */
|
265
|
+
/* 3: V_i <-- X */
|
266
|
+
X = (__m128i *) XY;
|
267
|
+
blockmix_salsa8(Y, X, r);
|
268
|
+
|
269
|
+
X32 = (uint32_t *) XY;
|
270
|
+
Y = (__m128i *)((uintptr_t)(XY) + s);
|
271
|
+
|
272
|
+
/* 7: j <-- Integerify(X) mod N */
|
273
|
+
j = integerify(X, r) & (N - 1);
|
274
|
+
|
275
|
+
/* 6: for i = 0 to N - 1 do */
|
276
|
+
for (i = 0; i < N; i += 2) {
|
277
|
+
__m128i * V_j = (__m128i *)((uintptr_t)(V) + j * s);
|
278
|
+
|
279
|
+
/* 8: X <-- H(X \xor V_j) */
|
280
|
+
/* 7: j <-- Integerify(X) mod N */
|
281
|
+
j = blockmix_salsa8_xor(X, V_j, Y, r) & (N - 1);
|
282
|
+
V_j = (__m128i *)((uintptr_t)(V) + j * s);
|
283
|
+
|
284
|
+
/* 8: X <-- H(X \xor V_j) */
|
285
|
+
/* 7: j <-- Integerify(X) mod N */
|
286
|
+
j = blockmix_salsa8_xor(Y, V_j, X, r) & (N - 1);
|
287
|
+
}
|
288
|
+
|
289
|
+
/* 10: B' <-- X */
|
290
|
+
for (k = 0; k < 2 * r; k++) {
|
291
|
+
for (i = 0; i < 16; i++) {
|
292
|
+
STORE32_LE(&B[(k * 16 + (i * 5 % 16)) * 4], X32[k * 16 + i]);
|
293
|
+
}
|
294
|
+
}
|
296
295
|
}
|
297
296
|
|
298
297
|
/**
|
@@ -312,81 +311,81 @@ escrypt_kdf_sse(escrypt_local_t * local,
|
|
312
311
|
uint64_t N, uint32_t _r, uint32_t _p,
|
313
312
|
uint8_t * buf, size_t buflen)
|
314
313
|
{
|
315
|
-
|
316
|
-
|
317
|
-
|
314
|
+
size_t B_size, V_size, XY_size, need;
|
315
|
+
uint8_t * B;
|
316
|
+
uint32_t * V, * XY;
|
318
317
|
size_t r = _r, p = _p;
|
319
|
-
|
318
|
+
uint32_t i;
|
320
319
|
|
321
|
-
|
320
|
+
/* Sanity-check parameters. */
|
322
321
|
#if SIZE_MAX > UINT32_MAX
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
322
|
+
if (buflen > (((uint64_t)(1) << 32) - 1) * 32) {
|
323
|
+
errno = EFBIG;
|
324
|
+
return -1;
|
325
|
+
}
|
327
326
|
#endif
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
327
|
+
if ((uint64_t)(r) * (uint64_t)(p) >= ((uint64_t) 1 << 30)) {
|
328
|
+
errno = EFBIG;
|
329
|
+
return -1;
|
330
|
+
}
|
331
|
+
if (N > UINT32_MAX) {
|
332
|
+
errno = EFBIG;
|
333
|
+
return -1;
|
334
|
+
}
|
335
|
+
if (((N & (N - 1)) != 0) || (N < 2)) {
|
336
|
+
errno = EINVAL;
|
337
|
+
return -1;
|
338
|
+
}
|
339
|
+
if (r == 0 || p == 0) {
|
340
|
+
errno = EINVAL;
|
341
|
+
return -1;
|
342
|
+
}
|
343
|
+
if ((r > SIZE_MAX / 128 / p) ||
|
345
344
|
#if SIZE_MAX / 256 <= UINT32_MAX
|
346
|
-
|
345
|
+
(r > SIZE_MAX / 256) ||
|
347
346
|
#endif
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
347
|
+
(N > SIZE_MAX / 128 / r)) {
|
348
|
+
errno = ENOMEM;
|
349
|
+
return -1;
|
350
|
+
}
|
351
|
+
|
352
|
+
/* Allocate memory. */
|
353
|
+
B_size = (size_t)128 * r * p;
|
354
|
+
V_size = (size_t)128 * r * N;
|
355
|
+
need = B_size + V_size;
|
356
|
+
if (need < V_size) {
|
357
|
+
errno = ENOMEM;
|
358
|
+
return -1;
|
359
|
+
}
|
360
|
+
XY_size = (size_t)256 * r + 64;
|
361
|
+
need += XY_size;
|
362
|
+
if (need < XY_size) {
|
363
|
+
errno = ENOMEM;
|
364
|
+
return -1;
|
365
|
+
}
|
366
|
+
if (local->size < need) {
|
367
|
+
if (free_region(local))
|
368
|
+
return -1; /* LCOV_EXCL_LINE */
|
369
|
+
if (!alloc_region(local, need))
|
370
|
+
return -1; /* LCOV_EXCL_LINE */
|
371
|
+
}
|
372
|
+
B = (uint8_t *)local->aligned;
|
373
|
+
V = (uint32_t *)((uint8_t *)B + B_size);
|
374
|
+
XY = (uint32_t *)((uint8_t *)V + V_size);
|
375
|
+
|
376
|
+
/* 1: (B_0 ... B_{p-1}) <-- PBKDF2(P, S, 1, p * MFLen) */
|
377
|
+
PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, 1, B, B_size);
|
378
|
+
|
379
|
+
/* 2: for i = 0 to p - 1 do */
|
380
|
+
for (i = 0; i < p; i++) {
|
381
|
+
/* 3: B_i <-- MF(B_i, N) */
|
382
|
+
smix(&B[(size_t)128 * i * r], r, (uint32_t) N, V, XY);
|
383
|
+
}
|
384
|
+
|
385
|
+
/* 5: DK <-- PBKDF2(P, B, 1, dkLen) */
|
386
|
+
PBKDF2_SHA256(passwd, passwdlen, B, B_size, 1, buf, buflen);
|
387
|
+
|
388
|
+
/* Success! */
|
389
|
+
return 0;
|
391
390
|
}
|
392
391
|
#endif
|