rbnacl-libsodium 0.4.5a
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +35 -0
- data/.gitmodules +3 -0
- data/CHANGES.md +3 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +23 -0
- data/Rakefile +1 -0
- data/ext/rbnacl/extconf.rb +30 -0
- data/lib/rbnacl/libsodium.rb +11 -0
- data/lib/rbnacl/libsodium/version.rb +5 -0
- data/rbnacl-libsodium.gemspec +25 -0
- data/vendor/libsodium/AUTHORS +101 -0
- data/vendor/libsodium/ChangeLog +68 -0
- data/vendor/libsodium/LICENSE +16 -0
- data/vendor/libsodium/Makefile.am +20 -0
- data/vendor/libsodium/README +1 -0
- data/vendor/libsodium/README.markdown +246 -0
- data/vendor/libsodium/THANKS +17 -0
- data/vendor/libsodium/autogen.sh +16 -0
- data/vendor/libsodium/configure.ac +405 -0
- data/vendor/libsodium/dist-build/android.sh +48 -0
- data/vendor/libsodium/dist-build/iphone.sh +16 -0
- data/vendor/libsodium/dist-build/msys.sh +9 -0
- data/vendor/libsodium/libsodium.pc.in +11 -0
- data/vendor/libsodium/libsodium.sln +38 -0
- data/vendor/libsodium/libsodium.vcxproj +508 -0
- data/vendor/libsodium/libsodium.vcxproj.filters +569 -0
- data/vendor/libsodium/logo.png +0 -0
- data/vendor/libsodium/m4/ax_check_compile_flag.m4 +73 -0
- data/vendor/libsodium/m4/ax_check_gnu_make.m4 +78 -0
- data/vendor/libsodium/m4/ax_check_link_flag.m4 +72 -0
- data/vendor/libsodium/m4/ld-output-def.m4 +29 -0
- data/vendor/libsodium/m4/pkg.m4 +214 -0
- data/vendor/libsodium/msvc-scripts/Makefile.am +4 -0
- data/vendor/libsodium/msvc-scripts/process.bat +8 -0
- data/vendor/libsodium/msvc-scripts/rep.vbs +12 -0
- data/vendor/libsodium/msvc-scripts/sodium.props +25 -0
- data/vendor/libsodium/src/Makefile.am +3 -0
- data/vendor/libsodium/src/libsodium/Makefile.am +232 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/crypto_auth.c +34 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/auth_hmacsha256_api.c +16 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/ref/api.h +10 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/ref/hmac_hmacsha256.c +83 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/ref/verify_hmacsha256.c +9 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/auth_hmacsha512256_api.c +16 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/ref/api.h +10 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/ref/hmac_hmacsha512256.c +86 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/ref/verify_hmacsha512256.c +9 -0
- data/vendor/libsodium/src/libsodium/crypto_auth/try.c +119 -0
- data/vendor/libsodium/src/libsodium/crypto_box/crypto_box.c +95 -0
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305_api.c +41 -0
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/after_curve25519xsalsa20poly1305.c +22 -0
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h +19 -0
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c +19 -0
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/box_curve25519xsalsa20poly1305.c +27 -0
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c +12 -0
- data/vendor/libsodium/src/libsodium/crypto_box/try.c +195 -0
- data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/core_hsalsa20_api.c +26 -0
- data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/api.h +11 -0
- data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20.c +108 -0
- data/vendor/libsodium/src/libsodium/crypto_core/salsa20/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_core/salsa20/core_salsa20_api.c +26 -0
- data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/api.h +11 -0
- data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/core_salsa20.c +134 -0
- data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/core_salsa2012_api.c +26 -0
- data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/api.h +11 -0
- data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/core_salsa2012.c +134 -0
- data/vendor/libsodium/src/libsodium/crypto_core/salsa208/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_core/salsa208/core_salsa208_api.c +26 -0
- data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/api.h +11 -0
- data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/core_salsa208.c +134 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c +31 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/api.h +4 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2-impl.h +132 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h +169 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +364 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2s-ref.c +355 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/generichash_blake2b.c +61 -0
- data/vendor/libsodium/src/libsodium/crypto_generichash/crypto_generichash.c +84 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/crypto_hash.c +9 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/hash_sha256_api.c +11 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/ref/api.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/ref/hash_sha256.c +69 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/hash_sha512_api.c +11 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/ref/api.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/ref/hash_sha512.c +71 -0
- data/vendor/libsodium/src/libsodium/crypto_hash/try.c +76 -0
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha256/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha256/hashblocks_sha256_api.c +16 -0
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha256/ref/api.h +9 -0
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha256/ref/blocks_sha256.c +212 -0
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha512/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha512/hashblocks_sha512_api.c +16 -0
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha512/ref/api.h +9 -0
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/sha512/ref/blocks_sha512.c +239 -0
- data/vendor/libsodium/src/libsodium/crypto_hashblocks/try.c +78 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/crypto_onetimeauth.c +34 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/53/api.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/53/auth_poly1305_53.c +1661 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/53/verify_poly1305_53.c +10 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/api.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/auth_poly1305_donna.c +151 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/portable-jane.h +772 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/verify_poly1305_donna.c +10 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c +36 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_api.c +16 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305_try.c +152 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/crypto_scalarmult.c +34 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/api.h +9 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/base_curve25519_donna_c64.c +13 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/smult_curve25519_donna_c64.c +426 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref/api.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref/base_curve25519_ref.c +20 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref/smult_curve25519_ref.c +268 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519_api.c +14 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/try.c +125 -0
- data/vendor/libsodium/src/libsodium/crypto_secretbox/crypto_secretbox.c +48 -0
- data/vendor/libsodium/src/libsodium/crypto_secretbox/try.c +129 -0
- data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/ref/api.h +12 -0
- data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/ref/box_xsalsa20poly1305.c +35 -0
- data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305_api.c +26 -0
- data/vendor/libsodium/src/libsodium/crypto_shorthash/crypto_shorthash.c +27 -0
- data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/api.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash24.c +91 -0
- data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/shorthash_siphash24_api.c +11 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/crypto_sign.c +61 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/description +1 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/api.h +14 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/base.h +1344 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/base2.h +40 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/d.h +1 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/d2.h +1 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe.h +56 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_0.c +19 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_1.c +19 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_add.c +57 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_cmov.c +63 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_copy.c +29 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_frombytes.c +73 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_invert.c +14 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_isnegative.c +16 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_isnonzero.c +19 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_mul.c +253 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_neg.c +45 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_pow22523.c +13 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_sq.c +149 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_sq2.c +160 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_sub.c +57 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_tobytes.c +119 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge.h +95 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_add.c +11 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_add.h +97 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_double_scalarmult.c +96 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_frombytes.c +50 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_madd.c +11 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_madd.h +88 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_msub.c +11 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_msub.h +88 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p1p1_to_p2.c +12 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p1p1_to_p3.c +13 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p2_0.c +8 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p2_dbl.c +11 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p2_dbl.h +73 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_0.c +9 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_dbl.c +12 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_to_cached.c +17 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_to_p2.c +12 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_tobytes.c +14 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_precomp_0.c +8 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_scalarmult_base.c +105 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_sub.c +11 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_sub.h +97 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_tobytes.c +14 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +31 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +40 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/pow22523.h +160 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/pow225521.h +160 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sc.h +15 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sc_muladd.c +368 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sc_reduce.c +275 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sign.c +38 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sqrtm1.h +1 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/sign_ed25519_api.c +26 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/api.h +13 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/fe25519.h +54 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/fe25519_edwards25519sha512batch.c +348 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/ge25519.h +34 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/ge25519_edwards25519sha512batch.c +230 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sc25519.h +51 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sc25519_edwards25519sha512batch.c +146 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sign_edwards25519sha512batch.c +102 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/sign_edwards25519sha512batch_api.c +21 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/try.c +87 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/afternm_aes128ctr.c +159 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/api.h +14 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/beforenm_aes128ctr.c +59 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/common.h +788 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/common_aes128ctr.c +64 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/consts.h +28 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/consts_aes128ctr.c +14 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128.h +47 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/int128_aes128ctr.c +131 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/stream_aes128ctr.c +28 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/types.h +10 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/xor_afternm_aes128ctr.c +181 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/stream_aes128ctr_api.c +21 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes-table-be.h +274 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes-table-le.h +274 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes-table.h +56 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes256-ctr.c +238 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/aes256.h +171 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/api.h +14 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/hongjun/ecrypt-sync.h +27 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/aes256estream/stream_aes256estream_api.c +21 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/crypto_stream.c +36 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/amd64_xmm6/api.h +1 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.S +950 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/api.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20_ref.c +55 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c +58 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20_api.c +16 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/api.h +11 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c +51 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c +54 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/stream_salsa2012_api.c +16 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/api.h +10 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c +51 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c +54 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/stream_salsa208_api.c +16 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/try.c +122 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/api.h +11 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c +24 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c +25 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/stream_xsalsa20_api.c +16 -0
- data/vendor/libsodium/src/libsodium/crypto_verify/16/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_verify/16/ref/api.h +2 -0
- data/vendor/libsodium/src/libsodium/crypto_verify/16/ref/verify_16.c +24 -0
- data/vendor/libsodium/src/libsodium/crypto_verify/16/verify_16_api.c +6 -0
- data/vendor/libsodium/src/libsodium/crypto_verify/32/checksum +1 -0
- data/vendor/libsodium/src/libsodium/crypto_verify/32/ref/api.h +2 -0
- data/vendor/libsodium/src/libsodium/crypto_verify/32/ref/verify_32.c +40 -0
- data/vendor/libsodium/src/libsodium/crypto_verify/32/verify_32_api.c +6 -0
- data/vendor/libsodium/src/libsodium/crypto_verify/try.c +76 -0
- data/vendor/libsodium/src/libsodium/include/Makefile.am +63 -0
- data/vendor/libsodium/src/libsodium/include/sodium.h +48 -0
- data/vendor/libsodium/src/libsodium/include/sodium/core.h +18 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth.h +36 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha256.h +36 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512256.h +36 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_box.h +83 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +72 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_hsalsa20.h +40 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_salsa20.h +40 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_salsa2012.h +40 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_core_salsa208.h +40 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash.h +70 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h +87 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash.h +23 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha256.h +29 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_hash_sha512.h +29 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_hashblocks_sha256.h +32 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_hashblocks_sha512.h +32 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_int32.h +8 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_int64.h +8 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth.h +37 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h +65 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_53.h +34 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305_donna.h +34 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult.h +36 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h.in +44 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox.h +47 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_secretbox_xsalsa20poly1305.h +44 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_shorthash.h +33 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_shorthash_siphash24.h +29 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign.h +61 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_ed25519.h +52 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_sign_edwards25519sha512batch.h +44 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream.h +46 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes128ctr.h +60 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_aes256estream.h +61 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa20.h.in +54 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa2012.h +43 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_salsa208.h +43 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_xsalsa20.h +44 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_uint16.h +8 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_uint32.h +8 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_uint64.h +8 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_uint8.h +8 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_verify_16.h +25 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_verify_32.h +25 -0
- data/vendor/libsodium/src/libsodium/include/sodium/export.h +32 -0
- data/vendor/libsodium/src/libsodium/include/sodium/randombytes.h +53 -0
- data/vendor/libsodium/src/libsodium/include/sodium/randombytes_salsa20_random.h +45 -0
- data/vendor/libsodium/src/libsodium/include/sodium/randombytes_sysrandom.h +45 -0
- data/vendor/libsodium/src/libsodium/include/sodium/utils.h +36 -0
- data/vendor/libsodium/src/libsodium/include/sodium/version.h.in +29 -0
- data/vendor/libsodium/src/libsodium/randombytes/randombytes.c +63 -0
- data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +317 -0
- data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +212 -0
- data/vendor/libsodium/src/libsodium/sodium/compat.c +248 -0
- data/vendor/libsodium/src/libsodium/sodium/core.c +21 -0
- data/vendor/libsodium/src/libsodium/sodium/utils.c +94 -0
- data/vendor/libsodium/src/libsodium/sodium/version.c +20 -0
- data/vendor/libsodium/test/Makefile.am +5 -0
- data/vendor/libsodium/test/default/Makefile.am +277 -0
- data/vendor/libsodium/test/default/auth.c +21 -0
- data/vendor/libsodium/test/default/auth.exp +4 -0
- data/vendor/libsodium/test/default/auth2.c +36 -0
- data/vendor/libsodium/test/default/auth2.exp +4 -0
- data/vendor/libsodium/test/default/auth3.c +36 -0
- data/vendor/libsodium/test/default/auth3.exp +1 -0
- data/vendor/libsodium/test/default/auth5.c +37 -0
- data/vendor/libsodium/test/default/auth5.exp +0 -0
- data/vendor/libsodium/test/default/box.c +65 -0
- data/vendor/libsodium/test/default/box.exp +19 -0
- data/vendor/libsodium/test/default/box2.c +66 -0
- data/vendor/libsodium/test/default/box2.exp +17 -0
- data/vendor/libsodium/test/default/box7.c +37 -0
- data/vendor/libsodium/test/default/box7.exp +0 -0
- data/vendor/libsodium/test/default/box8.c +44 -0
- data/vendor/libsodium/test/default/box8.exp +0 -0
- data/vendor/libsodium/test/default/cmptest.h +51 -0
- data/vendor/libsodium/test/default/core1.c +32 -0
- data/vendor/libsodium/test/default/core1.exp +4 -0
- data/vendor/libsodium/test/default/core2.c +35 -0
- data/vendor/libsodium/test/default/core2.exp +4 -0
- data/vendor/libsodium/test/default/core3.c +42 -0
- data/vendor/libsodium/test/default/core3.exp +1 -0
- data/vendor/libsodium/test/default/core4.c +35 -0
- data/vendor/libsodium/test/default/core4.exp +8 -0
- data/vendor/libsodium/test/default/core5.c +34 -0
- data/vendor/libsodium/test/default/core5.exp +4 -0
- data/vendor/libsodium/test/default/core6.c +49 -0
- data/vendor/libsodium/test/default/core6.exp +4 -0
- data/vendor/libsodium/test/default/generichash.c +27 -0
- data/vendor/libsodium/test/default/generichash.exp +64 -0
- data/vendor/libsodium/test/default/generichash2.c +31 -0
- data/vendor/libsodium/test/default/generichash2.exp +64 -0
- data/vendor/libsodium/test/default/hash.c +16 -0
- data/vendor/libsodium/test/default/hash.exp +1 -0
- data/vendor/libsodium/test/default/hash2.exp +1 -0
- data/vendor/libsodium/test/default/hash3.c +16 -0
- data/vendor/libsodium/test/default/hash3.exp +1 -0
- data/vendor/libsodium/test/default/onetimeauth.c +44 -0
- data/vendor/libsodium/test/default/onetimeauth.exp +2 -0
- data/vendor/libsodium/test/default/onetimeauth2.c +42 -0
- data/vendor/libsodium/test/default/onetimeauth2.exp +1 -0
- data/vendor/libsodium/test/default/onetimeauth7.c +37 -0
- data/vendor/libsodium/test/default/onetimeauth7.exp +0 -0
- data/vendor/libsodium/test/default/pre.js +33 -0
- data/vendor/libsodium/test/default/randombytes.c +16 -0
- data/vendor/libsodium/test/default/scalarmult.c +25 -0
- data/vendor/libsodium/test/default/scalarmult.exp +4 -0
- data/vendor/libsodium/test/default/scalarmult2.c +25 -0
- data/vendor/libsodium/test/default/scalarmult2.exp +4 -0
- data/vendor/libsodium/test/default/scalarmult5.c +32 -0
- data/vendor/libsodium/test/default/scalarmult5.exp +4 -0
- data/vendor/libsodium/test/default/scalarmult6.c +32 -0
- data/vendor/libsodium/test/default/scalarmult6.exp +4 -0
- data/vendor/libsodium/test/default/scalarmult7.c +34 -0
- data/vendor/libsodium/test/default/scalarmult7.exp +1 -0
- data/vendor/libsodium/test/default/scalarmult8.c +34 -0
- data/vendor/libsodium/test/default/scalarmult8.exp +1 -0
- data/vendor/libsodium/test/default/secretbox.c +58 -0
- data/vendor/libsodium/test/default/secretbox.exp +19 -0
- data/vendor/libsodium/test/default/secretbox2.c +59 -0
- data/vendor/libsodium/test/default/secretbox2.exp +17 -0
- data/vendor/libsodium/test/default/secretbox7.c +33 -0
- data/vendor/libsodium/test/default/secretbox7.exp +0 -0
- data/vendor/libsodium/test/default/secretbox8.c +40 -0
- data/vendor/libsodium/test/default/secretbox8.exp +0 -0
- data/vendor/libsodium/test/default/shorthash.c +23 -0
- data/vendor/libsodium/test/default/shorthash.exp +64 -0
- data/vendor/libsodium/test/default/sodium_core.c +11 -0
- data/vendor/libsodium/test/default/sodium_core.exp +1 -0
- data/vendor/libsodium/test/default/sodium_utils.c +27 -0
- data/vendor/libsodium/test/default/sodium_utils.exp +6 -0
- data/vendor/libsodium/test/default/sodium_version.c +13 -0
- data/vendor/libsodium/test/default/sodium_version.exp +3 -0
- data/vendor/libsodium/test/default/stream.c +30 -0
- data/vendor/libsodium/test/default/stream.exp +1 -0
- data/vendor/libsodium/test/default/stream2.c +28 -0
- data/vendor/libsodium/test/default/stream2.exp +1 -0
- data/vendor/libsodium/test/default/stream3.c +30 -0
- data/vendor/libsodium/test/default/stream3.exp +4 -0
- data/vendor/libsodium/test/default/stream4.c +55 -0
- data/vendor/libsodium/test/default/stream4.exp +17 -0
- data/vendor/libsodium/test/default/stream5.c +29 -0
- data/vendor/libsodium/test/default/stream5.exp +1 -0
- data/vendor/libsodium/test/default/stream6.c +54 -0
- data/vendor/libsodium/test/default/stream6.exp +17 -0
- data/vendor/libsodium/test/default/wintest.bat +56 -0
- data/vendor/libsodium/test/quirks/windows/windows-quirks.h +18 -0
- metadata +500 -0
@@ -0,0 +1,34 @@
|
|
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
|
@@ -0,0 +1,230 @@
|
|
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
|
+
}
|
@@ -0,0 +1,51 @@
|
|
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
|
@@ -0,0 +1,146 @@
|
|
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) r2[i+j] += m[i]*q3[j];
|
52
|
+
|
53
|
+
for(i=0;i<32;i++)
|
54
|
+
{
|
55
|
+
carry = r2[i] >> 8;
|
56
|
+
r2[i+1] += carry;
|
57
|
+
r2[i] &= 0xff;
|
58
|
+
}
|
59
|
+
|
60
|
+
for(i=0;i<32;i++)
|
61
|
+
{
|
62
|
+
b = (r1[i]<pb+r2[i]);
|
63
|
+
r->v[i] = r1[i]-pb-r2[i]+b*256;
|
64
|
+
pb = b;
|
65
|
+
}
|
66
|
+
|
67
|
+
/* XXX: Can it really happen that r<0?, See HAC, Alg 14.42, Step 3
|
68
|
+
* If so: Handle it here!
|
69
|
+
*/
|
70
|
+
|
71
|
+
reduce_add_sub(r);
|
72
|
+
reduce_add_sub(r);
|
73
|
+
}
|
74
|
+
|
75
|
+
/*
|
76
|
+
static int iszero(const sc25519 *x)
|
77
|
+
{
|
78
|
+
// Implement
|
79
|
+
return 0;
|
80
|
+
}
|
81
|
+
*/
|
82
|
+
|
83
|
+
void sc25519_from32bytes(sc25519 *r, const unsigned char x[32])
|
84
|
+
{
|
85
|
+
int i;
|
86
|
+
crypto_uint32 t[64] = {0};
|
87
|
+
for(i=0;i<32;i++) t[i] = x[i];
|
88
|
+
barrett_reduce(r, t);
|
89
|
+
}
|
90
|
+
|
91
|
+
void sc25519_from64bytes(sc25519 *r, const unsigned char x[64])
|
92
|
+
{
|
93
|
+
int i;
|
94
|
+
crypto_uint32 t[64] = {0};
|
95
|
+
for(i=0;i<64;i++) t[i] = x[i];
|
96
|
+
barrett_reduce(r, t);
|
97
|
+
}
|
98
|
+
|
99
|
+
/* XXX: What we actually want for crypto_group is probably just something like
|
100
|
+
* void sc25519_frombytes(sc25519 *r, const unsigned char *x, size_t xlen)
|
101
|
+
*/
|
102
|
+
|
103
|
+
void sc25519_to32bytes(unsigned char r[32], const sc25519 *x)
|
104
|
+
{
|
105
|
+
int i;
|
106
|
+
for(i=0;i<32;i++) r[i] = x->v[i];
|
107
|
+
}
|
108
|
+
|
109
|
+
void sc25519_add(sc25519 *r, const sc25519 *x, const sc25519 *y)
|
110
|
+
{
|
111
|
+
int i, carry;
|
112
|
+
for(i=0;i<32;i++) r->v[i] = x->v[i] + y->v[i];
|
113
|
+
for(i=0;i<31;i++)
|
114
|
+
{
|
115
|
+
carry = r->v[i] >> 8;
|
116
|
+
r->v[i+1] += carry;
|
117
|
+
r->v[i] &= 0xff;
|
118
|
+
}
|
119
|
+
reduce_add_sub(r);
|
120
|
+
}
|
121
|
+
|
122
|
+
void sc25519_mul(sc25519 *r, const sc25519 *x, const sc25519 *y)
|
123
|
+
{
|
124
|
+
int i,j,carry;
|
125
|
+
crypto_uint32 t[64];
|
126
|
+
for(i=0;i<64;i++)t[i] = 0;
|
127
|
+
|
128
|
+
for(i=0;i<32;i++)
|
129
|
+
for(j=0;j<32;j++)
|
130
|
+
t[i+j] += x->v[i] * y->v[j];
|
131
|
+
|
132
|
+
/* Reduce coefficients */
|
133
|
+
for(i=0;i<63;i++)
|
134
|
+
{
|
135
|
+
carry = t[i] >> 8;
|
136
|
+
t[i+1] += carry;
|
137
|
+
t[i] &= 0xff;
|
138
|
+
}
|
139
|
+
|
140
|
+
barrett_reduce(r, t);
|
141
|
+
}
|
142
|
+
|
143
|
+
void sc25519_square(sc25519 *r, const sc25519 *x)
|
144
|
+
{
|
145
|
+
sc25519_mul(r, x, x);
|
146
|
+
}
|