rbnacl-libsodium 1.0.6 → 1.0.7
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 +10 -3
- data/vendor/libsodium/ChangeLog +19 -1
- data/vendor/libsodium/Makefile.in +1 -0
- data/vendor/libsodium/README.markdown +1 -1
- data/vendor/libsodium/THANKS +1 -0
- data/vendor/libsodium/autogen.sh +24 -4
- data/vendor/libsodium/autom4te.cache/output.1 +208 -24
- data/vendor/libsodium/autom4te.cache/output.5 +208 -24
- data/vendor/libsodium/autom4te.cache/requests +869 -869
- data/vendor/libsodium/autom4te.cache/traces.1 +426 -406
- data/vendor/libsodium/autom4te.cache/traces.5 +255 -245
- data/vendor/libsodium/builds/msvc/version.h +2 -2
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +14 -44
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +36 -132
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +14 -44
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +36 -132
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +14 -44
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +36 -132
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +14 -44
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +62 -158
- data/vendor/libsodium/configure +208 -24
- data/vendor/libsodium/configure.ac +70 -15
- data/vendor/libsodium/dist-build/Makefile.in +1 -0
- data/vendor/libsodium/dist-build/emscripten.sh +52 -19
- data/vendor/libsodium/dist-build/ios.sh +8 -8
- data/vendor/libsodium/dist-build/msys2-win32.sh +2 -1
- data/vendor/libsodium/dist-build/msys2-win64.sh +2 -1
- data/vendor/libsodium/dist-build/osx.sh +2 -2
- data/vendor/libsodium/examples/box.c +3 -1
- data/vendor/libsodium/examples/box_detached.c +4 -2
- data/vendor/libsodium/examples/utils.h +3 -1
- data/vendor/libsodium/libsodium.vcxproj +13 -13
- data/vendor/libsodium/libsodium.vcxproj.filters +31 -35
- data/vendor/libsodium/msvc-scripts/Makefile.in +1 -0
- data/vendor/libsodium/msvc-scripts/process.bat +2 -2
- data/vendor/libsodium/src/Makefile.in +1 -0
- data/vendor/libsodium/src/libsodium/Makefile.am +43 -45
- data/vendor/libsodium/src/libsodium/Makefile.in +250 -249
- data/vendor/libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +28 -22
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/cp/hmac_hmacsha256.c +3 -4
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/cp/verify_hmacsha256.c +3 -3
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/hmac_hmacsha512.c +3 -4
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/verify_hmacsha512.c +4 -4
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/hmac_hmacsha512256.c +4 -4
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/verify_hmacsha512256.c +6 -4
- data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_easy.c +6 -2
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/after_curve25519xsalsa20poly1305.c +3 -3
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c +5 -3
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/box_curve25519xsalsa20poly1305.c +13 -9
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c +3 -3
- data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/core_salsa20.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/core_salsa2012.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/core_salsa208.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h +2 -2
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +36 -26
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/generichash_blake2b.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_generichash/crypto_generichash.c +1 -2
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +2 -3
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +2 -3
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/{auth_poly1305_donna.c → poly1305_donna.c} +18 -11
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +1 -5
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +10 -9
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +17 -9
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c +10 -1
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c +708 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.h +31 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +1 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/crypto_scalarmult.c +11 -12
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/{smult_curve25519_donna_c64.c → curve25519_donna_c64.c} +32 -15
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.h +9 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/curve25519_ref10.c +73 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/curve25519_ref10.h +9 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_frombytes_curve25519_ref10.c +1 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/consts.S +25 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/consts_namespace.h +20 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/curve25519_sandy2x.c +114 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/curve25519_sandy2x.h +9 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe.h +25 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51.h +33 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_invert.c +57 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_mul.S +189 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_namespace.h +16 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_nsquare.S +165 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_pack.S +219 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe_frombytes_sandy2x.c +76 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder.S +1432 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder.h +18 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base.S +1287 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base.h +18 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base_namespace.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_namespace.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/sandy2x.S +17 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519.c +67 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519.h +11 -0
- data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/ref/box_xsalsa20poly1305.c +3 -3
- data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash24.c +3 -2
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge.h +2 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_double_scalarmult.c +42 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +7 -7
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/obsolete.c +113 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +10 -7
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sign.c +10 -10
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/afternm_aes128ctr.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/beforenm_aes128ctr.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/stream_aes128ctr.c +10 -9
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/xor_afternm_aes128ctr.c +2 -3
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c +72 -68
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/{api.h → stream_chacha20_ref.h} +5 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/{stream_chacha20_api.c → stream_chacha20.c} +27 -7
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/stream_chacha20.h +22 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/vec/stream_chacha20_vec.c +329 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/vec/stream_chacha20_vec.h +27 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.S +1 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20_ref.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c +4 -4
- data/vendor/libsodium/src/libsodium/crypto_verify/16/ref/verify_16.c +14 -21
- data/vendor/libsodium/src/libsodium/crypto_verify/32/ref/verify_32.c +14 -37
- data/vendor/libsodium/src/libsodium/crypto_verify/64/ref/verify_64.c +14 -69
- data/vendor/libsodium/src/libsodium/include/Makefile.in +1 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_box.h +8 -4
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +4 -2
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h +2 -2
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h +2 -3
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult.h +2 -1
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h +6 -1
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_chacha20.h +5 -0
- data/vendor/libsodium/src/libsodium/include/sodium/randombytes_nativeclient.h +6 -20
- data/vendor/libsodium/src/libsodium/include/sodium/randombytes_salsa20_random.h +1 -28
- data/vendor/libsodium/src/libsodium/include/sodium/randombytes_sysrandom.h +1 -27
- data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/utils.h +6 -0
- data/vendor/libsodium/src/libsodium/randombytes/nativeclient/randombytes_nativeclient.c +3 -3
- data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +58 -51
- data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +23 -18
- data/vendor/libsodium/src/libsodium/sodium/core.c +4 -0
- data/vendor/libsodium/src/libsodium/sodium/runtime.c +34 -15
- data/vendor/libsodium/src/libsodium/sodium/utils.c +104 -14
- data/vendor/libsodium/test/Makefile.in +1 -0
- data/vendor/libsodium/test/default/Makefile.in +1 -0
- data/vendor/libsodium/test/default/auth.c +5 -5
- data/vendor/libsodium/test/default/auth2.c +3 -3
- data/vendor/libsodium/test/default/auth3.c +3 -3
- data/vendor/libsodium/test/default/auth5.c +4 -4
- data/vendor/libsodium/test/default/auth6.c +3 -3
- data/vendor/libsodium/test/default/auth7.c +4 -4
- data/vendor/libsodium/test/default/box.c +13 -9
- data/vendor/libsodium/test/default/box2.c +11 -8
- data/vendor/libsodium/test/default/box7.c +11 -9
- data/vendor/libsodium/test/default/box8.c +32 -19
- data/vendor/libsodium/test/default/box_easy.c +31 -10
- data/vendor/libsodium/test/default/box_easy.exp +3 -19
- data/vendor/libsodium/test/default/box_easy2.c +30 -15
- data/vendor/libsodium/test/default/box_seed.c +1 -1
- data/vendor/libsodium/test/default/cmptest.h +22 -1
- data/vendor/libsodium/test/default/core1.c +6 -5
- data/vendor/libsodium/test/default/core2.c +6 -5
- data/vendor/libsodium/test/default/core3.c +8 -7
- data/vendor/libsodium/test/default/core4.c +11 -8
- data/vendor/libsodium/test/default/core5.c +7 -5
- data/vendor/libsodium/test/default/core6.c +8 -6
- data/vendor/libsodium/test/default/generichash.c +0 -15
- data/vendor/libsodium/test/default/generichash.exp +0 -1
- data/vendor/libsodium/test/default/generichash3.c +1 -21
- data/vendor/libsodium/test/default/generichash3.exp +1 -1
- data/vendor/libsodium/test/default/hash.c +3 -3
- data/vendor/libsodium/test/default/hash3.c +2 -2
- data/vendor/libsodium/test/default/index.html.tpl +84 -0
- data/vendor/libsodium/test/default/onetimeauth.c +3 -3
- data/vendor/libsodium/test/default/onetimeauth2.c +5 -4
- data/vendor/libsodium/test/default/onetimeauth7.c +4 -4
- data/vendor/libsodium/test/default/pre.js.inc +14 -6
- data/vendor/libsodium/test/default/randombytes.c +2 -2
- data/vendor/libsodium/test/default/scalarmult.c +19 -6
- data/vendor/libsodium/test/default/scalarmult.exp +1 -0
- data/vendor/libsodium/test/default/scalarmult2.c +2 -2
- data/vendor/libsodium/test/default/scalarmult5.c +6 -4
- data/vendor/libsodium/test/default/scalarmult6.c +5 -3
- data/vendor/libsodium/test/default/scalarmult7.c +11 -7
- data/vendor/libsodium/test/default/secretbox.c +7 -6
- data/vendor/libsodium/test/default/secretbox2.c +7 -6
- data/vendor/libsodium/test/default/secretbox7.c +5 -5
- data/vendor/libsodium/test/default/secretbox8.c +5 -5
- data/vendor/libsodium/test/default/secretbox_easy.c +27 -17
- data/vendor/libsodium/test/default/secretbox_easy.exp +7 -95
- data/vendor/libsodium/test/default/secretbox_easy2.c +22 -10
- data/vendor/libsodium/test/default/sign.c +5 -0
- data/vendor/libsodium/test/default/sodium_utils.c +73 -0
- data/vendor/libsodium/test/default/sodium_utils.exp +6 -0
- data/vendor/libsodium/test/default/stream.c +7 -6
- data/vendor/libsodium/test/default/stream2.c +4 -4
- data/vendor/libsodium/test/default/stream3.c +6 -5
- data/vendor/libsodium/test/default/stream4.c +7 -6
- data/vendor/libsodium/test/default/verify1.c +61 -18
- data/vendor/libsodium/test/default/verify1.exp +2 -6
- metadata +37 -44
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/cp/api.h +0 -9
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/api.h +0 -9
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/api.h +0 -9
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h +0 -20
- data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/api.h +0 -10
- data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/api.h +0 -10
- data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/api.h +0 -10
- data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/api.h +0 -10
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/api.h +0 -2
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/api.h +0 -10
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/api.h +0 -10
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/api.h +0 -6
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/base_curve25519_donna_c64.c +0 -13
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/api.h +0 -5
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/base_curve25519_ref10.c +0 -14
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/scalarmult_curve25519_ref10.c +0 -54
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519_api.c +0 -14
- data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/ref/api.h +0 -11
- data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/api.h +0 -7
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/api.h +0 -15
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/api.h +0 -12
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/fe25519.h +0 -54
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/fe25519_edwards25519sha512batch.c +0 -348
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/ge25519.h +0 -34
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/ge25519_edwards25519sha512batch.c +0 -230
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sc25519.h +0 -51
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sc25519_edwards25519sha512batch.c +0 -150
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sign_edwards25519sha512batch.c +0 -106
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/sign_edwards25519sha512batch_api.c +0 -16
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/api.h +0 -13
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/amd64_xmm6/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/api.h +0 -5
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/api.h +0 -10
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/api.h +0 -9
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/api.h +0 -11
- data/vendor/libsodium/src/libsodium/crypto_verify/16/ref/api.h +0 -2
- data/vendor/libsodium/src/libsodium/crypto_verify/32/ref/api.h +0 -2
- data/vendor/libsodium/src/libsodium/crypto_verify/64/ref/api.h +0 -2
@@ -1,34 +0,0 @@
|
|
1
|
-
#ifndef GE25519_H
|
2
|
-
#define GE25519_H
|
3
|
-
|
4
|
-
#include "fe25519.h"
|
5
|
-
#include "sc25519.h"
|
6
|
-
|
7
|
-
#define ge25519 crypto_sign_edwards25519sha512batch_ge25519
|
8
|
-
#define ge25519_unpack_vartime crypto_sign_edwards25519sha512batch_ge25519_unpack_vartime
|
9
|
-
#define ge25519_pack crypto_sign_edwards25519sha512batch_ge25519_pack
|
10
|
-
#define ge25519_add crypto_sign_edwards25519sha512batch_ge25519_add
|
11
|
-
#define ge25519_double crypto_sign_edwards25519sha512batch_ge25519_double
|
12
|
-
#define ge25519_scalarmult crypto_sign_edwards25519sha512batch_ge25519_scalarmult
|
13
|
-
#define ge25519_scalarmult_base crypto_sign_edwards25519sha512batch_ge25519_scalarmult_base
|
14
|
-
|
15
|
-
typedef struct {
|
16
|
-
fe25519 x;
|
17
|
-
fe25519 y;
|
18
|
-
fe25519 z;
|
19
|
-
fe25519 t;
|
20
|
-
} ge25519;
|
21
|
-
|
22
|
-
int ge25519_unpack_vartime(ge25519 *r, const unsigned char p[32]);
|
23
|
-
|
24
|
-
void ge25519_pack(unsigned char r[32], const ge25519 *p);
|
25
|
-
|
26
|
-
void ge25519_add(ge25519 *r, const ge25519 *p, const ge25519 *q);
|
27
|
-
|
28
|
-
void ge25519_double(ge25519 *r, const ge25519 *p);
|
29
|
-
|
30
|
-
void ge25519_scalarmult(ge25519 *r, const ge25519 *p, const sc25519 *s);
|
31
|
-
|
32
|
-
void ge25519_scalarmult_base(ge25519 *r, const sc25519 *s);
|
33
|
-
|
34
|
-
#endif
|
@@ -1,230 +0,0 @@
|
|
1
|
-
#include "fe25519.h"
|
2
|
-
#include "sc25519.h"
|
3
|
-
#include "ge25519.h"
|
4
|
-
|
5
|
-
/*
|
6
|
-
* Arithmetic on the twisted Edwards curve -x^2 + y^2 = 1 + dx^2y^2
|
7
|
-
* with d = -(121665/121666) = 37095705934669439343138083508754565189542113879843219016388785533085940283555
|
8
|
-
* Base point: (15112221349535400772501151409588531511454012693041857206046113283949847762202,46316835694926478169428394003475163141307993866256225615783033603165251855960);
|
9
|
-
*/
|
10
|
-
|
11
|
-
typedef struct
|
12
|
-
{
|
13
|
-
fe25519 x;
|
14
|
-
fe25519 z;
|
15
|
-
fe25519 y;
|
16
|
-
fe25519 t;
|
17
|
-
} ge25519_p1p1;
|
18
|
-
|
19
|
-
typedef struct
|
20
|
-
{
|
21
|
-
fe25519 x;
|
22
|
-
fe25519 y;
|
23
|
-
fe25519 z;
|
24
|
-
} ge25519_p2;
|
25
|
-
|
26
|
-
#define ge25519_p3 ge25519
|
27
|
-
|
28
|
-
/* Windowsize for fixed-window scalar multiplication */
|
29
|
-
#define WINDOWSIZE 2 /* Should be 1,2, or 4 */
|
30
|
-
#define WINDOWMASK ((1<<WINDOWSIZE)-1)
|
31
|
-
|
32
|
-
/* packed parameter d in the Edwards curve equation */
|
33
|
-
static const unsigned char ecd[32] = {0xA3, 0x78, 0x59, 0x13, 0xCA, 0x4D, 0xEB, 0x75, 0xAB, 0xD8, 0x41, 0x41, 0x4D, 0x0A, 0x70, 0x00,
|
34
|
-
0x98, 0xE8, 0x79, 0x77, 0x79, 0x40, 0xC7, 0x8C, 0x73, 0xFE, 0x6F, 0x2B, 0xEE, 0x6C, 0x03, 0x52};
|
35
|
-
|
36
|
-
/* Packed coordinates of the base point */
|
37
|
-
static const unsigned char ge25519_base_x[32] = {0x1A, 0xD5, 0x25, 0x8F, 0x60, 0x2D, 0x56, 0xC9, 0xB2, 0xA7, 0x25, 0x95, 0x60, 0xC7, 0x2C, 0x69,
|
38
|
-
0x5C, 0xDC, 0xD6, 0xFD, 0x31, 0xE2, 0xA4, 0xC0, 0xFE, 0x53, 0x6E, 0xCD, 0xD3, 0x36, 0x69, 0x21};
|
39
|
-
static const unsigned char ge25519_base_y[32] = {0x58, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
|
40
|
-
0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66};
|
41
|
-
static const unsigned char ge25519_base_z[32] = {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
42
|
-
static const unsigned char ge25519_base_t[32] = {0xA3, 0xDD, 0xB7, 0xA5, 0xB3, 0x8A, 0xDE, 0x6D, 0xF5, 0x52, 0x51, 0x77, 0x80, 0x9F, 0xF0, 0x20,
|
43
|
-
0x7D, 0xE3, 0xAB, 0x64, 0x8E, 0x4E, 0xEA, 0x66, 0x65, 0x76, 0x8B, 0xD7, 0x0F, 0x5F, 0x87, 0x67};
|
44
|
-
|
45
|
-
/* Packed coordinates of the neutral element */
|
46
|
-
static const unsigned char ge25519_neutral_x[32] = {0};
|
47
|
-
static const unsigned char ge25519_neutral_y[32] = {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
48
|
-
static const unsigned char ge25519_neutral_z[32] = {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
49
|
-
static const unsigned char ge25519_neutral_t[32] = {0};
|
50
|
-
|
51
|
-
static void p1p1_to_p2(ge25519_p2 *r, const ge25519_p1p1 *p)
|
52
|
-
{
|
53
|
-
fe25519_mul(&r->x, &p->x, &p->t);
|
54
|
-
fe25519_mul(&r->y, &p->y, &p->z);
|
55
|
-
fe25519_mul(&r->z, &p->z, &p->t);
|
56
|
-
}
|
57
|
-
|
58
|
-
static void p1p1_to_p3(ge25519_p3 *r, const ge25519_p1p1 *p)
|
59
|
-
{
|
60
|
-
p1p1_to_p2((ge25519_p2 *)r, p);
|
61
|
-
fe25519_mul(&r->t, &p->x, &p->y);
|
62
|
-
}
|
63
|
-
|
64
|
-
/* Constant-time version of: if(b) r = p */
|
65
|
-
static void cmov_p3(ge25519_p3 *r, const ge25519_p3 *p, unsigned char b)
|
66
|
-
{
|
67
|
-
fe25519_cmov(&r->x, &p->x, b);
|
68
|
-
fe25519_cmov(&r->y, &p->y, b);
|
69
|
-
fe25519_cmov(&r->z, &p->z, b);
|
70
|
-
fe25519_cmov(&r->t, &p->t, b);
|
71
|
-
}
|
72
|
-
|
73
|
-
/* See http://www.hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html#doubling-dbl-2008-hwcd */
|
74
|
-
static void dbl_p1p1(ge25519_p1p1 *r, const ge25519_p2 *p)
|
75
|
-
{
|
76
|
-
fe25519 a,b,c,d;
|
77
|
-
fe25519_square(&a, &p->x);
|
78
|
-
fe25519_square(&b, &p->y);
|
79
|
-
fe25519_square(&c, &p->z);
|
80
|
-
fe25519_add(&c, &c, &c);
|
81
|
-
fe25519_neg(&d, &a);
|
82
|
-
|
83
|
-
fe25519_add(&r->x, &p->x, &p->y);
|
84
|
-
fe25519_square(&r->x, &r->x);
|
85
|
-
fe25519_sub(&r->x, &r->x, &a);
|
86
|
-
fe25519_sub(&r->x, &r->x, &b);
|
87
|
-
fe25519_add(&r->z, &d, &b);
|
88
|
-
fe25519_sub(&r->t, &r->z, &c);
|
89
|
-
fe25519_sub(&r->y, &d, &b);
|
90
|
-
}
|
91
|
-
|
92
|
-
static void add_p1p1(ge25519_p1p1 *r, const ge25519_p3 *p, const ge25519_p3 *q)
|
93
|
-
{
|
94
|
-
fe25519 a, b, c, d, t, fd;
|
95
|
-
fe25519_unpack(&fd, ecd);
|
96
|
-
|
97
|
-
fe25519_sub(&a, &p->y, &p->x); // A = (Y1-X1)*(Y2-X2)
|
98
|
-
fe25519_sub(&t, &q->y, &q->x);
|
99
|
-
fe25519_mul(&a, &a, &t);
|
100
|
-
fe25519_add(&b, &p->x, &p->y); // B = (Y1+X1)*(Y2+X2)
|
101
|
-
fe25519_add(&t, &q->x, &q->y);
|
102
|
-
fe25519_mul(&b, &b, &t);
|
103
|
-
fe25519_mul(&c, &p->t, &q->t); //C = T1*k*T2
|
104
|
-
fe25519_mul(&c, &c, &fd);
|
105
|
-
fe25519_add(&c, &c, &c); //XXX: Can save this addition by precomputing 2*ecd
|
106
|
-
fe25519_mul(&d, &p->z, &q->z); //D = Z1*2*Z2
|
107
|
-
fe25519_add(&d, &d, &d);
|
108
|
-
fe25519_sub(&r->x, &b, &a); // E = B-A
|
109
|
-
fe25519_sub(&r->t, &d, &c); // F = D-C
|
110
|
-
fe25519_add(&r->z, &d, &c); // G = D+C
|
111
|
-
fe25519_add(&r->y, &b, &a); // H = B+A
|
112
|
-
}
|
113
|
-
|
114
|
-
/* ********************************************************************
|
115
|
-
* EXPORTED FUNCTIONS
|
116
|
-
******************************************************************** */
|
117
|
-
|
118
|
-
/* return 0 on success, -1 otherwise */
|
119
|
-
int ge25519_unpack_vartime(ge25519_p3 *r, const unsigned char p[32])
|
120
|
-
{
|
121
|
-
int ret;
|
122
|
-
fe25519 t, fd;
|
123
|
-
unsigned char par;
|
124
|
-
|
125
|
-
fe25519_setone(&r->z);
|
126
|
-
fe25519_unpack(&fd, ecd);
|
127
|
-
par = p[31] >> 7;
|
128
|
-
fe25519_unpack(&r->y, p);
|
129
|
-
fe25519_square(&r->x, &r->y);
|
130
|
-
fe25519_mul(&t, &r->x, &fd);
|
131
|
-
fe25519_sub(&r->x, &r->x, &r->z);
|
132
|
-
fe25519_add(&t, &r->z, &t);
|
133
|
-
fe25519_invert(&t, &t);
|
134
|
-
fe25519_mul(&r->x, &r->x, &t);
|
135
|
-
ret = fe25519_sqrt_vartime(&r->x, &r->x, par);
|
136
|
-
fe25519_mul(&r->t, &r->x, &r->y);
|
137
|
-
return ret;
|
138
|
-
}
|
139
|
-
|
140
|
-
void ge25519_pack(unsigned char r[32], const ge25519_p3 *p)
|
141
|
-
{
|
142
|
-
fe25519 tx, ty, zi;
|
143
|
-
fe25519_invert(&zi, &p->z);
|
144
|
-
fe25519_mul(&tx, &p->x, &zi);
|
145
|
-
fe25519_mul(&ty, &p->y, &zi);
|
146
|
-
fe25519_pack(r, &ty);
|
147
|
-
r[31] ^= fe25519_getparity(&tx) << 7;
|
148
|
-
}
|
149
|
-
|
150
|
-
void ge25519_add(ge25519_p3 *r, const ge25519_p3 *p, const ge25519_p3 *q)
|
151
|
-
{
|
152
|
-
ge25519_p1p1 grp1p1;
|
153
|
-
add_p1p1(&grp1p1, p, q);
|
154
|
-
p1p1_to_p3(r, &grp1p1);
|
155
|
-
}
|
156
|
-
|
157
|
-
void ge25519_double(ge25519_p3 *r, const ge25519_p3 *p)
|
158
|
-
{
|
159
|
-
ge25519_p1p1 grp1p1;
|
160
|
-
dbl_p1p1(&grp1p1, (const ge25519_p2 *)p);
|
161
|
-
p1p1_to_p3(r, &grp1p1);
|
162
|
-
}
|
163
|
-
|
164
|
-
void ge25519_scalarmult(ge25519_p3 *r, const ge25519_p3 *p, const sc25519 *s)
|
165
|
-
{
|
166
|
-
int i,j,k;
|
167
|
-
ge25519_p3 g;
|
168
|
-
ge25519_p3 pre[(1 << WINDOWSIZE)];
|
169
|
-
ge25519_p3 t;
|
170
|
-
ge25519_p1p1 tp1p1;
|
171
|
-
unsigned char w;
|
172
|
-
unsigned char sb[32];
|
173
|
-
|
174
|
-
fe25519_unpack(&g.x, ge25519_neutral_x);
|
175
|
-
fe25519_unpack(&g.y, ge25519_neutral_y);
|
176
|
-
fe25519_unpack(&g.z, ge25519_neutral_z);
|
177
|
-
fe25519_unpack(&g.t, ge25519_neutral_t);
|
178
|
-
|
179
|
-
sc25519_to32bytes(sb, s);
|
180
|
-
|
181
|
-
// Precomputation
|
182
|
-
pre[0] = g;
|
183
|
-
pre[1] = *p;
|
184
|
-
for(i=2;i<(1<<WINDOWSIZE);i+=2)
|
185
|
-
{
|
186
|
-
dbl_p1p1(&tp1p1, (ge25519_p2 *)(pre+i/2));
|
187
|
-
p1p1_to_p3(pre+i, &tp1p1);
|
188
|
-
add_p1p1(&tp1p1, pre+i, pre+1);
|
189
|
-
p1p1_to_p3(pre+i+1, &tp1p1);
|
190
|
-
}
|
191
|
-
|
192
|
-
// Fixed-window scalar multiplication
|
193
|
-
for(i=32;i>0;i--)
|
194
|
-
{
|
195
|
-
for(j=8-WINDOWSIZE;j>=0;j-=WINDOWSIZE)
|
196
|
-
{
|
197
|
-
for(k=0;k<WINDOWSIZE-1;k++)
|
198
|
-
{
|
199
|
-
dbl_p1p1(&tp1p1, (ge25519_p2 *)&g);
|
200
|
-
p1p1_to_p2((ge25519_p2 *)&g, &tp1p1);
|
201
|
-
}
|
202
|
-
dbl_p1p1(&tp1p1, (ge25519_p2 *)&g);
|
203
|
-
p1p1_to_p3(&g, &tp1p1);
|
204
|
-
// Cache-timing resistant loading of precomputed value:
|
205
|
-
w = (sb[i-1]>>j) & WINDOWMASK;
|
206
|
-
t = pre[0];
|
207
|
-
for(k=1;k<(1<<WINDOWSIZE);k++)
|
208
|
-
cmov_p3(&t, &pre[k], k==w);
|
209
|
-
|
210
|
-
add_p1p1(&tp1p1, &g, &t);
|
211
|
-
if(j != 0) p1p1_to_p2((ge25519_p2 *)&g, &tp1p1);
|
212
|
-
else p1p1_to_p3(&g, &tp1p1); /* convert to p3 representation at the end */
|
213
|
-
}
|
214
|
-
}
|
215
|
-
r->x = g.x;
|
216
|
-
r->y = g.y;
|
217
|
-
r->z = g.z;
|
218
|
-
r->t = g.t;
|
219
|
-
}
|
220
|
-
|
221
|
-
void ge25519_scalarmult_base(ge25519_p3 *r, const sc25519 *s)
|
222
|
-
{
|
223
|
-
/* XXX: Better algorithm for known-base-point scalar multiplication */
|
224
|
-
ge25519_p3 t;
|
225
|
-
fe25519_unpack(&t.x, ge25519_base_x);
|
226
|
-
fe25519_unpack(&t.y, ge25519_base_y);
|
227
|
-
fe25519_unpack(&t.z, ge25519_base_z);
|
228
|
-
fe25519_unpack(&t.t, ge25519_base_t);
|
229
|
-
ge25519_scalarmult(r, &t, s);
|
230
|
-
}
|
@@ -1,51 +0,0 @@
|
|
1
|
-
#ifndef SC25519_H
|
2
|
-
#define SC25519_H
|
3
|
-
|
4
|
-
#define sc25519 crypto_sign_edwards25519sha512batch_sc25519
|
5
|
-
#define sc25519_from32bytes crypto_sign_edwards25519sha512batch_sc25519_from32bytes
|
6
|
-
#define sc25519_from64bytes crypto_sign_edwards25519sha512batch_sc25519_from64bytes
|
7
|
-
#define sc25519_to32bytes crypto_sign_edwards25519sha512batch_sc25519_to32bytes
|
8
|
-
#define sc25519_pack crypto_sign_edwards25519sha512batch_sc25519_pack
|
9
|
-
#define sc25519_getparity crypto_sign_edwards25519sha512batch_sc25519_getparity
|
10
|
-
#define sc25519_setone crypto_sign_edwards25519sha512batch_sc25519_setone
|
11
|
-
#define sc25519_setzero crypto_sign_edwards25519sha512batch_sc25519_setzero
|
12
|
-
#define sc25519_neg crypto_sign_edwards25519sha512batch_sc25519_neg
|
13
|
-
#define sc25519_add crypto_sign_edwards25519sha512batch_sc25519_add
|
14
|
-
#define sc25519_sub crypto_sign_edwards25519sha512batch_sc25519_sub
|
15
|
-
#define sc25519_mul crypto_sign_edwards25519sha512batch_sc25519_mul
|
16
|
-
#define sc25519_square crypto_sign_edwards25519sha512batch_sc25519_square
|
17
|
-
#define sc25519_invert crypto_sign_edwards25519sha512batch_sc25519_invert
|
18
|
-
|
19
|
-
#include "crypto_uint32.h"
|
20
|
-
|
21
|
-
typedef struct {
|
22
|
-
crypto_uint32 v[32];
|
23
|
-
} sc25519;
|
24
|
-
|
25
|
-
void sc25519_from32bytes(sc25519 *r, const unsigned char x[32]);
|
26
|
-
|
27
|
-
void sc25519_from64bytes(sc25519 *r, const unsigned char x[64]);
|
28
|
-
|
29
|
-
void sc25519_to32bytes(unsigned char r[32], const sc25519 *x);
|
30
|
-
|
31
|
-
void sc25519_pack(unsigned char r[32], const sc25519 *x);
|
32
|
-
|
33
|
-
unsigned char sc25519_getparity(const sc25519 *x);
|
34
|
-
|
35
|
-
void sc25519_setone(sc25519 *r);
|
36
|
-
|
37
|
-
void sc25519_setzero(sc25519 *r);
|
38
|
-
|
39
|
-
void sc25519_neg(sc25519 *r, const sc25519 *x);
|
40
|
-
|
41
|
-
void sc25519_add(sc25519 *r, const sc25519 *x, const sc25519 *y);
|
42
|
-
|
43
|
-
void sc25519_sub(sc25519 *r, const sc25519 *x, const sc25519 *y);
|
44
|
-
|
45
|
-
void sc25519_mul(sc25519 *r, const sc25519 *x, const sc25519 *y);
|
46
|
-
|
47
|
-
void sc25519_square(sc25519 *r, const sc25519 *x);
|
48
|
-
|
49
|
-
void sc25519_invert(sc25519 *r, const sc25519 *x);
|
50
|
-
|
51
|
-
#endif
|
@@ -1,150 +0,0 @@
|
|
1
|
-
#include "sc25519.h"
|
2
|
-
|
3
|
-
/*Arithmetic modulo the group order n = 2^252 + 27742317777372353535851937790883648493 = 7237005577332262213973186563042994240857116359379907606001950938285454250989 */
|
4
|
-
|
5
|
-
static const crypto_uint32 m[32] = {0xED, 0xD3, 0xF5, 0x5C, 0x1A, 0x63, 0x12, 0x58, 0xD6, 0x9C, 0xF7, 0xA2, 0xDE, 0xF9, 0xDE, 0x14,
|
6
|
-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10};
|
7
|
-
|
8
|
-
static const crypto_uint32 mu[33] = {0x1B, 0x13, 0x2C, 0x0A, 0xA3, 0xE5, 0x9C, 0xED, 0xA7, 0x29, 0x63, 0x08, 0x5D, 0x21, 0x06, 0x21,
|
9
|
-
0xEB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F};
|
10
|
-
|
11
|
-
/* Reduce coefficients of r before calling reduce_add_sub */
|
12
|
-
static void reduce_add_sub(sc25519 *r)
|
13
|
-
{
|
14
|
-
int i, b, pb=0, nb;
|
15
|
-
unsigned char t[32];
|
16
|
-
|
17
|
-
for(i=0;i<32;i++)
|
18
|
-
{
|
19
|
-
b = (r->v[i]<pb+m[i]);
|
20
|
-
t[i] = r->v[i]-pb-m[i]+b*256;
|
21
|
-
pb = b;
|
22
|
-
}
|
23
|
-
nb = 1-b;
|
24
|
-
for(i=0;i<32;i++)
|
25
|
-
r->v[i] = r->v[i]*b + t[i]*nb;
|
26
|
-
}
|
27
|
-
|
28
|
-
/* Reduce coefficients of x before calling barrett_reduce */
|
29
|
-
static void barrett_reduce(sc25519 *r, const crypto_uint32 x[64])
|
30
|
-
{
|
31
|
-
/* See HAC, Alg. 14.42 */
|
32
|
-
int i,j;
|
33
|
-
crypto_uint32 q2[66] = {0};
|
34
|
-
crypto_uint32 *q3 = q2 + 33;
|
35
|
-
crypto_uint32 r1[33];
|
36
|
-
crypto_uint32 r2[33] = {0};
|
37
|
-
crypto_uint32 carry;
|
38
|
-
int b, pb=0;
|
39
|
-
|
40
|
-
for(i=0;i<33;i++)
|
41
|
-
for(j=0;j<33;j++)
|
42
|
-
if(i+j >= 31) q2[i+j] += mu[i]*x[j+31];
|
43
|
-
carry = q2[31] >> 8;
|
44
|
-
q2[32] += carry;
|
45
|
-
carry = q2[32] >> 8;
|
46
|
-
q2[33] += carry;
|
47
|
-
|
48
|
-
for(i=0;i<33;i++)r1[i] = x[i];
|
49
|
-
for(i=0;i<32;i++) {
|
50
|
-
for(j=0;j<33;j++) {
|
51
|
-
if(i+j < 33) {
|
52
|
-
/* coverity[overrun-local] */
|
53
|
-
r2[i+j] += m[i]*q3[j];
|
54
|
-
}
|
55
|
-
}
|
56
|
-
}
|
57
|
-
for(i=0;i<32;i++)
|
58
|
-
{
|
59
|
-
carry = r2[i] >> 8;
|
60
|
-
r2[i+1] += carry;
|
61
|
-
r2[i] &= 0xff;
|
62
|
-
}
|
63
|
-
|
64
|
-
for(i=0;i<32;i++)
|
65
|
-
{
|
66
|
-
b = (r1[i]<pb+r2[i]);
|
67
|
-
r->v[i] = r1[i]-pb-r2[i]+b*256;
|
68
|
-
pb = b;
|
69
|
-
}
|
70
|
-
|
71
|
-
/* XXX: Can it really happen that r<0?, See HAC, Alg 14.42, Step 3
|
72
|
-
* If so: Handle it here!
|
73
|
-
*/
|
74
|
-
|
75
|
-
reduce_add_sub(r);
|
76
|
-
reduce_add_sub(r);
|
77
|
-
}
|
78
|
-
|
79
|
-
/*
|
80
|
-
static int iszero(const sc25519 *x)
|
81
|
-
{
|
82
|
-
// Implement
|
83
|
-
return 0;
|
84
|
-
}
|
85
|
-
*/
|
86
|
-
|
87
|
-
void sc25519_from32bytes(sc25519 *r, const unsigned char x[32])
|
88
|
-
{
|
89
|
-
int i;
|
90
|
-
crypto_uint32 t[64] = {0};
|
91
|
-
for(i=0;i<32;i++) t[i] = x[i];
|
92
|
-
barrett_reduce(r, t);
|
93
|
-
}
|
94
|
-
|
95
|
-
void sc25519_from64bytes(sc25519 *r, const unsigned char x[64])
|
96
|
-
{
|
97
|
-
int i;
|
98
|
-
crypto_uint32 t[64] = {0};
|
99
|
-
for(i=0;i<64;i++) t[i] = x[i];
|
100
|
-
barrett_reduce(r, t);
|
101
|
-
}
|
102
|
-
|
103
|
-
/* XXX: What we actually want for crypto_group is probably just something like
|
104
|
-
* void sc25519_frombytes(sc25519 *r, const unsigned char *x, size_t xlen)
|
105
|
-
*/
|
106
|
-
|
107
|
-
void sc25519_to32bytes(unsigned char r[32], const sc25519 *x)
|
108
|
-
{
|
109
|
-
int i;
|
110
|
-
for(i=0;i<32;i++) r[i] = x->v[i];
|
111
|
-
}
|
112
|
-
|
113
|
-
void sc25519_add(sc25519 *r, const sc25519 *x, const sc25519 *y)
|
114
|
-
{
|
115
|
-
int i, carry;
|
116
|
-
for(i=0;i<32;i++) r->v[i] = x->v[i] + y->v[i];
|
117
|
-
for(i=0;i<31;i++)
|
118
|
-
{
|
119
|
-
carry = r->v[i] >> 8;
|
120
|
-
r->v[i+1] += carry;
|
121
|
-
r->v[i] &= 0xff;
|
122
|
-
}
|
123
|
-
reduce_add_sub(r);
|
124
|
-
}
|
125
|
-
|
126
|
-
void sc25519_mul(sc25519 *r, const sc25519 *x, const sc25519 *y)
|
127
|
-
{
|
128
|
-
int i,j,carry;
|
129
|
-
crypto_uint32 t[64];
|
130
|
-
for(i=0;i<64;i++)t[i] = 0;
|
131
|
-
|
132
|
-
for(i=0;i<32;i++)
|
133
|
-
for(j=0;j<32;j++)
|
134
|
-
t[i+j] += x->v[i] * y->v[j];
|
135
|
-
|
136
|
-
/* Reduce coefficients */
|
137
|
-
for(i=0;i<63;i++)
|
138
|
-
{
|
139
|
-
carry = t[i] >> 8;
|
140
|
-
t[i+1] += carry;
|
141
|
-
t[i] &= 0xff;
|
142
|
-
}
|
143
|
-
|
144
|
-
barrett_reduce(r, t);
|
145
|
-
}
|
146
|
-
|
147
|
-
void sc25519_square(sc25519 *r, const sc25519 *x)
|
148
|
-
{
|
149
|
-
sc25519_mul(r, x, x);
|
150
|
-
}
|