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
@@ -22,6 +22,25 @@ crypto_generichash_blake2b(unsigned char *out, size_t outlen,
|
|
22
22
|
(uint8_t) outlen, (uint64_t) inlen, (uint8_t) keylen);
|
23
23
|
}
|
24
24
|
|
25
|
+
int
|
26
|
+
crypto_generichash_blake2b_salt_personal(unsigned char *out, size_t outlen,
|
27
|
+
const unsigned char *in, unsigned long long inlen,
|
28
|
+
const unsigned char *key, size_t keylen,
|
29
|
+
const unsigned char *salt,
|
30
|
+
const unsigned char *personal)
|
31
|
+
{
|
32
|
+
if (outlen <= 0U || outlen > BLAKE2B_OUTBYTES ||
|
33
|
+
keylen > BLAKE2B_KEYBYTES || inlen > UINT64_MAX) {
|
34
|
+
return -1;
|
35
|
+
}
|
36
|
+
assert(outlen <= UINT8_MAX);
|
37
|
+
assert(keylen <= UINT8_MAX);
|
38
|
+
|
39
|
+
return blake2b_salt_personal((uint8_t *) out, in, key,
|
40
|
+
(uint8_t) outlen, (uint64_t) inlen, (uint8_t) keylen,
|
41
|
+
salt, personal);
|
42
|
+
}
|
43
|
+
|
25
44
|
int
|
26
45
|
crypto_generichash_blake2b_init(crypto_generichash_blake2b_state *state,
|
27
46
|
const unsigned char *key,
|
@@ -33,11 +52,39 @@ crypto_generichash_blake2b_init(crypto_generichash_blake2b_state *state,
|
|
33
52
|
}
|
34
53
|
assert(outlen <= UINT8_MAX);
|
35
54
|
assert(keylen <= UINT8_MAX);
|
36
|
-
if (
|
55
|
+
if (key == NULL || keylen <= 0U) {
|
56
|
+
if (blake2b_init(state, (uint8_t) outlen) != 0) {
|
57
|
+
return -1;
|
58
|
+
}
|
59
|
+
} else if (blake2b_init_key(state, (uint8_t) outlen, key,
|
60
|
+
(uint8_t) keylen) != 0) {
|
37
61
|
return -1;
|
38
62
|
}
|
39
|
-
|
40
|
-
|
63
|
+
return 0;
|
64
|
+
}
|
65
|
+
|
66
|
+
int
|
67
|
+
crypto_generichash_blake2b_init_salt_personal(crypto_generichash_blake2b_state *state,
|
68
|
+
const unsigned char *key,
|
69
|
+
const size_t keylen, const size_t outlen,
|
70
|
+
const unsigned char *salt,
|
71
|
+
const unsigned char *personal)
|
72
|
+
{
|
73
|
+
if (outlen <= 0U || outlen > BLAKE2B_OUTBYTES ||
|
74
|
+
keylen > BLAKE2B_KEYBYTES) {
|
75
|
+
return -1;
|
76
|
+
}
|
77
|
+
assert(outlen <= UINT8_MAX);
|
78
|
+
assert(keylen <= UINT8_MAX);
|
79
|
+
if (key == NULL || keylen <= 0U) {
|
80
|
+
if (blake2b_init_salt_personal(state, (uint8_t) outlen,
|
81
|
+
salt, personal) != 0) {
|
82
|
+
return -1;
|
83
|
+
}
|
84
|
+
} else if (blake2b_init_key_salt_personal(state,
|
85
|
+
(uint8_t) outlen, key,
|
86
|
+
(uint8_t) keylen,
|
87
|
+
salt, personal) != 0) {
|
41
88
|
return -1;
|
42
89
|
}
|
43
90
|
return 0;
|
@@ -1,12 +1,6 @@
|
|
1
1
|
|
2
2
|
#include "crypto_generichash.h"
|
3
3
|
|
4
|
-
size_t
|
5
|
-
crypto_generichash_bytes(void)
|
6
|
-
{
|
7
|
-
return crypto_generichash_BYTES;
|
8
|
-
}
|
9
|
-
|
10
4
|
size_t
|
11
5
|
crypto_generichash_bytes_min(void)
|
12
6
|
{
|
@@ -20,9 +14,9 @@ crypto_generichash_bytes_max(void)
|
|
20
14
|
}
|
21
15
|
|
22
16
|
size_t
|
23
|
-
|
17
|
+
crypto_generichash_bytes(void)
|
24
18
|
{
|
25
|
-
return
|
19
|
+
return crypto_generichash_BYTES;
|
26
20
|
}
|
27
21
|
|
28
22
|
size_t
|
@@ -38,9 +32,9 @@ crypto_generichash_keybytes_max(void)
|
|
38
32
|
}
|
39
33
|
|
40
34
|
size_t
|
41
|
-
|
35
|
+
crypto_generichash_keybytes(void)
|
42
36
|
{
|
43
|
-
return
|
37
|
+
return crypto_generichash_KEYBYTES;
|
44
38
|
}
|
45
39
|
|
46
40
|
const char *crypto_generichash_primitive(void)
|
@@ -1,9 +1,20 @@
|
|
1
1
|
|
2
2
|
#include "crypto_hash.h"
|
3
3
|
|
4
|
+
size_t
|
5
|
+
crypto_hash_bytes(void)
|
6
|
+
{
|
7
|
+
return crypto_hash_BYTES;
|
8
|
+
}
|
9
|
+
|
4
10
|
int
|
5
11
|
crypto_hash(unsigned char *out, const unsigned char *in,
|
6
12
|
unsigned long long inlen)
|
7
13
|
{
|
8
14
|
return crypto_hash_sha512(out, in, inlen);
|
9
15
|
}
|
16
|
+
|
17
|
+
const char *
|
18
|
+
crypto_hash_primitive(void) {
|
19
|
+
return crypto_hash_PRIMITIVE;
|
20
|
+
}
|
@@ -2,7 +2,9 @@
|
|
2
2
|
#include "crypto_hash_sha256.h"
|
3
3
|
|
4
4
|
#define crypto_hash crypto_hash_sha256
|
5
|
+
#define crypto_hash_init crypto_hash_sha256_init
|
6
|
+
#define crypto_hash_update crypto_hash_sha256_update
|
7
|
+
#define crypto_hash_final crypto_hash_sha256_final
|
5
8
|
#define crypto_hash_BYTES crypto_hash_sha256_BYTES
|
6
|
-
#define crypto_hash_PRIMITIVE "sha256"
|
7
9
|
#define crypto_hash_IMPLEMENTATION crypto_hash_sha256_IMPLEMENTATION
|
8
10
|
#define crypto_hash_VERSION crypto_hash_sha256_VERSION
|
@@ -0,0 +1,294 @@
|
|
1
|
+
|
2
|
+
/*-
|
3
|
+
* Copyright 2005,2007,2009 Colin Percival
|
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
|
+
*/
|
28
|
+
|
29
|
+
#include "api.h"
|
30
|
+
#include "crypto_hash_sha256.h"
|
31
|
+
#include "utils.h"
|
32
|
+
|
33
|
+
#include <sys/types.h>
|
34
|
+
|
35
|
+
#include <limits.h>
|
36
|
+
#include <stdint.h>
|
37
|
+
#include <stdlib.h>
|
38
|
+
#include <string.h>
|
39
|
+
|
40
|
+
/* Avoid namespace collisions with BSD <sys/endian.h>. */
|
41
|
+
#define be32dec _sha256_be32dec
|
42
|
+
#define be32enc _sha256_be32enc
|
43
|
+
|
44
|
+
static inline uint32_t
|
45
|
+
be32dec(const void *pp)
|
46
|
+
{
|
47
|
+
const uint8_t *p = (uint8_t const *)pp;
|
48
|
+
|
49
|
+
return ((uint32_t)(p[3]) + ((uint32_t)(p[2]) << 8) +
|
50
|
+
((uint32_t)(p[1]) << 16) + ((uint32_t)(p[0]) << 24));
|
51
|
+
}
|
52
|
+
|
53
|
+
static inline void
|
54
|
+
be32enc(void *pp, uint32_t x)
|
55
|
+
{
|
56
|
+
uint8_t * p = (uint8_t *)pp;
|
57
|
+
|
58
|
+
p[3] = x & 0xff;
|
59
|
+
p[2] = (x >> 8) & 0xff;
|
60
|
+
p[1] = (x >> 16) & 0xff;
|
61
|
+
p[0] = (x >> 24) & 0xff;
|
62
|
+
}
|
63
|
+
|
64
|
+
static void
|
65
|
+
be32enc_vect(unsigned char *dst, const uint32_t *src, size_t len)
|
66
|
+
{
|
67
|
+
size_t i;
|
68
|
+
|
69
|
+
for (i = 0; i < len / 4; i++) {
|
70
|
+
be32enc(dst + i * 4, src[i]);
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
static void
|
75
|
+
be32dec_vect(uint32_t *dst, const unsigned char *src, size_t len)
|
76
|
+
{
|
77
|
+
size_t i;
|
78
|
+
|
79
|
+
for (i = 0; i < len / 4; i++) {
|
80
|
+
dst[i] = be32dec(src + i * 4);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
#define Ch(x, y, z) ((x & (y ^ z)) ^ z)
|
85
|
+
#define Maj(x, y, z) ((x & (y | z)) | (y & z))
|
86
|
+
#define SHR(x, n) (x >> n)
|
87
|
+
#define ROTR(x, n) ((x >> n) | (x << (32 - n)))
|
88
|
+
#define S0(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
|
89
|
+
#define S1(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
|
90
|
+
#define s0(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3))
|
91
|
+
#define s1(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHR(x, 10))
|
92
|
+
|
93
|
+
#define RND(a, b, c, d, e, f, g, h, k) \
|
94
|
+
t0 = h + S1(e) + Ch(e, f, g) + k; \
|
95
|
+
t1 = S0(a) + Maj(a, b, c); \
|
96
|
+
d += t0; \
|
97
|
+
h = t0 + t1;
|
98
|
+
|
99
|
+
#define RNDr(S, W, i, k) \
|
100
|
+
RND(S[(64 - i) % 8], S[(65 - i) % 8], \
|
101
|
+
S[(66 - i) % 8], S[(67 - i) % 8], \
|
102
|
+
S[(68 - i) % 8], S[(69 - i) % 8], \
|
103
|
+
S[(70 - i) % 8], S[(71 - i) % 8], \
|
104
|
+
W[i] + k)
|
105
|
+
|
106
|
+
static void
|
107
|
+
SHA256_Transform(uint32_t *state, const unsigned char block[64])
|
108
|
+
{
|
109
|
+
uint32_t W[64];
|
110
|
+
uint32_t S[8];
|
111
|
+
uint32_t t0, t1;
|
112
|
+
int i;
|
113
|
+
|
114
|
+
be32dec_vect(W, block, 64);
|
115
|
+
for (i = 16; i < 64; i++) {
|
116
|
+
W[i] = s1(W[i - 2]) + W[i - 7] + s0(W[i - 15]) + W[i - 16];
|
117
|
+
}
|
118
|
+
|
119
|
+
memcpy(S, state, 32);
|
120
|
+
|
121
|
+
RNDr(S, W, 0, 0x428a2f98);
|
122
|
+
RNDr(S, W, 1, 0x71374491);
|
123
|
+
RNDr(S, W, 2, 0xb5c0fbcf);
|
124
|
+
RNDr(S, W, 3, 0xe9b5dba5);
|
125
|
+
RNDr(S, W, 4, 0x3956c25b);
|
126
|
+
RNDr(S, W, 5, 0x59f111f1);
|
127
|
+
RNDr(S, W, 6, 0x923f82a4);
|
128
|
+
RNDr(S, W, 7, 0xab1c5ed5);
|
129
|
+
RNDr(S, W, 8, 0xd807aa98);
|
130
|
+
RNDr(S, W, 9, 0x12835b01);
|
131
|
+
RNDr(S, W, 10, 0x243185be);
|
132
|
+
RNDr(S, W, 11, 0x550c7dc3);
|
133
|
+
RNDr(S, W, 12, 0x72be5d74);
|
134
|
+
RNDr(S, W, 13, 0x80deb1fe);
|
135
|
+
RNDr(S, W, 14, 0x9bdc06a7);
|
136
|
+
RNDr(S, W, 15, 0xc19bf174);
|
137
|
+
RNDr(S, W, 16, 0xe49b69c1);
|
138
|
+
RNDr(S, W, 17, 0xefbe4786);
|
139
|
+
RNDr(S, W, 18, 0x0fc19dc6);
|
140
|
+
RNDr(S, W, 19, 0x240ca1cc);
|
141
|
+
RNDr(S, W, 20, 0x2de92c6f);
|
142
|
+
RNDr(S, W, 21, 0x4a7484aa);
|
143
|
+
RNDr(S, W, 22, 0x5cb0a9dc);
|
144
|
+
RNDr(S, W, 23, 0x76f988da);
|
145
|
+
RNDr(S, W, 24, 0x983e5152);
|
146
|
+
RNDr(S, W, 25, 0xa831c66d);
|
147
|
+
RNDr(S, W, 26, 0xb00327c8);
|
148
|
+
RNDr(S, W, 27, 0xbf597fc7);
|
149
|
+
RNDr(S, W, 28, 0xc6e00bf3);
|
150
|
+
RNDr(S, W, 29, 0xd5a79147);
|
151
|
+
RNDr(S, W, 30, 0x06ca6351);
|
152
|
+
RNDr(S, W, 31, 0x14292967);
|
153
|
+
RNDr(S, W, 32, 0x27b70a85);
|
154
|
+
RNDr(S, W, 33, 0x2e1b2138);
|
155
|
+
RNDr(S, W, 34, 0x4d2c6dfc);
|
156
|
+
RNDr(S, W, 35, 0x53380d13);
|
157
|
+
RNDr(S, W, 36, 0x650a7354);
|
158
|
+
RNDr(S, W, 37, 0x766a0abb);
|
159
|
+
RNDr(S, W, 38, 0x81c2c92e);
|
160
|
+
RNDr(S, W, 39, 0x92722c85);
|
161
|
+
RNDr(S, W, 40, 0xa2bfe8a1);
|
162
|
+
RNDr(S, W, 41, 0xa81a664b);
|
163
|
+
RNDr(S, W, 42, 0xc24b8b70);
|
164
|
+
RNDr(S, W, 43, 0xc76c51a3);
|
165
|
+
RNDr(S, W, 44, 0xd192e819);
|
166
|
+
RNDr(S, W, 45, 0xd6990624);
|
167
|
+
RNDr(S, W, 46, 0xf40e3585);
|
168
|
+
RNDr(S, W, 47, 0x106aa070);
|
169
|
+
RNDr(S, W, 48, 0x19a4c116);
|
170
|
+
RNDr(S, W, 49, 0x1e376c08);
|
171
|
+
RNDr(S, W, 50, 0x2748774c);
|
172
|
+
RNDr(S, W, 51, 0x34b0bcb5);
|
173
|
+
RNDr(S, W, 52, 0x391c0cb3);
|
174
|
+
RNDr(S, W, 53, 0x4ed8aa4a);
|
175
|
+
RNDr(S, W, 54, 0x5b9cca4f);
|
176
|
+
RNDr(S, W, 55, 0x682e6ff3);
|
177
|
+
RNDr(S, W, 56, 0x748f82ee);
|
178
|
+
RNDr(S, W, 57, 0x78a5636f);
|
179
|
+
RNDr(S, W, 58, 0x84c87814);
|
180
|
+
RNDr(S, W, 59, 0x8cc70208);
|
181
|
+
RNDr(S, W, 60, 0x90befffa);
|
182
|
+
RNDr(S, W, 61, 0xa4506ceb);
|
183
|
+
RNDr(S, W, 62, 0xbef9a3f7);
|
184
|
+
RNDr(S, W, 63, 0xc67178f2);
|
185
|
+
|
186
|
+
for (i = 0; i < 8; i++) {
|
187
|
+
state[i] += S[i];
|
188
|
+
}
|
189
|
+
|
190
|
+
sodium_memzero((void *) W, sizeof W);
|
191
|
+
sodium_memzero((void *) S, sizeof S);
|
192
|
+
sodium_memzero((void *) &t0, sizeof t0);
|
193
|
+
sodium_memzero((void *) &t1, sizeof t1);
|
194
|
+
}
|
195
|
+
|
196
|
+
static unsigned char PAD[64] = {
|
197
|
+
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
198
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
199
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
200
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
201
|
+
};
|
202
|
+
|
203
|
+
static void
|
204
|
+
SHA256_Pad(crypto_hash_sha256_state *state)
|
205
|
+
{
|
206
|
+
unsigned char len[8];
|
207
|
+
uint32_t r, plen;
|
208
|
+
|
209
|
+
be32enc_vect(len, state->count, 8);
|
210
|
+
|
211
|
+
r = (state->count[1] >> 3) & 0x3f;
|
212
|
+
plen = (r < 56) ? (56 - r) : (120 - r);
|
213
|
+
crypto_hash_sha256_update(state, PAD, (unsigned long long) plen);
|
214
|
+
|
215
|
+
crypto_hash_sha256_update(state, len, 8);
|
216
|
+
}
|
217
|
+
|
218
|
+
int
|
219
|
+
crypto_hash_sha256_init(crypto_hash_sha256_state *state)
|
220
|
+
{
|
221
|
+
state->count[0] = state->count[1] = 0;
|
222
|
+
|
223
|
+
state->state[0] = 0x6A09E667;
|
224
|
+
state->state[1] = 0xBB67AE85;
|
225
|
+
state->state[2] = 0x3C6EF372;
|
226
|
+
state->state[3] = 0xA54FF53A;
|
227
|
+
state->state[4] = 0x510E527F;
|
228
|
+
state->state[5] = 0x9B05688C;
|
229
|
+
state->state[6] = 0x1F83D9AB;
|
230
|
+
state->state[7] = 0x5BE0CD19;
|
231
|
+
|
232
|
+
return 0;
|
233
|
+
}
|
234
|
+
|
235
|
+
int
|
236
|
+
crypto_hash_sha256_update(crypto_hash_sha256_state *state,
|
237
|
+
const unsigned char *in,
|
238
|
+
unsigned long long inlen)
|
239
|
+
{
|
240
|
+
uint32_t bitlen[2];
|
241
|
+
uint32_t r;
|
242
|
+
|
243
|
+
r = (state->count[1] >> 3) & 0x3f;
|
244
|
+
|
245
|
+
bitlen[1] = ((uint32_t)inlen) << 3;
|
246
|
+
bitlen[0] = (uint32_t)(inlen >> 29);
|
247
|
+
|
248
|
+
if ((state->count[1] += bitlen[1]) < bitlen[1]) {
|
249
|
+
state->count[0]++;
|
250
|
+
}
|
251
|
+
state->count[0] += bitlen[0];
|
252
|
+
|
253
|
+
if (inlen < 64 - r) {
|
254
|
+
memcpy(&state->buf[r], in, inlen);
|
255
|
+
return 0;
|
256
|
+
}
|
257
|
+
memcpy(&state->buf[r], in, 64 - r);
|
258
|
+
SHA256_Transform(state->state, state->buf);
|
259
|
+
in += 64 - r;
|
260
|
+
inlen -= 64 - r;
|
261
|
+
|
262
|
+
while (inlen >= 64) {
|
263
|
+
SHA256_Transform(state->state, in);
|
264
|
+
in += 64;
|
265
|
+
inlen -= 64;
|
266
|
+
}
|
267
|
+
memcpy(state->buf, in, inlen);
|
268
|
+
|
269
|
+
return 0;
|
270
|
+
}
|
271
|
+
|
272
|
+
int
|
273
|
+
crypto_hash_sha256_final(crypto_hash_sha256_state *state,
|
274
|
+
unsigned char *out)
|
275
|
+
{
|
276
|
+
SHA256_Pad(state);
|
277
|
+
be32enc_vect(out, state->state, 32);
|
278
|
+
sodium_memzero((void *) state, sizeof *state);
|
279
|
+
|
280
|
+
return 0;
|
281
|
+
}
|
282
|
+
|
283
|
+
int
|
284
|
+
crypto_hash(unsigned char *out, const unsigned char *in,
|
285
|
+
unsigned long long inlen)
|
286
|
+
{
|
287
|
+
crypto_hash_sha256_state state;
|
288
|
+
|
289
|
+
crypto_hash_sha256_init(&state);
|
290
|
+
crypto_hash_sha256_update(&state, in, inlen);
|
291
|
+
crypto_hash_sha256_final(&state, out);
|
292
|
+
|
293
|
+
return 0;
|
294
|
+
}
|
@@ -2,7 +2,9 @@
|
|
2
2
|
#include "crypto_hash_sha512.h"
|
3
3
|
|
4
4
|
#define crypto_hash crypto_hash_sha512
|
5
|
+
#define crypto_hash_init crypto_hash_sha512_init
|
6
|
+
#define crypto_hash_update crypto_hash_sha512_update
|
7
|
+
#define crypto_hash_final crypto_hash_sha512_final
|
5
8
|
#define crypto_hash_BYTES crypto_hash_sha512_BYTES
|
6
|
-
#define crypto_hash_PRIMITIVE "sha512"
|
7
9
|
#define crypto_hash_IMPLEMENTATION crypto_hash_sha512_IMPLEMENTATION
|
8
10
|
#define crypto_hash_VERSION crypto_hash_sha512_VERSION
|