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,10 @@
|
|
1
|
+
#include "api.h"
|
2
|
+
#include "crypto_onetimeauth_poly1305_donna.h"
|
3
|
+
#include "crypto_verify_16.h"
|
4
|
+
|
5
|
+
int crypto_onetimeauth_verify(const unsigned char *h,const unsigned char *in,unsigned long long inlen,const unsigned char *k)
|
6
|
+
{
|
7
|
+
unsigned char correct[16];
|
8
|
+
crypto_onetimeauth(correct,in,inlen,k);
|
9
|
+
return crypto_verify_16(h,correct);
|
10
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
#include "crypto_onetimeauth_poly1305.h"
|
3
|
+
#include "crypto_onetimeauth_poly1305_donna.h"
|
4
|
+
|
5
|
+
static const crypto_onetimeauth_poly1305_implementation *implementation =
|
6
|
+
&crypto_onetimeauth_poly1305_donna_implementation;
|
7
|
+
|
8
|
+
int
|
9
|
+
crypto_onetimeauth_poly1305_set_implementation(crypto_onetimeauth_poly1305_implementation *impl)
|
10
|
+
{
|
11
|
+
implementation = impl;
|
12
|
+
|
13
|
+
return 0;
|
14
|
+
}
|
15
|
+
|
16
|
+
const char *
|
17
|
+
crypto_onetimeauth_poly1305_implementation_name(void)
|
18
|
+
{
|
19
|
+
return implementation->implementation_name();
|
20
|
+
}
|
21
|
+
|
22
|
+
int
|
23
|
+
crypto_onetimeauth_poly1305(unsigned char *out, const unsigned char *in,
|
24
|
+
unsigned long long inlen, const unsigned char *k)
|
25
|
+
{
|
26
|
+
return implementation->onetimeauth(out, in, inlen, k);
|
27
|
+
}
|
28
|
+
|
29
|
+
int
|
30
|
+
crypto_onetimeauth_poly1305_verify(const unsigned char *h,
|
31
|
+
const unsigned char *in,
|
32
|
+
unsigned long long inlen,
|
33
|
+
const unsigned char *k)
|
34
|
+
{
|
35
|
+
return implementation->onetimeauth_verify(h, in, inlen, k);
|
36
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#include "crypto_onetimeauth_poly1305.h"
|
2
|
+
|
3
|
+
size_t
|
4
|
+
crypto_onetimeauth_poly1305_bytes(void) {
|
5
|
+
return crypto_onetimeauth_poly1305_BYTES;
|
6
|
+
}
|
7
|
+
|
8
|
+
size_t
|
9
|
+
crypto_onetimeauth_poly1305_keybytes(void) {
|
10
|
+
return crypto_onetimeauth_poly1305_KEYBYTES;
|
11
|
+
}
|
12
|
+
|
13
|
+
const char *
|
14
|
+
crypto_onetimeauth_poly1305_primitive(void) {
|
15
|
+
return "poly1305";
|
16
|
+
}
|
@@ -0,0 +1,152 @@
|
|
1
|
+
|
2
|
+
#include <stdlib.h>
|
3
|
+
#include <string.h>
|
4
|
+
#include "crypto_hash_sha256.h"
|
5
|
+
#include "crypto_onetimeauth.h"
|
6
|
+
#include "crypto_onetimeauth_poly1305.h"
|
7
|
+
#include "crypto_onetimeauth_poly1305_donna.h"
|
8
|
+
#include "crypto_onetimeauth_poly1305_53.h"
|
9
|
+
#include "utils.h"
|
10
|
+
|
11
|
+
#define MAXTEST_BYTES 10000
|
12
|
+
#define CHECKSUM_BYTES 4096
|
13
|
+
|
14
|
+
#define CHECKSUM "e836d5ca58cf673fca2b4910f23f3990"
|
15
|
+
|
16
|
+
static char checksum[crypto_onetimeauth_BYTES * 2U + 1U];
|
17
|
+
|
18
|
+
static unsigned char *h, *h_;
|
19
|
+
static unsigned char *m, *m_;
|
20
|
+
static unsigned char *k, *k_;
|
21
|
+
static unsigned char *h2, *h2_;
|
22
|
+
static unsigned char *m2, *m2_;
|
23
|
+
static unsigned char *k2, *k2_;
|
24
|
+
|
25
|
+
static int
|
26
|
+
allocate(void)
|
27
|
+
{
|
28
|
+
h = _sodium_alignedcalloc(&h_, crypto_onetimeauth_BYTES);
|
29
|
+
m = _sodium_alignedcalloc(&m_, MAXTEST_BYTES);
|
30
|
+
k = _sodium_alignedcalloc(&k_, crypto_onetimeauth_KEYBYTES);
|
31
|
+
h2 = _sodium_alignedcalloc(&h2_, crypto_onetimeauth_BYTES);
|
32
|
+
m2 = _sodium_alignedcalloc(&m2_, MAXTEST_BYTES + crypto_onetimeauth_BYTES);
|
33
|
+
k2 = _sodium_alignedcalloc(&k2_, crypto_onetimeauth_KEYBYTES +
|
34
|
+
crypto_onetimeauth_BYTES);
|
35
|
+
|
36
|
+
return -!(h && m && k && h2 && m2 && k2);
|
37
|
+
}
|
38
|
+
|
39
|
+
static void
|
40
|
+
deallocate(void)
|
41
|
+
{
|
42
|
+
free(h_);
|
43
|
+
free(m_);
|
44
|
+
free(k_);
|
45
|
+
free(h2_);
|
46
|
+
free(m2_);
|
47
|
+
free(k2_);
|
48
|
+
}
|
49
|
+
|
50
|
+
#ifdef HAVE_ARC4RANDOM
|
51
|
+
# undef rand
|
52
|
+
# define rand(X) arc4random(X)
|
53
|
+
#endif
|
54
|
+
|
55
|
+
static const char *
|
56
|
+
checksum_compute(void)
|
57
|
+
{
|
58
|
+
long long i;
|
59
|
+
long long j;
|
60
|
+
|
61
|
+
for (i = 0;i < CHECKSUM_BYTES;++i) {
|
62
|
+
long long mlen = i;
|
63
|
+
long long klen = crypto_onetimeauth_KEYBYTES;
|
64
|
+
long long hlen = crypto_onetimeauth_BYTES;
|
65
|
+
|
66
|
+
for (j = -16;j < 0;++j) h[j] = rand();
|
67
|
+
for (j = -16;j < 0;++j) k[j] = rand();
|
68
|
+
for (j = -16;j < 0;++j) m[j] = rand();
|
69
|
+
for (j = hlen;j < hlen + 16;++j) h[j] = rand();
|
70
|
+
for (j = klen;j < klen + 16;++j) k[j] = rand();
|
71
|
+
for (j = mlen;j < mlen + 16;++j) m[j] = rand();
|
72
|
+
for (j = -16;j < hlen + 16;++j) h2[j] = h[j];
|
73
|
+
for (j = -16;j < klen + 16;++j) k2[j] = k[j];
|
74
|
+
for (j = -16;j < mlen + 16;++j) m2[j] = m[j];
|
75
|
+
|
76
|
+
if (crypto_onetimeauth(h,m,mlen,k) != 0) return "crypto_onetimeauth returns nonzero";
|
77
|
+
|
78
|
+
for (j = -16;j < klen + 16;++j) if (k[j] != k2[j]) return "crypto_onetimeauth overwrites k";
|
79
|
+
for (j = -16;j < mlen + 16;++j) if (m[j] != m2[j]) return "crypto_onetimeauth overwrites m";
|
80
|
+
for (j = -16;j < 0;++j) if (h[j] != h2[j]) return "crypto_onetimeauth writes before output";
|
81
|
+
for (j = hlen;j < hlen + 16;++j) if (h[j] != h2[j]) return "crypto_onetimeauth writes after output";
|
82
|
+
|
83
|
+
for (j = -16;j < 0;++j) h[j] = rand();
|
84
|
+
for (j = -16;j < 0;++j) k[j] = rand();
|
85
|
+
for (j = -16;j < 0;++j) m[j] = rand();
|
86
|
+
for (j = hlen;j < hlen + 16;++j) h[j] = rand();
|
87
|
+
for (j = klen;j < klen + 16;++j) k[j] = rand();
|
88
|
+
for (j = mlen;j < mlen + 16;++j) m[j] = rand();
|
89
|
+
for (j = -16;j < hlen + 16;++j) h2[j] = h[j];
|
90
|
+
for (j = -16;j < klen + 16;++j) k2[j] = k[j];
|
91
|
+
for (j = -16;j < mlen + 16;++j) m2[j] = m[j];
|
92
|
+
|
93
|
+
if (crypto_onetimeauth(m2,m2,mlen,k) != 0) return "crypto_onetimeauth returns nonzero";
|
94
|
+
for (j = 0;j < hlen;++j) if (m2[j] != h[j]) return "crypto_onetimeauth does not handle m overlap";
|
95
|
+
for (j = 0;j < hlen;++j) m2[j] = m[j];
|
96
|
+
if (crypto_onetimeauth(k2,m2,mlen,k2) != 0) return "crypto_onetimeauth returns nonzero";
|
97
|
+
for (j = 0;j < hlen;++j) if (k2[j] != h[j]) return "crypto_onetimeauth does not handle k overlap";
|
98
|
+
for (j = 0;j < hlen;++j) k2[j] = k[j];
|
99
|
+
|
100
|
+
if (crypto_onetimeauth_verify(h,m,mlen,k) != 0) return "crypto_onetimeauth_verify returns nonzero";
|
101
|
+
|
102
|
+
for (j = -16;j < hlen + 16;++j) if (h[j] != h2[j]) return "crypto_onetimeauth overwrites h";
|
103
|
+
for (j = -16;j < klen + 16;++j) if (k[j] != k2[j]) return "crypto_onetimeauth overwrites k";
|
104
|
+
for (j = -16;j < mlen + 16;++j) if (m[j] != m2[j]) return "crypto_onetimeauth overwrites m";
|
105
|
+
|
106
|
+
crypto_hash_sha256(h2,h,hlen);
|
107
|
+
for (j = 0;j < klen;++j) k[j] ^= h2[j % 32];
|
108
|
+
if (crypto_onetimeauth(h,m,mlen,k) != 0) return "crypto_onetimeauth returns nonzero";
|
109
|
+
if (crypto_onetimeauth_verify(h,m,mlen,k) != 0) return "crypto_onetimeauth_verify returns nonzero";
|
110
|
+
|
111
|
+
crypto_hash_sha256(h2,h,hlen);
|
112
|
+
for (j = 0;j < mlen;++j) m[j] ^= h2[j % 32];
|
113
|
+
m[mlen] = h2[0];
|
114
|
+
}
|
115
|
+
if (crypto_onetimeauth(h,m,CHECKSUM_BYTES,k) != 0) return "crypto_onetimeauth returns nonzero";
|
116
|
+
if (crypto_onetimeauth_verify(h,m,CHECKSUM_BYTES,k) != 0) return "crypto_onetimeauth_verify returns nonzero";
|
117
|
+
|
118
|
+
sodium_bin2hex(checksum, sizeof checksum, h, crypto_onetimeauth_BYTES);
|
119
|
+
|
120
|
+
return NULL;
|
121
|
+
}
|
122
|
+
|
123
|
+
crypto_onetimeauth_poly1305_implementation *
|
124
|
+
crypto_onetimeauth_pick_best_implementation(void)
|
125
|
+
{
|
126
|
+
crypto_onetimeauth_poly1305_implementation *implementations[] = {
|
127
|
+
#ifdef HAVE_FENV_H
|
128
|
+
&crypto_onetimeauth_poly1305_53_implementation,
|
129
|
+
#endif
|
130
|
+
&crypto_onetimeauth_poly1305_donna_implementation,
|
131
|
+
NULL
|
132
|
+
};
|
133
|
+
const char *err;
|
134
|
+
size_t i = (size_t) 0U;
|
135
|
+
|
136
|
+
do {
|
137
|
+
if (crypto_onetimeauth_poly1305_set_implementation
|
138
|
+
(implementations[i]) != 0) {
|
139
|
+
continue;
|
140
|
+
}
|
141
|
+
if (allocate() != 0) {
|
142
|
+
return NULL;
|
143
|
+
}
|
144
|
+
err = checksum_compute();
|
145
|
+
deallocate();
|
146
|
+
if (err == NULL && strcmp(checksum, CHECKSUM) == 0) {
|
147
|
+
break;
|
148
|
+
}
|
149
|
+
} while (implementations[++i] != NULL);
|
150
|
+
|
151
|
+
return implementations[i];
|
152
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
#include "crypto_scalarmult.h"
|
3
|
+
|
4
|
+
size_t
|
5
|
+
crypto_scalarmult_bytes(void)
|
6
|
+
{
|
7
|
+
return crypto_scalarmult_BYTES;
|
8
|
+
}
|
9
|
+
|
10
|
+
size_t
|
11
|
+
crypto_scalarmult_scalarbytes(void)
|
12
|
+
{
|
13
|
+
return crypto_scalarmult_SCALARBYTES;
|
14
|
+
}
|
15
|
+
|
16
|
+
const char *
|
17
|
+
crypto_scalarmult_primitive(void)
|
18
|
+
{
|
19
|
+
return crypto_scalarmult_PRIMITIVE;
|
20
|
+
}
|
21
|
+
|
22
|
+
int
|
23
|
+
crypto_scalarmult_base(unsigned char *q, const unsigned char *n)
|
24
|
+
{
|
25
|
+
return crypto_scalarmult_curve25519_base(q, n);
|
26
|
+
}
|
27
|
+
|
28
|
+
int
|
29
|
+
crypto_scalarmult(unsigned char *q, const unsigned char *n,
|
30
|
+
const unsigned char *p)
|
31
|
+
{
|
32
|
+
return crypto_scalarmult_curve25519(q, n, p);
|
33
|
+
}
|
34
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
dacdae4a0f12353dfc66757f2fd1fff538fe6616115dace9afb8016a55be2a52
|
@@ -0,0 +1,9 @@
|
|
1
|
+
|
2
|
+
#include "crypto_scalarmult_curve25519.h"
|
3
|
+
|
4
|
+
#define crypto_scalarmult_curve25519_implementation_name \
|
5
|
+
crypto_scalarmult_curve25519_donna_c64_implementation_name
|
6
|
+
|
7
|
+
#define crypto_scalarmult crypto_scalarmult_curve25519_donna_c64
|
8
|
+
#define crypto_scalarmult_base crypto_scalarmult_curve25519_donna_c64_base
|
9
|
+
|
@@ -0,0 +1,426 @@
|
|
1
|
+
/* Copyright 2008, Google Inc.
|
2
|
+
* All rights reserved.
|
3
|
+
*
|
4
|
+
* Code released into the public domain.
|
5
|
+
*
|
6
|
+
* curve25519-donna: Curve25519 elliptic curve, public key function
|
7
|
+
*
|
8
|
+
* http://code.google.com/p/curve25519-donna/
|
9
|
+
*
|
10
|
+
* Adam Langley <agl@imperialviolet.org>
|
11
|
+
* Parts optimised by floodyberry
|
12
|
+
* Derived from public domain C code by Daniel J. Bernstein <djb@cr.yp.to>
|
13
|
+
*
|
14
|
+
* More information about curve25519 can be found here
|
15
|
+
* http://cr.yp.to/ecdh.html
|
16
|
+
*
|
17
|
+
* djb's sample implementation of curve25519 is written in a special assembly
|
18
|
+
* language called qhasm and uses the floating point registers.
|
19
|
+
*
|
20
|
+
* This is, almost, a clean room reimplementation from the curve25519 paper. It
|
21
|
+
* uses many of the tricks described therein. Only the crecip function is taken
|
22
|
+
* from the sample implementation.
|
23
|
+
*/
|
24
|
+
|
25
|
+
#include <string.h>
|
26
|
+
#include <stdint.h>
|
27
|
+
#include "api.h"
|
28
|
+
|
29
|
+
#ifdef HAVE_TI_MODE
|
30
|
+
|
31
|
+
typedef uint8_t u8;
|
32
|
+
typedef uint64_t limb;
|
33
|
+
typedef limb felem[5];
|
34
|
+
// This is a special gcc mode for 128-bit integers. It's implemented on 64-bit
|
35
|
+
// platforms only as far as I know.
|
36
|
+
typedef unsigned uint128_t __attribute__((mode(TI)));
|
37
|
+
|
38
|
+
#undef force_inline
|
39
|
+
#define force_inline inline __attribute__((always_inline))
|
40
|
+
|
41
|
+
/* Sum two numbers: output += in */
|
42
|
+
static force_inline void
|
43
|
+
fsum(limb *output, const limb *in) {
|
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];
|
49
|
+
}
|
50
|
+
|
51
|
+
/* Find the difference of two numbers: output = in - output
|
52
|
+
* (note the order of the arguments!)
|
53
|
+
*
|
54
|
+
* Assumes that out[i] < 2**52
|
55
|
+
* On return, out[i] < 2**55
|
56
|
+
*/
|
57
|
+
static force_inline void
|
58
|
+
fdifference_backwards(felem out, const felem in) {
|
59
|
+
/* 152 is 19 << 3 */
|
60
|
+
static const limb two54m152 = (((limb)1) << 54) - 152;
|
61
|
+
static const limb two54m8 = (((limb)1) << 54) - 8;
|
62
|
+
|
63
|
+
out[0] = in[0] + two54m152 - out[0];
|
64
|
+
out[1] = in[1] + two54m8 - out[1];
|
65
|
+
out[2] = in[2] + two54m8 - out[2];
|
66
|
+
out[3] = in[3] + two54m8 - out[3];
|
67
|
+
out[4] = in[4] + two54m8 - out[4];
|
68
|
+
}
|
69
|
+
|
70
|
+
/* Multiply a number by a scalar: output = in * scalar */
|
71
|
+
static force_inline void
|
72
|
+
fscalar_product(felem output, const felem in, const limb scalar) {
|
73
|
+
uint128_t a;
|
74
|
+
|
75
|
+
a = ((uint128_t) in[0]) * scalar;
|
76
|
+
output[0] = ((limb)a) & 0x7ffffffffffff;
|
77
|
+
|
78
|
+
a = ((uint128_t) in[1]) * scalar + ((limb) (a >> 51));
|
79
|
+
output[1] = ((limb)a) & 0x7ffffffffffff;
|
80
|
+
|
81
|
+
a = ((uint128_t) in[2]) * scalar + ((limb) (a >> 51));
|
82
|
+
output[2] = ((limb)a) & 0x7ffffffffffff;
|
83
|
+
|
84
|
+
a = ((uint128_t) in[3]) * scalar + ((limb) (a >> 51));
|
85
|
+
output[3] = ((limb)a) & 0x7ffffffffffff;
|
86
|
+
|
87
|
+
a = ((uint128_t) in[4]) * scalar + ((limb) (a >> 51));
|
88
|
+
output[4] = ((limb)a) & 0x7ffffffffffff;
|
89
|
+
|
90
|
+
output[0] += (a >> 51) * 19;
|
91
|
+
}
|
92
|
+
|
93
|
+
/* Multiply two numbers: output = in2 * in
|
94
|
+
*
|
95
|
+
* output must be distinct to both inputs. The inputs are reduced coefficient
|
96
|
+
* form, the output is not.
|
97
|
+
*
|
98
|
+
* Assumes that in[i] < 2**55 and likewise for in2.
|
99
|
+
* On return, output[i] < 2**52
|
100
|
+
*/
|
101
|
+
static force_inline void
|
102
|
+
fmul(felem output, const felem in2, const felem in) {
|
103
|
+
uint128_t t[5];
|
104
|
+
limb r0,r1,r2,r3,r4,s0,s1,s2,s3,s4,c;
|
105
|
+
|
106
|
+
r0 = in[0];
|
107
|
+
r1 = in[1];
|
108
|
+
r2 = in[2];
|
109
|
+
r3 = in[3];
|
110
|
+
r4 = in[4];
|
111
|
+
|
112
|
+
s0 = in2[0];
|
113
|
+
s1 = in2[1];
|
114
|
+
s2 = in2[2];
|
115
|
+
s3 = in2[3];
|
116
|
+
s4 = in2[4];
|
117
|
+
|
118
|
+
t[0] = ((uint128_t) r0) * s0;
|
119
|
+
t[1] = ((uint128_t) r0) * s1 + ((uint128_t) r1) * s0;
|
120
|
+
t[2] = ((uint128_t) r0) * s2 + ((uint128_t) r2) * s0 + ((uint128_t) r1) * s1;
|
121
|
+
t[3] = ((uint128_t) r0) * s3 + ((uint128_t) r3) * s0 + ((uint128_t) r1) * s2 + ((uint128_t) r2) * s1;
|
122
|
+
t[4] = ((uint128_t) r0) * s4 + ((uint128_t) r4) * s0 + ((uint128_t) r3) * s1 + ((uint128_t) r1) * s3 + ((uint128_t) r2) * s2;
|
123
|
+
|
124
|
+
r4 *= 19;
|
125
|
+
r1 *= 19;
|
126
|
+
r2 *= 19;
|
127
|
+
r3 *= 19;
|
128
|
+
|
129
|
+
t[0] += ((uint128_t) r4) * s1 + ((uint128_t) r1) * s4 + ((uint128_t) r2) * s3 + ((uint128_t) r3) * s2;
|
130
|
+
t[1] += ((uint128_t) r4) * s2 + ((uint128_t) r2) * s4 + ((uint128_t) r3) * s3;
|
131
|
+
t[2] += ((uint128_t) r4) * s3 + ((uint128_t) r3) * s4;
|
132
|
+
t[3] += ((uint128_t) r4) * s4;
|
133
|
+
|
134
|
+
r0 = (limb)t[0] & 0x7ffffffffffff; c = (limb)(t[0] >> 51);
|
135
|
+
t[1] += c; r1 = (limb)t[1] & 0x7ffffffffffff; c = (limb)(t[1] >> 51);
|
136
|
+
t[2] += c; r2 = (limb)t[2] & 0x7ffffffffffff; c = (limb)(t[2] >> 51);
|
137
|
+
t[3] += c; r3 = (limb)t[3] & 0x7ffffffffffff; c = (limb)(t[3] >> 51);
|
138
|
+
t[4] += c; r4 = (limb)t[4] & 0x7ffffffffffff; c = (limb)(t[4] >> 51);
|
139
|
+
r0 += c * 19; c = r0 >> 51; r0 = r0 & 0x7ffffffffffff;
|
140
|
+
r1 += c; c = r1 >> 51; r1 = r1 & 0x7ffffffffffff;
|
141
|
+
r2 += c;
|
142
|
+
|
143
|
+
output[0] = r0;
|
144
|
+
output[1] = r1;
|
145
|
+
output[2] = r2;
|
146
|
+
output[3] = r3;
|
147
|
+
output[4] = r4;
|
148
|
+
}
|
149
|
+
|
150
|
+
static force_inline void
|
151
|
+
fsquare_times(felem output, const felem in, limb count) {
|
152
|
+
uint128_t t[5];
|
153
|
+
limb r0,r1,r2,r3,r4,c;
|
154
|
+
limb d0,d1,d2,d4,d419;
|
155
|
+
|
156
|
+
r0 = in[0];
|
157
|
+
r1 = in[1];
|
158
|
+
r2 = in[2];
|
159
|
+
r3 = in[3];
|
160
|
+
r4 = in[4];
|
161
|
+
|
162
|
+
do {
|
163
|
+
d0 = r0 * 2;
|
164
|
+
d1 = r1 * 2;
|
165
|
+
d2 = r2 * 2 * 19;
|
166
|
+
d419 = r4 * 19;
|
167
|
+
d4 = d419 * 2;
|
168
|
+
|
169
|
+
t[0] = ((uint128_t) r0) * r0 + ((uint128_t) d4) * r1 + (((uint128_t) d2) * (r3 ));
|
170
|
+
t[1] = ((uint128_t) d0) * r1 + ((uint128_t) d4) * r2 + (((uint128_t) r3) * (r3 * 19));
|
171
|
+
t[2] = ((uint128_t) d0) * r2 + ((uint128_t) r1) * r1 + (((uint128_t) d4) * (r3 ));
|
172
|
+
t[3] = ((uint128_t) d0) * r3 + ((uint128_t) d1) * r2 + (((uint128_t) r4) * (d419 ));
|
173
|
+
t[4] = ((uint128_t) d0) * r4 + ((uint128_t) d1) * r3 + (((uint128_t) r2) * (r2 ));
|
174
|
+
|
175
|
+
r0 = (limb)t[0] & 0x7ffffffffffff; c = (limb)(t[0] >> 51);
|
176
|
+
t[1] += c; r1 = (limb)t[1] & 0x7ffffffffffff; c = (limb)(t[1] >> 51);
|
177
|
+
t[2] += c; r2 = (limb)t[2] & 0x7ffffffffffff; c = (limb)(t[2] >> 51);
|
178
|
+
t[3] += c; r3 = (limb)t[3] & 0x7ffffffffffff; c = (limb)(t[3] >> 51);
|
179
|
+
t[4] += c; r4 = (limb)t[4] & 0x7ffffffffffff; c = (limb)(t[4] >> 51);
|
180
|
+
r0 += c * 19; c = r0 >> 51; r0 = r0 & 0x7ffffffffffff;
|
181
|
+
r1 += c; c = r1 >> 51; r1 = r1 & 0x7ffffffffffff;
|
182
|
+
r2 += c;
|
183
|
+
} while(--count);
|
184
|
+
|
185
|
+
output[0] = r0;
|
186
|
+
output[1] = r1;
|
187
|
+
output[2] = r2;
|
188
|
+
output[3] = r3;
|
189
|
+
output[4] = r4;
|
190
|
+
}
|
191
|
+
|
192
|
+
/* Take a little-endian, 32-byte number and expand it into polynomial form */
|
193
|
+
static void
|
194
|
+
fexpand(limb *output, const u8 *in) {
|
195
|
+
output[0] = *((const uint64_t *)(in)) & 0x7ffffffffffff;
|
196
|
+
output[1] = (*((const uint64_t *)(in+6)) >> 3) & 0x7ffffffffffff;
|
197
|
+
output[2] = (*((const uint64_t *)(in+12)) >> 6) & 0x7ffffffffffff;
|
198
|
+
output[3] = (*((const uint64_t *)(in+19)) >> 1) & 0x7ffffffffffff;
|
199
|
+
output[4] = (*((const uint64_t *)(in+25)) >> 4) & 0xfffffffffffff;
|
200
|
+
}
|
201
|
+
|
202
|
+
/* Take a fully reduced polynomial form number and contract it into a
|
203
|
+
* little-endian, 32-byte array
|
204
|
+
*/
|
205
|
+
static void
|
206
|
+
fcontract(u8 *output, const felem input) {
|
207
|
+
uint128_t t[5];
|
208
|
+
|
209
|
+
t[0] = input[0];
|
210
|
+
t[1] = input[1];
|
211
|
+
t[2] = input[2];
|
212
|
+
t[3] = input[3];
|
213
|
+
t[4] = input[4];
|
214
|
+
|
215
|
+
t[1] += t[0] >> 51; t[0] &= 0x7ffffffffffff;
|
216
|
+
t[2] += t[1] >> 51; t[1] &= 0x7ffffffffffff;
|
217
|
+
t[3] += t[2] >> 51; t[2] &= 0x7ffffffffffff;
|
218
|
+
t[4] += t[3] >> 51; t[3] &= 0x7ffffffffffff;
|
219
|
+
t[0] += 19 * (t[4] >> 51); t[4] &= 0x7ffffffffffff;
|
220
|
+
|
221
|
+
t[1] += t[0] >> 51; t[0] &= 0x7ffffffffffff;
|
222
|
+
t[2] += t[1] >> 51; t[1] &= 0x7ffffffffffff;
|
223
|
+
t[3] += t[2] >> 51; t[2] &= 0x7ffffffffffff;
|
224
|
+
t[4] += t[3] >> 51; t[3] &= 0x7ffffffffffff;
|
225
|
+
t[0] += 19 * (t[4] >> 51); t[4] &= 0x7ffffffffffff;
|
226
|
+
|
227
|
+
/* now t is between 0 and 2^255-1, properly carried. */
|
228
|
+
/* case 1: between 0 and 2^255-20. case 2: between 2^255-19 and 2^255-1. */
|
229
|
+
|
230
|
+
t[0] += 19;
|
231
|
+
|
232
|
+
t[1] += t[0] >> 51; t[0] &= 0x7ffffffffffff;
|
233
|
+
t[2] += t[1] >> 51; t[1] &= 0x7ffffffffffff;
|
234
|
+
t[3] += t[2] >> 51; t[2] &= 0x7ffffffffffff;
|
235
|
+
t[4] += t[3] >> 51; t[3] &= 0x7ffffffffffff;
|
236
|
+
t[0] += 19 * (t[4] >> 51); t[4] &= 0x7ffffffffffff;
|
237
|
+
|
238
|
+
/* now between 19 and 2^255-1 in both cases, and offset by 19. */
|
239
|
+
|
240
|
+
t[0] += 0x8000000000000 - 19;
|
241
|
+
t[1] += 0x8000000000000 - 1;
|
242
|
+
t[2] += 0x8000000000000 - 1;
|
243
|
+
t[3] += 0x8000000000000 - 1;
|
244
|
+
t[4] += 0x8000000000000 - 1;
|
245
|
+
|
246
|
+
/* now between 2^255 and 2^256-20, and offset by 2^255. */
|
247
|
+
|
248
|
+
t[1] += t[0] >> 51; t[0] &= 0x7ffffffffffff;
|
249
|
+
t[2] += t[1] >> 51; t[1] &= 0x7ffffffffffff;
|
250
|
+
t[3] += t[2] >> 51; t[2] &= 0x7ffffffffffff;
|
251
|
+
t[4] += t[3] >> 51; t[3] &= 0x7ffffffffffff;
|
252
|
+
t[4] &= 0x7ffffffffffff;
|
253
|
+
|
254
|
+
*((uint64_t *)(output)) = t[0] | (t[1] << 51);
|
255
|
+
*((uint64_t *)(output+8)) = (t[1] >> 13) | (t[2] << 38);
|
256
|
+
*((uint64_t *)(output+16)) = (t[2] >> 26) | (t[3] << 25);
|
257
|
+
*((uint64_t *)(output+24)) = (t[3] >> 39) | (t[4] << 12);
|
258
|
+
}
|
259
|
+
|
260
|
+
/* Input: Q, Q', Q-Q'
|
261
|
+
* Output: 2Q, Q+Q'
|
262
|
+
*
|
263
|
+
* x2 z3: long form
|
264
|
+
* x3 z3: long form
|
265
|
+
* x z: short form, destroyed
|
266
|
+
* xprime zprime: short form, destroyed
|
267
|
+
* qmqp: short form, preserved
|
268
|
+
*/
|
269
|
+
static void
|
270
|
+
fmonty(limb *x2, limb *z2, /* output 2Q */
|
271
|
+
limb *x3, limb *z3, /* output Q + Q' */
|
272
|
+
limb *x, limb *z, /* input Q */
|
273
|
+
limb *xprime, limb *zprime, /* input Q' */
|
274
|
+
const limb *qmqp /* input Q - Q' */) {
|
275
|
+
limb origx[5], origxprime[5], zzz[5], xx[5], zz[5], xxprime[5],
|
276
|
+
zzprime[5], zzzprime[5];
|
277
|
+
|
278
|
+
memcpy(origx, x, 5 * sizeof(limb));
|
279
|
+
fsum(x, z);
|
280
|
+
fdifference_backwards(z, origx); // does x - z
|
281
|
+
|
282
|
+
memcpy(origxprime, xprime, sizeof(limb) * 5);
|
283
|
+
fsum(xprime, zprime);
|
284
|
+
fdifference_backwards(zprime, origxprime);
|
285
|
+
fmul(xxprime, xprime, z);
|
286
|
+
fmul(zzprime, x, zprime);
|
287
|
+
memcpy(origxprime, xxprime, sizeof(limb) * 5);
|
288
|
+
fsum(xxprime, zzprime);
|
289
|
+
fdifference_backwards(zzprime, origxprime);
|
290
|
+
fsquare_times(x3, xxprime, 1);
|
291
|
+
fsquare_times(zzzprime, zzprime, 1);
|
292
|
+
fmul(z3, zzzprime, qmqp);
|
293
|
+
|
294
|
+
fsquare_times(xx, x, 1);
|
295
|
+
fsquare_times(zz, z, 1);
|
296
|
+
fmul(x2, xx, zz);
|
297
|
+
fdifference_backwards(zz, xx); // does zz = xx - zz
|
298
|
+
fscalar_product(zzz, zz, 121665);
|
299
|
+
fsum(zzz, xx);
|
300
|
+
fmul(z2, zz, zzz);
|
301
|
+
}
|
302
|
+
|
303
|
+
// -----------------------------------------------------------------------------
|
304
|
+
// Maybe swap the contents of two limb arrays (@a and @b), each @len elements
|
305
|
+
// long. Perform the swap iff @swap is non-zero.
|
306
|
+
//
|
307
|
+
// This function performs the swap without leaking any side-channel
|
308
|
+
// information.
|
309
|
+
// -----------------------------------------------------------------------------
|
310
|
+
static void
|
311
|
+
swap_conditional(limb a[5], limb b[5], limb iswap) {
|
312
|
+
unsigned i;
|
313
|
+
const limb swap = -iswap;
|
314
|
+
|
315
|
+
for (i = 0; i < 5; ++i) {
|
316
|
+
const limb x = swap & (a[i] ^ b[i]);
|
317
|
+
a[i] ^= x;
|
318
|
+
b[i] ^= x;
|
319
|
+
}
|
320
|
+
}
|
321
|
+
|
322
|
+
/* Calculates nQ where Q is the x-coordinate of a point on the curve
|
323
|
+
*
|
324
|
+
* resultx/resultz: the x coordinate of the resulting curve point (short form)
|
325
|
+
* n: a little endian, 32-byte number
|
326
|
+
* q: a point of the curve (short form)
|
327
|
+
*/
|
328
|
+
static void
|
329
|
+
cmult(limb *resultx, limb *resultz, const u8 *n, const limb *q) {
|
330
|
+
limb a[5] = {0}, b[5] = {1}, c[5] = {1}, d[5] = {0};
|
331
|
+
limb *nqpqx = a, *nqpqz = b, *nqx = c, *nqz = d, *t;
|
332
|
+
limb e[5] = {0}, f[5] = {1}, g[5] = {0}, h[5] = {1};
|
333
|
+
limb *nqpqx2 = e, *nqpqz2 = f, *nqx2 = g, *nqz2 = h;
|
334
|
+
|
335
|
+
unsigned i, j;
|
336
|
+
|
337
|
+
memcpy(nqpqx, q, sizeof(limb) * 5);
|
338
|
+
|
339
|
+
for (i = 0; i < 32; ++i) {
|
340
|
+
u8 byte = n[31 - i];
|
341
|
+
for (j = 0; j < 8; ++j) {
|
342
|
+
const limb bit = byte >> 7;
|
343
|
+
|
344
|
+
swap_conditional(nqx, nqpqx, bit);
|
345
|
+
swap_conditional(nqz, nqpqz, bit);
|
346
|
+
fmonty(nqx2, nqz2,
|
347
|
+
nqpqx2, nqpqz2,
|
348
|
+
nqx, nqz,
|
349
|
+
nqpqx, nqpqz,
|
350
|
+
q);
|
351
|
+
swap_conditional(nqx2, nqpqx2, bit);
|
352
|
+
swap_conditional(nqz2, nqpqz2, bit);
|
353
|
+
|
354
|
+
t = nqx;
|
355
|
+
nqx = nqx2;
|
356
|
+
nqx2 = t;
|
357
|
+
t = nqz;
|
358
|
+
nqz = nqz2;
|
359
|
+
nqz2 = t;
|
360
|
+
t = nqpqx;
|
361
|
+
nqpqx = nqpqx2;
|
362
|
+
nqpqx2 = t;
|
363
|
+
t = nqpqz;
|
364
|
+
nqpqz = nqpqz2;
|
365
|
+
nqpqz2 = t;
|
366
|
+
|
367
|
+
byte <<= 1;
|
368
|
+
}
|
369
|
+
}
|
370
|
+
|
371
|
+
memcpy(resultx, nqx, sizeof(limb) * 5);
|
372
|
+
memcpy(resultz, nqz, sizeof(limb) * 5);
|
373
|
+
}
|
374
|
+
|
375
|
+
|
376
|
+
// -----------------------------------------------------------------------------
|
377
|
+
// Shamelessly copied from djb's code, tightened a little
|
378
|
+
// -----------------------------------------------------------------------------
|
379
|
+
static void
|
380
|
+
crecip(felem out, const felem z) {
|
381
|
+
felem a,t0,b,c;
|
382
|
+
|
383
|
+
/* 2 */ fsquare_times(a, z, 1); // a = 2
|
384
|
+
/* 8 */ fsquare_times(t0, a, 2);
|
385
|
+
/* 9 */ fmul(b, t0, z); // b = 9
|
386
|
+
/* 11 */ fmul(a, b, a); // a = 11
|
387
|
+
/* 22 */ fsquare_times(t0, a, 1);
|
388
|
+
/* 2^5 - 2^0 = 31 */ fmul(b, t0, b);
|
389
|
+
/* 2^10 - 2^5 */ fsquare_times(t0, b, 5);
|
390
|
+
/* 2^10 - 2^0 */ fmul(b, t0, b);
|
391
|
+
/* 2^20 - 2^10 */ fsquare_times(t0, b, 10);
|
392
|
+
/* 2^20 - 2^0 */ fmul(c, t0, b);
|
393
|
+
/* 2^40 - 2^20 */ fsquare_times(t0, c, 20);
|
394
|
+
/* 2^40 - 2^0 */ fmul(t0, t0, c);
|
395
|
+
/* 2^50 - 2^10 */ fsquare_times(t0, t0, 10);
|
396
|
+
/* 2^50 - 2^0 */ fmul(b, t0, b);
|
397
|
+
/* 2^100 - 2^50 */ fsquare_times(t0, b, 50);
|
398
|
+
/* 2^100 - 2^0 */ fmul(c, t0, b);
|
399
|
+
/* 2^200 - 2^100 */ fsquare_times(t0, c, 100);
|
400
|
+
/* 2^200 - 2^0 */ fmul(t0, t0, c);
|
401
|
+
/* 2^250 - 2^50 */ fsquare_times(t0, t0, 50);
|
402
|
+
/* 2^250 - 2^0 */ fmul(t0, t0, b);
|
403
|
+
/* 2^255 - 2^5 */ fsquare_times(t0, t0, 5);
|
404
|
+
/* 2^255 - 21 */ fmul(out, t0, a);
|
405
|
+
}
|
406
|
+
|
407
|
+
int
|
408
|
+
crypto_scalarmult(u8 *mypublic, const u8 *secret, const u8 *basepoint) {
|
409
|
+
limb bp[5], x[5], z[5], zmone[5];
|
410
|
+
uint8_t e[32];
|
411
|
+
int i;
|
412
|
+
|
413
|
+
for (i = 0;i < 32;++i) e[i] = secret[i];
|
414
|
+
e[0] &= 248;
|
415
|
+
e[31] &= 127;
|
416
|
+
e[31] |= 64;
|
417
|
+
|
418
|
+
fexpand(bp, basepoint);
|
419
|
+
cmult(x, z, e, bp);
|
420
|
+
crecip(zmone, z);
|
421
|
+
fmul(z, x, zmone);
|
422
|
+
fcontract(mypublic, z);
|
423
|
+
return 0;
|
424
|
+
}
|
425
|
+
|
426
|
+
#endif
|