rbnacl-libsodium 0.4.5 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbnacl/libsodium/version.rb +1 -1
- data/vendor/libsodium/AUTHORS +14 -9
- data/vendor/libsodium/ChangeLog +26 -0
- data/vendor/libsodium/LICENSE +1 -1
- data/vendor/libsodium/Makefile.am +1 -0
- data/vendor/libsodium/README.markdown +185 -46
- data/vendor/libsodium/THANKS +10 -0
- data/vendor/libsodium/builds/msvc/properties/Common.props +21 -0
- data/vendor/libsodium/builds/msvc/properties/DLL.props +16 -0
- data/vendor/libsodium/builds/msvc/properties/Debug.props +29 -0
- data/vendor/libsodium/builds/msvc/properties/DebugDEXE.props +21 -0
- data/vendor/libsodium/builds/msvc/properties/DebugDLL.props +20 -0
- data/vendor/libsodium/builds/msvc/properties/DebugLEXE.props +20 -0
- data/vendor/libsodium/builds/msvc/properties/DebugLIB.props +20 -0
- data/vendor/libsodium/builds/msvc/properties/DebugLTCG.props +19 -0
- data/vendor/libsodium/builds/msvc/properties/DebugSEXE.props +21 -0
- data/vendor/libsodium/builds/msvc/properties/EXE.props +17 -0
- data/vendor/libsodium/builds/msvc/properties/LIB.props +16 -0
- data/vendor/libsodium/builds/msvc/properties/LTCG.props +13 -0
- data/vendor/libsodium/builds/msvc/properties/Link.props +21 -0
- data/vendor/libsodium/builds/msvc/properties/Messages.props +15 -0
- data/vendor/libsodium/builds/msvc/properties/Output.props +30 -0
- data/vendor/libsodium/builds/msvc/properties/Release.props +41 -0
- data/vendor/libsodium/builds/msvc/properties/ReleaseDEXE.props +20 -0
- data/vendor/libsodium/builds/msvc/properties/ReleaseDLL.props +19 -0
- data/vendor/libsodium/builds/msvc/properties/ReleaseLEXE.props +20 -0
- data/vendor/libsodium/builds/msvc/properties/ReleaseLIB.props +19 -0
- data/vendor/libsodium/builds/msvc/properties/ReleaseLTCG.props +19 -0
- data/vendor/libsodium/builds/msvc/properties/ReleaseSEXE.props +20 -0
- data/vendor/libsodium/builds/msvc/properties/Win32.props +20 -0
- data/vendor/libsodium/builds/msvc/properties/x64.props +23 -0
- data/vendor/libsodium/builds/msvc/resource.h +0 -0
- data/vendor/libsodium/builds/msvc/resource.rc +0 -0
- data/vendor/libsodium/builds/msvc/version.h +29 -0
- data/vendor/libsodium/builds/msvc/vs2010/libsodium.import.props +52 -0
- data/vendor/libsodium/builds/msvc/vs2010/libsodium.import.xml +17 -0
- data/vendor/libsodium/builds/msvc/vs2010/libsodium.sln +79 -0
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.props +43 -0
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +345 -0
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +1037 -0
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.xml +15 -0
- data/vendor/libsodium/builds/msvc/vs2010/test/test.props +37 -0
- data/vendor/libsodium/builds/msvc/vs2010/test/test.runner.bat +78 -0
- data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj +220 -0
- data/vendor/libsodium/builds/msvc/vs2010/test/test.vcxproj.filters +168 -0
- data/vendor/libsodium/builds/msvc/vs2012/libsodium.import.props +52 -0
- data/vendor/libsodium/builds/msvc/vs2012/libsodium.import.xml +17 -0
- data/vendor/libsodium/builds/msvc/vs2012/libsodium.sln +79 -0
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.props +43 -0
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +345 -0
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +1037 -0
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.xml +15 -0
- data/vendor/libsodium/builds/msvc/vs2012/test/test.props +37 -0
- data/vendor/libsodium/builds/msvc/vs2012/test/test.runner.bat +78 -0
- data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj +220 -0
- data/vendor/libsodium/builds/msvc/vs2012/test/test.vcxproj.filters +168 -0
- data/vendor/libsodium/builds/msvc/vs2013/libsodium.import.props +52 -0
- data/vendor/libsodium/builds/msvc/vs2013/libsodium.import.xml +17 -0
- data/vendor/libsodium/builds/msvc/vs2013/libsodium.sln +81 -0
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.props +43 -0
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +345 -0
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +1037 -0
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.xml +15 -0
- data/vendor/libsodium/builds/msvc/vs2013/test/test.props +37 -0
- data/vendor/libsodium/builds/msvc/vs2013/test/test.runner.bat +78 -0
- data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj +220 -0
- data/vendor/libsodium/builds/msvc/vs2013/test/test.vcxproj.filters +168 -0
- data/vendor/libsodium/configure.ac +87 -68
- data/vendor/libsodium/dist-build/Makefile.am +10 -0
- data/vendor/libsodium/dist-build/android-arm.sh +3 -0
- data/vendor/libsodium/dist-build/android-armv7.sh +3 -0
- data/vendor/libsodium/dist-build/android-build.sh +37 -0
- data/vendor/libsodium/dist-build/android-mips.sh +3 -0
- data/vendor/libsodium/dist-build/android-x86.sh +3 -0
- data/vendor/libsodium/dist-build/emscripten.sh +13 -0
- data/vendor/libsodium/dist-build/{iphone.sh → ios.sh} +2 -2
- data/vendor/libsodium/dist-build/msys2-win32.sh +10 -0
- data/vendor/libsodium/dist-build/msys2-win64.sh +10 -0
- data/vendor/libsodium/libsodium.vcxproj +25 -13
- data/vendor/libsodium/libsodium.vcxproj.filters +60 -24
- data/vendor/libsodium/msvc-scripts/process.bat +3 -7
- data/vendor/libsodium/packaging/nuget/package.bat +13 -0
- data/vendor/libsodium/packaging/nuget/package.config +4 -0
- data/vendor/libsodium/packaging/nuget/package.gsl +255 -0
- data/vendor/libsodium/packaging/nuget/package.nuspec +93 -0
- data/vendor/libsodium/packaging/nuget/package.targets +128 -0
- data/vendor/libsodium/packaging/nuget/package.xml +22 -0
- data/vendor/libsodium/src/libsodium/Makefile.am +32 -20
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/auth_hmacsha256_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/{ref → cp}/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/cp/hmac_hmacsha256.c +110 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/{ref → cp}/verify_hmacsha256.c +0 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/auth_hmacsha512_api.c +11 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/api.h +9 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/hmac_hmacsha512.c +110 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/verify_hmacsha512.c +10 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/auth_hmacsha512256_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/{ref → cp}/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/hmac_hmacsha512256.c +54 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/{ref → cp}/verify_hmacsha512256.c +2 -1
- data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_easy.c +94 -0
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/core_hsalsa20_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_core/salsa20/core_salsa20_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/core_salsa2012_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_core/salsa208/core_salsa208_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c +15 -5
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/api.h +0 -2
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h +14 -6
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +95 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/generichash_blake2b.c +50 -3
- data/vendor/libsodium/src/libsodium/crypto_generichash/crypto_generichash.c +4 -10
- data/vendor/libsodium/src/libsodium/crypto_hash/crypto_hash.c +11 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/{ref → cp}/api.h +3 -1
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +294 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/hash_sha256_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/{ref → cp}/api.h +3 -1
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +321 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/hash_sha512_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/auth_poly1305_donna.c +51 -127
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +12 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +221 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +209 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c +1 -140
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/crypto_scrypt-common.c +250 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/crypto_scrypt.h +100 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/nosse/pwhash_scryptxsalsa208sha256_nosse.c +302 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/pbkdf2-sha256.c +94 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/pbkdf2-sha256.h +45 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/pwhash_scryptxsalsa208sha256.c +172 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/scrypt_platform.c +96 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/sse/pwhash_scryptxsalsa208sha256_sse.c +391 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/sysendian.h +146 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/api.h +2 -2
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/smult_curve25519_donna_c64.c +39 -9
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref/api.h +2 -2
- data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox.c +6 -0
- data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +94 -0
- data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/ref/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305_api.c +3 -3
- data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/shorthash_siphash24_api.c +3 -3
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_scalarmult_base.c +6 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +5 -3
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +28 -18
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sign.c +14 -9
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/sign_ed25519_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/sign_edwards25519sha512batch_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/afternm_aes128ctr.c +21 -21
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128.h +6 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/xor_afternm_aes128ctr.c +42 -42
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/stream_aes128ctr_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes-table-be.h +4 -4
- data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes-table-le.h +4 -4
- data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes256-ctr.c +15 -14
- data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/ecrypt-sync.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/stream_aes256estream_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.S +153 -160
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/api.h +2 -5
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20_ref.c +9 -3
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c +9 -3
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/stream_salsa2012_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/stream_salsa208_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/stream_xsalsa20_api.c +0 -5
- data/vendor/libsodium/src/libsodium/crypto_verify/64/ref/api.h +2 -0
- data/vendor/libsodium/src/libsodium/crypto_verify/64/ref/verify_64.c +72 -0
- data/vendor/libsodium/src/libsodium/crypto_verify/64/verify_64_api.c +6 -0
- data/vendor/libsodium/src/libsodium/include/Makefile.am +6 -7
- data/vendor/libsodium/src/libsodium/include/sodium.h +4 -3
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha256.h +31 -9
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512.h +58 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512256.h +26 -9
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_box.h +13 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +38 -24
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_hsalsa20.h +6 -11
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_salsa20.h +6 -11
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_salsa2012.h +6 -11
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_salsa208.h +6 -11
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash.h +7 -8
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h +36 -16
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash.h +13 -4
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha256.h +25 -7
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha512.h +25 -7
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h +5 -5
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_donna.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_scryptxsalsa208sha256.h +48 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h +31 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox.h +17 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h +21 -11
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_shorthash.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_shorthash_siphash24.h +8 -7
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_ed25519.h +16 -17
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h +18 -14
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes128ctr.h +18 -18
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes256estream.h +19 -18
- data/vendor/libsodium/src/libsodium/include/sodium/{crypto_stream_salsa20.h.in → crypto_stream_salsa20.h} +8 -19
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa2012.h +8 -8
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa208.h +8 -8
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_xsalsa20.h +10 -11
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_verify_16.h +1 -4
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_verify_32.h +1 -4
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_verify_64.h +22 -0
- data/vendor/libsodium/src/libsodium/include/sodium/randombytes.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +27 -0
- data/vendor/libsodium/src/libsodium/include/sodium/utils.h +15 -3
- data/vendor/libsodium/src/libsodium/randombytes/randombytes.c +3 -1
- data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +18 -7
- data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +57 -9
- data/vendor/libsodium/src/libsodium/sodium/compat.c +62 -0
- data/vendor/libsodium/src/libsodium/sodium/core.c +2 -0
- data/vendor/libsodium/src/libsodium/sodium/runtime.c +134 -0
- data/vendor/libsodium/src/libsodium/sodium/utils.c +100 -8
- data/vendor/libsodium/test/default/Makefile.am +63 -3
- data/vendor/libsodium/test/default/auth6.c +21 -0
- data/vendor/libsodium/test/default/auth6.exp +8 -0
- data/vendor/libsodium/test/default/auth7.c +37 -0
- data/vendor/libsodium/test/default/auth7.exp +0 -0
- data/vendor/libsodium/test/default/box_easy.c +59 -0
- data/vendor/libsodium/test/default/box_easy.exp +19 -0
- data/vendor/libsodium/test/default/box_easy2.c +31 -0
- data/vendor/libsodium/test/default/box_easy2.exp +1 -0
- data/vendor/libsodium/test/default/cmptest.h +7 -1
- data/vendor/libsodium/test/default/generichash3.c +36 -0
- data/vendor/libsodium/test/default/generichash3.exp +64 -0
- data/vendor/libsodium/test/default/pwhash.c +59 -0
- data/vendor/libsodium/test/default/pwhash.exp +2 -0
- data/vendor/libsodium/test/default/scalarmult7.c +0 -2
- data/vendor/libsodium/test/default/scalarmult8.c +0 -2
- data/vendor/libsodium/test/default/secretbox_easy.c +51 -0
- data/vendor/libsodium/test/default/secretbox_easy.exp +19 -0
- data/vendor/libsodium/test/default/secretbox_easy2.c +27 -0
- data/vendor/libsodium/test/default/secretbox_easy2.exp +1 -0
- data/vendor/libsodium/test/default/sign.c +1106 -0
- data/vendor/libsodium/test/default/sign.exp +3 -0
- data/vendor/libsodium/test/default/sodium_utils.c +8 -0
- data/vendor/libsodium/test/default/sodium_utils.exp +2 -1
- data/vendor/libsodium/test/default/sodium_version.c +1 -1
- data/vendor/libsodium/test/default/verify1.c +34 -0
- data/vendor/libsodium/test/default/verify1.exp +6 -0
- metadata +138 -33
- data/vendor/libsodium/dist-build/android.sh +0 -48
- data/vendor/libsodium/dist-build/msys.sh +0 -9
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/ref/hmac_hmacsha256.c +0 -83
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/ref/hmac_hmacsha512256.c +0 -86
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/ref/hash_sha256.c +0 -69
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/ref/hash_sha512.c +0 -71
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha256/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha256/hashblocks_sha256_api.c +0 -16
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha256/ref/api.h +0 -9
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha256/ref/blocks_sha256.c +0 -212
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha512/checksum +0 -1
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha512/hashblocks_sha512_api.c +0 -16
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha512/ref/api.h +0 -9
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha512/ref/blocks_sha512.c +0 -239
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/try.c +0 -78
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/53/api.h +0 -8
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/53/auth_poly1305_53.c +0 -1661
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/53/verify_poly1305_53.c +0 -10
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/portable-jane.h +0 -772
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_hashblocks_sha256.h +0 -32
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_hashblocks_sha512.h +0 -32
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_53.h +0 -34
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h.in +0 -44
@@ -1,152 +1,13 @@
|
|
1
1
|
|
2
2
|
#include <stdlib.h>
|
3
3
|
#include <string.h>
|
4
|
-
#include "crypto_hash_sha256.h"
|
5
4
|
#include "crypto_onetimeauth.h"
|
6
5
|
#include "crypto_onetimeauth_poly1305.h"
|
7
6
|
#include "crypto_onetimeauth_poly1305_donna.h"
|
8
|
-
#include "crypto_onetimeauth_poly1305_53.h"
|
9
7
|
#include "utils.h"
|
10
8
|
|
11
|
-
#define MAXTEST_BYTES 10000
|
12
|
-
#define CHECKSUM_BYTES 4096
|
13
|
-
|
14
|
-
#define CHECKSUM "e836d5ca58cf673fca2b4910f23f3990"
|
15
|
-
|
16
|
-
static char checksum[crypto_onetimeauth_BYTES * 2U + 1U];
|
17
|
-
|
18
|
-
static unsigned char *h, *h_;
|
19
|
-
static unsigned char *m, *m_;
|
20
|
-
static unsigned char *k, *k_;
|
21
|
-
static unsigned char *h2, *h2_;
|
22
|
-
static unsigned char *m2, *m2_;
|
23
|
-
static unsigned char *k2, *k2_;
|
24
|
-
|
25
|
-
static int
|
26
|
-
allocate(void)
|
27
|
-
{
|
28
|
-
h = _sodium_alignedcalloc(&h_, crypto_onetimeauth_BYTES);
|
29
|
-
m = _sodium_alignedcalloc(&m_, MAXTEST_BYTES);
|
30
|
-
k = _sodium_alignedcalloc(&k_, crypto_onetimeauth_KEYBYTES);
|
31
|
-
h2 = _sodium_alignedcalloc(&h2_, crypto_onetimeauth_BYTES);
|
32
|
-
m2 = _sodium_alignedcalloc(&m2_, MAXTEST_BYTES + crypto_onetimeauth_BYTES);
|
33
|
-
k2 = _sodium_alignedcalloc(&k2_, crypto_onetimeauth_KEYBYTES +
|
34
|
-
crypto_onetimeauth_BYTES);
|
35
|
-
|
36
|
-
return -!(h && m && k && h2 && m2 && k2);
|
37
|
-
}
|
38
|
-
|
39
|
-
static void
|
40
|
-
deallocate(void)
|
41
|
-
{
|
42
|
-
free(h_);
|
43
|
-
free(m_);
|
44
|
-
free(k_);
|
45
|
-
free(h2_);
|
46
|
-
free(m2_);
|
47
|
-
free(k2_);
|
48
|
-
}
|
49
|
-
|
50
|
-
#ifdef HAVE_ARC4RANDOM
|
51
|
-
# undef rand
|
52
|
-
# define rand(X) arc4random(X)
|
53
|
-
#endif
|
54
|
-
|
55
|
-
static const char *
|
56
|
-
checksum_compute(void)
|
57
|
-
{
|
58
|
-
long long i;
|
59
|
-
long long j;
|
60
|
-
|
61
|
-
for (i = 0;i < CHECKSUM_BYTES;++i) {
|
62
|
-
long long mlen = i;
|
63
|
-
long long klen = crypto_onetimeauth_KEYBYTES;
|
64
|
-
long long hlen = crypto_onetimeauth_BYTES;
|
65
|
-
|
66
|
-
for (j = -16;j < 0;++j) h[j] = rand();
|
67
|
-
for (j = -16;j < 0;++j) k[j] = rand();
|
68
|
-
for (j = -16;j < 0;++j) m[j] = rand();
|
69
|
-
for (j = hlen;j < hlen + 16;++j) h[j] = rand();
|
70
|
-
for (j = klen;j < klen + 16;++j) k[j] = rand();
|
71
|
-
for (j = mlen;j < mlen + 16;++j) m[j] = rand();
|
72
|
-
for (j = -16;j < hlen + 16;++j) h2[j] = h[j];
|
73
|
-
for (j = -16;j < klen + 16;++j) k2[j] = k[j];
|
74
|
-
for (j = -16;j < mlen + 16;++j) m2[j] = m[j];
|
75
|
-
|
76
|
-
if (crypto_onetimeauth(h,m,mlen,k) != 0) return "crypto_onetimeauth returns nonzero";
|
77
|
-
|
78
|
-
for (j = -16;j < klen + 16;++j) if (k[j] != k2[j]) return "crypto_onetimeauth overwrites k";
|
79
|
-
for (j = -16;j < mlen + 16;++j) if (m[j] != m2[j]) return "crypto_onetimeauth overwrites m";
|
80
|
-
for (j = -16;j < 0;++j) if (h[j] != h2[j]) return "crypto_onetimeauth writes before output";
|
81
|
-
for (j = hlen;j < hlen + 16;++j) if (h[j] != h2[j]) return "crypto_onetimeauth writes after output";
|
82
|
-
|
83
|
-
for (j = -16;j < 0;++j) h[j] = rand();
|
84
|
-
for (j = -16;j < 0;++j) k[j] = rand();
|
85
|
-
for (j = -16;j < 0;++j) m[j] = rand();
|
86
|
-
for (j = hlen;j < hlen + 16;++j) h[j] = rand();
|
87
|
-
for (j = klen;j < klen + 16;++j) k[j] = rand();
|
88
|
-
for (j = mlen;j < mlen + 16;++j) m[j] = rand();
|
89
|
-
for (j = -16;j < hlen + 16;++j) h2[j] = h[j];
|
90
|
-
for (j = -16;j < klen + 16;++j) k2[j] = k[j];
|
91
|
-
for (j = -16;j < mlen + 16;++j) m2[j] = m[j];
|
92
|
-
|
93
|
-
if (crypto_onetimeauth(m2,m2,mlen,k) != 0) return "crypto_onetimeauth returns nonzero";
|
94
|
-
for (j = 0;j < hlen;++j) if (m2[j] != h[j]) return "crypto_onetimeauth does not handle m overlap";
|
95
|
-
for (j = 0;j < hlen;++j) m2[j] = m[j];
|
96
|
-
if (crypto_onetimeauth(k2,m2,mlen,k2) != 0) return "crypto_onetimeauth returns nonzero";
|
97
|
-
for (j = 0;j < hlen;++j) if (k2[j] != h[j]) return "crypto_onetimeauth does not handle k overlap";
|
98
|
-
for (j = 0;j < hlen;++j) k2[j] = k[j];
|
99
|
-
|
100
|
-
if (crypto_onetimeauth_verify(h,m,mlen,k) != 0) return "crypto_onetimeauth_verify returns nonzero";
|
101
|
-
|
102
|
-
for (j = -16;j < hlen + 16;++j) if (h[j] != h2[j]) return "crypto_onetimeauth overwrites h";
|
103
|
-
for (j = -16;j < klen + 16;++j) if (k[j] != k2[j]) return "crypto_onetimeauth overwrites k";
|
104
|
-
for (j = -16;j < mlen + 16;++j) if (m[j] != m2[j]) return "crypto_onetimeauth overwrites m";
|
105
|
-
|
106
|
-
crypto_hash_sha256(h2,h,hlen);
|
107
|
-
for (j = 0;j < klen;++j) k[j] ^= h2[j % 32];
|
108
|
-
if (crypto_onetimeauth(h,m,mlen,k) != 0) return "crypto_onetimeauth returns nonzero";
|
109
|
-
if (crypto_onetimeauth_verify(h,m,mlen,k) != 0) return "crypto_onetimeauth_verify returns nonzero";
|
110
|
-
|
111
|
-
crypto_hash_sha256(h2,h,hlen);
|
112
|
-
for (j = 0;j < mlen;++j) m[j] ^= h2[j % 32];
|
113
|
-
m[mlen] = h2[0];
|
114
|
-
}
|
115
|
-
if (crypto_onetimeauth(h,m,CHECKSUM_BYTES,k) != 0) return "crypto_onetimeauth returns nonzero";
|
116
|
-
if (crypto_onetimeauth_verify(h,m,CHECKSUM_BYTES,k) != 0) return "crypto_onetimeauth_verify returns nonzero";
|
117
|
-
|
118
|
-
sodium_bin2hex(checksum, sizeof checksum, h, crypto_onetimeauth_BYTES);
|
119
|
-
|
120
|
-
return NULL;
|
121
|
-
}
|
122
|
-
|
123
9
|
crypto_onetimeauth_poly1305_implementation *
|
124
10
|
crypto_onetimeauth_pick_best_implementation(void)
|
125
11
|
{
|
126
|
-
|
127
|
-
#ifdef HAVE_FENV_H
|
128
|
-
&crypto_onetimeauth_poly1305_53_implementation,
|
129
|
-
#endif
|
130
|
-
&crypto_onetimeauth_poly1305_donna_implementation,
|
131
|
-
NULL
|
132
|
-
};
|
133
|
-
const char *err;
|
134
|
-
size_t i = (size_t) 0U;
|
135
|
-
|
136
|
-
do {
|
137
|
-
if (crypto_onetimeauth_poly1305_set_implementation
|
138
|
-
(implementations[i]) != 0) {
|
139
|
-
continue;
|
140
|
-
}
|
141
|
-
if (allocate() != 0) {
|
142
|
-
return NULL;
|
143
|
-
}
|
144
|
-
err = checksum_compute();
|
145
|
-
deallocate();
|
146
|
-
if (err == NULL && strcmp(checksum, CHECKSUM) == 0) {
|
147
|
-
break;
|
148
|
-
}
|
149
|
-
} while (implementations[++i] != NULL);
|
150
|
-
|
151
|
-
return implementations[i];
|
12
|
+
return &crypto_onetimeauth_poly1305_donna_implementation;
|
152
13
|
}
|
data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptxsalsa208sha256/crypto_scrypt-common.c
ADDED
@@ -0,0 +1,250 @@
|
|
1
|
+
/*-
|
2
|
+
* Copyright 2013 Alexander Peslyak
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
6
|
+
* modification, are permitted.
|
7
|
+
*
|
8
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
9
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
10
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
11
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
12
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
13
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
14
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
15
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
16
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
17
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
18
|
+
* SUCH DAMAGE.
|
19
|
+
*/
|
20
|
+
|
21
|
+
#include <stdint.h>
|
22
|
+
#include <string.h>
|
23
|
+
|
24
|
+
#include "crypto_pwhash_scryptxsalsa208sha256.h"
|
25
|
+
#include "crypto_scrypt.h"
|
26
|
+
#include "runtime.h"
|
27
|
+
#include "utils.h"
|
28
|
+
|
29
|
+
static const char * const itoa64 =
|
30
|
+
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
31
|
+
|
32
|
+
static uint8_t *
|
33
|
+
encode64_uint32(uint8_t * dst, size_t dstlen, uint32_t src, uint32_t srcbits)
|
34
|
+
{
|
35
|
+
uint32_t bit;
|
36
|
+
|
37
|
+
for (bit = 0; bit < srcbits; bit += 6) {
|
38
|
+
if (dstlen < 1) {
|
39
|
+
return NULL;
|
40
|
+
}
|
41
|
+
*dst++ = itoa64[src & 0x3f];
|
42
|
+
dstlen--;
|
43
|
+
src >>= 6;
|
44
|
+
}
|
45
|
+
|
46
|
+
return dst;
|
47
|
+
}
|
48
|
+
|
49
|
+
static uint8_t *
|
50
|
+
encode64(uint8_t * dst, size_t dstlen, const uint8_t * src, size_t srclen)
|
51
|
+
{
|
52
|
+
size_t i;
|
53
|
+
|
54
|
+
for (i = 0; i < srclen; ) {
|
55
|
+
uint8_t * dnext;
|
56
|
+
uint32_t value = 0, bits = 0;
|
57
|
+
do {
|
58
|
+
value |= (uint32_t)src[i++] << bits;
|
59
|
+
bits += 8;
|
60
|
+
} while (bits < 24 && i < srclen);
|
61
|
+
dnext = encode64_uint32(dst, dstlen, value, bits);
|
62
|
+
if (!dnext) {
|
63
|
+
return NULL;
|
64
|
+
}
|
65
|
+
dstlen -= dnext - dst;
|
66
|
+
dst = dnext;
|
67
|
+
}
|
68
|
+
|
69
|
+
return dst;
|
70
|
+
}
|
71
|
+
|
72
|
+
static int
|
73
|
+
decode64_one(uint32_t * dst, uint8_t src)
|
74
|
+
{
|
75
|
+
const char *ptr = strchr(itoa64, src);
|
76
|
+
|
77
|
+
if (ptr) {
|
78
|
+
*dst = ptr - itoa64;
|
79
|
+
return 0;
|
80
|
+
}
|
81
|
+
*dst = 0;
|
82
|
+
return -1;
|
83
|
+
}
|
84
|
+
|
85
|
+
static const uint8_t *
|
86
|
+
decode64_uint32(uint32_t * dst, uint32_t dstbits, const uint8_t * src)
|
87
|
+
{
|
88
|
+
uint32_t bit;
|
89
|
+
uint32_t value;
|
90
|
+
|
91
|
+
value = 0;
|
92
|
+
for (bit = 0; bit < dstbits; bit += 6) {
|
93
|
+
uint32_t one;
|
94
|
+
if (decode64_one(&one, *src)) {
|
95
|
+
*dst = 0;
|
96
|
+
return NULL;
|
97
|
+
}
|
98
|
+
src++;
|
99
|
+
value |= one << bit;
|
100
|
+
}
|
101
|
+
|
102
|
+
*dst = value;
|
103
|
+
return src;
|
104
|
+
}
|
105
|
+
|
106
|
+
uint8_t *
|
107
|
+
escrypt_r(escrypt_local_t * local, const uint8_t * passwd, size_t passwdlen,
|
108
|
+
const uint8_t * setting, uint8_t * buf, size_t buflen)
|
109
|
+
{
|
110
|
+
uint8_t hash[crypto_pwhash_scryptxsalsa208sha256_STRHASHBYTES];
|
111
|
+
escrypt_kdf_t escrypt_kdf;
|
112
|
+
const uint8_t *src;
|
113
|
+
const uint8_t *salt;
|
114
|
+
uint8_t *dst;
|
115
|
+
size_t prefixlen;
|
116
|
+
size_t saltlen;
|
117
|
+
size_t need;
|
118
|
+
uint64_t N;
|
119
|
+
uint32_t N_log2;
|
120
|
+
uint32_t r;
|
121
|
+
uint32_t p;
|
122
|
+
|
123
|
+
if (setting[0] != '$' || setting[1] != '7' || setting[2] != '$') {
|
124
|
+
return NULL;
|
125
|
+
}
|
126
|
+
src = setting + 3;
|
127
|
+
|
128
|
+
if (decode64_one(&N_log2, *src)) {
|
129
|
+
return NULL;
|
130
|
+
}
|
131
|
+
src++;
|
132
|
+
N = (uint64_t)1 << N_log2;
|
133
|
+
|
134
|
+
src = decode64_uint32(&r, 30, src);
|
135
|
+
if (!src) {
|
136
|
+
return NULL;
|
137
|
+
}
|
138
|
+
src = decode64_uint32(&p, 30, src);
|
139
|
+
if (!src) {
|
140
|
+
return NULL;
|
141
|
+
}
|
142
|
+
prefixlen = src - setting;
|
143
|
+
|
144
|
+
salt = src;
|
145
|
+
src = (uint8_t *) strrchr((char *)salt, '$');
|
146
|
+
if (src) {
|
147
|
+
saltlen = src - salt;
|
148
|
+
} else {
|
149
|
+
saltlen = strlen((char *)salt);
|
150
|
+
}
|
151
|
+
need = prefixlen + saltlen + 1 +
|
152
|
+
crypto_pwhash_scryptxsalsa208sha256_STRHASHBYTES_ENCODED + 1;
|
153
|
+
if (need > buflen || need < saltlen) {
|
154
|
+
return NULL;
|
155
|
+
}
|
156
|
+
#if defined(HAVE_EMMINTRIN_H) || defined(_MSC_VER)
|
157
|
+
escrypt_kdf =
|
158
|
+
sodium_runtime_has_sse2() ? escrypt_kdf_sse : escrypt_kdf_nosse;
|
159
|
+
#else
|
160
|
+
escrypt_kdf = escrypt_kdf_nosse;
|
161
|
+
#endif
|
162
|
+
if (escrypt_kdf(local, passwd, passwdlen, salt, saltlen,
|
163
|
+
N, r, p, hash, sizeof(hash))) {
|
164
|
+
return NULL;
|
165
|
+
}
|
166
|
+
|
167
|
+
dst = buf;
|
168
|
+
memcpy(dst, setting, prefixlen + saltlen);
|
169
|
+
dst += prefixlen + saltlen;
|
170
|
+
*dst++ = '$';
|
171
|
+
|
172
|
+
dst = encode64(dst, buflen - (dst - buf), hash, sizeof(hash));
|
173
|
+
sodium_memzero(hash, sizeof hash);
|
174
|
+
if (!dst || dst >= buf + buflen) { /* Can't happen */
|
175
|
+
return NULL;
|
176
|
+
}
|
177
|
+
*dst = 0; /* NUL termination */
|
178
|
+
|
179
|
+
return buf;
|
180
|
+
}
|
181
|
+
|
182
|
+
uint8_t *
|
183
|
+
escrypt_gensalt_r(uint32_t N_log2, uint32_t r, uint32_t p,
|
184
|
+
const uint8_t * src, size_t srclen,
|
185
|
+
uint8_t * buf, size_t buflen)
|
186
|
+
{
|
187
|
+
uint8_t *dst;
|
188
|
+
size_t prefixlen =
|
189
|
+
(sizeof "$7$" - 1U) + (1U /* N_log2 */) + (5U /* r */) + (5U /* p */);
|
190
|
+
size_t saltlen = BYTES2CHARS(srclen);
|
191
|
+
size_t need;
|
192
|
+
|
193
|
+
need = prefixlen + saltlen + 1;
|
194
|
+
if (need > buflen || need < saltlen || saltlen < srclen) {
|
195
|
+
return NULL;
|
196
|
+
}
|
197
|
+
if (N_log2 > 63 || ((uint64_t)r * (uint64_t)p >= (1U << 30))) {
|
198
|
+
return NULL;
|
199
|
+
}
|
200
|
+
dst = buf;
|
201
|
+
*dst++ = '$';
|
202
|
+
*dst++ = '7';
|
203
|
+
*dst++ = '$';
|
204
|
+
|
205
|
+
*dst++ = itoa64[N_log2];
|
206
|
+
|
207
|
+
dst = encode64_uint32(dst, buflen - (dst - buf), r, 30);
|
208
|
+
if (!dst) { /* Can't happen */
|
209
|
+
return NULL;
|
210
|
+
}
|
211
|
+
dst = encode64_uint32(dst, buflen - (dst - buf), p, 30);
|
212
|
+
if (!dst) { /* Can't happen */
|
213
|
+
return NULL;
|
214
|
+
}
|
215
|
+
dst = encode64(dst, buflen - (dst - buf), src, srclen);
|
216
|
+
if (!dst || dst >= buf + buflen) { /* Can't happen */
|
217
|
+
return NULL;
|
218
|
+
}
|
219
|
+
*dst = 0; /* NUL termination */
|
220
|
+
|
221
|
+
return buf;
|
222
|
+
}
|
223
|
+
|
224
|
+
int
|
225
|
+
crypto_scrypt_compat(const uint8_t * passwd, size_t passwdlen,
|
226
|
+
const uint8_t * salt, size_t saltlen,
|
227
|
+
uint64_t N, uint32_t r, uint32_t p,
|
228
|
+
uint8_t * buf, size_t buflen)
|
229
|
+
{
|
230
|
+
escrypt_kdf_t escrypt_kdf;
|
231
|
+
escrypt_local_t local;
|
232
|
+
int retval;
|
233
|
+
|
234
|
+
if (escrypt_init_local(&local)) {
|
235
|
+
return -1;
|
236
|
+
}
|
237
|
+
#if defined(HAVE_EMMINTRIN_H) || defined(_MSC_VER)
|
238
|
+
escrypt_kdf =
|
239
|
+
sodium_runtime_has_sse2() ? escrypt_kdf_sse : escrypt_kdf_nosse;
|
240
|
+
#else
|
241
|
+
escrypt_kdf = escrypt_kdf_nosse;
|
242
|
+
#endif
|
243
|
+
retval = escrypt_kdf(&local,
|
244
|
+
passwd, passwdlen, salt, saltlen,
|
245
|
+
N, r, p, buf, buflen);
|
246
|
+
if (escrypt_free_local(&local)) {
|
247
|
+
return -1;
|
248
|
+
}
|
249
|
+
return retval;
|
250
|
+
}
|
@@ -0,0 +1,100 @@
|
|
1
|
+
/*-
|
2
|
+
* Copyright 2009 Colin Percival
|
3
|
+
* Copyright 2013 Alexander Peslyak
|
4
|
+
* All rights reserved.
|
5
|
+
*
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
7
|
+
* modification, are permitted provided that the following conditions
|
8
|
+
* are met:
|
9
|
+
* 1. Redistributions of source code must retain the above copyright
|
10
|
+
* notice, this list of conditions and the following disclaimer.
|
11
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
12
|
+
* notice, this list of conditions and the following disclaimer in the
|
13
|
+
* documentation and/or other materials provided with the distribution.
|
14
|
+
*
|
15
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
16
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
17
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
18
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
19
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
20
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
21
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
22
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
23
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
24
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
25
|
+
* SUCH DAMAGE.
|
26
|
+
*
|
27
|
+
* This file was originally written by Colin Percival as part of the Tarsnap
|
28
|
+
* online backup system.
|
29
|
+
*/
|
30
|
+
#ifndef _CRYPTO_SCRYPT_H_
|
31
|
+
#define _CRYPTO_SCRYPT_H_
|
32
|
+
|
33
|
+
#include <stdint.h>
|
34
|
+
|
35
|
+
#define crypto_pwhash_scryptxsalsa208sha256_STRPREFIXBYTES 14
|
36
|
+
#define crypto_pwhash_scryptxsalsa208sha256_STRSETTINGBYTES 57
|
37
|
+
#define crypto_pwhash_scryptxsalsa208sha256_STRSALTBYTES 32
|
38
|
+
#define crypto_pwhash_scryptxsalsa208sha256_STRSALTBYTES_ENCODED 43
|
39
|
+
#define crypto_pwhash_scryptxsalsa208sha256_STRHASHBYTES 32
|
40
|
+
#define crypto_pwhash_scryptxsalsa208sha256_STRHASHBYTES_ENCODED 43
|
41
|
+
|
42
|
+
#define BYTES2CHARS(bytes) ((((bytes) * 8) + 5) / 6)
|
43
|
+
|
44
|
+
/**
|
45
|
+
* crypto_scrypt_compat(passwd, passwdlen, salt, saltlen, N, r, p, buf, buflen):
|
46
|
+
* Compute scrypt(passwd[0 .. passwdlen - 1], salt[0 .. saltlen - 1], N, r,
|
47
|
+
* p, buflen) and write the result into buf. The parameters r, p, and buflen
|
48
|
+
* must satisfy r * p < 2^30 and buflen <= (2^32 - 1) * 32. The parameter N
|
49
|
+
* must be a power of 2 greater than 1.
|
50
|
+
*
|
51
|
+
* Return 0 on success; or -1 on error.
|
52
|
+
*/
|
53
|
+
extern int crypto_scrypt_compat(const uint8_t * __passwd, size_t __passwdlen,
|
54
|
+
const uint8_t * __salt, size_t __saltlen,
|
55
|
+
uint64_t __N, uint32_t __r, uint32_t __p,
|
56
|
+
uint8_t * __buf, size_t __buflen);
|
57
|
+
|
58
|
+
typedef struct {
|
59
|
+
void * base, * aligned;
|
60
|
+
size_t size;
|
61
|
+
} escrypt_region_t;
|
62
|
+
|
63
|
+
typedef escrypt_region_t escrypt_local_t;
|
64
|
+
|
65
|
+
extern int escrypt_init_local(escrypt_local_t * __local);
|
66
|
+
|
67
|
+
extern int escrypt_free_local(escrypt_local_t * __local);
|
68
|
+
|
69
|
+
extern void *alloc_region(escrypt_region_t * region, size_t size);
|
70
|
+
extern int free_region(escrypt_region_t * region);
|
71
|
+
|
72
|
+
typedef int (*escrypt_kdf_t)(escrypt_local_t * __local,
|
73
|
+
const uint8_t * __passwd, size_t __passwdlen,
|
74
|
+
const uint8_t * __salt, size_t __saltlen,
|
75
|
+
uint64_t __N, uint32_t __r, uint32_t __p,
|
76
|
+
uint8_t * __buf, size_t __buflen);
|
77
|
+
|
78
|
+
extern int escrypt_kdf_nosse(escrypt_local_t * __local,
|
79
|
+
const uint8_t * __passwd, size_t __passwdlen,
|
80
|
+
const uint8_t * __salt, size_t __saltlen,
|
81
|
+
uint64_t __N, uint32_t __r, uint32_t __p,
|
82
|
+
uint8_t * __buf, size_t __buflen);
|
83
|
+
|
84
|
+
extern int escrypt_kdf_sse(escrypt_local_t * __local,
|
85
|
+
const uint8_t * __passwd, size_t __passwdlen,
|
86
|
+
const uint8_t * __salt, size_t __saltlen,
|
87
|
+
uint64_t __N, uint32_t __r, uint32_t __p,
|
88
|
+
uint8_t * __buf, size_t __buflen);
|
89
|
+
|
90
|
+
extern uint8_t * escrypt_r(escrypt_local_t * __local,
|
91
|
+
const uint8_t * __passwd, size_t __passwdlen,
|
92
|
+
const uint8_t * __setting,
|
93
|
+
uint8_t * __buf, size_t __buflen);
|
94
|
+
|
95
|
+
extern uint8_t * escrypt_gensalt_r(
|
96
|
+
uint32_t __N_log2, uint32_t __r, uint32_t __p,
|
97
|
+
const uint8_t * __src, size_t __srclen,
|
98
|
+
uint8_t * __buf, size_t __buflen);
|
99
|
+
|
100
|
+
#endif /* !_CRYPTO_SCRYPT_H_ */
|