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,221 @@
|
|
1
|
+
/*
|
2
|
+
poly1305 implementation using 32 bit * 32 bit = 64 bit multiplication and 64 bit addition
|
3
|
+
*/
|
4
|
+
|
5
|
+
#define POLY1305_IMPLEMENTATION_NAME "donna32"
|
6
|
+
|
7
|
+
#if defined(_MSC_VER)
|
8
|
+
# define POLY1305_NOINLINE __declspec(noinline)
|
9
|
+
#elif defined(__GNUC__)
|
10
|
+
# define POLY1305_NOINLINE __attribute__((noinline))
|
11
|
+
#else
|
12
|
+
# define POLY1305_NOINLINE
|
13
|
+
#endif
|
14
|
+
|
15
|
+
#define poly1305_block_size 16
|
16
|
+
|
17
|
+
/* 17 + sizeof(unsigned long long) + 14*sizeof(unsigned long) */
|
18
|
+
typedef struct poly1305_state_internal_t {
|
19
|
+
unsigned long r[5];
|
20
|
+
unsigned long h[5];
|
21
|
+
unsigned long pad[4];
|
22
|
+
unsigned long long leftover;
|
23
|
+
unsigned char buffer[poly1305_block_size];
|
24
|
+
unsigned char final;
|
25
|
+
} poly1305_state_internal_t;
|
26
|
+
|
27
|
+
/* interpret four 8 bit unsigned integers as a 32 bit unsigned integer in little endian */
|
28
|
+
static unsigned long
|
29
|
+
U8TO32(const unsigned char *p) {
|
30
|
+
return
|
31
|
+
(((unsigned long)(p[0] & 0xff) ) |
|
32
|
+
((unsigned long)(p[1] & 0xff) << 8) |
|
33
|
+
((unsigned long)(p[2] & 0xff) << 16) |
|
34
|
+
((unsigned long)(p[3] & 0xff) << 24));
|
35
|
+
}
|
36
|
+
|
37
|
+
/* store a 32 bit unsigned integer as four 8 bit unsigned integers in little endian */
|
38
|
+
static void
|
39
|
+
U32TO8(unsigned char *p, unsigned long v) {
|
40
|
+
p[0] = (v ) & 0xff;
|
41
|
+
p[1] = (v >> 8) & 0xff;
|
42
|
+
p[2] = (v >> 16) & 0xff;
|
43
|
+
p[3] = (v >> 24) & 0xff;
|
44
|
+
}
|
45
|
+
|
46
|
+
static void
|
47
|
+
poly1305_init(poly1305_context *ctx, const unsigned char key[32]) {
|
48
|
+
poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx;
|
49
|
+
|
50
|
+
/* r &= 0xffffffc0ffffffc0ffffffc0fffffff */
|
51
|
+
st->r[0] = (U8TO32(&key[ 0]) ) & 0x3ffffff;
|
52
|
+
st->r[1] = (U8TO32(&key[ 3]) >> 2) & 0x3ffff03;
|
53
|
+
st->r[2] = (U8TO32(&key[ 6]) >> 4) & 0x3ffc0ff;
|
54
|
+
st->r[3] = (U8TO32(&key[ 9]) >> 6) & 0x3f03fff;
|
55
|
+
st->r[4] = (U8TO32(&key[12]) >> 8) & 0x00fffff;
|
56
|
+
|
57
|
+
/* h = 0 */
|
58
|
+
st->h[0] = 0;
|
59
|
+
st->h[1] = 0;
|
60
|
+
st->h[2] = 0;
|
61
|
+
st->h[3] = 0;
|
62
|
+
st->h[4] = 0;
|
63
|
+
|
64
|
+
/* save pad for later */
|
65
|
+
st->pad[0] = U8TO32(&key[16]);
|
66
|
+
st->pad[1] = U8TO32(&key[20]);
|
67
|
+
st->pad[2] = U8TO32(&key[24]);
|
68
|
+
st->pad[3] = U8TO32(&key[28]);
|
69
|
+
|
70
|
+
st->leftover = 0;
|
71
|
+
st->final = 0;
|
72
|
+
}
|
73
|
+
|
74
|
+
static void
|
75
|
+
poly1305_blocks(poly1305_state_internal_t *st, const unsigned char *m, unsigned long long bytes) {
|
76
|
+
const unsigned long hibit = (st->final) ? 0 : (1 << 24); /* 1 << 128 */
|
77
|
+
unsigned long r0,r1,r2,r3,r4;
|
78
|
+
unsigned long s1,s2,s3,s4;
|
79
|
+
unsigned long h0,h1,h2,h3,h4;
|
80
|
+
unsigned long long d0,d1,d2,d3,d4;
|
81
|
+
unsigned long c;
|
82
|
+
|
83
|
+
r0 = st->r[0];
|
84
|
+
r1 = st->r[1];
|
85
|
+
r2 = st->r[2];
|
86
|
+
r3 = st->r[3];
|
87
|
+
r4 = st->r[4];
|
88
|
+
|
89
|
+
s1 = r1 * 5;
|
90
|
+
s2 = r2 * 5;
|
91
|
+
s3 = r3 * 5;
|
92
|
+
s4 = r4 * 5;
|
93
|
+
|
94
|
+
h0 = st->h[0];
|
95
|
+
h1 = st->h[1];
|
96
|
+
h2 = st->h[2];
|
97
|
+
h3 = st->h[3];
|
98
|
+
h4 = st->h[4];
|
99
|
+
|
100
|
+
while (bytes >= poly1305_block_size) {
|
101
|
+
/* h += m[i] */
|
102
|
+
h0 += (U8TO32(m+ 0) ) & 0x3ffffff;
|
103
|
+
h1 += (U8TO32(m+ 3) >> 2) & 0x3ffffff;
|
104
|
+
h2 += (U8TO32(m+ 6) >> 4) & 0x3ffffff;
|
105
|
+
h3 += (U8TO32(m+ 9) >> 6) & 0x3ffffff;
|
106
|
+
h4 += (U8TO32(m+12) >> 8) | hibit;
|
107
|
+
|
108
|
+
/* h *= r */
|
109
|
+
d0 = ((unsigned long long)h0 * r0) + ((unsigned long long)h1 * s4) + ((unsigned long long)h2 * s3) + ((unsigned long long)h3 * s2) + ((unsigned long long)h4 * s1);
|
110
|
+
d1 = ((unsigned long long)h0 * r1) + ((unsigned long long)h1 * r0) + ((unsigned long long)h2 * s4) + ((unsigned long long)h3 * s3) + ((unsigned long long)h4 * s2);
|
111
|
+
d2 = ((unsigned long long)h0 * r2) + ((unsigned long long)h1 * r1) + ((unsigned long long)h2 * r0) + ((unsigned long long)h3 * s4) + ((unsigned long long)h4 * s3);
|
112
|
+
d3 = ((unsigned long long)h0 * r3) + ((unsigned long long)h1 * r2) + ((unsigned long long)h2 * r1) + ((unsigned long long)h3 * r0) + ((unsigned long long)h4 * s4);
|
113
|
+
d4 = ((unsigned long long)h0 * r4) + ((unsigned long long)h1 * r3) + ((unsigned long long)h2 * r2) + ((unsigned long long)h3 * r1) + ((unsigned long long)h4 * r0);
|
114
|
+
|
115
|
+
/* (partial) h %= p */
|
116
|
+
c = (unsigned long)(d0 >> 26); h0 = (unsigned long)d0 & 0x3ffffff;
|
117
|
+
d1 += c; c = (unsigned long)(d1 >> 26); h1 = (unsigned long)d1 & 0x3ffffff;
|
118
|
+
d2 += c; c = (unsigned long)(d2 >> 26); h2 = (unsigned long)d2 & 0x3ffffff;
|
119
|
+
d3 += c; c = (unsigned long)(d3 >> 26); h3 = (unsigned long)d3 & 0x3ffffff;
|
120
|
+
d4 += c; c = (unsigned long)(d4 >> 26); h4 = (unsigned long)d4 & 0x3ffffff;
|
121
|
+
h0 += c * 5; c = (h0 >> 26); h0 = h0 & 0x3ffffff;
|
122
|
+
h1 += c;
|
123
|
+
|
124
|
+
m += poly1305_block_size;
|
125
|
+
bytes -= poly1305_block_size;
|
126
|
+
}
|
127
|
+
|
128
|
+
st->h[0] = h0;
|
129
|
+
st->h[1] = h1;
|
130
|
+
st->h[2] = h2;
|
131
|
+
st->h[3] = h3;
|
132
|
+
st->h[4] = h4;
|
133
|
+
}
|
134
|
+
|
135
|
+
static POLY1305_NOINLINE void
|
136
|
+
poly1305_finish(poly1305_context *ctx, unsigned char mac[16]) {
|
137
|
+
poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx;
|
138
|
+
unsigned long h0,h1,h2,h3,h4,c;
|
139
|
+
unsigned long g0,g1,g2,g3,g4;
|
140
|
+
unsigned long long f;
|
141
|
+
unsigned long mask;
|
142
|
+
|
143
|
+
/* process the remaining block */
|
144
|
+
if (st->leftover) {
|
145
|
+
unsigned long long i = st->leftover;
|
146
|
+
st->buffer[i++] = 1;
|
147
|
+
for (; i < poly1305_block_size; i++)
|
148
|
+
st->buffer[i] = 0;
|
149
|
+
st->final = 1;
|
150
|
+
poly1305_blocks(st, st->buffer, poly1305_block_size);
|
151
|
+
}
|
152
|
+
|
153
|
+
/* fully carry h */
|
154
|
+
h0 = st->h[0];
|
155
|
+
h1 = st->h[1];
|
156
|
+
h2 = st->h[2];
|
157
|
+
h3 = st->h[3];
|
158
|
+
h4 = st->h[4];
|
159
|
+
|
160
|
+
c = h1 >> 26; h1 = h1 & 0x3ffffff;
|
161
|
+
h2 += c; c = h2 >> 26; h2 = h2 & 0x3ffffff;
|
162
|
+
h3 += c; c = h3 >> 26; h3 = h3 & 0x3ffffff;
|
163
|
+
h4 += c; c = h4 >> 26; h4 = h4 & 0x3ffffff;
|
164
|
+
h0 += c * 5; c = h0 >> 26; h0 = h0 & 0x3ffffff;
|
165
|
+
h1 += c;
|
166
|
+
|
167
|
+
/* compute h + -p */
|
168
|
+
g0 = h0 + 5; c = g0 >> 26; g0 &= 0x3ffffff;
|
169
|
+
g1 = h1 + c; c = g1 >> 26; g1 &= 0x3ffffff;
|
170
|
+
g2 = h2 + c; c = g2 >> 26; g2 &= 0x3ffffff;
|
171
|
+
g3 = h3 + c; c = g3 >> 26; g3 &= 0x3ffffff;
|
172
|
+
g4 = h4 + c - (1 << 26);
|
173
|
+
|
174
|
+
/* select h if h < p, or h + -p if h >= p */
|
175
|
+
mask = (g4 >> ((sizeof(unsigned long) * 8) - 1)) - 1;
|
176
|
+
g0 &= mask;
|
177
|
+
g1 &= mask;
|
178
|
+
g2 &= mask;
|
179
|
+
g3 &= mask;
|
180
|
+
g4 &= mask;
|
181
|
+
mask = ~mask;
|
182
|
+
h0 = (h0 & mask) | g0;
|
183
|
+
h1 = (h1 & mask) | g1;
|
184
|
+
h2 = (h2 & mask) | g2;
|
185
|
+
h3 = (h3 & mask) | g3;
|
186
|
+
h4 = (h4 & mask) | g4;
|
187
|
+
|
188
|
+
/* h = h % (2^128) */
|
189
|
+
h0 = ((h0 ) | (h1 << 26)) & 0xffffffff;
|
190
|
+
h1 = ((h1 >> 6) | (h2 << 20)) & 0xffffffff;
|
191
|
+
h2 = ((h2 >> 12) | (h3 << 14)) & 0xffffffff;
|
192
|
+
h3 = ((h3 >> 18) | (h4 << 8)) & 0xffffffff;
|
193
|
+
|
194
|
+
/* mac = (h + pad) % (2^128) */
|
195
|
+
f = (unsigned long long)h0 + st->pad[0] ; h0 = (unsigned long)f;
|
196
|
+
f = (unsigned long long)h1 + st->pad[1] + (f >> 32); h1 = (unsigned long)f;
|
197
|
+
f = (unsigned long long)h2 + st->pad[2] + (f >> 32); h2 = (unsigned long)f;
|
198
|
+
f = (unsigned long long)h3 + st->pad[3] + (f >> 32); h3 = (unsigned long)f;
|
199
|
+
|
200
|
+
U32TO8(mac + 0, h0);
|
201
|
+
U32TO8(mac + 4, h1);
|
202
|
+
U32TO8(mac + 8, h2);
|
203
|
+
U32TO8(mac + 12, h3);
|
204
|
+
|
205
|
+
/* zero out the state */
|
206
|
+
st->h[0] = 0;
|
207
|
+
st->h[1] = 0;
|
208
|
+
st->h[2] = 0;
|
209
|
+
st->h[3] = 0;
|
210
|
+
st->h[4] = 0;
|
211
|
+
st->r[0] = 0;
|
212
|
+
st->r[1] = 0;
|
213
|
+
st->r[2] = 0;
|
214
|
+
st->r[3] = 0;
|
215
|
+
st->r[4] = 0;
|
216
|
+
st->pad[0] = 0;
|
217
|
+
st->pad[1] = 0;
|
218
|
+
st->pad[2] = 0;
|
219
|
+
st->pad[3] = 0;
|
220
|
+
}
|
221
|
+
|
@@ -0,0 +1,209 @@
|
|
1
|
+
/*
|
2
|
+
poly1305 implementation using 64 bit * 64 bit = 128 bit multiplication and 128 bit addition
|
3
|
+
*/
|
4
|
+
|
5
|
+
#define POLY1305_IMPLEMENTATION_NAME "donna64"
|
6
|
+
|
7
|
+
#if defined(__SIZEOF_INT128__)
|
8
|
+
typedef unsigned __int128 uint128_t;
|
9
|
+
#else
|
10
|
+
typedef unsigned uint128_t __attribute__((mode(TI)));
|
11
|
+
#endif
|
12
|
+
|
13
|
+
#define MUL(out, x, y) out = ((uint128_t)x * y)
|
14
|
+
#define ADD(out, in) out += in
|
15
|
+
#define ADDLO(out, in) out += in
|
16
|
+
#define SHR(in, shift) (unsigned long long)(in >> (shift))
|
17
|
+
#define LO(in) (unsigned long long)(in)
|
18
|
+
|
19
|
+
#define POLY1305_NOINLINE __attribute__((noinline))
|
20
|
+
|
21
|
+
#define poly1305_block_size 16
|
22
|
+
|
23
|
+
/* 17 + sizeof(unsigned long long) + 8*sizeof(unsigned long long) */
|
24
|
+
typedef struct poly1305_state_internal_t {
|
25
|
+
unsigned long long r[3];
|
26
|
+
unsigned long long h[3];
|
27
|
+
unsigned long long pad[2];
|
28
|
+
unsigned long long leftover;
|
29
|
+
unsigned char buffer[poly1305_block_size];
|
30
|
+
unsigned char final;
|
31
|
+
} poly1305_state_internal_t;
|
32
|
+
|
33
|
+
/* interpret eight 8 bit unsigned integers as a 64 bit unsigned integer in little endian */
|
34
|
+
static unsigned long long
|
35
|
+
U8TO64(const unsigned char *p) {
|
36
|
+
return
|
37
|
+
(((unsigned long long)(p[0] & 0xff) ) |
|
38
|
+
((unsigned long long)(p[1] & 0xff) << 8) |
|
39
|
+
((unsigned long long)(p[2] & 0xff) << 16) |
|
40
|
+
((unsigned long long)(p[3] & 0xff) << 24) |
|
41
|
+
((unsigned long long)(p[4] & 0xff) << 32) |
|
42
|
+
((unsigned long long)(p[5] & 0xff) << 40) |
|
43
|
+
((unsigned long long)(p[6] & 0xff) << 48) |
|
44
|
+
((unsigned long long)(p[7] & 0xff) << 56));
|
45
|
+
}
|
46
|
+
|
47
|
+
/* store a 64 bit unsigned integer as eight 8 bit unsigned integers in little endian */
|
48
|
+
static void
|
49
|
+
U64TO8(unsigned char *p, unsigned long long v) {
|
50
|
+
p[0] = (v ) & 0xff;
|
51
|
+
p[1] = (v >> 8) & 0xff;
|
52
|
+
p[2] = (v >> 16) & 0xff;
|
53
|
+
p[3] = (v >> 24) & 0xff;
|
54
|
+
p[4] = (v >> 32) & 0xff;
|
55
|
+
p[5] = (v >> 40) & 0xff;
|
56
|
+
p[6] = (v >> 48) & 0xff;
|
57
|
+
p[7] = (v >> 56) & 0xff;
|
58
|
+
}
|
59
|
+
|
60
|
+
static void
|
61
|
+
poly1305_init(poly1305_context *ctx, const unsigned char key[32]) {
|
62
|
+
poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx;
|
63
|
+
unsigned long long t0,t1;
|
64
|
+
|
65
|
+
/* r &= 0xffffffc0ffffffc0ffffffc0fffffff */
|
66
|
+
t0 = U8TO64(&key[0]);
|
67
|
+
t1 = U8TO64(&key[8]);
|
68
|
+
|
69
|
+
st->r[0] = ( t0 ) & 0xffc0fffffff;
|
70
|
+
st->r[1] = ((t0 >> 44) | (t1 << 20)) & 0xfffffc0ffff;
|
71
|
+
st->r[2] = ((t1 >> 24) ) & 0x00ffffffc0f;
|
72
|
+
|
73
|
+
/* h = 0 */
|
74
|
+
st->h[0] = 0;
|
75
|
+
st->h[1] = 0;
|
76
|
+
st->h[2] = 0;
|
77
|
+
|
78
|
+
/* save pad for later */
|
79
|
+
st->pad[0] = U8TO64(&key[16]);
|
80
|
+
st->pad[1] = U8TO64(&key[24]);
|
81
|
+
|
82
|
+
st->leftover = 0;
|
83
|
+
st->final = 0;
|
84
|
+
}
|
85
|
+
|
86
|
+
static void
|
87
|
+
poly1305_blocks(poly1305_state_internal_t *st, const unsigned char *m, unsigned long long bytes) {
|
88
|
+
const unsigned long long hibit = (st->final) ? 0 : ((unsigned long long)1 << 40); /* 1 << 128 */
|
89
|
+
unsigned long long r0,r1,r2;
|
90
|
+
unsigned long long s1,s2;
|
91
|
+
unsigned long long h0,h1,h2;
|
92
|
+
unsigned long long c;
|
93
|
+
uint128_t d0,d1,d2,d;
|
94
|
+
|
95
|
+
r0 = st->r[0];
|
96
|
+
r1 = st->r[1];
|
97
|
+
r2 = st->r[2];
|
98
|
+
|
99
|
+
h0 = st->h[0];
|
100
|
+
h1 = st->h[1];
|
101
|
+
h2 = st->h[2];
|
102
|
+
|
103
|
+
s1 = r1 * (5 << 2);
|
104
|
+
s2 = r2 * (5 << 2);
|
105
|
+
|
106
|
+
while (bytes >= poly1305_block_size) {
|
107
|
+
unsigned long long t0,t1;
|
108
|
+
|
109
|
+
/* h += m[i] */
|
110
|
+
t0 = U8TO64(&m[0]);
|
111
|
+
t1 = U8TO64(&m[8]);
|
112
|
+
|
113
|
+
h0 += (( t0 ) & 0xfffffffffff);
|
114
|
+
h1 += (((t0 >> 44) | (t1 << 20)) & 0xfffffffffff);
|
115
|
+
h2 += (((t1 >> 24) ) & 0x3ffffffffff) | hibit;
|
116
|
+
|
117
|
+
/* h *= r */
|
118
|
+
MUL(d0, h0, r0); MUL(d, h1, s2); ADD(d0, d); MUL(d, h2, s1); ADD(d0, d);
|
119
|
+
MUL(d1, h0, r1); MUL(d, h1, r0); ADD(d1, d); MUL(d, h2, s2); ADD(d1, d);
|
120
|
+
MUL(d2, h0, r2); MUL(d, h1, r1); ADD(d2, d); MUL(d, h2, r0); ADD(d2, d);
|
121
|
+
|
122
|
+
/* (partial) h %= p */
|
123
|
+
c = SHR(d0, 44); h0 = LO(d0) & 0xfffffffffff;
|
124
|
+
ADDLO(d1, c); c = SHR(d1, 44); h1 = LO(d1) & 0xfffffffffff;
|
125
|
+
ADDLO(d2, c); c = SHR(d2, 42); h2 = LO(d2) & 0x3ffffffffff;
|
126
|
+
h0 += c * 5; c = (h0 >> 44); h0 = h0 & 0xfffffffffff;
|
127
|
+
h1 += c;
|
128
|
+
|
129
|
+
m += poly1305_block_size;
|
130
|
+
bytes -= poly1305_block_size;
|
131
|
+
}
|
132
|
+
|
133
|
+
st->h[0] = h0;
|
134
|
+
st->h[1] = h1;
|
135
|
+
st->h[2] = h2;
|
136
|
+
}
|
137
|
+
|
138
|
+
|
139
|
+
static POLY1305_NOINLINE void
|
140
|
+
poly1305_finish(poly1305_context *ctx, unsigned char mac[16]) {
|
141
|
+
poly1305_state_internal_t *st = (poly1305_state_internal_t *)ctx;
|
142
|
+
unsigned long long h0,h1,h2,c;
|
143
|
+
unsigned long long g0,g1,g2;
|
144
|
+
unsigned long long t0,t1;
|
145
|
+
|
146
|
+
/* process the remaining block */
|
147
|
+
if (st->leftover) {
|
148
|
+
unsigned long long i = st->leftover;
|
149
|
+
st->buffer[i] = 1;
|
150
|
+
for (i = i + 1; i < poly1305_block_size; i++)
|
151
|
+
st->buffer[i] = 0;
|
152
|
+
st->final = 1;
|
153
|
+
poly1305_blocks(st, st->buffer, poly1305_block_size);
|
154
|
+
}
|
155
|
+
|
156
|
+
/* fully carry h */
|
157
|
+
h0 = st->h[0];
|
158
|
+
h1 = st->h[1];
|
159
|
+
h2 = st->h[2];
|
160
|
+
|
161
|
+
c = (h1 >> 44); h1 &= 0xfffffffffff;
|
162
|
+
h2 += c; c = (h2 >> 42); h2 &= 0x3ffffffffff;
|
163
|
+
h0 += c * 5; c = (h0 >> 44); h0 &= 0xfffffffffff;
|
164
|
+
h1 += c; c = (h1 >> 44); h1 &= 0xfffffffffff;
|
165
|
+
h2 += c; c = (h2 >> 42); h2 &= 0x3ffffffffff;
|
166
|
+
h0 += c * 5; c = (h0 >> 44); h0 &= 0xfffffffffff;
|
167
|
+
h1 += c;
|
168
|
+
|
169
|
+
/* compute h + -p */
|
170
|
+
g0 = h0 + 5; c = (g0 >> 44); g0 &= 0xfffffffffff;
|
171
|
+
g1 = h1 + c; c = (g1 >> 44); g1 &= 0xfffffffffff;
|
172
|
+
g2 = h2 + c - ((unsigned long long)1 << 42);
|
173
|
+
|
174
|
+
/* select h if h < p, or h + -p if h >= p */
|
175
|
+
c = (g2 >> ((sizeof(unsigned long long) * 8) - 1)) - 1;
|
176
|
+
g0 &= c;
|
177
|
+
g1 &= c;
|
178
|
+
g2 &= c;
|
179
|
+
c = ~c;
|
180
|
+
h0 = (h0 & c) | g0;
|
181
|
+
h1 = (h1 & c) | g1;
|
182
|
+
h2 = (h2 & c) | g2;
|
183
|
+
|
184
|
+
/* h = (h + pad) */
|
185
|
+
t0 = st->pad[0];
|
186
|
+
t1 = st->pad[1];
|
187
|
+
|
188
|
+
h0 += (( t0 ) & 0xfffffffffff) ; c = (h0 >> 44); h0 &= 0xfffffffffff;
|
189
|
+
h1 += (((t0 >> 44) | (t1 << 20)) & 0xfffffffffff) + c; c = (h1 >> 44); h1 &= 0xfffffffffff;
|
190
|
+
h2 += (((t1 >> 24) ) & 0x3ffffffffff) + c; h2 &= 0x3ffffffffff;
|
191
|
+
|
192
|
+
/* mac = h % (2^128) */
|
193
|
+
h0 = ((h0 ) | (h1 << 44));
|
194
|
+
h1 = ((h1 >> 20) | (h2 << 24));
|
195
|
+
|
196
|
+
U64TO8(&mac[0], h0);
|
197
|
+
U64TO8(&mac[8], h1);
|
198
|
+
|
199
|
+
/* zero out the state */
|
200
|
+
st->h[0] = 0;
|
201
|
+
st->h[1] = 0;
|
202
|
+
st->h[2] = 0;
|
203
|
+
st->r[0] = 0;
|
204
|
+
st->r[1] = 0;
|
205
|
+
st->r[2] = 0;
|
206
|
+
st->pad[0] = 0;
|
207
|
+
st->pad[1] = 0;
|
208
|
+
}
|
209
|
+
|