rbnacl-libsodium 1.0.11 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/rbnacl/libsodium/version.rb +1 -1
- data/vendor/libsodium/AUTHORS +45 -33
- data/vendor/libsodium/ChangeLog +63 -2
- data/vendor/libsodium/LICENSE +1 -1
- data/vendor/libsodium/Makefile.am +1 -0
- data/vendor/libsodium/Makefile.in +17 -14
- data/vendor/libsodium/README.markdown +1 -0
- data/vendor/libsodium/THANKS +38 -4
- data/vendor/libsodium/aclocal.m4 +25 -24
- data/vendor/libsodium/autogen.sh +12 -7
- data/vendor/libsodium/autom4te.cache/output.0 +5066 -2281
- data/vendor/libsodium/autom4te.cache/output.1 +1013 -600
- data/vendor/libsodium/autom4te.cache/output.2 +5066 -2281
- data/vendor/libsodium/autom4te.cache/requests +426 -1584
- data/vendor/libsodium/autom4te.cache/traces.0 +2044 -876
- data/vendor/libsodium/autom4te.cache/traces.1 +996 -523
- data/vendor/libsodium/autom4te.cache/traces.2 +1996 -828
- data/vendor/libsodium/build-aux/compile +5 -4
- data/vendor/libsodium/build-aux/config.guess +120 -68
- data/vendor/libsodium/build-aux/config.sub +51 -22
- data/vendor/libsodium/build-aux/depcomp +3 -3
- data/vendor/libsodium/build-aux/install-sh +2 -2
- data/vendor/libsodium/build-aux/missing +3 -3
- data/vendor/libsodium/build-aux/test-driver +3 -3
- data/vendor/libsodium/builds/msvc/properties/Win32.props +4 -1
- data/vendor/libsodium/builds/msvc/properties/x64.props +4 -1
- data/vendor/libsodium/builds/msvc/resource.h +14 -0
- data/vendor/libsodium/builds/msvc/resource.rc +63 -0
- data/vendor/libsodium/builds/msvc/version.h +7 -4
- data/vendor/libsodium/builds/msvc/vs2010/libsodium.import.props +1 -1
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.props +10 -5
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +182 -139
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +632 -470
- data/vendor/libsodium/builds/msvc/vs2012/libsodium.import.props +1 -1
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.props +10 -5
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +182 -129
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +632 -470
- data/vendor/libsodium/builds/msvc/vs2013/libsodium.import.props +1 -1
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.props +10 -5
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +182 -129
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +632 -470
- data/vendor/libsodium/builds/msvc/vs2015/libsodium.import.props +1 -1
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.props +10 -5
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +181 -118
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +632 -470
- data/vendor/libsodium/builds/msvc/vs2017/libsodium.import.props +52 -0
- data/vendor/libsodium/builds/msvc/vs2017/libsodium.import.xml +17 -0
- data/vendor/libsodium/builds/msvc/vs2017/libsodium.sln +52 -0
- data/vendor/libsodium/builds/msvc/vs2017/libsodium/libsodium.props +48 -0
- data/vendor/libsodium/builds/msvc/vs2017/libsodium/libsodium.vcxproj +320 -0
- data/vendor/libsodium/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters +962 -0
- data/vendor/libsodium/builds/msvc/vs2017/libsodium/libsodium.xml +15 -0
- data/vendor/libsodium/configure +1002 -589
- data/vendor/libsodium/configure.ac +48 -21
- data/vendor/libsodium/contrib/Findsodium.cmake +267 -0
- data/vendor/libsodium/contrib/Makefile.am +3 -0
- data/vendor/libsodium/contrib/Makefile.in +483 -0
- data/vendor/libsodium/dist-build/Makefile.in +11 -7
- data/vendor/libsodium/dist-build/android-armv8-a.sh +1 -1
- data/vendor/libsodium/dist-build/android-build.sh +25 -17
- data/vendor/libsodium/dist-build/android-mips32.sh +1 -1
- data/vendor/libsodium/dist-build/android-mips64.sh +1 -1
- data/vendor/libsodium/dist-build/android-x86_64.sh +1 -1
- data/vendor/libsodium/dist-build/emscripten-symbols.def +150 -2
- data/vendor/libsodium/dist-build/emscripten-wasm.sh +132 -0
- data/vendor/libsodium/dist-build/emscripten.sh +8 -6
- data/vendor/libsodium/dist-build/ios.sh +29 -5
- data/vendor/libsodium/libsodium.vcxproj +139 -77
- data/vendor/libsodium/libsodium.vcxproj.filters +315 -144
- data/vendor/libsodium/m4/ax_check_catchable_segv.m4 +42 -0
- data/vendor/libsodium/m4/ax_check_compile_flag.m4 +6 -4
- data/vendor/libsodium/m4/ax_check_define.m4 +3 -3
- data/vendor/libsodium/m4/ax_check_gnu_make.m4 +31 -25
- data/vendor/libsodium/m4/ax_check_link_flag.m4 +8 -6
- data/vendor/libsodium/m4/ax_pthread.m4 +275 -275
- data/vendor/libsodium/m4/ax_valgrind_check.m4 +92 -41
- data/vendor/libsodium/m4/pkg.m4 +1 -1
- data/vendor/libsodium/msvc-scripts/Makefile.in +11 -7
- data/vendor/libsodium/msvc-scripts/process.bat +4 -3
- data/vendor/libsodium/packaging/dotnet-core/README.md +59 -0
- data/vendor/libsodium/packaging/dotnet-core/desktop.targets +16 -0
- data/vendor/libsodium/packaging/dotnet-core/libsodium.props +33 -0
- data/vendor/libsodium/packaging/dotnet-core/prepare.py +262 -0
- data/vendor/libsodium/packaging/dotnet-core/recipes/alpine-x64 +3 -0
- data/vendor/libsodium/packaging/dotnet-core/recipes/build +9 -0
- data/vendor/libsodium/packaging/dotnet-core/recipes/centos-x64 +3 -0
- data/vendor/libsodium/packaging/dotnet-core/recipes/debian-x64 +4 -0
- data/vendor/libsodium/packaging/dotnet-core/recipes/fedora-x64 +3 -0
- data/vendor/libsodium/packaging/dotnet-core/recipes/opensuse-x64 +3 -0
- data/vendor/libsodium/packaging/dotnet-core/recipes/pack +5 -0
- data/vendor/libsodium/packaging/dotnet-core/recipes/test +27 -0
- data/vendor/libsodium/packaging/dotnet-core/recipes/ubuntu-x64 +4 -0
- data/vendor/libsodium/packaging/nuget/package.config +1 -1
- data/vendor/libsodium/packaging/nuget/package.gsl +3 -3
- data/vendor/libsodium/src/Makefile.in +11 -7
- data/vendor/libsodium/src/libsodium/Makefile.am +113 -98
- data/vendor/libsodium/src/libsodium/Makefile.in +1034 -1236
- data/vendor/libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +31 -12
- data/vendor/libsodium/src/libsodium/crypto_aead/chacha20poly1305/sodium/aead_chacha20poly1305.c +31 -10
- data/vendor/libsodium/src/libsodium/crypto_aead/xchacha20poly1305/sodium/aead_xchacha20poly1305.c +153 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/crypto_auth.c +7 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/{cp/hmac_hmacsha256.c → auth_hmacsha256.c} +43 -35
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/{cp/hmac_hmacsha512.c → auth_hmacsha512.c} +43 -35
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/{cp/hmac_hmacsha512256.c → auth_hmacsha512256.c} +48 -9
- data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_easy.c +4 -3
- data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_seal.c +2 -1
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xchacha20poly1305/box_curve25519xchacha20poly1305.c +197 -0
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xchacha20poly1305/box_seal_curve25519xchacha20poly1305.c +79 -0
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305.c +150 -0
- data/vendor/libsodium/src/libsodium/crypto_core/curve25519/ref10/curve25519_ref10.c +1156 -662
- data/vendor/libsodium/src/libsodium/crypto_core/hchacha20/core_hchacha20.c +12 -5
- data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/{core_hsalsa20_api.c → core_hsalsa20.c} +0 -0
- data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20_ref2.c +95 -0
- data/vendor/libsodium/src/libsodium/crypto_core/salsa/ref/core_salsa_ref.c +195 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/{blake2/generichash_blake2_api.c → blake2b/generichash_blake2.c} +7 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2.h +109 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-avx2.c +49 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-avx2.h +140 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ref.c +92 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-sse41.c +87 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-sse41.h +103 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ssse3.c +90 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-compress-ssse3.h +103 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-load-avx2.h +340 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-load-sse2.h +164 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-load-sse41.h +307 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2b/ref/blake2b-ref.c +494 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/{blake2 → blake2b}/ref/generichash_blake2b.c +22 -26
- data/vendor/libsodium/src/libsodium/crypto_generichash/crypto_generichash.c +7 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256_cp.c +254 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/{hash_sha256_api.c → hash_sha256.c} +4 -2
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512_cp.c +280 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/{hash_sha512_api.c → hash_sha512.c} +4 -2
- data/vendor/libsodium/src/libsodium/crypto_kdf/blake2b/kdf_blake2b.c +52 -0
- data/vendor/libsodium/src/libsodium/crypto_kdf/crypto_kdf.c +49 -0
- data/vendor/libsodium/src/libsodium/crypto_kx/crypto_kx.c +136 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/crypto_onetimeauth.c +6 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.c +34 -27
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +203 -156
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +178 -134
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c +22 -4
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.h +10 -12
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c +564 -315
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.h +1 -1
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.c +131 -84
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-core.h +23 -18
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-encoding.c +163 -145
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-encoding.h +2 -1
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-avx2.c +247 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ref.c +42 -29
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-fill-block-ssse3.c +71 -47
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.c +100 -65
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2.h +77 -23
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blake2b-long.c +30 -31
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blamka-round-avx2.h +150 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blamka-round-ref.h +28 -26
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/blamka-round-ssse3.h +102 -99
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/pwhash_argon2i.c +90 -41
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/pwhash_argon2id.c +213 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/crypto_pwhash.c +72 -4
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt-common.c +34 -37
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +27 -32
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c +120 -86
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.c +16 -13
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pbkdf2-sha256.h +4 -4
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +98 -50
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/scrypt_platform.c +23 -18
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/sse/pwhash_scryptsalsa208sha256_sse.c +105 -105
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.c +395 -330
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.c +225 -198
- data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox.c +7 -0
- data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox_easy.c +6 -5
- data/vendor/libsodium/src/libsodium/crypto_secretbox/xchacha20poly1305/secretbox_xchacha20poly1305.c +170 -0
- data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305.c +83 -0
- data/vendor/libsodium/src/libsodium/crypto_shorthash/crypto_shorthash.c +7 -0
- data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash24_ref.c +65 -0
- data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash_ref.h +24 -0
- data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphashx24_ref.c +71 -0
- data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/{shorthash_siphash24_api.c → shorthash_siphash24.c} +0 -0
- data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/shorthash_siphashx24.c +11 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/crypto_sign.c +33 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ed25519_ref10.h +18 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +18 -13
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/obsolete.c +29 -26
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +75 -36
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sign.c +39 -15
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/sign_ed25519.c +91 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/afternm_aes128ctr.c +174 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/beforenm_aes128ctr.c +66 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/common.h +766 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/consts.h +28 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/consts_aes128ctr.c +28 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/int128.h +50 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/int128_aes128ctr.c +149 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/stream_aes128ctr_nacl.c +31 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/nacl/xor_afternm_aes128ctr.c +195 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/{stream_aes128ctr_api.c → stream_aes128ctr.c} +6 -3
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/chacha20_dolbeau-avx2.c +179 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/chacha20_dolbeau-avx2.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/chacha20_dolbeau-ssse3.c +173 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/chacha20_dolbeau-ssse3.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/u0.h +86 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/u1.h +98 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/u4.h +175 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/dolbeau/u8.h +357 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/{stream_chacha20_ref.c → chacha20_ref.c} +93 -94
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/chacha20_ref.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/stream_chacha20.c +39 -7
- data/vendor/libsodium/src/libsodium/crypto_stream/crypto_stream.c +7 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/salsa20_ref.c +120 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/salsa20_ref.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20.c +93 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20.h +16 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/{amd64_xmm6/stream_salsa20_amd64_xmm6.S → xmm6/salsa20_xmm6-asm.S} +20 -12
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6/salsa20_xmm6.c +31 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6/salsa20_xmm6.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/salsa20_xmm6int-avx2.c +131 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/salsa20_xmm6int-avx2.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/salsa20_xmm6int-sse2.c +122 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/salsa20_xmm6int-sse2.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/u0.h +195 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/u1.h +207 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/u4.h +547 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/xmm6int/u8.h +476 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012_ref.c +106 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/stream_salsa2012.c +20 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208_ref.c +106 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/stream_salsa208.c +20 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/xchacha20/stream_xchacha20.c +63 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/stream_xsalsa20.c +60 -0
- data/vendor/libsodium/src/libsodium/crypto_verify/sodium/verify.c +61 -0
- data/vendor/libsodium/src/libsodium/include/Makefile.am +8 -6
- data/vendor/libsodium/src/libsodium/include/Makefile.in +29 -21
- data/vendor/libsodium/src/libsodium/include/sodium.h +15 -4
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_aes256gcm.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_chacha20poly1305.h +6 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_aead_xchacha20poly1305.h +91 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha256.h +5 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512256.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xchacha20poly1305.h +153 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h +3 -4
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha256.h +4 -3
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha512.h +4 -3
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_kdf.h +51 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_kdf_blake2b.h +42 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_kx.h +64 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h +11 -9
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash.h +37 -1
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_argon2i.h +40 -10
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_argon2id.h +116 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_pwhash_scryptsalsa208sha256.h +37 -4
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h +0 -4
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xchacha20poly1305.h +62 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h +5 -1
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_shorthash.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_shorthash_siphash24.h +18 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign.h +22 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_ed25519.h +28 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes128ctr.h +10 -5
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_chacha20.h +14 -3
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa20.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa2012.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa208.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_xchacha20.h +53 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_xsalsa20.h +4 -0
- data/vendor/libsodium/src/libsodium/include/sodium/private/common.h +84 -17
- data/vendor/libsodium/src/libsodium/include/sodium/private/implementations.h +11 -0
- data/vendor/libsodium/src/libsodium/include/sodium/private/sse2_64_32.h +50 -0
- data/vendor/libsodium/src/libsodium/include/sodium/randombytes.h +10 -2
- data/vendor/libsodium/src/libsodium/include/sodium/utils.h +4 -5
- data/vendor/libsodium/src/libsodium/include/sodium/version.h.in +4 -0
- data/vendor/libsodium/src/libsodium/randombytes/randombytes.c +47 -19
- data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +30 -50
- data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +25 -15
- data/vendor/libsodium/src/libsodium/sodium/core.c +25 -23
- data/vendor/libsodium/src/libsodium/sodium/runtime.c +66 -57
- data/vendor/libsodium/src/libsodium/sodium/utils.c +120 -106
- data/vendor/libsodium/src/libsodium/sodium/version.c +10 -0
- data/vendor/libsodium/test/Makefile.in +11 -7
- data/vendor/libsodium/test/default/Makefile.am +65 -5
- data/vendor/libsodium/test/default/Makefile.in +243 -78
- data/vendor/libsodium/test/default/aead_aes256gcm.c +2 -2
- data/vendor/libsodium/test/default/aead_xchacha20poly1305.c +188 -0
- data/vendor/libsodium/test/default/aead_xchacha20poly1305.exp +51 -0
- data/vendor/libsodium/test/default/auth.c +11 -7
- data/vendor/libsodium/test/default/auth2.c +15 -12
- data/vendor/libsodium/test/default/auth3.c +18 -15
- data/vendor/libsodium/test/default/auth5.c +3 -2
- data/vendor/libsodium/test/default/auth6.c +4 -3
- data/vendor/libsodium/test/default/auth7.c +3 -2
- data/vendor/libsodium/test/default/box.c +57 -52
- data/vendor/libsodium/test/default/box2.c +41 -36
- data/vendor/libsodium/test/default/box7.c +4 -3
- data/vendor/libsodium/test/default/box8.c +4 -3
- data/vendor/libsodium/test/default/box_easy.c +36 -32
- data/vendor/libsodium/test/default/box_easy2.c +41 -34
- data/vendor/libsodium/test/default/box_seal.c +7 -6
- data/vendor/libsodium/test/default/box_seed.c +10 -8
- data/vendor/libsodium/test/default/chacha20.c +18 -3
- data/vendor/libsodium/test/default/chacha20.exp +45 -0
- data/vendor/libsodium/test/default/cmptest.h +1 -0
- data/vendor/libsodium/test/default/core1.c +10 -9
- data/vendor/libsodium/test/default/core2.c +13 -12
- data/vendor/libsodium/test/default/core3.c +13 -12
- data/vendor/libsodium/test/default/core4.c +11 -12
- data/vendor/libsodium/test/default/core5.c +13 -12
- data/vendor/libsodium/test/default/core6.c +15 -13
- data/vendor/libsodium/test/default/ed25519_convert.c +12 -9
- data/vendor/libsodium/test/default/hash.c +10 -6
- data/vendor/libsodium/test/default/hash3.c +3 -2
- data/vendor/libsodium/test/default/index-wasm.html.tpl +118 -0
- data/vendor/libsodium/test/default/kdf.c +61 -0
- data/vendor/libsodium/test/default/kdf.exp +77 -0
- data/vendor/libsodium/test/default/keygen.c +64 -0
- data/vendor/libsodium/test/default/keygen.exp +1 -0
- data/vendor/libsodium/test/default/kx.c +119 -0
- data/vendor/libsodium/test/default/kx.exp +7 -0
- data/vendor/libsodium/test/default/nacl-test-wrapper.sh +9 -2
- data/vendor/libsodium/test/default/onetimeauth.c +26 -23
- data/vendor/libsodium/test/default/onetimeauth2.c +22 -20
- data/vendor/libsodium/test/default/onetimeauth7.c +3 -2
- data/vendor/libsodium/test/default/pwhash.c +209 -157
- data/vendor/libsodium/test/default/pwhash_argon2id.c +388 -0
- data/vendor/libsodium/test/default/pwhash_argon2id.exp +15 -0
- data/vendor/libsodium/test/default/pwhash_scrypt.c +232 -224
- data/vendor/libsodium/test/default/pwhash_scrypt.exp +2 -1
- data/vendor/libsodium/test/default/pwhash_scrypt_ll.c +39 -41
- data/vendor/libsodium/test/default/randombytes.c +34 -13
- data/vendor/libsodium/test/default/randombytes.exp +1 -0
- data/vendor/libsodium/test/default/scalarmult.c +21 -18
- data/vendor/libsodium/test/default/scalarmult2.c +8 -6
- data/vendor/libsodium/test/default/scalarmult5.c +13 -10
- data/vendor/libsodium/test/default/scalarmult6.c +17 -14
- data/vendor/libsodium/test/default/scalarmult7.c +9 -10
- data/vendor/libsodium/test/default/secretbox.c +39 -36
- data/vendor/libsodium/test/default/secretbox2.c +28 -25
- data/vendor/libsodium/test/default/secretbox7.c +3 -2
- data/vendor/libsodium/test/default/secretbox8.c +4 -3
- data/vendor/libsodium/test/default/secretbox_easy.c +40 -37
- data/vendor/libsodium/test/default/secretbox_easy2.c +19 -18
- data/vendor/libsodium/test/default/shorthash.c +4 -4
- data/vendor/libsodium/test/default/sign.c +70 -13
- data/vendor/libsodium/test/default/sign.exp +2 -0
- data/vendor/libsodium/test/default/siphashx24.c +33 -0
- data/vendor/libsodium/test/default/siphashx24.exp +64 -0
- data/vendor/libsodium/test/default/sodium_core.c +9 -8
- data/vendor/libsodium/test/default/sodium_utils.c +52 -46
- data/vendor/libsodium/test/default/sodium_utils2.c +17 -8
- data/vendor/libsodium/test/default/sodium_utils3.c +15 -6
- data/vendor/libsodium/test/default/sodium_version.c +7 -1
- data/vendor/libsodium/test/default/stream.c +31 -18
- data/vendor/libsodium/test/default/stream.exp +65 -0
- data/vendor/libsodium/test/default/stream2.c +13 -9
- data/vendor/libsodium/test/default/stream3.c +12 -10
- data/vendor/libsodium/test/default/stream4.c +30 -27
- data/vendor/libsodium/test/default/verify1.c +5 -4
- data/vendor/libsodium/test/default/xchacha20.c +376 -0
- data/vendor/libsodium/test/default/xchacha20.exp +5 -0
- data/vendor/libsodium/test/quirks/quirks.h +4 -3
- metadata +140 -111
- data/vendor/libsodium/autom4te.cache/output.3 +0 -17240
- data/vendor/libsodium/autom4te.cache/output.4 +0 -17517
- data/vendor/libsodium/autom4te.cache/output.5 +0 -18535
- data/vendor/libsodium/autom4te.cache/output.6 +0 -19077
- data/vendor/libsodium/autom4te.cache/output.7 +0 -19837
- data/vendor/libsodium/autom4te.cache/traces.3 +0 -2833
- data/vendor/libsodium/autom4te.cache/traces.4 +0 -2951
- data/vendor/libsodium/autom4te.cache/traces.5 +0 -3042
- data/vendor/libsodium/autom4te.cache/traces.6 +0 -3194
- data/vendor/libsodium/autom4te.cache/traces.7 +0 -3614
- data/vendor/libsodium/builds/msvc/properties/ARM.props +0 -20
- data/vendor/libsodium/compile +0 -347
- data/vendor/libsodium/config.guess +0 -1568
- data/vendor/libsodium/config.sub +0 -1793
- data/vendor/libsodium/depcomp +0 -791
- data/vendor/libsodium/install-sh +0 -527
- data/vendor/libsodium/ltmain.sh +0 -9655
- data/vendor/libsodium/missing +0 -215
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/auth_hmacsha256_api.c +0 -16
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/cp/verify_hmacsha256.c +0 -11
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/auth_hmacsha512_api.c +0 -16
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/verify_hmacsha512.c +0 -12
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/auth_hmacsha512256_api.c +0 -16
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/verify_hmacsha512256.c +0 -14
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305_api.c +0 -41
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/after_curve25519xsalsa20poly1305.c +0 -22
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c +0 -18
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/box_curve25519xsalsa20poly1305.c +0 -42
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c +0 -29
- data/vendor/libsodium/src/libsodium/crypto_core/hchacha20/core_hchacha20.h +0 -28
- data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20.c +0 -100
- data/vendor/libsodium/src/libsodium/crypto_core/salsa20/core_salsa20_api.c +0 -21
- data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/core_salsa20.c +0 -126
- data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/core_salsa2012_api.c +0 -21
- data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/core_salsa2012.c +0 -126
- data/vendor/libsodium/src/libsodium/crypto_core/salsa208/core_salsa208_api.c +0 -21
- data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/core_salsa208.c +0 -126
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2-impl.h +0 -48
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h +0 -97
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-avx2.c +0 -45
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-avx2.h +0 -123
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ref.c +0 -94
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-sse41.c +0 -80
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-sse41.h +0 -97
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ssse3.c +0 -87
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-compress-ssse3.h +0 -97
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-avx2.h +0 -339
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-sse2.h +0 -66
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-load-sse41.h +0 -400
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +0 -456
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +0 -269
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +0 -298
- data/vendor/libsodium/src/libsodium/crypto_pwhash/argon2/argon2-impl.h +0 -40
- data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/ref/box_xsalsa20poly1305.c +0 -35
- data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305_api.c +0 -26
- data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash24.c +0 -72
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/description +0 -1
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/sign_ed25519_api.c +0 -39
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/afternm_aes128ctr.c +0 -159
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/beforenm_aes128ctr.c +0 -59
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/common.h +0 -771
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/consts.h +0 -28
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/consts_aes128ctr.c +0 -14
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128.h +0 -56
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128_aes128ctr.c +0 -131
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/stream_aes128ctr.c +0 -29
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/types.h +0 -10
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/xor_afternm_aes128ctr.c +0 -180
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.h +0 -28
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/vec/stream_chacha20_vec.c +0 -336
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/vec/stream_chacha20_vec.h +0 -28
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20_ref.c +0 -55
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c +0 -63
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20_api.c +0 -19
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c +0 -51
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c +0 -54
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/stream_salsa2012_api.c +0 -11
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c +0 -51
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c +0 -54
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/stream_salsa208_api.c +0 -11
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c +0 -24
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c +0 -35
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/stream_xsalsa20_api.c +0 -11
- data/vendor/libsodium/src/libsodium/crypto_verify/16/ref/verify_16.c +0 -17
- data/vendor/libsodium/src/libsodium/crypto_verify/16/verify_16_api.c +0 -6
- data/vendor/libsodium/src/libsodium/crypto_verify/32/ref/verify_32.c +0 -17
- data/vendor/libsodium/src/libsodium/crypto_verify/32/verify_32_api.c +0 -6
- data/vendor/libsodium/src/libsodium/crypto_verify/64/ref/verify_64.c +0 -17
- data/vendor/libsodium/src/libsodium/crypto_verify/64/verify_64_api.c +0 -6
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_int32.h +0 -8
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_int64.h +0 -8
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_uint16.h +0 -8
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_uint32.h +0 -8
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_uint64.h +0 -8
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_uint8.h +0 -8
- data/vendor/libsodium/test-driver +0 -139
data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.c
CHANGED
@@ -22,29 +22,30 @@
|
|
22
22
|
* from the sample implementation.
|
23
23
|
*/
|
24
24
|
|
25
|
-
#include <string.h>
|
26
25
|
#include <stdint.h>
|
26
|
+
#include <string.h>
|
27
27
|
|
28
28
|
#ifdef HAVE_TI_MODE
|
29
29
|
|
30
|
-
#include "utils.h"
|
31
|
-
#include "curve25519_donna_c64.h"
|
32
30
|
#include "../scalarmult_curve25519.h"
|
31
|
+
#include "curve25519_donna_c64.h"
|
32
|
+
#include "utils.h"
|
33
33
|
|
34
34
|
typedef uint8_t u8;
|
35
35
|
typedef uint64_t limb;
|
36
36
|
typedef limb felem[5];
|
37
37
|
/* Special gcc mode for 128-bit integers */
|
38
|
-
typedef unsigned uint128_t __attribute__
|
38
|
+
typedef unsigned uint128_t __attribute__((mode(TI)));
|
39
39
|
|
40
40
|
/* Sum two numbers: output += in */
|
41
41
|
static inline void
|
42
|
-
fsum(limb *output, const limb *in)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
fsum(limb *output, const limb *in)
|
43
|
+
{
|
44
|
+
output[0] += in[0];
|
45
|
+
output[1] += in[1];
|
46
|
+
output[2] += in[2];
|
47
|
+
output[3] += in[3];
|
48
|
+
output[4] += in[4];
|
48
49
|
}
|
49
50
|
|
50
51
|
/* Find the difference of two numbers: output = in - output
|
@@ -54,39 +55,41 @@ fsum(limb *output, const limb *in) {
|
|
54
55
|
* On return, out[i] < 2**55
|
55
56
|
*/
|
56
57
|
static inline void
|
57
|
-
fdifference_backwards(felem out, const felem in)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
58
|
+
fdifference_backwards(felem out, const felem in)
|
59
|
+
{
|
60
|
+
/* 152 is 19 << 3 */
|
61
|
+
static const limb two54m152 = (((limb)1) << 54) - 152;
|
62
|
+
static const limb two54m8 = (((limb)1) << 54) - 8;
|
63
|
+
|
64
|
+
out[0] = in[0] + two54m152 - out[0];
|
65
|
+
out[1] = in[1] + two54m8 - out[1];
|
66
|
+
out[2] = in[2] + two54m8 - out[2];
|
67
|
+
out[3] = in[3] + two54m8 - out[3];
|
68
|
+
out[4] = in[4] + two54m8 - out[4];
|
67
69
|
}
|
68
70
|
|
69
71
|
/* Multiply a number by a scalar: output = in * scalar */
|
70
72
|
static inline void
|
71
|
-
fscalar_product(felem output, const felem in, const limb scalar)
|
72
|
-
|
73
|
+
fscalar_product(felem output, const felem in, const limb scalar)
|
74
|
+
{
|
75
|
+
uint128_t a;
|
73
76
|
|
74
|
-
|
75
|
-
|
77
|
+
a = in[0] * (uint128_t)scalar;
|
78
|
+
output[0] = ((limb)a) & 0x7ffffffffffff;
|
76
79
|
|
77
|
-
|
78
|
-
|
80
|
+
a = in[1] * (uint128_t)scalar + ((limb)(a >> 51));
|
81
|
+
output[1] = ((limb)a) & 0x7ffffffffffff;
|
79
82
|
|
80
|
-
|
81
|
-
|
83
|
+
a = in[2] * (uint128_t)scalar + ((limb)(a >> 51));
|
84
|
+
output[2] = ((limb)a) & 0x7ffffffffffff;
|
82
85
|
|
83
|
-
|
84
|
-
|
86
|
+
a = in[3] * (uint128_t)scalar + ((limb)(a >> 51));
|
87
|
+
output[3] = ((limb)a) & 0x7ffffffffffff;
|
85
88
|
|
86
|
-
|
87
|
-
|
89
|
+
a = in[4] * (uint128_t)scalar + ((limb)(a >> 51));
|
90
|
+
output[4] = ((limb)a) & 0x7ffffffffffff;
|
88
91
|
|
89
|
-
|
92
|
+
output[0] += (a >> 51) * 19;
|
90
93
|
}
|
91
94
|
|
92
95
|
/* Multiply two numbers: output = in2 * in
|
@@ -98,200 +101,257 @@ fscalar_product(felem output, const felem in, const limb scalar) {
|
|
98
101
|
* On return, output[i] < 2**52
|
99
102
|
*/
|
100
103
|
static inline void
|
101
|
-
fmul(felem output, const felem in2, const felem in)
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
104
|
+
fmul(felem output, const felem in2, const felem in)
|
105
|
+
{
|
106
|
+
uint128_t t[5];
|
107
|
+
limb r0, r1, r2, r3, r4, s0, s1, s2, s3, s4, c;
|
108
|
+
|
109
|
+
r0 = in[0];
|
110
|
+
r1 = in[1];
|
111
|
+
r2 = in[2];
|
112
|
+
r3 = in[3];
|
113
|
+
r4 = in[4];
|
114
|
+
|
115
|
+
s0 = in2[0];
|
116
|
+
s1 = in2[1];
|
117
|
+
s2 = in2[2];
|
118
|
+
s3 = in2[3];
|
119
|
+
s4 = in2[4];
|
120
|
+
|
121
|
+
t[0] = ((uint128_t)r0) * s0;
|
122
|
+
t[1] = ((uint128_t)r0) * s1 + ((uint128_t)r1) * s0;
|
123
|
+
t[2] = ((uint128_t)r0) * s2 + ((uint128_t)r2) * s0 + ((uint128_t)r1) * s1;
|
124
|
+
t[3] = ((uint128_t)r0) * s3 + ((uint128_t)r3) * s0 + ((uint128_t)r1) * s2
|
125
|
+
+ ((uint128_t)r2) * s1;
|
126
|
+
t[4] = ((uint128_t)r0) * s4 + ((uint128_t)r4) * s0 + ((uint128_t)r3) * s1
|
127
|
+
+ ((uint128_t)r1) * s3 + ((uint128_t)r2) * s2;
|
128
|
+
|
129
|
+
r4 *= 19;
|
130
|
+
r1 *= 19;
|
131
|
+
r2 *= 19;
|
132
|
+
r3 *= 19;
|
133
|
+
|
134
|
+
t[0] += ((uint128_t)r4) * s1 + ((uint128_t)r1) * s4 + ((uint128_t)r2) * s3
|
135
|
+
+ ((uint128_t)r3) * s2;
|
136
|
+
t[1] += ((uint128_t)r4) * s2 + ((uint128_t)r2) * s4 + ((uint128_t)r3) * s3;
|
137
|
+
t[2] += ((uint128_t)r4) * s3 + ((uint128_t)r3) * s4;
|
138
|
+
t[3] += ((uint128_t)r4) * s4;
|
139
|
+
|
140
|
+
r0 = (limb)t[0] & 0x7ffffffffffff;
|
141
|
+
c = (limb)(t[0] >> 51);
|
142
|
+
t[1] += c;
|
143
|
+
r1 = (limb)t[1] & 0x7ffffffffffff;
|
144
|
+
c = (limb)(t[1] >> 51);
|
145
|
+
t[2] += c;
|
146
|
+
r2 = (limb)t[2] & 0x7ffffffffffff;
|
147
|
+
c = (limb)(t[2] >> 51);
|
148
|
+
t[3] += c;
|
149
|
+
r3 = (limb)t[3] & 0x7ffffffffffff;
|
150
|
+
c = (limb)(t[3] >> 51);
|
151
|
+
t[4] += c;
|
152
|
+
r4 = (limb)t[4] & 0x7ffffffffffff;
|
153
|
+
c = (limb)(t[4] >> 51);
|
154
|
+
r0 += c * 19;
|
155
|
+
c = r0 >> 51;
|
156
|
+
r0 = r0 & 0x7ffffffffffff;
|
157
|
+
r1 += c;
|
158
|
+
c = r1 >> 51;
|
159
|
+
r1 = r1 & 0x7ffffffffffff;
|
160
|
+
r2 += c;
|
161
|
+
|
162
|
+
output[0] = r0;
|
163
|
+
output[1] = r1;
|
164
|
+
output[2] = r2;
|
165
|
+
output[3] = r3;
|
166
|
+
output[4] = r4;
|
147
167
|
}
|
148
168
|
|
149
169
|
static inline void
|
150
|
-
fsquare_times(felem output, const felem in, limb count)
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
170
|
+
fsquare_times(felem output, const felem in, limb count)
|
171
|
+
{
|
172
|
+
uint128_t t[5];
|
173
|
+
limb r0, r1, r2, r3, r4, c;
|
174
|
+
limb d0, d1, d2, d4, d419;
|
175
|
+
|
176
|
+
r0 = in[0];
|
177
|
+
r1 = in[1];
|
178
|
+
r2 = in[2];
|
179
|
+
r3 = in[3];
|
180
|
+
r4 = in[4];
|
181
|
+
|
182
|
+
do {
|
183
|
+
d0 = r0 * 2;
|
184
|
+
d1 = r1 * 2;
|
185
|
+
d2 = r2 * 2 * 19;
|
186
|
+
d419 = r4 * 19;
|
187
|
+
d4 = d419 * 2;
|
188
|
+
|
189
|
+
t[0] = ((uint128_t)r0) * r0 + ((uint128_t)d4) * r1
|
190
|
+
+ (((uint128_t)d2) * (r3));
|
191
|
+
t[1] = ((uint128_t)d0) * r1 + ((uint128_t)d4) * r2
|
192
|
+
+ (((uint128_t)r3) * (r3 * 19));
|
193
|
+
t[2] = ((uint128_t)d0) * r2 + ((uint128_t)r1) * r1
|
194
|
+
+ (((uint128_t)d4) * (r3));
|
195
|
+
t[3] = ((uint128_t)d0) * r3 + ((uint128_t)d1) * r2
|
196
|
+
+ (((uint128_t)r4) * (d419));
|
197
|
+
t[4] = ((uint128_t)d0) * r4 + ((uint128_t)d1) * r3
|
198
|
+
+ (((uint128_t)r2) * (r2));
|
199
|
+
|
200
|
+
r0 = (limb)t[0] & 0x7ffffffffffff;
|
201
|
+
c = (limb)(t[0] >> 51);
|
202
|
+
t[1] += c;
|
203
|
+
r1 = (limb)t[1] & 0x7ffffffffffff;
|
204
|
+
c = (limb)(t[1] >> 51);
|
205
|
+
t[2] += c;
|
206
|
+
r2 = (limb)t[2] & 0x7ffffffffffff;
|
207
|
+
c = (limb)(t[2] >> 51);
|
208
|
+
t[3] += c;
|
209
|
+
r3 = (limb)t[3] & 0x7ffffffffffff;
|
210
|
+
c = (limb)(t[3] >> 51);
|
211
|
+
t[4] += c;
|
212
|
+
r4 = (limb)t[4] & 0x7ffffffffffff;
|
213
|
+
c = (limb)(t[4] >> 51);
|
214
|
+
r0 += c * 19;
|
215
|
+
c = r0 >> 51;
|
216
|
+
r0 = r0 & 0x7ffffffffffff;
|
217
|
+
r1 += c;
|
218
|
+
c = r1 >> 51;
|
219
|
+
r1 = r1 & 0x7ffffffffffff;
|
220
|
+
r2 += c;
|
221
|
+
} while (--count);
|
222
|
+
|
223
|
+
output[0] = r0;
|
224
|
+
output[1] = r1;
|
225
|
+
output[2] = r2;
|
226
|
+
output[3] = r3;
|
227
|
+
output[4] = r4;
|
189
228
|
}
|
190
229
|
|
191
230
|
#ifdef NATIVE_LITTLE_ENDIAN
|
192
231
|
static inline limb
|
193
|
-
load_limb(const u8 *in)
|
232
|
+
load_limb(const u8 *in)
|
233
|
+
{
|
194
234
|
limb out;
|
195
|
-
|
235
|
+
|
236
|
+
memcpy(&out, in, sizeof(limb));
|
196
237
|
return out;
|
197
238
|
}
|
198
239
|
static inline void
|
199
|
-
store_limb(u8 *out, limb in)
|
200
|
-
|
240
|
+
store_limb(u8 *out, limb in)
|
241
|
+
{
|
242
|
+
memcpy(out, &in, sizeof(limb));
|
201
243
|
}
|
202
244
|
#else
|
203
245
|
static inline limb
|
204
|
-
load_limb(const u8 *in)
|
205
|
-
|
206
|
-
((limb)in[0]) |
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
(((limb)in[4]) << 32) |
|
211
|
-
(((limb)in[5]) << 40) |
|
212
|
-
(((limb)in[6]) << 48) |
|
213
|
-
(((limb)in[7]) << 56);
|
246
|
+
load_limb(const u8 *in)
|
247
|
+
{
|
248
|
+
return ((limb)in[0]) | (((limb)in[1]) << 8) | (((limb)in[2]) << 16)
|
249
|
+
| (((limb)in[3]) << 24) | (((limb)in[4]) << 32)
|
250
|
+
| (((limb)in[5]) << 40) | (((limb)in[6]) << 48)
|
251
|
+
| (((limb)in[7]) << 56);
|
214
252
|
}
|
215
253
|
|
216
254
|
static inline void
|
217
|
-
store_limb(u8 *out, limb in)
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
255
|
+
store_limb(u8 *out, limb in)
|
256
|
+
{
|
257
|
+
out[0] = in & 0xff;
|
258
|
+
out[1] = (in >> 8) & 0xff;
|
259
|
+
out[2] = (in >> 16) & 0xff;
|
260
|
+
out[3] = (in >> 24) & 0xff;
|
261
|
+
out[4] = (in >> 32) & 0xff;
|
262
|
+
out[5] = (in >> 40) & 0xff;
|
263
|
+
out[6] = (in >> 48) & 0xff;
|
264
|
+
out[7] = (in >> 56) & 0xff;
|
226
265
|
}
|
227
266
|
#endif
|
228
267
|
|
229
268
|
/* Take a little-endian, 32-byte number and expand it into polynomial form */
|
230
269
|
static void
|
231
|
-
fexpand(limb *output, const u8 *in)
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
270
|
+
fexpand(limb *output, const u8 *in)
|
271
|
+
{
|
272
|
+
output[0] = load_limb(in) & 0x7ffffffffffff;
|
273
|
+
output[1] = (load_limb(in + 6) >> 3) & 0x7ffffffffffff;
|
274
|
+
output[2] = (load_limb(in + 12) >> 6) & 0x7ffffffffffff;
|
275
|
+
output[3] = (load_limb(in + 19) >> 1) & 0x7ffffffffffff;
|
276
|
+
output[4] = (load_limb(in + 24) >> 12) & 0x7ffffffffffff;
|
237
277
|
}
|
238
278
|
|
239
279
|
/* Take a fully reduced polynomial form number and contract it into a
|
240
280
|
* little-endian, 32-byte array
|
241
281
|
*/
|
242
282
|
static void
|
243
|
-
fcontract(u8 *output, const felem input)
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
283
|
+
fcontract(u8 *output, const felem input)
|
284
|
+
{
|
285
|
+
uint128_t t[5];
|
286
|
+
|
287
|
+
t[0] = input[0];
|
288
|
+
t[1] = input[1];
|
289
|
+
t[2] = input[2];
|
290
|
+
t[3] = input[3];
|
291
|
+
t[4] = input[4];
|
292
|
+
|
293
|
+
t[1] += t[0] >> 51;
|
294
|
+
t[0] &= 0x7ffffffffffff;
|
295
|
+
t[2] += t[1] >> 51;
|
296
|
+
t[1] &= 0x7ffffffffffff;
|
297
|
+
t[3] += t[2] >> 51;
|
298
|
+
t[2] &= 0x7ffffffffffff;
|
299
|
+
t[4] += t[3] >> 51;
|
300
|
+
t[3] &= 0x7ffffffffffff;
|
301
|
+
t[0] += 19 * (t[4] >> 51);
|
302
|
+
t[4] &= 0x7ffffffffffff;
|
303
|
+
|
304
|
+
t[1] += t[0] >> 51;
|
305
|
+
t[0] &= 0x7ffffffffffff;
|
306
|
+
t[2] += t[1] >> 51;
|
307
|
+
t[1] &= 0x7ffffffffffff;
|
308
|
+
t[3] += t[2] >> 51;
|
309
|
+
t[2] &= 0x7ffffffffffff;
|
310
|
+
t[4] += t[3] >> 51;
|
311
|
+
t[3] &= 0x7ffffffffffff;
|
312
|
+
t[0] += 19 * (t[4] >> 51);
|
313
|
+
t[4] &= 0x7ffffffffffff;
|
314
|
+
|
315
|
+
/* now t is between 0 and 2^255-1, properly carried. */
|
316
|
+
/* case 1: between 0 and 2^255-20. case 2: between 2^255-19 and 2^255-1. */
|
317
|
+
|
318
|
+
t[0] += 19;
|
319
|
+
|
320
|
+
t[1] += t[0] >> 51;
|
321
|
+
t[0] &= 0x7ffffffffffff;
|
322
|
+
t[2] += t[1] >> 51;
|
323
|
+
t[1] &= 0x7ffffffffffff;
|
324
|
+
t[3] += t[2] >> 51;
|
325
|
+
t[2] &= 0x7ffffffffffff;
|
326
|
+
t[4] += t[3] >> 51;
|
327
|
+
t[3] &= 0x7ffffffffffff;
|
328
|
+
t[0] += 19 * (t[4] >> 51);
|
329
|
+
t[4] &= 0x7ffffffffffff;
|
330
|
+
|
331
|
+
/* now between 19 and 2^255-1 in both cases, and offset by 19. */
|
332
|
+
|
333
|
+
t[0] += 0x8000000000000 - 19;
|
334
|
+
t[1] += 0x8000000000000 - 1;
|
335
|
+
t[2] += 0x8000000000000 - 1;
|
336
|
+
t[3] += 0x8000000000000 - 1;
|
337
|
+
t[4] += 0x8000000000000 - 1;
|
338
|
+
|
339
|
+
/* now between 2^255 and 2^256-20, and offset by 2^255. */
|
340
|
+
|
341
|
+
t[1] += t[0] >> 51;
|
342
|
+
t[0] &= 0x7ffffffffffff;
|
343
|
+
t[2] += t[1] >> 51;
|
344
|
+
t[1] &= 0x7ffffffffffff;
|
345
|
+
t[3] += t[2] >> 51;
|
346
|
+
t[2] &= 0x7ffffffffffff;
|
347
|
+
t[4] += t[3] >> 51;
|
348
|
+
t[3] &= 0x7ffffffffffff;
|
349
|
+
t[4] &= 0x7ffffffffffff;
|
350
|
+
|
351
|
+
store_limb(output, t[0] | (t[1] << 51));
|
352
|
+
store_limb(output + 8, (t[1] >> 13) | (t[2] << 38));
|
353
|
+
store_limb(output + 16, (t[2] >> 26) | (t[3] << 25));
|
354
|
+
store_limb(output + 24, (t[3] >> 39) | (t[4] << 12));
|
295
355
|
}
|
296
356
|
|
297
357
|
/* Input: Q, Q', Q-Q'
|
@@ -304,37 +364,38 @@ fcontract(u8 *output, const felem input) {
|
|
304
364
|
* qmqp: short form, preserved
|
305
365
|
*/
|
306
366
|
static void
|
307
|
-
fmonty(limb *x2, limb *z2,
|
308
|
-
limb *x3, limb *z3,
|
309
|
-
limb *x, limb *z,
|
367
|
+
fmonty(limb *x2, limb *z2, /* output 2Q */
|
368
|
+
limb *x3, limb *z3, /* output Q + Q' */
|
369
|
+
limb *x, limb *z, /* input Q */
|
310
370
|
limb *xprime, limb *zprime, /* input Q' */
|
311
|
-
const limb *qmqp /* input Q - Q' */)
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
371
|
+
const limb *qmqp /* input Q - Q' */)
|
372
|
+
{
|
373
|
+
limb origx[5], origxprime[5], zzz[5], xx[5], zz[5], xxprime[5], zzprime[5],
|
374
|
+
zzzprime[5];
|
375
|
+
|
376
|
+
memcpy(origx, x, 5 * sizeof(limb));
|
377
|
+
fsum(x, z);
|
378
|
+
fdifference_backwards(z, origx); /* does x - z */
|
379
|
+
|
380
|
+
memcpy(origxprime, xprime, sizeof(limb) * 5);
|
381
|
+
fsum(xprime, zprime);
|
382
|
+
fdifference_backwards(zprime, origxprime);
|
383
|
+
fmul(xxprime, xprime, z);
|
384
|
+
fmul(zzprime, x, zprime);
|
385
|
+
memcpy(origxprime, xxprime, sizeof(limb) * 5);
|
386
|
+
fsum(xxprime, zzprime);
|
387
|
+
fdifference_backwards(zzprime, origxprime);
|
388
|
+
fsquare_times(x3, xxprime, 1);
|
389
|
+
fsquare_times(zzzprime, zzprime, 1);
|
390
|
+
fmul(z3, zzzprime, qmqp);
|
391
|
+
|
392
|
+
fsquare_times(xx, x, 1);
|
393
|
+
fsquare_times(zz, z, 1);
|
394
|
+
fmul(x2, xx, zz);
|
395
|
+
fdifference_backwards(zz, xx); /* does zz = xx - zz */
|
396
|
+
fscalar_product(zzz, zz, 121665);
|
397
|
+
fsum(zzz, xx);
|
398
|
+
fmul(z2, zz, zzz);
|
338
399
|
}
|
339
400
|
|
340
401
|
/* -----------------------------------------------------------------------------
|
@@ -343,17 +404,19 @@ fmonty(limb *x2, limb *z2, /* output 2Q */
|
|
343
404
|
|
344
405
|
This function performs the swap without leaking any side-channel
|
345
406
|
information.
|
346
|
-
-----------------------------------------------------------------------------
|
407
|
+
-----------------------------------------------------------------------------
|
408
|
+
*/
|
347
409
|
static void
|
348
|
-
swap_conditional(limb a[5], limb b[5], limb iswap)
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
410
|
+
swap_conditional(limb a[5], limb b[5], limb iswap)
|
411
|
+
{
|
412
|
+
const limb swap = -iswap;
|
413
|
+
unsigned i;
|
414
|
+
|
415
|
+
for (i = 0; i < 5; ++i) {
|
416
|
+
const limb x = swap & (a[i] ^ b[i]);
|
417
|
+
a[i] ^= x;
|
418
|
+
b[i] ^= x;
|
419
|
+
}
|
357
420
|
}
|
358
421
|
|
359
422
|
/* Calculates nQ where Q is the x-coordinate of a point on the curve
|
@@ -363,118 +426,120 @@ swap_conditional(limb a[5], limb b[5], limb iswap) {
|
|
363
426
|
* q: a point of the curve (short form)
|
364
427
|
*/
|
365
428
|
static void
|
366
|
-
cmult(limb *resultx, limb *resultz, const u8 *n, const limb *q)
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
byte <<= 1;
|
429
|
+
cmult(limb *resultx, limb *resultz, const u8 *n, const limb *q)
|
430
|
+
{
|
431
|
+
limb a[5] = { 0 }, b[5] = { 1 }, c[5] = { 1 }, d[5] = { 0 };
|
432
|
+
limb *nqpqx = a, *nqpqz = b, *nqx = c, *nqz = d, *t;
|
433
|
+
limb e[5] = { 0 }, f[5] = { 1 }, g[5] = { 0 }, h[5] = { 1 };
|
434
|
+
limb *nqpqx2 = e, *nqpqz2 = f, *nqx2 = g, *nqz2 = h;
|
435
|
+
|
436
|
+
unsigned i, j;
|
437
|
+
|
438
|
+
memcpy(nqpqx, q, sizeof(limb) * 5);
|
439
|
+
|
440
|
+
for (i = 0; i < 32; ++i) {
|
441
|
+
u8 byte = n[31 - i];
|
442
|
+
for (j = 0; j < 8; ++j) {
|
443
|
+
const limb bit = byte >> 7;
|
444
|
+
|
445
|
+
swap_conditional(nqx, nqpqx, bit);
|
446
|
+
swap_conditional(nqz, nqpqz, bit);
|
447
|
+
fmonty(nqx2, nqz2, nqpqx2, nqpqz2, nqx, nqz, nqpqx, nqpqz, q);
|
448
|
+
swap_conditional(nqx2, nqpqx2, bit);
|
449
|
+
swap_conditional(nqz2, nqpqz2, bit);
|
450
|
+
|
451
|
+
t = nqx;
|
452
|
+
nqx = nqx2;
|
453
|
+
nqx2 = t;
|
454
|
+
t = nqz;
|
455
|
+
nqz = nqz2;
|
456
|
+
nqz2 = t;
|
457
|
+
t = nqpqx;
|
458
|
+
nqpqx = nqpqx2;
|
459
|
+
nqpqx2 = t;
|
460
|
+
t = nqpqz;
|
461
|
+
nqpqz = nqpqz2;
|
462
|
+
nqpqz2 = t;
|
463
|
+
|
464
|
+
byte <<= 1;
|
465
|
+
}
|
405
466
|
}
|
406
|
-
}
|
407
467
|
|
408
|
-
|
409
|
-
|
468
|
+
memcpy(resultx, nqx, sizeof(limb) * 5);
|
469
|
+
memcpy(resultz, nqz, sizeof(limb) * 5);
|
410
470
|
}
|
411
471
|
|
412
|
-
|
413
472
|
/* -----------------------------------------------------------------------------
|
414
473
|
Shamelessly copied from djb's code, tightened a little
|
415
|
-
-----------------------------------------------------------------------------
|
474
|
+
-----------------------------------------------------------------------------
|
475
|
+
*/
|
416
476
|
static void
|
417
|
-
crecip(felem out, const felem z)
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
477
|
+
crecip(felem out, const felem z)
|
478
|
+
{
|
479
|
+
felem a, t0, b, c;
|
480
|
+
|
481
|
+
/* 2 */ fsquare_times(a, z, 1); /* a = 2 */
|
482
|
+
/* 8 */ fsquare_times(t0, a, 2);
|
483
|
+
/* 9 */ fmul(b, t0, z); /* b = 9 */
|
484
|
+
/* 11 */ fmul(a, b, a); /* a = 11 */
|
485
|
+
/* 22 */ fsquare_times(t0, a, 1);
|
486
|
+
/* 2^5 - 2^0 = 31 */ fmul(b, t0, b);
|
487
|
+
/* 2^10 - 2^5 */ fsquare_times(t0, b, 5);
|
488
|
+
/* 2^10 - 2^0 */ fmul(b, t0, b);
|
489
|
+
/* 2^20 - 2^10 */ fsquare_times(t0, b, 10);
|
490
|
+
/* 2^20 - 2^0 */ fmul(c, t0, b);
|
491
|
+
/* 2^40 - 2^20 */ fsquare_times(t0, c, 20);
|
492
|
+
/* 2^40 - 2^0 */ fmul(t0, t0, c);
|
493
|
+
/* 2^50 - 2^10 */ fsquare_times(t0, t0, 10);
|
494
|
+
/* 2^50 - 2^0 */ fmul(b, t0, b);
|
495
|
+
/* 2^100 - 2^50 */ fsquare_times(t0, b, 50);
|
496
|
+
/* 2^100 - 2^0 */ fmul(c, t0, b);
|
497
|
+
/* 2^200 - 2^100 */ fsquare_times(t0, c, 100);
|
498
|
+
/* 2^200 - 2^0 */ fmul(t0, t0, c);
|
499
|
+
/* 2^250 - 2^50 */ fsquare_times(t0, t0, 50);
|
500
|
+
/* 2^250 - 2^0 */ fmul(t0, t0, b);
|
501
|
+
/* 2^255 - 2^5 */ fsquare_times(t0, t0, 5);
|
502
|
+
/* 2^255 - 21 */ fmul(out, t0, a);
|
442
503
|
}
|
443
504
|
|
444
|
-
static const unsigned char basepoint[32] = {9};
|
505
|
+
static const unsigned char basepoint[32] = { 9 };
|
445
506
|
|
446
507
|
static int
|
447
508
|
crypto_scalarmult_curve25519_donna_c64(unsigned char *mypublic,
|
448
509
|
const unsigned char *secret,
|
449
|
-
const unsigned char *basepoint)
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
510
|
+
const unsigned char *basepoint)
|
511
|
+
{
|
512
|
+
limb bp[5], x[5], z[5], zmone[5];
|
513
|
+
uint8_t e[32];
|
514
|
+
int i;
|
515
|
+
|
516
|
+
for (i = 0; i < 32; ++i) {
|
517
|
+
e[i] = secret[i];
|
518
|
+
}
|
519
|
+
e[0] &= 248;
|
520
|
+
e[31] &= 127;
|
521
|
+
e[31] |= 64;
|
522
|
+
|
523
|
+
fexpand(bp, basepoint);
|
524
|
+
cmult(x, z, e, bp);
|
525
|
+
crecip(zmone, z);
|
526
|
+
fmul(z, x, zmone);
|
527
|
+
fcontract(mypublic, z);
|
528
|
+
|
529
|
+
return 0;
|
465
530
|
}
|
466
531
|
|
467
532
|
static int
|
468
533
|
crypto_scalarmult_curve25519_donna_c64_base(unsigned char *q,
|
469
534
|
const unsigned char *n)
|
470
535
|
{
|
471
|
-
|
536
|
+
return crypto_scalarmult_curve25519_donna_c64(q, n, basepoint);
|
472
537
|
}
|
473
538
|
|
474
539
|
struct crypto_scalarmult_curve25519_implementation
|
475
|
-
crypto_scalarmult_curve25519_donna_c64_implementation = {
|
476
|
-
|
477
|
-
|
478
|
-
};
|
540
|
+
crypto_scalarmult_curve25519_donna_c64_implementation = {
|
541
|
+
SODIUM_C99(.mult =) crypto_scalarmult_curve25519_donna_c64,
|
542
|
+
SODIUM_C99(.mult_base =) crypto_scalarmult_curve25519_donna_c64_base
|
543
|
+
};
|
479
544
|
|
480
545
|
#endif
|