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
@@ -0,0 +1,321 @@
|
|
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_sha512.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 be64dec _sha512_be64dec
|
42
|
+
#define be64enc _sha512_be64enc
|
43
|
+
|
44
|
+
static inline uint64_t
|
45
|
+
be64dec(const void *pp)
|
46
|
+
{
|
47
|
+
const uint8_t *p = (uint8_t const *)pp;
|
48
|
+
|
49
|
+
return ((uint64_t)(p[7]) + ((uint64_t)(p[6]) << 8) +
|
50
|
+
((uint64_t)(p[5]) << 16) + ((uint64_t)(p[4]) << 24) +
|
51
|
+
((uint64_t)(p[3]) << 32) + ((uint64_t)(p[2]) << 40) +
|
52
|
+
((uint64_t)(p[1]) << 48) + ((uint64_t)(p[0]) << 56));
|
53
|
+
}
|
54
|
+
|
55
|
+
static inline void
|
56
|
+
be64enc(void *pp, uint64_t x)
|
57
|
+
{
|
58
|
+
uint8_t *p = (uint8_t *)pp;
|
59
|
+
|
60
|
+
p[7] = x & 0xff;
|
61
|
+
p[6] = (x >> 8) & 0xff;
|
62
|
+
p[5] = (x >> 16) & 0xff;
|
63
|
+
p[4] = (x >> 24) & 0xff;
|
64
|
+
p[3] = (x >> 32) & 0xff;
|
65
|
+
p[2] = (x >> 40) & 0xff;
|
66
|
+
p[1] = (x >> 48) & 0xff;
|
67
|
+
p[0] = (x >> 56) & 0xff;
|
68
|
+
}
|
69
|
+
|
70
|
+
static void
|
71
|
+
be64enc_vect(unsigned char *dst, const uint64_t *src, size_t len)
|
72
|
+
{
|
73
|
+
size_t i;
|
74
|
+
|
75
|
+
for (i = 0; i < len / 8; i++) {
|
76
|
+
be64enc(dst + i * 8, src[i]);
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
static void
|
81
|
+
be64dec_vect(uint64_t *dst, const unsigned char *src, size_t len)
|
82
|
+
{
|
83
|
+
size_t i;
|
84
|
+
|
85
|
+
for (i = 0; i < len / 8; i++) {
|
86
|
+
dst[i] = be64dec(src + i * 8);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
#define Ch(x, y, z) ((x & (y ^ z)) ^ z)
|
91
|
+
#define Maj(x, y, z) ((x & (y | z)) | (y & z))
|
92
|
+
#define SHR(x, n) (x >> n)
|
93
|
+
#define ROTR(x, n) ((x >> n) | (x << (64 - n)))
|
94
|
+
#define S0(x) (ROTR(x, 28) ^ ROTR(x, 34) ^ ROTR(x, 39))
|
95
|
+
#define S1(x) (ROTR(x, 14) ^ ROTR(x, 18) ^ ROTR(x, 41))
|
96
|
+
#define s0(x) (ROTR(x, 1) ^ ROTR(x, 8) ^ SHR(x, 7))
|
97
|
+
#define s1(x) (ROTR(x, 19) ^ ROTR(x, 61) ^ SHR(x, 6))
|
98
|
+
|
99
|
+
#define RND(a, b, c, d, e, f, g, h, k) \
|
100
|
+
t0 = h + S1(e) + Ch(e, f, g) + k; \
|
101
|
+
t1 = S0(a) + Maj(a, b, c); \
|
102
|
+
d += t0; \
|
103
|
+
h = t0 + t1;
|
104
|
+
|
105
|
+
#define RNDr(S, W, i, k) \
|
106
|
+
RND(S[(80 - i) % 8], S[(81 - i) % 8], \
|
107
|
+
S[(82 - i) % 8], S[(83 - i) % 8], \
|
108
|
+
S[(84 - i) % 8], S[(85 - i) % 8], \
|
109
|
+
S[(86 - i) % 8], S[(87 - i) % 8], \
|
110
|
+
W[i] + k)
|
111
|
+
|
112
|
+
static void
|
113
|
+
SHA512_Transform(uint64_t *state, const unsigned char block[128])
|
114
|
+
{
|
115
|
+
uint64_t W[80];
|
116
|
+
uint64_t S[8];
|
117
|
+
uint64_t t0, t1;
|
118
|
+
int i;
|
119
|
+
|
120
|
+
be64dec_vect(W, block, 128);
|
121
|
+
for (i = 16; i < 80; i++) {
|
122
|
+
W[i] = s1(W[i - 2]) + W[i - 7] + s0(W[i - 15]) + W[i - 16];
|
123
|
+
}
|
124
|
+
|
125
|
+
memcpy(S, state, 64);
|
126
|
+
|
127
|
+
RNDr(S, W, 0, 0x428a2f98d728ae22ULL);
|
128
|
+
RNDr(S, W, 1, 0x7137449123ef65cdULL);
|
129
|
+
RNDr(S, W, 2, 0xb5c0fbcfec4d3b2fULL);
|
130
|
+
RNDr(S, W, 3, 0xe9b5dba58189dbbcULL);
|
131
|
+
RNDr(S, W, 4, 0x3956c25bf348b538ULL);
|
132
|
+
RNDr(S, W, 5, 0x59f111f1b605d019ULL);
|
133
|
+
RNDr(S, W, 6, 0x923f82a4af194f9bULL);
|
134
|
+
RNDr(S, W, 7, 0xab1c5ed5da6d8118ULL);
|
135
|
+
RNDr(S, W, 8, 0xd807aa98a3030242ULL);
|
136
|
+
RNDr(S, W, 9, 0x12835b0145706fbeULL);
|
137
|
+
RNDr(S, W, 10, 0x243185be4ee4b28cULL);
|
138
|
+
RNDr(S, W, 11, 0x550c7dc3d5ffb4e2ULL);
|
139
|
+
RNDr(S, W, 12, 0x72be5d74f27b896fULL);
|
140
|
+
RNDr(S, W, 13, 0x80deb1fe3b1696b1ULL);
|
141
|
+
RNDr(S, W, 14, 0x9bdc06a725c71235ULL);
|
142
|
+
RNDr(S, W, 15, 0xc19bf174cf692694ULL);
|
143
|
+
RNDr(S, W, 16, 0xe49b69c19ef14ad2ULL);
|
144
|
+
RNDr(S, W, 17, 0xefbe4786384f25e3ULL);
|
145
|
+
RNDr(S, W, 18, 0x0fc19dc68b8cd5b5ULL);
|
146
|
+
RNDr(S, W, 19, 0x240ca1cc77ac9c65ULL);
|
147
|
+
RNDr(S, W, 20, 0x2de92c6f592b0275ULL);
|
148
|
+
RNDr(S, W, 21, 0x4a7484aa6ea6e483ULL);
|
149
|
+
RNDr(S, W, 22, 0x5cb0a9dcbd41fbd4ULL);
|
150
|
+
RNDr(S, W, 23, 0x76f988da831153b5ULL);
|
151
|
+
RNDr(S, W, 24, 0x983e5152ee66dfabULL);
|
152
|
+
RNDr(S, W, 25, 0xa831c66d2db43210ULL);
|
153
|
+
RNDr(S, W, 26, 0xb00327c898fb213fULL);
|
154
|
+
RNDr(S, W, 27, 0xbf597fc7beef0ee4ULL);
|
155
|
+
RNDr(S, W, 28, 0xc6e00bf33da88fc2ULL);
|
156
|
+
RNDr(S, W, 29, 0xd5a79147930aa725ULL);
|
157
|
+
RNDr(S, W, 30, 0x06ca6351e003826fULL);
|
158
|
+
RNDr(S, W, 31, 0x142929670a0e6e70ULL);
|
159
|
+
RNDr(S, W, 32, 0x27b70a8546d22ffcULL);
|
160
|
+
RNDr(S, W, 33, 0x2e1b21385c26c926ULL);
|
161
|
+
RNDr(S, W, 34, 0x4d2c6dfc5ac42aedULL);
|
162
|
+
RNDr(S, W, 35, 0x53380d139d95b3dfULL);
|
163
|
+
RNDr(S, W, 36, 0x650a73548baf63deULL);
|
164
|
+
RNDr(S, W, 37, 0x766a0abb3c77b2a8ULL);
|
165
|
+
RNDr(S, W, 38, 0x81c2c92e47edaee6ULL);
|
166
|
+
RNDr(S, W, 39, 0x92722c851482353bULL);
|
167
|
+
RNDr(S, W, 40, 0xa2bfe8a14cf10364ULL);
|
168
|
+
RNDr(S, W, 41, 0xa81a664bbc423001ULL);
|
169
|
+
RNDr(S, W, 42, 0xc24b8b70d0f89791ULL);
|
170
|
+
RNDr(S, W, 43, 0xc76c51a30654be30ULL);
|
171
|
+
RNDr(S, W, 44, 0xd192e819d6ef5218ULL);
|
172
|
+
RNDr(S, W, 45, 0xd69906245565a910ULL);
|
173
|
+
RNDr(S, W, 46, 0xf40e35855771202aULL);
|
174
|
+
RNDr(S, W, 47, 0x106aa07032bbd1b8ULL);
|
175
|
+
RNDr(S, W, 48, 0x19a4c116b8d2d0c8ULL);
|
176
|
+
RNDr(S, W, 49, 0x1e376c085141ab53ULL);
|
177
|
+
RNDr(S, W, 50, 0x2748774cdf8eeb99ULL);
|
178
|
+
RNDr(S, W, 51, 0x34b0bcb5e19b48a8ULL);
|
179
|
+
RNDr(S, W, 52, 0x391c0cb3c5c95a63ULL);
|
180
|
+
RNDr(S, W, 53, 0x4ed8aa4ae3418acbULL);
|
181
|
+
RNDr(S, W, 54, 0x5b9cca4f7763e373ULL);
|
182
|
+
RNDr(S, W, 55, 0x682e6ff3d6b2b8a3ULL);
|
183
|
+
RNDr(S, W, 56, 0x748f82ee5defb2fcULL);
|
184
|
+
RNDr(S, W, 57, 0x78a5636f43172f60ULL);
|
185
|
+
RNDr(S, W, 58, 0x84c87814a1f0ab72ULL);
|
186
|
+
RNDr(S, W, 59, 0x8cc702081a6439ecULL);
|
187
|
+
RNDr(S, W, 60, 0x90befffa23631e28ULL);
|
188
|
+
RNDr(S, W, 61, 0xa4506cebde82bde9ULL);
|
189
|
+
RNDr(S, W, 62, 0xbef9a3f7b2c67915ULL);
|
190
|
+
RNDr(S, W, 63, 0xc67178f2e372532bULL);
|
191
|
+
RNDr(S, W, 64, 0xca273eceea26619cULL);
|
192
|
+
RNDr(S, W, 65, 0xd186b8c721c0c207ULL);
|
193
|
+
RNDr(S, W, 66, 0xeada7dd6cde0eb1eULL);
|
194
|
+
RNDr(S, W, 67, 0xf57d4f7fee6ed178ULL);
|
195
|
+
RNDr(S, W, 68, 0x06f067aa72176fbaULL);
|
196
|
+
RNDr(S, W, 69, 0x0a637dc5a2c898a6ULL);
|
197
|
+
RNDr(S, W, 70, 0x113f9804bef90daeULL);
|
198
|
+
RNDr(S, W, 71, 0x1b710b35131c471bULL);
|
199
|
+
RNDr(S, W, 72, 0x28db77f523047d84ULL);
|
200
|
+
RNDr(S, W, 73, 0x32caab7b40c72493ULL);
|
201
|
+
RNDr(S, W, 74, 0x3c9ebe0a15c9bebcULL);
|
202
|
+
RNDr(S, W, 75, 0x431d67c49c100d4cULL);
|
203
|
+
RNDr(S, W, 76, 0x4cc5d4becb3e42b6ULL);
|
204
|
+
RNDr(S, W, 77, 0x597f299cfc657e2aULL);
|
205
|
+
RNDr(S, W, 78, 0x5fcb6fab3ad6faecULL);
|
206
|
+
RNDr(S, W, 79, 0x6c44198c4a475817ULL);
|
207
|
+
|
208
|
+
for (i = 0; i < 8; i++) {
|
209
|
+
state[i] += S[i];
|
210
|
+
}
|
211
|
+
|
212
|
+
sodium_memzero((void *) W, sizeof W);
|
213
|
+
sodium_memzero((void *) S, sizeof S);
|
214
|
+
sodium_memzero((void *) &t0, sizeof t0);
|
215
|
+
sodium_memzero((void *) &t1, sizeof t1);
|
216
|
+
}
|
217
|
+
|
218
|
+
static unsigned char PAD[128] = {
|
219
|
+
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
220
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
221
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
222
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
223
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
224
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
225
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
226
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
227
|
+
};
|
228
|
+
|
229
|
+
static void
|
230
|
+
SHA512_Pad(crypto_hash_sha512_state *state)
|
231
|
+
{
|
232
|
+
unsigned char len[16];
|
233
|
+
uint64_t r, plen;
|
234
|
+
|
235
|
+
be64enc_vect(len, state->count, 16);
|
236
|
+
|
237
|
+
r = (state->count[1] >> 3) & 0x7f;
|
238
|
+
plen = (r < 112) ? (112 - r) : (240 - r);
|
239
|
+
crypto_hash_sha512_update(state, PAD, (unsigned long long) plen);
|
240
|
+
|
241
|
+
crypto_hash_sha512_update(state, len, 16);
|
242
|
+
}
|
243
|
+
|
244
|
+
int
|
245
|
+
crypto_hash_sha512_init(crypto_hash_sha512_state *state)
|
246
|
+
{
|
247
|
+
state->count[0] = state->count[1] = 0;
|
248
|
+
|
249
|
+
state->state[0] = 0x6a09e667f3bcc908ULL;
|
250
|
+
state->state[1] = 0xbb67ae8584caa73bULL;
|
251
|
+
state->state[2] = 0x3c6ef372fe94f82bULL;
|
252
|
+
state->state[3] = 0xa54ff53a5f1d36f1ULL;
|
253
|
+
state->state[4] = 0x510e527fade682d1ULL;
|
254
|
+
state->state[5] = 0x9b05688c2b3e6c1fULL;
|
255
|
+
state->state[6] = 0x1f83d9abfb41bd6bULL;
|
256
|
+
state->state[7] = 0x5be0cd19137e2179ULL;
|
257
|
+
|
258
|
+
return 0;
|
259
|
+
}
|
260
|
+
|
261
|
+
int
|
262
|
+
crypto_hash_sha512_update(crypto_hash_sha512_state *state,
|
263
|
+
const unsigned char *in,
|
264
|
+
unsigned long long inlen)
|
265
|
+
{
|
266
|
+
uint64_t bitlen[2];
|
267
|
+
uint64_t r;
|
268
|
+
const unsigned char *src = in;
|
269
|
+
|
270
|
+
r = (state->count[1] >> 3) & 0x7f;
|
271
|
+
|
272
|
+
bitlen[1] = ((uint64_t)inlen) << 3;
|
273
|
+
bitlen[0] = ((uint64_t)inlen) >> 61;
|
274
|
+
|
275
|
+
if ((state->count[1] += bitlen[1]) < bitlen[1]) {
|
276
|
+
state->count[0]++;
|
277
|
+
}
|
278
|
+
state->count[0] += bitlen[0];
|
279
|
+
|
280
|
+
if (inlen < 128 - r) {
|
281
|
+
memcpy(&state->buf[r], src, inlen);
|
282
|
+
return 0;
|
283
|
+
}
|
284
|
+
memcpy(&state->buf[r], src, 128 - r);
|
285
|
+
SHA512_Transform(state->state, state->buf);
|
286
|
+
src += 128 - r;
|
287
|
+
inlen -= 128 - r;
|
288
|
+
|
289
|
+
while (inlen >= 128) {
|
290
|
+
SHA512_Transform(state->state, src);
|
291
|
+
src += 128;
|
292
|
+
inlen -= 128;
|
293
|
+
}
|
294
|
+
memcpy(state->buf, src, inlen);
|
295
|
+
|
296
|
+
return 0;
|
297
|
+
}
|
298
|
+
|
299
|
+
int
|
300
|
+
crypto_hash_sha512_final(crypto_hash_sha512_state *state,
|
301
|
+
unsigned char *out)
|
302
|
+
{
|
303
|
+
SHA512_Pad(state);
|
304
|
+
be64enc_vect(out, state->state, 64);
|
305
|
+
sodium_memzero((void *) state, sizeof *state);
|
306
|
+
|
307
|
+
return 0;
|
308
|
+
}
|
309
|
+
|
310
|
+
int
|
311
|
+
crypto_hash(unsigned char *out, const unsigned char *in,
|
312
|
+
unsigned long long inlen)
|
313
|
+
{
|
314
|
+
crypto_hash_sha512_state state;
|
315
|
+
|
316
|
+
crypto_hash_sha512_init(&state);
|
317
|
+
crypto_hash_sha512_update(&state, in, inlen);
|
318
|
+
crypto_hash_sha512_final(&state, out);
|
319
|
+
|
320
|
+
return 0;
|
321
|
+
}
|
@@ -1,138 +1,62 @@
|
|
1
1
|
|
2
2
|
#include "api.h"
|
3
|
-
#include "crypto_onetimeauth_poly1305_donna.h"
|
4
3
|
#include "utils.h"
|
5
4
|
|
6
|
-
#include "
|
5
|
+
#include "crypto_onetimeauth_poly1305_donna.h"
|
6
|
+
#include "poly1305_donna.h"
|
7
|
+
|
8
|
+
#ifdef HAVE_TI_MODE
|
9
|
+
# include "poly1305_donna64.h"
|
10
|
+
#else
|
11
|
+
# include "poly1305_donna32.h"
|
12
|
+
#endif
|
13
|
+
|
14
|
+
static void
|
15
|
+
poly1305_update(poly1305_context *ctx, const unsigned char *m,
|
16
|
+
unsigned long long bytes) {
|
17
|
+
poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx;
|
18
|
+
unsigned long long i;
|
19
|
+
|
20
|
+
/* handle leftover */
|
21
|
+
if (st->leftover) {
|
22
|
+
unsigned long long want = (poly1305_block_size - st->leftover);
|
23
|
+
if (want > bytes)
|
24
|
+
want = bytes;
|
25
|
+
for (i = 0; i < want; i++)
|
26
|
+
st->buffer[st->leftover + i] = m[i];
|
27
|
+
bytes -= want;
|
28
|
+
m += want;
|
29
|
+
st->leftover += want;
|
30
|
+
if (st->leftover < poly1305_block_size)
|
31
|
+
return;
|
32
|
+
poly1305_blocks(st, st->buffer, poly1305_block_size);
|
33
|
+
st->leftover = 0;
|
34
|
+
}
|
35
|
+
|
36
|
+
/* process full blocks */
|
37
|
+
if (bytes >= poly1305_block_size) {
|
38
|
+
unsigned long long want = (bytes & ~(poly1305_block_size - 1));
|
39
|
+
poly1305_blocks(st, m, want);
|
40
|
+
m += want;
|
41
|
+
bytes -= want;
|
42
|
+
}
|
43
|
+
|
44
|
+
/* store leftover */
|
45
|
+
if (bytes) {
|
46
|
+
for (i = 0; i < bytes; i++)
|
47
|
+
st->buffer[st->leftover + i] = m[i];
|
48
|
+
st->leftover += bytes;
|
49
|
+
}
|
50
|
+
}
|
7
51
|
|
8
52
|
int
|
9
53
|
crypto_onetimeauth(unsigned char *out, const unsigned char *m,
|
10
54
|
unsigned long long inlen, const unsigned char *key)
|
11
55
|
{
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
uint32_t b, nb;
|
17
|
-
unsigned long long j;
|
18
|
-
uint64_t t[5];
|
19
|
-
uint64_t f0,f1,f2,f3;
|
20
|
-
uint32_t g0,g1,g2,g3,g4;
|
21
|
-
uint64_t c;
|
22
|
-
unsigned char mp[16];
|
23
|
-
|
24
|
-
/* clamp key */
|
25
|
-
t0 = U8TO32_LE(key+0);
|
26
|
-
t1 = U8TO32_LE(key+4);
|
27
|
-
t2 = U8TO32_LE(key+8);
|
28
|
-
t3 = U8TO32_LE(key+12);
|
29
|
-
|
30
|
-
/* precompute multipliers */
|
31
|
-
r0 = t0 & 0x3ffffff; t0 >>= 26; t0 |= t1 << 6;
|
32
|
-
r1 = t0 & 0x3ffff03; t1 >>= 20; t1 |= t2 << 12;
|
33
|
-
r2 = t1 & 0x3ffc0ff; t2 >>= 14; t2 |= t3 << 18;
|
34
|
-
r3 = t2 & 0x3f03fff; t3 >>= 8;
|
35
|
-
r4 = t3 & 0x00fffff;
|
36
|
-
|
37
|
-
s1 = r1 * 5;
|
38
|
-
s2 = r2 * 5;
|
39
|
-
s3 = r3 * 5;
|
40
|
-
s4 = r4 * 5;
|
41
|
-
|
42
|
-
/* init state */
|
43
|
-
h0 = 0;
|
44
|
-
h1 = 0;
|
45
|
-
h2 = 0;
|
46
|
-
h3 = 0;
|
47
|
-
h4 = 0;
|
48
|
-
|
49
|
-
/* full blocks */
|
50
|
-
if (inlen < 16) goto poly1305_donna_atmost15bytes;
|
51
|
-
poly1305_donna_16bytes:
|
52
|
-
m += 16;
|
53
|
-
inlen -= 16;
|
54
|
-
|
55
|
-
t0 = U8TO32_LE(m-16);
|
56
|
-
t1 = U8TO32_LE(m-12);
|
57
|
-
t2 = U8TO32_LE(m-8);
|
58
|
-
t3 = U8TO32_LE(m-4);
|
59
|
-
|
60
|
-
h0 += t0 & 0x3ffffff;
|
61
|
-
h1 += ((((uint64_t)t1 << 32) | t0) >> 26) & 0x3ffffff;
|
62
|
-
h2 += ((((uint64_t)t2 << 32) | t1) >> 20) & 0x3ffffff;
|
63
|
-
h3 += ((((uint64_t)t3 << 32) | t2) >> 14) & 0x3ffffff;
|
64
|
-
h4 += (t3 >> 8) | (1 << 24);
|
65
|
-
|
66
|
-
|
67
|
-
poly1305_donna_mul:
|
68
|
-
t[0] = mul32x32_64(h0,r0) + mul32x32_64(h1,s4) + mul32x32_64(h2,s3) + mul32x32_64(h3,s2) + mul32x32_64(h4,s1);
|
69
|
-
t[1] = mul32x32_64(h0,r1) + mul32x32_64(h1,r0) + mul32x32_64(h2,s4) + mul32x32_64(h3,s3) + mul32x32_64(h4,s2);
|
70
|
-
t[2] = mul32x32_64(h0,r2) + mul32x32_64(h1,r1) + mul32x32_64(h2,r0) + mul32x32_64(h3,s4) + mul32x32_64(h4,s3);
|
71
|
-
t[3] = mul32x32_64(h0,r3) + mul32x32_64(h1,r2) + mul32x32_64(h2,r1) + mul32x32_64(h3,r0) + mul32x32_64(h4,s4);
|
72
|
-
t[4] = mul32x32_64(h0,r4) + mul32x32_64(h1,r3) + mul32x32_64(h2,r2) + mul32x32_64(h3,r1) + mul32x32_64(h4,r0);
|
73
|
-
|
74
|
-
h0 = (uint32_t)t[0] & 0x3ffffff; c = (t[0] >> 26);
|
75
|
-
t[1] += c; h1 = (uint32_t)t[1] & 0x3ffffff; b = (uint32_t)(t[1] >> 26);
|
76
|
-
t[2] += b; h2 = (uint32_t)t[2] & 0x3ffffff; b = (uint32_t)(t[2] >> 26);
|
77
|
-
t[3] += b; h3 = (uint32_t)t[3] & 0x3ffffff; b = (uint32_t)(t[3] >> 26);
|
78
|
-
t[4] += b; h4 = (uint32_t)t[4] & 0x3ffffff; b = (uint32_t)(t[4] >> 26);
|
79
|
-
h0 += b * 5;
|
80
|
-
|
81
|
-
if (inlen >= 16) goto poly1305_donna_16bytes;
|
82
|
-
|
83
|
-
/* final bytes */
|
84
|
-
poly1305_donna_atmost15bytes:
|
85
|
-
if (!inlen) goto poly1305_donna_finish;
|
86
|
-
|
87
|
-
for (j = 0; j < inlen; j++) mp[j] = m[j];
|
88
|
-
mp[j++] = 1;
|
89
|
-
for (; j < 16; j++) mp[j] = 0;
|
90
|
-
inlen = 0;
|
91
|
-
|
92
|
-
t0 = U8TO32_LE(mp+0);
|
93
|
-
t1 = U8TO32_LE(mp+4);
|
94
|
-
t2 = U8TO32_LE(mp+8);
|
95
|
-
t3 = U8TO32_LE(mp+12);
|
96
|
-
|
97
|
-
h0 += t0 & 0x3ffffff;
|
98
|
-
h1 += ((((uint64_t)t1 << 32) | t0) >> 26) & 0x3ffffff;
|
99
|
-
h2 += ((((uint64_t)t2 << 32) | t1) >> 20) & 0x3ffffff;
|
100
|
-
h3 += ((((uint64_t)t3 << 32) | t2) >> 14) & 0x3ffffff;
|
101
|
-
h4 += (t3 >> 8);
|
102
|
-
|
103
|
-
goto poly1305_donna_mul;
|
104
|
-
|
105
|
-
poly1305_donna_finish:
|
106
|
-
b = h0 >> 26; h0 = h0 & 0x3ffffff;
|
107
|
-
h1 += b; b = h1 >> 26; h1 = h1 & 0x3ffffff;
|
108
|
-
h2 += b; b = h2 >> 26; h2 = h2 & 0x3ffffff;
|
109
|
-
h3 += b; b = h3 >> 26; h3 = h3 & 0x3ffffff;
|
110
|
-
h4 += b; b = h4 >> 26; h4 = h4 & 0x3ffffff;
|
111
|
-
h0 += b * 5;
|
112
|
-
|
113
|
-
g0 = h0 + 5; b = g0 >> 26; g0 &= 0x3ffffff;
|
114
|
-
g1 = h1 + b; b = g1 >> 26; g1 &= 0x3ffffff;
|
115
|
-
g2 = h2 + b; b = g2 >> 26; g2 &= 0x3ffffff;
|
116
|
-
g3 = h3 + b; b = g3 >> 26; g3 &= 0x3ffffff;
|
117
|
-
g4 = h4 + b - (1 << 26);
|
118
|
-
|
119
|
-
b = (g4 >> 31) - 1;
|
120
|
-
nb = ~b;
|
121
|
-
h0 = (h0 & nb) | (g0 & b);
|
122
|
-
h1 = (h1 & nb) | (g1 & b);
|
123
|
-
h2 = (h2 & nb) | (g2 & b);
|
124
|
-
h3 = (h3 & nb) | (g3 & b);
|
125
|
-
h4 = (h4 & nb) | (g4 & b);
|
126
|
-
|
127
|
-
f0 = ((h0 ) | (h1 << 26)) + (uint64_t)U8TO32_LE(&key[16]);
|
128
|
-
f1 = ((h1 >> 6) | (h2 << 20)) + (uint64_t)U8TO32_LE(&key[20]);
|
129
|
-
f2 = ((h2 >> 12) | (h3 << 14)) + (uint64_t)U8TO32_LE(&key[24]);
|
130
|
-
f3 = ((h3 >> 18) | (h4 << 8)) + (uint64_t)U8TO32_LE(&key[28]);
|
131
|
-
|
132
|
-
U32TO8_LE(&out[ 0], f0); f1 += (f0 >> 32);
|
133
|
-
U32TO8_LE(&out[ 4], f1); f2 += (f1 >> 32);
|
134
|
-
U32TO8_LE(&out[ 8], f2); f3 += (f2 >> 32);
|
135
|
-
U32TO8_LE(&out[12], f3);
|
56
|
+
poly1305_context ctx;
|
57
|
+
poly1305_init(&ctx, key);
|
58
|
+
poly1305_update(&ctx, m, inlen);
|
59
|
+
poly1305_finish(&ctx, out);
|
136
60
|
|
137
61
|
return 0;
|
138
62
|
}
|
@@ -140,7 +64,7 @@ poly1305_donna_finish:
|
|
140
64
|
const char *
|
141
65
|
crypto_onetimeauth_poly1305_implementation_name(void)
|
142
66
|
{
|
143
|
-
return
|
67
|
+
return POLY1305_IMPLEMENTATION_NAME;
|
144
68
|
}
|
145
69
|
|
146
70
|
struct crypto_onetimeauth_poly1305_implementation
|