rbnacl-libsodium 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/lib/rbnacl/libsodium/version.rb +1 -1
- data/vendor/libsodium/AUTHORS +10 -3
- data/vendor/libsodium/ChangeLog +19 -1
- data/vendor/libsodium/Makefile.in +1 -0
- data/vendor/libsodium/README.markdown +1 -1
- data/vendor/libsodium/THANKS +1 -0
- data/vendor/libsodium/autogen.sh +24 -4
- data/vendor/libsodium/autom4te.cache/output.1 +208 -24
- data/vendor/libsodium/autom4te.cache/output.5 +208 -24
- data/vendor/libsodium/autom4te.cache/requests +869 -869
- data/vendor/libsodium/autom4te.cache/traces.1 +426 -406
- data/vendor/libsodium/autom4te.cache/traces.5 +255 -245
- data/vendor/libsodium/builds/msvc/version.h +2 -2
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj +14 -44
- data/vendor/libsodium/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +36 -132
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj +14 -44
- data/vendor/libsodium/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +36 -132
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj +14 -44
- data/vendor/libsodium/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +36 -132
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj +14 -44
- data/vendor/libsodium/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +62 -158
- data/vendor/libsodium/configure +208 -24
- data/vendor/libsodium/configure.ac +70 -15
- data/vendor/libsodium/dist-build/Makefile.in +1 -0
- data/vendor/libsodium/dist-build/emscripten.sh +52 -19
- data/vendor/libsodium/dist-build/ios.sh +8 -8
- data/vendor/libsodium/dist-build/msys2-win32.sh +2 -1
- data/vendor/libsodium/dist-build/msys2-win64.sh +2 -1
- data/vendor/libsodium/dist-build/osx.sh +2 -2
- data/vendor/libsodium/examples/box.c +3 -1
- data/vendor/libsodium/examples/box_detached.c +4 -2
- data/vendor/libsodium/examples/utils.h +3 -1
- data/vendor/libsodium/libsodium.vcxproj +13 -13
- data/vendor/libsodium/libsodium.vcxproj.filters +31 -35
- data/vendor/libsodium/msvc-scripts/Makefile.in +1 -0
- data/vendor/libsodium/msvc-scripts/process.bat +2 -2
- data/vendor/libsodium/src/Makefile.in +1 -0
- data/vendor/libsodium/src/libsodium/Makefile.am +43 -45
- data/vendor/libsodium/src/libsodium/Makefile.in +250 -249
- data/vendor/libsodium/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +28 -22
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/cp/hmac_hmacsha256.c +3 -4
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/cp/verify_hmacsha256.c +3 -3
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/hmac_hmacsha512.c +3 -4
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/verify_hmacsha512.c +4 -4
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/hmac_hmacsha512256.c +4 -4
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/verify_hmacsha512256.c +6 -4
- data/vendor/libsodium/src/libsodium/crypto_box/crypto_box_easy.c +6 -2
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/after_curve25519xsalsa20poly1305.c +3 -3
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c +5 -3
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/box_curve25519xsalsa20poly1305.c +13 -9
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c +3 -3
- data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/core_hsalsa20.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/core_salsa20.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/core_salsa2012.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/core_salsa208.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2.h +2 -2
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/blake2b-ref.c +36 -26
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/generichash_blake2b.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_generichash/crypto_generichash.c +1 -2
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/hash_sha256.c +2 -3
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/hash_sha512.c +2 -3
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/{auth_poly1305_donna.c → poly1305_donna.c} +18 -11
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h +1 -5
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna32.h +10 -9
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna64.h +17 -9
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.c +10 -1
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.c +708 -0
- data/vendor/libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.h +31 -0
- data/vendor/libsodium/src/libsodium/crypto_pwhash/scryptsalsa208sha256/crypto_scrypt.h +1 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/crypto_scalarmult.c +11 -12
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/{smult_curve25519_donna_c64.c → curve25519_donna_c64.c} +32 -15
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.h +9 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/curve25519_ref10.c +73 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/curve25519_ref10.h +9 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_frombytes_curve25519_ref10.c +1 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/consts.S +25 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/consts_namespace.h +20 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/curve25519_sandy2x.c +114 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/curve25519_sandy2x.h +9 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe.h +25 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51.h +33 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_invert.c +57 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_mul.S +189 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_namespace.h +16 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_nsquare.S +165 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_pack.S +219 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe_frombytes_sandy2x.c +76 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder.S +1432 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder.h +18 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base.S +1287 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base.h +18 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base_namespace.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_namespace.h +8 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/sandy2x.S +17 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519.c +67 -0
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519.h +11 -0
- data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/ref/box_xsalsa20poly1305.c +3 -3
- data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/shorthash_siphash24.c +3 -2
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge.h +2 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_double_scalarmult.c +42 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +7 -7
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/obsolete.c +113 -0
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/open.c +10 -7
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/sign.c +10 -10
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/afternm_aes128ctr.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/beforenm_aes128ctr.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/stream_aes128ctr.c +10 -9
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/xor_afternm_aes128ctr.c +2 -3
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.c +72 -68
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/ref/{api.h → stream_chacha20_ref.h} +5 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/{stream_chacha20_api.c → stream_chacha20.c} +27 -7
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/stream_chacha20.h +22 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/vec/stream_chacha20_vec.c +329 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/chacha20/vec/stream_chacha20_vec.h +27 -0
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.S +1 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/stream_salsa20_ref.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c +1 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/xor_salsa2012.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/stream_salsa208.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c +2 -2
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c +4 -4
- data/vendor/libsodium/src/libsodium/crypto_verify/16/ref/verify_16.c +14 -21
- data/vendor/libsodium/src/libsodium/crypto_verify/32/ref/verify_32.c +14 -37
- data/vendor/libsodium/src/libsodium/crypto_verify/64/ref/verify_64.c +14 -69
- data/vendor/libsodium/src/libsodium/include/Makefile.in +1 -0
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_box.h +8 -4
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_box_curve25519xsalsa20poly1305.h +4 -2
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_generichash_blake2b.h +2 -2
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_onetimeauth_poly1305.h +2 -3
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult.h +2 -1
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h +6 -1
- data/vendor/libsodium/src/libsodium/include/sodium/crypto_stream_chacha20.h +5 -0
- data/vendor/libsodium/src/libsodium/include/sodium/randombytes_nativeclient.h +6 -20
- data/vendor/libsodium/src/libsodium/include/sodium/randombytes_salsa20_random.h +1 -28
- data/vendor/libsodium/src/libsodium/include/sodium/randombytes_sysrandom.h +1 -27
- data/vendor/libsodium/src/libsodium/include/sodium/runtime.h +3 -0
- data/vendor/libsodium/src/libsodium/include/sodium/utils.h +6 -0
- data/vendor/libsodium/src/libsodium/randombytes/nativeclient/randombytes_nativeclient.c +3 -3
- data/vendor/libsodium/src/libsodium/randombytes/salsa20/randombytes_salsa20_random.c +58 -51
- data/vendor/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c +23 -18
- data/vendor/libsodium/src/libsodium/sodium/core.c +4 -0
- data/vendor/libsodium/src/libsodium/sodium/runtime.c +34 -15
- data/vendor/libsodium/src/libsodium/sodium/utils.c +104 -14
- data/vendor/libsodium/test/Makefile.in +1 -0
- data/vendor/libsodium/test/default/Makefile.in +1 -0
- data/vendor/libsodium/test/default/auth.c +5 -5
- data/vendor/libsodium/test/default/auth2.c +3 -3
- data/vendor/libsodium/test/default/auth3.c +3 -3
- data/vendor/libsodium/test/default/auth5.c +4 -4
- data/vendor/libsodium/test/default/auth6.c +3 -3
- data/vendor/libsodium/test/default/auth7.c +4 -4
- data/vendor/libsodium/test/default/box.c +13 -9
- data/vendor/libsodium/test/default/box2.c +11 -8
- data/vendor/libsodium/test/default/box7.c +11 -9
- data/vendor/libsodium/test/default/box8.c +32 -19
- data/vendor/libsodium/test/default/box_easy.c +31 -10
- data/vendor/libsodium/test/default/box_easy.exp +3 -19
- data/vendor/libsodium/test/default/box_easy2.c +30 -15
- data/vendor/libsodium/test/default/box_seed.c +1 -1
- data/vendor/libsodium/test/default/cmptest.h +22 -1
- data/vendor/libsodium/test/default/core1.c +6 -5
- data/vendor/libsodium/test/default/core2.c +6 -5
- data/vendor/libsodium/test/default/core3.c +8 -7
- data/vendor/libsodium/test/default/core4.c +11 -8
- data/vendor/libsodium/test/default/core5.c +7 -5
- data/vendor/libsodium/test/default/core6.c +8 -6
- data/vendor/libsodium/test/default/generichash.c +0 -15
- data/vendor/libsodium/test/default/generichash.exp +0 -1
- data/vendor/libsodium/test/default/generichash3.c +1 -21
- data/vendor/libsodium/test/default/generichash3.exp +1 -1
- data/vendor/libsodium/test/default/hash.c +3 -3
- data/vendor/libsodium/test/default/hash3.c +2 -2
- data/vendor/libsodium/test/default/index.html.tpl +84 -0
- data/vendor/libsodium/test/default/onetimeauth.c +3 -3
- data/vendor/libsodium/test/default/onetimeauth2.c +5 -4
- data/vendor/libsodium/test/default/onetimeauth7.c +4 -4
- data/vendor/libsodium/test/default/pre.js.inc +14 -6
- data/vendor/libsodium/test/default/randombytes.c +2 -2
- data/vendor/libsodium/test/default/scalarmult.c +19 -6
- data/vendor/libsodium/test/default/scalarmult.exp +1 -0
- data/vendor/libsodium/test/default/scalarmult2.c +2 -2
- data/vendor/libsodium/test/default/scalarmult5.c +6 -4
- data/vendor/libsodium/test/default/scalarmult6.c +5 -3
- data/vendor/libsodium/test/default/scalarmult7.c +11 -7
- data/vendor/libsodium/test/default/secretbox.c +7 -6
- data/vendor/libsodium/test/default/secretbox2.c +7 -6
- data/vendor/libsodium/test/default/secretbox7.c +5 -5
- data/vendor/libsodium/test/default/secretbox8.c +5 -5
- data/vendor/libsodium/test/default/secretbox_easy.c +27 -17
- data/vendor/libsodium/test/default/secretbox_easy.exp +7 -95
- data/vendor/libsodium/test/default/secretbox_easy2.c +22 -10
- data/vendor/libsodium/test/default/sign.c +5 -0
- data/vendor/libsodium/test/default/sodium_utils.c +73 -0
- data/vendor/libsodium/test/default/sodium_utils.exp +6 -0
- data/vendor/libsodium/test/default/stream.c +7 -6
- data/vendor/libsodium/test/default/stream2.c +4 -4
- data/vendor/libsodium/test/default/stream3.c +6 -5
- data/vendor/libsodium/test/default/stream4.c +7 -6
- data/vendor/libsodium/test/default/verify1.c +61 -18
- data/vendor/libsodium/test/default/verify1.exp +2 -6
- metadata +37 -44
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha256/cp/api.h +0 -9
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512/cp/api.h +0 -9
- data/vendor/libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/api.h +0 -9
- data/vendor/libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/api.h +0 -20
- data/vendor/libsodium/src/libsodium/crypto_core/hsalsa20/ref2/api.h +0 -10
- data/vendor/libsodium/src/libsodium/crypto_core/salsa20/ref/api.h +0 -10
- data/vendor/libsodium/src/libsodium/crypto_core/salsa2012/ref/api.h +0 -10
- data/vendor/libsodium/src/libsodium/crypto_core/salsa208/ref/api.h +0 -10
- data/vendor/libsodium/src/libsodium/crypto_generichash/blake2/ref/api.h +0 -2
- data/vendor/libsodium/src/libsodium/crypto_hash/sha256/cp/api.h +0 -10
- data/vendor/libsodium/src/libsodium/crypto_hash/sha512/cp/api.h +0 -10
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/api.h +0 -6
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/base_curve25519_donna_c64.c +0 -13
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/api.h +0 -5
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/base_curve25519_ref10.c +0 -14
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/scalarmult_curve25519_ref10.c +0 -54
- data/vendor/libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519_api.c +0 -14
- data/vendor/libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/ref/api.h +0 -11
- data/vendor/libsodium/src/libsodium/crypto_shorthash/siphash24/ref/api.h +0 -7
- data/vendor/libsodium/src/libsodium/crypto_sign/ed25519/ref10/api.h +0 -15
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/api.h +0 -12
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/fe25519.h +0 -54
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/fe25519_edwards25519sha512batch.c +0 -348
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/ge25519.h +0 -34
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/ge25519_edwards25519sha512batch.c +0 -230
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sc25519.h +0 -51
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sc25519_edwards25519sha512batch.c +0 -150
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/ref/sign_edwards25519sha512batch.c +0 -106
- data/vendor/libsodium/src/libsodium/crypto_sign/edwards25519sha512batch/sign_edwards25519sha512batch_api.c +0 -16
- data/vendor/libsodium/src/libsodium/crypto_stream/aes128ctr/portable/api.h +0 -13
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/amd64_xmm6/api.h +0 -1
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa20/ref/api.h +0 -5
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa2012/ref/api.h +0 -10
- data/vendor/libsodium/src/libsodium/crypto_stream/salsa208/ref/api.h +0 -9
- data/vendor/libsodium/src/libsodium/crypto_stream/xsalsa20/ref/api.h +0 -11
- data/vendor/libsodium/src/libsodium/crypto_verify/16/ref/api.h +0 -2
- data/vendor/libsodium/src/libsodium/crypto_verify/32/ref/api.h +0 -2
- data/vendor/libsodium/src/libsodium/crypto_verify/64/ref/api.h +0 -2
@@ -2,6 +2,8 @@
|
|
2
2
|
#include "core.h"
|
3
3
|
#include "crypto_generichash.h"
|
4
4
|
#include "crypto_onetimeauth.h"
|
5
|
+
#include "crypto_scalarmult.h"
|
6
|
+
#include "crypto_stream_chacha20.h"
|
5
7
|
#include "randombytes.h"
|
6
8
|
#include "runtime.h"
|
7
9
|
#include "utils.h"
|
@@ -19,6 +21,8 @@ sodium_init(void)
|
|
19
21
|
_sodium_alloc_init();
|
20
22
|
_crypto_generichash_blake2b_pick_best_implementation();
|
21
23
|
_crypto_onetimeauth_poly1305_pick_best_implementation();
|
24
|
+
_crypto_scalarmult_curve25519_pick_best_implementation();
|
25
|
+
_crypto_stream_chacha20_pick_best_implementation();
|
22
26
|
initialized = 1;
|
23
27
|
|
24
28
|
return 0;
|
@@ -12,6 +12,7 @@ typedef struct CPUFeatures_ {
|
|
12
12
|
int has_sse3;
|
13
13
|
int has_ssse3;
|
14
14
|
int has_sse41;
|
15
|
+
int has_avx;
|
15
16
|
int has_pclmul;
|
16
17
|
int has_aesni;
|
17
18
|
} CPUFeatures;
|
@@ -22,6 +23,7 @@ static CPUFeatures _cpu_features;
|
|
22
23
|
#define CPUIDECX_SSE3 0x00000001
|
23
24
|
#define CPUIDECX_SSSE3 0x00000200
|
24
25
|
#define CPUIDECX_SSE41 0x00080000
|
26
|
+
#define CPUIDECX_AVX 0x10000000
|
25
27
|
#define CPUIDECX_PCLMUL 0x00000002
|
26
28
|
#define CPUIDECX_AESNI 0x02000000
|
27
29
|
|
@@ -100,36 +102,48 @@ _sodium_runtime_intel_cpu_features(CPUFeatures * const cpu_features)
|
|
100
102
|
return -1; /* LCOV_EXCL_LINE */
|
101
103
|
}
|
102
104
|
_cpuid(cpu_info, 0x00000001);
|
103
|
-
#
|
104
|
-
|
105
|
-
#else
|
105
|
+
#if defined(HAVE_EMMINTRIN_H) || \
|
106
|
+
(defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
|
106
107
|
cpu_features->has_sse2 = ((cpu_info[3] & CPUID_SSE2) != 0x0);
|
108
|
+
#else
|
109
|
+
cpu_features->has_sse2 = 0;
|
107
110
|
#endif
|
108
111
|
|
109
|
-
#
|
110
|
-
|
111
|
-
#else
|
112
|
+
#if defined(HAVE_PMMINTRIN_H) || \
|
113
|
+
(defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
|
112
114
|
cpu_features->has_sse3 = ((cpu_info[2] & CPUIDECX_SSE3) != 0x0);
|
115
|
+
#else
|
116
|
+
cpu_features->has_sse3 = 0;
|
113
117
|
#endif
|
114
118
|
|
115
|
-
#
|
116
|
-
|
117
|
-
#else
|
119
|
+
#if defined(HAVE_TMMINTRIN_H) || \
|
120
|
+
(defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
|
118
121
|
cpu_features->has_ssse3 = ((cpu_info[2] & CPUIDECX_SSSE3) != 0x0);
|
122
|
+
#else
|
123
|
+
cpu_features->has_ssse3 = 0;
|
119
124
|
#endif
|
120
125
|
|
121
|
-
#
|
122
|
-
|
123
|
-
#else
|
126
|
+
#if defined(HAVE_SMMINTRIN_H) || \
|
127
|
+
(defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
|
124
128
|
cpu_features->has_sse41 = ((cpu_info[2] & CPUIDECX_SSE41) != 0x0);
|
129
|
+
#else
|
130
|
+
cpu_features->has_sse41 = 0;
|
125
131
|
#endif
|
126
132
|
|
127
|
-
#
|
128
|
-
|
129
|
-
cpu_features->
|
133
|
+
#if defined(HAVE_AVXINTRIN_H) || \
|
134
|
+
(defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
|
135
|
+
cpu_features->has_avx = ((cpu_info[2] & CPUIDECX_AVX) != 0x0);
|
130
136
|
#else
|
137
|
+
cpu_features->has_avx = 0;
|
138
|
+
#endif
|
139
|
+
|
140
|
+
#if defined(HAVE_WMMINTRIN_H) || \
|
141
|
+
(defined(_MSC_VER) && (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)))
|
131
142
|
cpu_features->has_pclmul = ((cpu_info[2] & CPUIDECX_PCLMUL) != 0x0);
|
132
143
|
cpu_features->has_aesni = ((cpu_info[2] & CPUIDECX_AESNI) != 0x0);
|
144
|
+
#else
|
145
|
+
cpu_features->has_pclmul = 0;
|
146
|
+
cpu_features->has_aesni = 0;
|
133
147
|
#endif
|
134
148
|
|
135
149
|
return 0;
|
@@ -172,6 +186,11 @@ sodium_runtime_has_sse41(void) {
|
|
172
186
|
return _cpu_features.has_sse41;
|
173
187
|
}
|
174
188
|
|
189
|
+
int
|
190
|
+
sodium_runtime_has_avx(void) {
|
191
|
+
return _cpu_features.has_avx;
|
192
|
+
}
|
193
|
+
|
175
194
|
int
|
176
195
|
sodium_runtime_has_pclmul(void) {
|
177
196
|
return _cpu_features.has_pclmul;
|
@@ -113,7 +113,7 @@ sodium_memcmp(const void * const b1_, const void * const b2_, size_t len)
|
|
113
113
|
for (i = 0U; i < len; i++) {
|
114
114
|
d |= b1[i] ^ b2[i];
|
115
115
|
}
|
116
|
-
return (
|
116
|
+
return (1 & ((d - 1) >> 8)) - 1;
|
117
117
|
}
|
118
118
|
|
119
119
|
#ifdef HAVE_WEAK_SYMBOLS
|
@@ -154,6 +154,109 @@ sodium_compare(const unsigned char *b1_, const unsigned char *b2_, size_t len)
|
|
154
154
|
return (int) (gt + gt + eq) - 1;
|
155
155
|
}
|
156
156
|
|
157
|
+
int
|
158
|
+
sodium_is_zero(const unsigned char *n, const size_t nlen)
|
159
|
+
{
|
160
|
+
size_t i;
|
161
|
+
unsigned char d = 0U;
|
162
|
+
|
163
|
+
for (i = 0U; i < nlen; i++) {
|
164
|
+
d |= n[i];
|
165
|
+
}
|
166
|
+
return 1 & ((d - 1) >> 8);
|
167
|
+
}
|
168
|
+
|
169
|
+
void
|
170
|
+
sodium_increment(unsigned char *n, const size_t nlen)
|
171
|
+
{
|
172
|
+
size_t i = 0U;
|
173
|
+
uint_fast16_t c = 1U;
|
174
|
+
|
175
|
+
#ifdef HAVE_AMD64_ASM
|
176
|
+
uint64_t t64, t64_2;
|
177
|
+
uint32_t t32;
|
178
|
+
|
179
|
+
if (nlen == 12U) {
|
180
|
+
__asm__ __volatile__("xorq %[t64], %[t64] \n"
|
181
|
+
"xorl %[t32], %[t32] \n"
|
182
|
+
"stc \n"
|
183
|
+
"adcq %[t64], (%[out]) \n"
|
184
|
+
"adcl %[t32], 8(%[out]) \n"
|
185
|
+
: [t64] "=&r"(t64), [t32] "=&r" (t32)
|
186
|
+
: [out] "D"(n)
|
187
|
+
: "memory", "flags", "cc");
|
188
|
+
return;
|
189
|
+
} else if (nlen == 24U) {
|
190
|
+
__asm__ __volatile__("movq $1, %[t64] \n"
|
191
|
+
"xorq %[t64_2], %[t64_2] \n"
|
192
|
+
"addq %[t64], (%[out]) \n"
|
193
|
+
"adcq %[t64_2], 8(%[out]) \n"
|
194
|
+
"adcq %[t64_2], 16(%[out]) \n"
|
195
|
+
: [t64] "=&r"(t64), [t64_2] "=&r" (t64_2)
|
196
|
+
: [out] "D"(n)
|
197
|
+
: "memory", "flags", "cc");
|
198
|
+
return;
|
199
|
+
} else if (nlen == 8U) {
|
200
|
+
__asm__ __volatile__("incq (%[out]) \n"
|
201
|
+
:
|
202
|
+
: [out] "D"(n)
|
203
|
+
: "memory", "flags", "cc");
|
204
|
+
return;
|
205
|
+
}
|
206
|
+
#endif
|
207
|
+
for (; i < nlen; i++) {
|
208
|
+
c += (uint_fast16_t) n[i];
|
209
|
+
n[i] = (unsigned char) c;
|
210
|
+
c >>= 8;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
void
|
215
|
+
sodium_add(unsigned char *a, const unsigned char *b, const size_t len)
|
216
|
+
{
|
217
|
+
size_t i = 0U;
|
218
|
+
uint_fast16_t c = 0U;
|
219
|
+
|
220
|
+
#ifdef HAVE_AMD64_ASM
|
221
|
+
uint64_t t64, t64_2, t64_3;
|
222
|
+
uint32_t t32;
|
223
|
+
|
224
|
+
if (len == 12U) {
|
225
|
+
__asm__ __volatile__("movq (%[in]), %[t64] \n"
|
226
|
+
"movl 8(%[in]), %[t32] \n"
|
227
|
+
"addq %[t64], (%[out]) \n"
|
228
|
+
"adcl %[t32], 8(%[out]) \n"
|
229
|
+
: [t64] "=&r"(t64), [t32] "=&r" (t32)
|
230
|
+
: [in] "S"(b), [out] "D"(a)
|
231
|
+
: "memory", "flags", "cc");
|
232
|
+
return;
|
233
|
+
} else if (len == 24U) {
|
234
|
+
__asm__ __volatile__("movq (%[in]), %[t64] \n"
|
235
|
+
"movq 8(%[in]), %[t64_2] \n"
|
236
|
+
"movq 16(%[in]), %[t64_3] \n"
|
237
|
+
"addq %[t64], (%[out]) \n"
|
238
|
+
"adcq %[t64_2], 8(%[out]) \n"
|
239
|
+
"adcq %[t64_3], 16(%[out]) \n"
|
240
|
+
: [t64] "=&r"(t64), [t64_2] "=&r"(t64_2), [t64_3] "=&r"(t64_3)
|
241
|
+
: [in] "S"(b), [out] "D"(a)
|
242
|
+
: "memory", "flags", "cc");
|
243
|
+
return;
|
244
|
+
} else if (len == 8U) {
|
245
|
+
__asm__ __volatile__("movq (%[in]), %[t64] \n"
|
246
|
+
"addq %[t64], (%[out]) \n"
|
247
|
+
: [t64] "=&r"(t64)
|
248
|
+
: [in] "S"(b), [out] "D"(a)
|
249
|
+
: "memory", "flags", "cc");
|
250
|
+
return;
|
251
|
+
}
|
252
|
+
#endif
|
253
|
+
for (; i < len; i++) {
|
254
|
+
c += (uint_fast16_t) a[i] + (uint_fast16_t) b[i];
|
255
|
+
a[i] = (unsigned char) c;
|
256
|
+
c >>= 8;
|
257
|
+
}
|
258
|
+
}
|
259
|
+
|
157
260
|
/* Derived from original code by CodesInChaos */
|
158
261
|
char *
|
159
262
|
sodium_bin2hex(char * const hex, const size_t hex_maxlen,
|
@@ -568,16 +671,3 @@ sodium_mprotect_readwrite(void *ptr)
|
|
568
671
|
{
|
569
672
|
return _sodium_mprotect(ptr, _mprotect_readwrite);
|
570
673
|
}
|
571
|
-
|
572
|
-
void
|
573
|
-
sodium_increment(unsigned char *n, const size_t nlen)
|
574
|
-
{
|
575
|
-
size_t i;
|
576
|
-
unsigned int c = 1U << 8;
|
577
|
-
|
578
|
-
for (i = (size_t) 0U; i < nlen; i++) {
|
579
|
-
c >>= 8;
|
580
|
-
c += n[i];
|
581
|
-
n[i] = (unsigned char) c;
|
582
|
-
}
|
583
|
-
}
|
@@ -3,14 +3,14 @@
|
|
3
3
|
#include "cmptest.h"
|
4
4
|
|
5
5
|
/* "Test Case 2" from RFC 4231 */
|
6
|
-
unsigned char key[32] = "Jefe";
|
7
|
-
unsigned char c[] = "what do ya want for nothing?";
|
6
|
+
static unsigned char key[32] = "Jefe";
|
7
|
+
static unsigned char c[] = "what do ya want for nothing?";
|
8
8
|
|
9
9
|
/* Hacker manifesto */
|
10
|
-
unsigned char key2[] = "Another one got caught today, it's all over the papers. \"Teenager Arrested in Computer Crime Scandal\", \"Hacker Arrested after Bank Tampering\"... Damn kids. They're all alike.";
|
10
|
+
static unsigned char key2[] = "Another one got caught today, it's all over the papers. \"Teenager Arrested in Computer Crime Scandal\", \"Hacker Arrested after Bank Tampering\"... Damn kids. They're all alike.";
|
11
11
|
|
12
|
-
unsigned char a[crypto_auth_BYTES];
|
13
|
-
unsigned char a2[crypto_auth_hmacsha512_BYTES];
|
12
|
+
static unsigned char a[crypto_auth_BYTES];
|
13
|
+
static unsigned char a2[crypto_auth_hmacsha512_BYTES];
|
14
14
|
|
15
15
|
int main(void)
|
16
16
|
{
|
@@ -3,19 +3,19 @@
|
|
3
3
|
#define TEST_NAME "auth2"
|
4
4
|
#include "cmptest.h"
|
5
5
|
|
6
|
-
unsigned char key[32]
|
6
|
+
static unsigned char key[32]
|
7
7
|
= { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
|
8
8
|
0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
|
9
9
|
0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20 };
|
10
10
|
|
11
|
-
unsigned char c[50]
|
11
|
+
static unsigned char c[50]
|
12
12
|
= { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
|
13
13
|
0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
|
14
14
|
0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
|
15
15
|
0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
|
16
16
|
0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd };
|
17
17
|
|
18
|
-
unsigned char a[32];
|
18
|
+
static unsigned char a[32];
|
19
19
|
|
20
20
|
int main(void)
|
21
21
|
{
|
@@ -3,19 +3,19 @@
|
|
3
3
|
#define TEST_NAME "auth3"
|
4
4
|
#include "cmptest.h"
|
5
5
|
|
6
|
-
unsigned char key[32]
|
6
|
+
static unsigned char key[32]
|
7
7
|
= { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
|
8
8
|
0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
|
9
9
|
0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20 };
|
10
10
|
|
11
|
-
unsigned char c[50]
|
11
|
+
static unsigned char c[50]
|
12
12
|
= { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
|
13
13
|
0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
|
14
14
|
0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
|
15
15
|
0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
|
16
16
|
0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd };
|
17
17
|
|
18
|
-
unsigned char a[32]
|
18
|
+
static unsigned char a[32]
|
19
19
|
= { 0x37, 0x2e, 0xfc, 0xf9, 0xb4, 0x0b, 0x35, 0xc2, 0x11, 0x5b, 0x13,
|
20
20
|
0x46, 0x90, 0x3d, 0x2e, 0xf4, 0x2f, 0xce, 0xd4, 0x6f, 0x08, 0x46,
|
21
21
|
0xe7, 0x25, 0x7b, 0xb1, 0x56, 0xd3, 0xd7, 0xb3, 0x0d, 0x3f };
|
@@ -2,15 +2,15 @@
|
|
2
2
|
#define TEST_NAME "auth5"
|
3
3
|
#include "cmptest.h"
|
4
4
|
|
5
|
-
unsigned char key[32];
|
6
|
-
unsigned char c[
|
7
|
-
unsigned char a[32];
|
5
|
+
static unsigned char key[32];
|
6
|
+
static unsigned char c[1000];
|
7
|
+
static unsigned char a[32];
|
8
8
|
|
9
9
|
int main(void)
|
10
10
|
{
|
11
11
|
size_t clen;
|
12
12
|
|
13
|
-
for (clen = 0; clen <
|
13
|
+
for (clen = 0; clen < 1000; ++clen) {
|
14
14
|
randombytes_buf(key, sizeof key);
|
15
15
|
randombytes_buf(c, clen);
|
16
16
|
crypto_auth(a, c, clen, key);
|
@@ -3,10 +3,10 @@
|
|
3
3
|
#include "cmptest.h"
|
4
4
|
|
5
5
|
/* "Test Case 2" from RFC 4231 */
|
6
|
-
unsigned char key[32] = "Jefe";
|
7
|
-
unsigned char c[] = "what do ya want for nothing?";
|
6
|
+
static unsigned char key[32] = "Jefe";
|
7
|
+
static unsigned char c[] = "what do ya want for nothing?";
|
8
8
|
|
9
|
-
unsigned char a[64];
|
9
|
+
static unsigned char a[64];
|
10
10
|
|
11
11
|
int main(void)
|
12
12
|
{
|
@@ -2,15 +2,15 @@
|
|
2
2
|
#define TEST_NAME "auth7"
|
3
3
|
#include "cmptest.h"
|
4
4
|
|
5
|
-
unsigned char key[32];
|
6
|
-
unsigned char c[
|
7
|
-
unsigned char a[64];
|
5
|
+
static unsigned char key[32];
|
6
|
+
static unsigned char c[600];
|
7
|
+
static unsigned char a[64];
|
8
8
|
|
9
9
|
int main(void)
|
10
10
|
{
|
11
11
|
int clen;
|
12
12
|
|
13
|
-
for (clen = 0; clen <
|
13
|
+
for (clen = 0; clen < sizeof c; ++clen) {
|
14
14
|
randombytes_buf(key, sizeof key);
|
15
15
|
randombytes_buf(c, clen);
|
16
16
|
crypto_auth_hmacsha512(a, c, clen, key);
|
@@ -2,22 +2,23 @@
|
|
2
2
|
#define TEST_NAME "box"
|
3
3
|
#include "cmptest.h"
|
4
4
|
|
5
|
-
unsigned char alicesk[32]
|
5
|
+
static unsigned char alicesk[32]
|
6
6
|
= { 0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d, 0x3c, 0x16, 0xc1,
|
7
7
|
0x72, 0x51, 0xb2, 0x66, 0x45, 0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0,
|
8
8
|
0x99, 0x2a, 0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a };
|
9
9
|
|
10
|
-
unsigned char bobpk[32]
|
10
|
+
static unsigned char bobpk[32]
|
11
11
|
= { 0xde, 0x9e, 0xdb, 0x7d, 0x7b, 0x7d, 0xc1, 0xb4, 0xd3, 0x5b, 0x61,
|
12
12
|
0xc2, 0xec, 0xe4, 0x35, 0x37, 0x3f, 0x83, 0x43, 0xc8, 0x5b, 0x78,
|
13
13
|
0x67, 0x4d, 0xad, 0xfc, 0x7e, 0x14, 0x6f, 0x88, 0x2b, 0x4f };
|
14
14
|
|
15
|
-
unsigned char nonce[24]
|
16
|
-
|
17
|
-
|
15
|
+
static unsigned char nonce[24]
|
16
|
+
= { 0x69, 0x69, 0x6e, 0xe9, 0x55, 0xb6, 0x2b, 0x73,
|
17
|
+
0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6,
|
18
|
+
0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 };
|
18
19
|
|
19
20
|
// API requires first 32 bytes to be 0
|
20
|
-
unsigned char m[163]
|
21
|
+
static unsigned char m[163]
|
21
22
|
= { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
22
23
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
23
24
|
0, 0, 0, 0, 0, 0, 0, 0, 0xbe, 0x07, 0x5f, 0xc5,
|
@@ -33,14 +34,16 @@ unsigned char m[163]
|
|
33
34
|
0xf0, 0xa0, 0x89, 0xbc, 0x76, 0x89, 0x70, 0x40, 0xe0, 0x82, 0xf9, 0x37,
|
34
35
|
0x76, 0x38, 0x48, 0x64, 0x5e, 0x07, 0x05 };
|
35
36
|
|
36
|
-
unsigned char c[163];
|
37
|
+
static unsigned char c[163];
|
37
38
|
|
38
39
|
int main(void)
|
39
40
|
{
|
40
41
|
unsigned char k[crypto_box_BEFORENMBYTES];
|
41
42
|
int i;
|
43
|
+
int ret;
|
42
44
|
|
43
|
-
crypto_box(c, m, 163, nonce, bobpk, alicesk);
|
45
|
+
ret = crypto_box(c, m, 163, nonce, bobpk, alicesk);
|
46
|
+
assert(ret == 0);
|
44
47
|
for (i = 16; i < 163; ++i) {
|
45
48
|
printf(",0x%02x", (unsigned int)c[i]);
|
46
49
|
if (i % 8 == 7)
|
@@ -49,7 +52,8 @@ int main(void)
|
|
49
52
|
printf("\n");
|
50
53
|
|
51
54
|
memset(c, 0, sizeof c);
|
52
|
-
crypto_box_beforenm(k, bobpk, alicesk);
|
55
|
+
ret = crypto_box_beforenm(k, bobpk, alicesk);
|
56
|
+
assert(ret == 0);
|
53
57
|
crypto_box_afternm(c, m, 163, nonce, k);
|
54
58
|
for (i = 16; i < 163; ++i) {
|
55
59
|
printf(",0x%02x", (unsigned int)c[i]);
|
@@ -2,22 +2,23 @@
|
|
2
2
|
#define TEST_NAME "box2"
|
3
3
|
#include "cmptest.h"
|
4
4
|
|
5
|
-
unsigned char bobsk[32]
|
5
|
+
static unsigned char bobsk[32]
|
6
6
|
= { 0x5d, 0xab, 0x08, 0x7e, 0x62, 0x4a, 0x8a, 0x4b, 0x79, 0xe1, 0x7f,
|
7
7
|
0x8b, 0x83, 0x80, 0x0e, 0xe6, 0x6f, 0x3b, 0xb1, 0x29, 0x26, 0x18,
|
8
8
|
0xb6, 0xfd, 0x1c, 0x2f, 0x8b, 0x27, 0xff, 0x88, 0xe0, 0xeb };
|
9
9
|
|
10
|
-
unsigned char alicepk[32]
|
10
|
+
static unsigned char alicepk[32]
|
11
11
|
= { 0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 0x74, 0x8b, 0x7d,
|
12
12
|
0xdc, 0xb4, 0x3e, 0xf7, 0x5a, 0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38,
|
13
13
|
0x1a, 0xf4, 0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a };
|
14
14
|
|
15
|
-
unsigned char nonce[24]
|
16
|
-
|
17
|
-
|
15
|
+
static unsigned char nonce[24]
|
16
|
+
= { 0x69, 0x69, 0x6e, 0xe9, 0x55, 0xb6, 0x2b, 0x73,
|
17
|
+
0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6,
|
18
|
+
0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 };
|
18
19
|
|
19
20
|
// API requires first 16 bytes to be 0
|
20
|
-
unsigned char c[163]
|
21
|
+
static unsigned char c[163]
|
21
22
|
= { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
22
23
|
0, 0, 0, 0, 0xf3, 0xff, 0xc7, 0x70, 0x3f, 0x94, 0x00, 0xe5,
|
23
24
|
0x2a, 0x7d, 0xfb, 0x4b, 0x3d, 0x33, 0x05, 0xd9, 0x8e, 0x99, 0x3b, 0x9f,
|
@@ -33,12 +34,13 @@ unsigned char c[163]
|
|
33
34
|
0x79, 0x73, 0xf6, 0x22, 0xa4, 0x3d, 0x14, 0xa6, 0x59, 0x9b, 0x1f, 0x65,
|
34
35
|
0x4c, 0xb4, 0x5a, 0x74, 0xe3, 0x55, 0xa5 };
|
35
36
|
|
36
|
-
unsigned char m[163];
|
37
|
+
static unsigned char m[163];
|
37
38
|
|
38
39
|
int main(void)
|
39
40
|
{
|
40
41
|
unsigned char k[crypto_box_BEFORENMBYTES];
|
41
42
|
int i;
|
43
|
+
int ret;
|
42
44
|
|
43
45
|
if (crypto_box_open(m, c, 163, nonce, alicepk, bobsk) == 0) {
|
44
46
|
for (i = 32; i < 163; ++i) {
|
@@ -50,7 +52,8 @@ int main(void)
|
|
50
52
|
}
|
51
53
|
|
52
54
|
memset(m, 0, sizeof m);
|
53
|
-
crypto_box_beforenm(k, alicepk, bobsk);
|
55
|
+
ret = crypto_box_beforenm(k, alicepk, bobsk);
|
56
|
+
assert(ret == 0);
|
54
57
|
if (crypto_box_open_afternm(m, c, 163, nonce, k) == 0) {
|
55
58
|
for (i = 32; i < 163; ++i) {
|
56
59
|
printf(",0x%02x", (unsigned int)m[i]);
|