├── .github └── issue_template.md ├── .gitignore ├── .travis.yml ├── .uncrustify.cfg ├── AUTHORS ├── CMakeLists.txt ├── COPYING ├── Changes ├── INSTALL ├── LICENSE ├── Makefile.am ├── Makefile.in ├── README.md ├── acl ├── chn.acl ├── gfwlist.acl ├── local.acl └── server_block_chn.acl ├── aclocal.m4 ├── auto ├── ar-lib ├── compile ├── config.guess ├── config.rpath ├── config.sub ├── depcomp ├── install-sh ├── ltmain.sh └── missing ├── autogen.sh ├── cmake ├── CheckDIRSymbolExists.cmake ├── CheckPrototypeExists.cmake ├── CheckSTDC.cmake ├── FindPCRE.cmake ├── configure.cmake └── dist.cmake ├── completions └── bash │ ├── ss-local │ ├── ss-manager │ ├── ss-redir │ ├── ss-server │ └── ss-tunnel ├── config.h.cmake ├── config.h.in ├── configure ├── configure.ac ├── debian ├── .gitignore ├── README.Debian ├── changelog ├── compat ├── config.json ├── control ├── copyright ├── copyright.original ├── libshadowsocks-libev-dev.install ├── libshadowsocks-libev2.install ├── rules ├── shadowsocks-libev-local@.service ├── shadowsocks-libev-redir@.service ├── shadowsocks-libev-server@.service ├── shadowsocks-libev-tunnel@.service ├── shadowsocks-libev.default ├── shadowsocks-libev.docs ├── shadowsocks-libev.init ├── shadowsocks-libev.install ├── shadowsocks-libev.postinst ├── shadowsocks-libev.postrm ├── shadowsocks-libev.service ├── source.lintian-overrides ├── source │ └── format └── watch ├── doc ├── Makefile.am ├── Makefile.in ├── asciidoc.conf ├── manpage-base.xsl ├── manpage-bold-literal.xsl ├── manpage-normal.xsl ├── shadowsocks-libev.asciidoc ├── ss-local.asciidoc ├── ss-manager.asciidoc ├── ss-nat.asciidoc ├── ss-redir.asciidoc ├── ss-server.asciidoc └── ss-tunnel.asciidoc ├── docker ├── alpine │ ├── Dockerfile │ ├── README.md │ └── docker-compose.yml └── ubuntu │ ├── Dockerfile │ ├── README.md │ └── entrypoint ├── libcork ├── .idea │ ├── libcork-develop.iml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml ├── CMakeLists.txt ├── COPYING ├── Makefile.am ├── Makefile.in ├── README.markdown ├── cli │ └── commands.c ├── cmake │ └── FindCTargets.cmake ├── core │ ├── allocator.c │ ├── error.c │ ├── gc.c │ ├── hash.c │ ├── ip-address.c │ ├── mempool.c │ ├── timestamp.c │ ├── u128.c │ └── version.c ├── ds │ ├── array.c │ ├── bitset.c │ ├── buffer.c │ ├── dllist.c │ ├── file-stream.c │ ├── hash-table.c │ ├── managed-buffer.c │ ├── ring-buffer.c │ └── slice.c ├── include │ └── libcork │ │ ├── cli.h │ │ ├── cli │ │ └── commands.h │ │ ├── config.h │ │ ├── config │ │ ├── arch.h │ │ ├── bsd.h │ │ ├── config.h │ │ ├── gcc.h │ │ ├── linux.h │ │ ├── macosx.h │ │ ├── mingw32.h │ │ ├── solaris.h │ │ └── version.h │ │ ├── core.h │ │ ├── core │ │ ├── allocator.h │ │ ├── api.h │ │ ├── attributes.h │ │ ├── byte-order.h │ │ ├── callbacks.h │ │ ├── error.h │ │ ├── gc.h │ │ ├── hash.h │ │ ├── id.h │ │ ├── mempool.h │ │ ├── net-addresses.h │ │ ├── timestamp.h │ │ ├── types.h │ │ └── u128.h │ │ ├── ds.h │ │ ├── ds │ │ ├── array.h │ │ ├── bitset.h │ │ ├── buffer.h │ │ ├── dllist.h │ │ ├── hash-table.h │ │ ├── managed-buffer.h │ │ ├── ring-buffer.h │ │ ├── slice.h │ │ └── stream.h │ │ ├── helpers │ │ ├── errors.h │ │ ├── gc.h │ │ └── posix.h │ │ ├── os.h │ │ ├── os │ │ ├── files.h │ │ ├── process.h │ │ └── subprocess.h │ │ ├── threads.h │ │ └── threads │ │ ├── atomics.h │ │ └── basics.h ├── posix │ ├── directory-walker.c │ ├── env.c │ ├── exec.c │ ├── files.c │ ├── process.c │ └── subprocess.c └── pthreads │ └── thread.c ├── libev ├── CMakeLists.txt ├── Changes ├── LICENSE ├── Makefile.am ├── Makefile.in ├── README ├── Symbols.ev ├── Symbols.event ├── aclocal.m4 ├── autogen.sh ├── cmake │ ├── configure.cmake │ └── dist.cmake ├── config.h.cmake ├── configure.ac ├── ev++.h ├── ev.3 ├── ev.c ├── ev.h ├── ev.pod ├── ev_epoll.c ├── ev_kqueue.c ├── ev_poll.c ├── ev_port.c ├── ev_select.c ├── ev_vars.h ├── ev_win32.c ├── ev_wrap.h ├── event.c ├── event.h └── libev.m4 ├── libipset ├── CMakeLists.txt ├── LICENSE.txt ├── Makefile.am ├── Makefile.in ├── README.markdown ├── bdd │ ├── Makefile.am │ ├── Makefile.in │ ├── assignments.c │ ├── basics.c │ ├── bdd-iterator.c │ ├── expanded.c │ ├── reachable.c │ ├── read.c │ └── write.c ├── cmake │ └── FindCTargets.cmake ├── general.c ├── include │ └── ipset │ │ ├── bdd │ │ └── nodes.h │ │ ├── bits.h │ │ ├── errors.h │ │ ├── ipset.h │ │ └── logging.h ├── map │ ├── Makefile.am │ ├── Makefile.in │ ├── allocation.c │ ├── inspection-template.c.in │ ├── inspection.c │ ├── ipv4_map.c │ ├── ipv6_map.c │ └── storage.c └── set │ ├── Makefile.am │ ├── Makefile.in │ ├── allocation.c │ ├── inspection-template.c.in │ ├── inspection.c │ ├── ipv4_set.c │ ├── ipv6_set.c │ ├── iterator.c │ └── storage.c ├── libsodium ├── .gitignore ├── .travis.yml ├── AUTHORS ├── CMakeLists.txt ├── ChangeLog ├── LICENSE ├── Makefile.am ├── Makefile.in ├── README ├── README.markdown ├── THANKS ├── autogen.sh ├── build-aux │ ├── config.guess │ ├── config.sub │ ├── depcomp │ ├── install-sh │ ├── ltmain.sh │ └── missing ├── configure ├── configure.ac ├── libsodium.pc.in ├── libsodium.sln ├── libsodium.vcxproj ├── libsodium.vcxproj.filters ├── logo.png ├── m4 │ ├── ax_check_compile_flag.m4 │ ├── ax_check_define.m4 │ ├── ax_check_gnu_make.m4 │ ├── ax_check_link_flag.m4 │ ├── ld-output-def.m4 │ └── pkg.m4 ├── packaging │ └── nuget │ │ ├── .gitignore │ │ ├── package.bat │ │ ├── package.config │ │ ├── package.gsl │ │ ├── package.nuspec │ │ ├── package.targets │ │ └── package.xml ├── src │ ├── Makefile.am │ ├── Makefile.in │ └── libsodium │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── crypto_aead │ │ ├── aes256gcm │ │ │ └── aesni │ │ │ │ └── aead_aes256gcm_aesni.c │ │ └── chacha20poly1305 │ │ │ └── sodium │ │ │ └── aead_chacha20poly1305.c │ │ ├── crypto_auth │ │ ├── crypto_auth.c │ │ ├── hmacsha256 │ │ │ ├── auth_hmacsha256_api.c │ │ │ └── cp │ │ │ │ ├── hmac_hmacsha256.c │ │ │ │ └── verify_hmacsha256.c │ │ ├── hmacsha512 │ │ │ ├── auth_hmacsha512_api.c │ │ │ └── cp │ │ │ │ ├── hmac_hmacsha512.c │ │ │ │ └── verify_hmacsha512.c │ │ └── hmacsha512256 │ │ │ ├── auth_hmacsha512256_api.c │ │ │ └── cp │ │ │ ├── hmac_hmacsha512256.c │ │ │ └── verify_hmacsha512256.c │ │ ├── crypto_box │ │ ├── crypto_box.c │ │ ├── crypto_box_easy.c │ │ ├── crypto_box_seal.c │ │ └── curve25519xsalsa20poly1305 │ │ │ ├── box_curve25519xsalsa20poly1305_api.c │ │ │ └── ref │ │ │ ├── after_curve25519xsalsa20poly1305.c │ │ │ ├── before_curve25519xsalsa20poly1305.c │ │ │ ├── box_curve25519xsalsa20poly1305.c │ │ │ └── keypair_curve25519xsalsa20poly1305.c │ │ ├── crypto_core │ │ ├── hsalsa20 │ │ │ ├── core_hsalsa20_api.c │ │ │ └── ref2 │ │ │ │ └── core_hsalsa20.c │ │ ├── salsa20 │ │ │ ├── core_salsa20_api.c │ │ │ └── ref │ │ │ │ └── core_salsa20.c │ │ ├── salsa2012 │ │ │ ├── core_salsa2012_api.c │ │ │ └── ref │ │ │ │ └── core_salsa2012.c │ │ └── salsa208 │ │ │ ├── core_salsa208_api.c │ │ │ └── ref │ │ │ └── core_salsa208.c │ │ ├── crypto_generichash │ │ ├── blake2 │ │ │ ├── generichash_blake2_api.c │ │ │ └── ref │ │ │ │ ├── blake2-impl.h │ │ │ │ ├── blake2.h │ │ │ │ ├── blake2b-compress-ref.c │ │ │ │ ├── blake2b-compress-sse41.c │ │ │ │ ├── blake2b-compress-ssse3.c │ │ │ │ ├── blake2b-load-sse2.h │ │ │ │ ├── blake2b-load-sse41.h │ │ │ │ ├── blake2b-ref.c │ │ │ │ ├── blake2b-round.h │ │ │ │ └── generichash_blake2b.c │ │ └── crypto_generichash.c │ │ ├── crypto_hash │ │ ├── crypto_hash.c │ │ ├── sha256 │ │ │ ├── cp │ │ │ │ └── hash_sha256.c │ │ │ └── hash_sha256_api.c │ │ └── sha512 │ │ │ ├── cp │ │ │ └── hash_sha512.c │ │ │ └── hash_sha512_api.c │ │ ├── crypto_onetimeauth │ │ ├── crypto_onetimeauth.c │ │ └── poly1305 │ │ │ ├── donna │ │ │ ├── poly1305_donna.c │ │ │ ├── poly1305_donna.h │ │ │ ├── poly1305_donna32.h │ │ │ └── poly1305_donna64.h │ │ │ ├── onetimeauth_poly1305.c │ │ │ ├── onetimeauth_poly1305.h │ │ │ └── sse2 │ │ │ ├── poly1305_sse2.c │ │ │ └── poly1305_sse2.h │ │ ├── crypto_pwhash │ │ └── scryptsalsa208sha256 │ │ │ ├── crypto_scrypt-common.c │ │ │ ├── crypto_scrypt.h │ │ │ ├── nosse │ │ │ └── pwhash_scryptsalsa208sha256_nosse.c │ │ │ ├── pbkdf2-sha256.c │ │ │ ├── pbkdf2-sha256.h │ │ │ ├── pwhash_scryptsalsa208sha256.c │ │ │ ├── scrypt_platform.c │ │ │ ├── sse │ │ │ └── pwhash_scryptsalsa208sha256_sse.c │ │ │ └── sysendian.h │ │ ├── crypto_scalarmult │ │ ├── crypto_scalarmult.c │ │ └── curve25519 │ │ │ ├── donna_c64 │ │ │ ├── curve25519_donna_c64.c │ │ │ └── curve25519_donna_c64.h │ │ │ ├── ref10 │ │ │ ├── curve25519_ref10.c │ │ │ ├── curve25519_ref10.h │ │ │ ├── fe.h │ │ │ ├── fe_0_curve25519_ref10.c │ │ │ ├── fe_1_curve25519_ref10.c │ │ │ ├── fe_add_curve25519_ref10.c │ │ │ ├── fe_copy_curve25519_ref10.c │ │ │ ├── fe_cswap_curve25519_ref10.c │ │ │ ├── fe_frombytes_curve25519_ref10.c │ │ │ ├── fe_invert_curve25519_ref10.c │ │ │ ├── fe_mul121666_curve25519_ref10.c │ │ │ ├── fe_mul_curve25519_ref10.c │ │ │ ├── fe_sq_curve25519_ref10.c │ │ │ ├── fe_sub_curve25519_ref10.c │ │ │ ├── fe_tobytes_curve25519_ref10.c │ │ │ ├── montgomery.h │ │ │ └── pow225521.h │ │ │ ├── sandy2x │ │ │ ├── consts.S │ │ │ ├── consts_namespace.h │ │ │ ├── curve25519_sandy2x.c │ │ │ ├── curve25519_sandy2x.h │ │ │ ├── fe.h │ │ │ ├── fe51.h │ │ │ ├── fe51_invert.c │ │ │ ├── fe51_mul.S │ │ │ ├── fe51_namespace.h │ │ │ ├── fe51_nsquare.S │ │ │ ├── fe51_pack.S │ │ │ ├── fe_frombytes_sandy2x.c │ │ │ ├── ladder.S │ │ │ ├── ladder.h │ │ │ ├── ladder_base.S │ │ │ ├── ladder_base.h │ │ │ ├── ladder_base_namespace.h │ │ │ ├── ladder_namespace.h │ │ │ └── sandy2x.S │ │ │ ├── scalarmult_curve25519.c │ │ │ └── scalarmult_curve25519.h │ │ ├── crypto_secretbox │ │ ├── crypto_secretbox.c │ │ ├── crypto_secretbox_easy.c │ │ └── xsalsa20poly1305 │ │ │ ├── ref │ │ │ └── box_xsalsa20poly1305.c │ │ │ └── secretbox_xsalsa20poly1305_api.c │ │ ├── crypto_shorthash │ │ ├── crypto_shorthash.c │ │ └── siphash24 │ │ │ ├── ref │ │ │ └── shorthash_siphash24.c │ │ │ └── shorthash_siphash24_api.c │ │ ├── crypto_sign │ │ ├── crypto_sign.c │ │ └── ed25519 │ │ │ ├── description │ │ │ ├── ref10 │ │ │ ├── base.h │ │ │ ├── base2.h │ │ │ ├── d.h │ │ │ ├── d2.h │ │ │ ├── fe.h │ │ │ ├── fe_0.c │ │ │ ├── fe_1.c │ │ │ ├── fe_add.c │ │ │ ├── fe_cmov.c │ │ │ ├── fe_copy.c │ │ │ ├── fe_frombytes.c │ │ │ ├── fe_invert.c │ │ │ ├── fe_isnegative.c │ │ │ ├── fe_isnonzero.c │ │ │ ├── fe_mul.c │ │ │ ├── fe_neg.c │ │ │ ├── fe_pow22523.c │ │ │ ├── fe_sq.c │ │ │ ├── fe_sq2.c │ │ │ ├── fe_sub.c │ │ │ ├── fe_tobytes.c │ │ │ ├── ge.h │ │ │ ├── ge_add.c │ │ │ ├── ge_add.h │ │ │ ├── ge_double_scalarmult.c │ │ │ ├── ge_frombytes.c │ │ │ ├── ge_madd.c │ │ │ ├── ge_madd.h │ │ │ ├── ge_msub.c │ │ │ ├── ge_msub.h │ │ │ ├── ge_p1p1_to_p2.c │ │ │ ├── ge_p1p1_to_p3.c │ │ │ ├── ge_p2_0.c │ │ │ ├── ge_p2_dbl.c │ │ │ ├── ge_p2_dbl.h │ │ │ ├── ge_p3_0.c │ │ │ ├── ge_p3_dbl.c │ │ │ ├── ge_p3_to_cached.c │ │ │ ├── ge_p3_to_p2.c │ │ │ ├── ge_p3_tobytes.c │ │ │ ├── ge_precomp_0.c │ │ │ ├── ge_scalarmult_base.c │ │ │ ├── ge_sub.c │ │ │ ├── ge_sub.h │ │ │ ├── ge_tobytes.c │ │ │ ├── keypair.c │ │ │ ├── obsolete.c │ │ │ ├── open.c │ │ │ ├── pow22523.h │ │ │ ├── pow225521.h │ │ │ ├── sc.h │ │ │ ├── sc_muladd.c │ │ │ ├── sc_reduce.c │ │ │ ├── sign.c │ │ │ └── sqrtm1.h │ │ │ └── sign_ed25519_api.c │ │ ├── crypto_stream │ │ ├── aes128ctr │ │ │ ├── portable │ │ │ │ ├── afternm_aes128ctr.c │ │ │ │ ├── beforenm_aes128ctr.c │ │ │ │ ├── common.h │ │ │ │ ├── common_aes128ctr.c │ │ │ │ ├── consts.h │ │ │ │ ├── consts_aes128ctr.c │ │ │ │ ├── int128.h │ │ │ │ ├── int128_aes128ctr.c │ │ │ │ ├── stream_aes128ctr.c │ │ │ │ ├── types.h │ │ │ │ └── xor_afternm_aes128ctr.c │ │ │ └── stream_aes128ctr_api.c │ │ ├── chacha20 │ │ │ ├── ref │ │ │ │ ├── stream_chacha20_ref.c │ │ │ │ └── stream_chacha20_ref.h │ │ │ ├── stream_chacha20.c │ │ │ ├── stream_chacha20.h │ │ │ └── vec │ │ │ │ ├── stream_chacha20_vec.c │ │ │ │ └── stream_chacha20_vec.h │ │ ├── crypto_stream.c │ │ ├── salsa20 │ │ │ ├── amd64_xmm6 │ │ │ │ └── stream_salsa20_amd64_xmm6.S │ │ │ ├── ref │ │ │ │ ├── stream_salsa20_ref.c │ │ │ │ └── xor_salsa20_ref.c │ │ │ └── stream_salsa20_api.c │ │ ├── salsa2012 │ │ │ ├── ref │ │ │ │ ├── stream_salsa2012.c │ │ │ │ └── xor_salsa2012.c │ │ │ └── stream_salsa2012_api.c │ │ ├── salsa208 │ │ │ ├── ref │ │ │ │ ├── stream_salsa208.c │ │ │ │ └── xor_salsa208.c │ │ │ └── stream_salsa208_api.c │ │ └── xsalsa20 │ │ │ ├── ref │ │ │ ├── stream_xsalsa20.c │ │ │ └── xor_xsalsa20.c │ │ │ └── stream_xsalsa20_api.c │ │ ├── crypto_verify │ │ ├── 16 │ │ │ ├── ref │ │ │ │ └── verify_16.c │ │ │ └── verify_16_api.c │ │ ├── 32 │ │ │ ├── ref │ │ │ │ └── verify_32.c │ │ │ └── verify_32_api.c │ │ └── 64 │ │ │ ├── ref │ │ │ └── verify_64.c │ │ │ └── verify_64_api.c │ │ ├── include │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── sodium.h │ │ └── sodium │ │ │ ├── core.h │ │ │ ├── crypto_aead_aes256gcm.h │ │ │ ├── crypto_aead_chacha20poly1305.h │ │ │ ├── crypto_auth.h │ │ │ ├── crypto_auth_hmacsha256.h │ │ │ ├── crypto_auth_hmacsha512.h │ │ │ ├── crypto_auth_hmacsha512256.h │ │ │ ├── crypto_box.h │ │ │ ├── crypto_box_curve25519xsalsa20poly1305.h │ │ │ ├── crypto_core_hsalsa20.h │ │ │ ├── crypto_core_salsa20.h │ │ │ ├── crypto_core_salsa2012.h │ │ │ ├── crypto_core_salsa208.h │ │ │ ├── crypto_generichash.h │ │ │ ├── crypto_generichash_blake2b.h │ │ │ ├── crypto_hash.h │ │ │ ├── crypto_hash_sha256.h │ │ │ ├── crypto_hash_sha512.h │ │ │ ├── crypto_int32.h │ │ │ ├── crypto_int64.h │ │ │ ├── crypto_onetimeauth.h │ │ │ ├── crypto_onetimeauth_poly1305.h │ │ │ ├── crypto_pwhash_scryptsalsa208sha256.h │ │ │ ├── crypto_scalarmult.h │ │ │ ├── crypto_scalarmult_curve25519.h │ │ │ ├── crypto_secretbox.h │ │ │ ├── crypto_secretbox_xsalsa20poly1305.h │ │ │ ├── crypto_shorthash.h │ │ │ ├── crypto_shorthash_siphash24.h │ │ │ ├── crypto_sign.h │ │ │ ├── crypto_sign_ed25519.h │ │ │ ├── crypto_sign_edwards25519sha512batch.h │ │ │ ├── crypto_stream.h │ │ │ ├── crypto_stream_aes128ctr.h │ │ │ ├── crypto_stream_chacha20.h │ │ │ ├── crypto_stream_salsa20.h │ │ │ ├── crypto_stream_salsa2012.h │ │ │ ├── crypto_stream_salsa208.h │ │ │ ├── crypto_stream_xsalsa20.h │ │ │ ├── crypto_uint16.h │ │ │ ├── crypto_uint32.h │ │ │ ├── crypto_uint64.h │ │ │ ├── crypto_uint8.h │ │ │ ├── crypto_verify_16.h │ │ │ ├── crypto_verify_32.h │ │ │ ├── crypto_verify_64.h │ │ │ ├── export.h │ │ │ ├── randombytes.h │ │ │ ├── randombytes_nativeclient.h │ │ │ ├── randombytes_salsa20_random.h │ │ │ ├── randombytes_sysrandom.h │ │ │ ├── runtime.h │ │ │ ├── utils.h │ │ │ └── version.h.in │ │ ├── randombytes │ │ ├── nativeclient │ │ │ └── randombytes_nativeclient.c │ │ ├── randombytes.c │ │ ├── salsa20 │ │ │ └── randombytes_salsa20_random.c │ │ └── sysrandom │ │ │ └── randombytes_sysrandom.c │ │ └── sodium │ │ ├── core.c │ │ ├── runtime.c │ │ ├── utils.c │ │ └── version.c └── test │ ├── HAVE_AMD64_ASM.c │ ├── HAVE_CPUID.c │ ├── HAVE_TI_MODE.c │ ├── HAVE_WEAK_SYMBOLS.c │ ├── IS_STDC_LIMIT_MACROS_NEEDED.c │ ├── Makefile.am │ ├── default │ ├── CMakeLists.txt │ ├── Makefile.am │ ├── aead_chacha20poly1305.c │ ├── auth.c │ ├── auth2.c │ ├── auth3.c │ ├── auth5.c │ ├── auth6.c │ ├── auth7.c │ ├── box.c │ ├── box2.c │ ├── box7.c │ ├── box8.c │ ├── box_easy.c │ ├── box_easy2.c │ ├── box_seal.c │ ├── box_seed.c │ ├── chacha20.c │ ├── cmptest.h │ ├── core1.c │ ├── core2.c │ ├── core3.c │ ├── core4.c │ ├── core5.c │ ├── core6.c │ ├── ed25519_convert.c │ ├── generichash.c │ ├── generichash2.c │ ├── generichash3.c │ ├── hash.c │ ├── hash3.c │ ├── onetimeauth.c │ ├── onetimeauth2.c │ ├── onetimeauth7.c │ ├── pre.js.inc │ ├── pwhash.c │ ├── pwhash_scrypt_ll.c │ ├── randombytes.c │ ├── scalarmult.c │ ├── scalarmult2.c │ ├── scalarmult5.c │ ├── scalarmult6.c │ ├── scalarmult7.c │ ├── secretbox.c │ ├── secretbox2.c │ ├── secretbox7.c │ ├── secretbox8.c │ ├── secretbox_easy.c │ ├── secretbox_easy2.c │ ├── shorthash.c │ ├── sign.c │ ├── sodium_core.c │ ├── sodium_utils.c │ ├── sodium_utils2.c │ ├── sodium_utils3.c │ ├── sodium_version.c │ ├── stream.c │ ├── stream2.c │ ├── stream3.c │ ├── stream4.c │ ├── verify1.c │ └── wintest.bat │ └── quirks │ └── quirks.h ├── libudns ├── CMakeLists.txt ├── COPYING.LGPL ├── Makefile.am ├── Makefile.in ├── NEWS ├── NOTES ├── TODO ├── dnsget.1 ├── dnsget.c ├── ex-rdns.c ├── getopt.c ├── inet_XtoX.c ├── rblcheck.1 ├── rblcheck.c ├── udns.3 ├── udns.h ├── udns_XtoX.c ├── udns_bl.c ├── udns_codes.c ├── udns_dn.c ├── udns_dntosp.c ├── udns_init.c ├── udns_jran.c ├── udns_misc.c ├── udns_parse.c ├── udns_resolver.c ├── udns_rr_a.c ├── udns_rr_mx.c ├── udns_rr_naptr.c ├── udns_rr_ptr.c ├── udns_rr_srv.c └── udns_rr_txt.c ├── m4 ├── ax_pthread.m4 ├── ax_tls.m4 ├── inet_ntop.m4 ├── libtool.m4 ├── ltoptions.m4 ├── ltsugar.m4 ├── ltversion.m4 ├── lt~obsolete.m4 ├── mbedtls.m4 ├── openssl.m4 ├── pcre.m4 ├── polarssl.m4 ├── stack-protector.m4 └── zlib.m4 ├── rpm ├── SOURCES │ └── etc │ │ └── init.d │ │ └── shadowsocks-libev ├── SPECS │ └── shadowsocks-libev.spec.in └── genrpm.sh ├── shadowsocks-libev.pc.in └── src ├── CMakeLists.txt ├── Makefile.am ├── Makefile.in ├── acl.c ├── acl.h ├── android.c ├── cache.c ├── cache.h ├── common.h ├── encrypt.c ├── encrypt.h ├── http.c ├── http.h ├── includeobfs.h ├── jconf.c ├── jconf.h ├── json.c ├── json.h ├── local.c ├── local.h ├── manager.c ├── manager.h ├── netutils.c ├── netutils.h ├── obfs ├── auth.c ├── auth.h ├── auth_chain.c ├── auth_chain.h ├── base64.c ├── base64.h ├── crc32.c ├── crc32.h ├── http_simple.c ├── http_simple.h ├── obfs.c ├── obfs.h ├── obfsutil.c ├── obfsutil.h ├── tls1.2_ticket.c ├── tls1.2_ticket.h ├── verify.c └── verify.h ├── protocol.h ├── redir.c ├── redir.h ├── resolv.c ├── resolv.h ├── rule.c ├── rule.h ├── server.c ├── server.h ├── shadowsocks.h ├── socks5.h ├── ss-nat ├── ssrlink.py ├── tls.c ├── tls.h ├── tunnel.c ├── tunnel.h ├── udprelay.c ├── udprelay.h ├── uthash.h ├── utils.c ├── utils.h ├── win32.c └── win32.h /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | Please answer these questions before submitting your issue. Thanks! 2 | 3 | ### What version of shadowsocks-libev are you using? 4 | 5 | 6 | ### What operating system are you using? 7 | 8 | 9 | ### What did you do? 10 | 11 | 12 | ### What did you expect to see? 13 | 14 | 15 | ### What did you see instead? 16 | 17 | 18 | ### What is your config in detail (with all sensitive info masked)? 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | .deps/ 3 | /Makefile 4 | src/Makefile 5 | libev/Makefile 6 | libudns/Makefile 7 | libcork/Makefile 8 | libipset/Makefile 9 | doc/Makefile 10 | autom4te.cache/ 11 | /config.h 12 | config.log 13 | config.status 14 | libtool 15 | pid 16 | src/ss-* 17 | !src/ss-nat 18 | stamp-h1 19 | .libs 20 | .pc 21 | debian/shadowsocks-libev/ 22 | debian/patches/ 23 | debian/files 24 | debian/shadowsocks-libev.substvars 25 | debian/*.debhelper* 26 | .dirstamp 27 | shadowsocks-libev.pc 28 | debian/libshadowsocks-libev*.symbols 29 | libsodium/src/libsodium/include/sodium/version.h 30 | rpm/SPECS/shadowsocks-libev.spec 31 | 32 | # Ignore per-project vim config 33 | .vimrc 34 | 35 | # Ignore garbage of OS X 36 | *.DS_Store 37 | 38 | # Ignore vim cache 39 | *.swp 40 | 41 | # Documentation files 42 | doc/*.1 43 | doc/*.8 44 | doc/*.gz 45 | doc/*.xml 46 | doc/*.html 47 | 48 | # Do not edit the following section 49 | # Edit Compile Debug Document Distribute 50 | *~ 51 | *.bak 52 | *.bin 53 | *.dll 54 | *.exe 55 | *-ISO*.bdf 56 | *-JIS*.bdf 57 | *-KOI8*.bdf 58 | *.kld 59 | *.ko 60 | *.ko.cmd 61 | *.lai 62 | *.l[oa] 63 | *.[oa] 64 | *.obj 65 | *.patch 66 | *.so 67 | *.pcf.gz 68 | *.pdb 69 | *.tar.bz2 70 | *.tar.gz 71 | # 72 | cmake-build* 73 | .idea/ 74 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | compiler: 3 | - gcc 4 | - clang 5 | addons: 6 | apt: 7 | packages: 8 | - asciidoc 9 | - xmlto 10 | script: "./configure && make" 11 | branches: 12 | only: 13 | - master 14 | notifications: 15 | recipients: 16 | - max.c.lv@gmail.com 17 | email: 18 | on_success: change 19 | on_failure: always 20 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Shadowsocks-libev was originally created in late 2013, by 2 | Clowwindy , then rewritten and maintained by 3 | Max Lv . 4 | 5 | Here is an inevitably incomplete list of MUCH-APPRECIATED CONTRIBUTORS -- 6 | people who have submitted patches, fixed bugs, added translations, and 7 | generally made shadowsocks-libev that much better: 8 | 9 | https://github.com/shadowsocks/shadowsocks-libev/graphs/contributors 10 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # ---------------------------------------------------------------------- 3 | # Copyright © 2011-2015, RedJack, LLC. 4 | # All rights reserved. 5 | # 6 | # Please see the COPYING file in this distribution for license details. 7 | # ---------------------------------------------------------------------- 8 | 9 | set(CMAKE_LEGACY_CYGWIN_WIN32 0) 10 | 11 | cmake_minimum_required(VERSION 2.6) 12 | set(PROJECT_NAME shadowsocks-libev) 13 | set(RELEASE_DATE 2015-09-03) 14 | project(${PROJECT_NAME}) 15 | 16 | set(VERSION 2.5.6) 17 | 18 | 19 | set(with_crypto_library "openssl" CACHE STRING "build with the given crypto library, TYPE=openssl|polarssl|mbedtls default=openssl") 20 | 21 | 22 | 23 | include ( cmake/dist.cmake ) 24 | include ( configure ) 25 | 26 | configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ) 27 | 28 | add_subdirectory(libsodium) 29 | add_subdirectory(libcork) 30 | add_subdirectory(libipset) 31 | add_subdirectory(libev) 32 | 33 | 34 | include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) 35 | 36 | add_subdirectory(libudns) 37 | add_subdirectory(src) 38 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | This program is free software: you can redistribute it and/or modify 2 | it under the terms of the GNU General Public License as published by 3 | the Free Software Foundation, either version 3 of the License, or 4 | (at your option) any later version. 5 | 6 | This program is distributed in the hope that it will be useful, 7 | but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License 12 | along with this program. If not, see . 13 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | if USE_SYSTEM_SHARED_LIB 2 | SUBDIRS = libcork libipset src 3 | else 4 | SUBDIRS = libsodium libcork libipset libudns libev src 5 | endif 6 | 7 | if ENABLE_DOCUMENTATION 8 | SUBDIRS += doc 9 | endif 10 | 11 | ACLOCAL_AMFLAGS = -I m4 12 | 13 | pkgconfiglibdir = $(libdir)/pkgconfig 14 | pkgconfiglib_DATA = shadowsocks-libev.pc 15 | -------------------------------------------------------------------------------- /acl/local.acl: -------------------------------------------------------------------------------- 1 | [reject_all] 2 | 3 | [white_list] 4 | 127.0.0.1 5 | ::1 6 | 10.0.0.0/8 7 | 172.16.0.0/12 8 | 192.168.0.0/16 9 | fc00::/7 10 | -------------------------------------------------------------------------------- /auto/config.rpath: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shadowsocksr-rm/shadowsocksr-libev/a32c032cb1e424686748fb4fa3a2beae1b342334/auto/config.rpath -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | autoreconf --install --force 4 | -------------------------------------------------------------------------------- /cmake/dist.cmake: -------------------------------------------------------------------------------- 1 | # LuaDist CMake utility library. 2 | # Provides sane project defaults and macros common to LuaDist CMake builds. 3 | # 4 | # Copyright (C) 2007-2012 LuaDist. 5 | # by David Manura, Peter Drahoš 6 | # Redistribution and use of this file is allowed according to the terms of the MIT license. 7 | # For details see the COPYRIGHT file distributed with LuaDist. 8 | # Please note that the package source code is licensed under its own license. 9 | 10 | 11 | # Tweaks and other defaults 12 | # Setting CMAKE to use loose block and search for find modules in source directory 13 | set ( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true ) 14 | set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH} ) 15 | 16 | # In MSVC, prevent warnings that can occur when using standard libraries. 17 | if ( MSVC ) 18 | add_definitions ( -D_CRT_SECURE_NO_WARNINGS ) 19 | endif () 20 | 21 | -------------------------------------------------------------------------------- /completions/bash/ss-local: -------------------------------------------------------------------------------- 1 | _ss_local() 2 | { 3 | local cur prev opts ciphers 4 | opts='-s -b -p -k -f -t -m -c -a -n -u -U -v -h -A --fast-open --mtu --help --mptcp -i --acl -l' 5 | ciphers='rc4-md5 table rc4 aes-128-cfb aes-192-cfb aes-256-cfb aes-128-ctr aes-192-ctr aes-256-ctr bf-cfb camellia-128-cfb camellia-192-cfb camellia-256-cfb cast5-cfb des-cfb idea-cfb rc2-cfb seed-cfb salsa20 chacha20 and chacha20-ietf' 6 | cur=${COMP_WORDS[COMP_CWORD]} 7 | prev="${COMP_WORDS[COMP_CWORD-1]}" 8 | case "$prev" in 9 | -c|-f|--acl) 10 | _filedir || COMPREPLY=( $(compgen -o plusdirs -f ${cur}) ) 11 | ;; 12 | -s|-b) 13 | _known_hosts_real -- "${cur}" || OMPREPLY=( $(compgen -A hostname -- ${cur}) ) 14 | ;; 15 | -m) 16 | COMPREPLY=( $(compgen -W "$ciphers" -- ${cur}) ) 17 | ;; 18 | -a) 19 | _allowed_users || COMPREPLY=( $(compgen -u -- ${cur}) ) 20 | ;; 21 | -p|-k|-t|-n|--mtu|-l) 22 | ;; 23 | -i) 24 | _available_interfaces -a || true 25 | ;; 26 | *) 27 | COMPREPLY+=( $(compgen -W "${opts}" -- ${cur}) ) 28 | ;; 29 | esac 30 | return 0 31 | } 32 | 33 | complete -F _ss_local ss-local 34 | -------------------------------------------------------------------------------- /completions/bash/ss-redir: -------------------------------------------------------------------------------- 1 | _ss_redir() 2 | { 3 | local cur prev opts ciphers 4 | ciphers='rc4-md5 table rc4 aes-128-cfb aes-192-cfb aes-256-cfb aes-128-ctr aes-192-ctr aes-256-ctr bf-cfb camellia-128-cfb camellia-192-cfb camellia-256-cfb cast5-cfb des-cfb idea-cfb rc2-cfb seed-cfb salsa20 chacha20 and chacha20-ietf' 5 | opts='-s -b -p -k -f -t -m -c -a -n -u -U -v -h -A --mtu --help --mptcp -l' 6 | cur=${COMP_WORDS[COMP_CWORD]} 7 | prev="${COMP_WORDS[COMP_CWORD-1]}" 8 | case "$prev" in 9 | -c|-f) 10 | _filedir || COMPREPLY=( $(compgen -o plusdirs -f ${cur}) ) 11 | ;; 12 | -s|-b) 13 | _known_hosts_real -- "${cur}" || OMPREPLY=( $(compgen -A hostname -- ${cur}) ) 14 | ;; 15 | -m) 16 | COMPREPLY=( $(compgen -W "$ciphers" -- ${cur}) ) 17 | ;; 18 | -a) 19 | _allowed_users || COMPREPLY=( $(compgen -u -- ${cur}) ) 20 | ;; 21 | -p|-k|-t|-n|--mtu|-l) 22 | ;; 23 | *) 24 | COMPREPLY+=( $(compgen -W "${opts}" -- ${cur}) ) 25 | ;; 26 | esac 27 | return 0 28 | } 29 | 30 | complete -F _ss_redir ss-redir 31 | -------------------------------------------------------------------------------- /debian/.gitignore: -------------------------------------------------------------------------------- 1 | *.substvars 2 | debhelper-build-stamp 3 | libshadowsocks-libev*/ 4 | libshadowsocks-libev-dev/ 5 | tmp/ 6 | -------------------------------------------------------------------------------- /debian/README.Debian: -------------------------------------------------------------------------------- 1 | shadowsocks-libev for Debian 2 | ---------------------- 3 | 4 | The Debian package has added systemd support. A default server service which 5 | reads the default configuration in /etc/default/shadowsocks-libev is installed 6 | and enabled by default, plus some other service templates placed in 7 | /lib/systemd/system, which can be used by users later. 8 | 9 | Another problem is that shadowsocks-libev is licensed under GPLv3+. This will 10 | conflict with OpenSSL License when linked against OpenSSL library. As a 11 | result, this package faces licensing problem. Use it at your own risk. 12 | 13 | -- Boyuan Yang <073plan@gmail.com> Wed, 14 Oct 2015 09:18:50 +0800 14 | 15 | (No special notes.) 16 | 17 | -- Max Lv Sat, 06 Apr 2013 16:59:15 +0800 18 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /debian/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "server":"127.0.0.1", 3 | "server_port":8388, 4 | "local_port":1080, 5 | "password":"barfoo!", 6 | "timeout":60, 7 | "method":null 8 | } 9 | -------------------------------------------------------------------------------- /debian/copyright.original: -------------------------------------------------------------------------------- 1 | This work was packaged for Debian by: 2 | 3 | Max Lv on Sat, 06 Apr 2013 16:59:15 +0800 4 | 5 | It was downloaded from: 6 | 7 | https://github.com/madeye/shadowsocks-libev 8 | 9 | Upstream Author(s): 10 | 11 | clowwindy 12 | 13 | Copyright: 14 | 15 | Copyright (C) 2013 Max Lv 16 | 17 | License: 18 | 19 | GPLv3 20 | 21 | The Debian packaging is: 22 | 23 | Copyright (C) 2013 Max Lv 24 | -------------------------------------------------------------------------------- /debian/libshadowsocks-libev-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/ 2 | usr/lib/*/libshadowsocks-libev.so 3 | usr/lib/*/pkgconfig/ 4 | -------------------------------------------------------------------------------- /debian/libshadowsocks-libev2.install: -------------------------------------------------------------------------------- 1 | usr/lib/*/libshadowsocks-libev.so.* 2 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # See debhelper(7) (uncomment to enable) 3 | # output every command that modifies files on the build system. 4 | #export DH_VERBOSE = 1 5 | 6 | # Security Hardening 7 | export DEB_BUILD_MAINT_OPTIONS = hardening=+all 8 | 9 | DPKG_EXPORT_BUILDFLAGS = 1 10 | include /usr/share/dpkg/buildflags.mk 11 | 12 | override_dh_auto_install: 13 | find src/ -name '*.la' -delete 14 | dh_auto_install 15 | 16 | override_dh_auto_configure: 17 | dh_auto_configure -- \ 18 | --enable-shared \ 19 | --disable-ssp 20 | 21 | override_dh_installchangelogs: 22 | dh_installchangelogs -XChanges 23 | 24 | %: 25 | dh $@ --with systemd 26 | -------------------------------------------------------------------------------- /debian/shadowsocks-libev-local@.service: -------------------------------------------------------------------------------- 1 | # This file is part of shadowsocks-libev. 2 | # 3 | # Shadowsocks-libev is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This is a template unit file. Users may copy and rename the file into 9 | # config directories to make new service instances. See systemd.unit(5) 10 | # for details. 11 | 12 | [Unit] 13 | Description=Shadowsocks-Libev Custom Client Service for %I 14 | Documentation=man:ss-local(1) 15 | After=network.target 16 | 17 | [Service] 18 | Type=simple 19 | CapabilityBoundingSet=CAP_NET_BIND_SERVICE 20 | ExecStart=/usr/bin/ss-local -c /etc/shadowsocks-libev/%i.json 21 | 22 | [Install] 23 | WantedBy=multi-user.target 24 | 25 | -------------------------------------------------------------------------------- /debian/shadowsocks-libev-redir@.service: -------------------------------------------------------------------------------- 1 | # This file is part of shadowsocks-libev. 2 | # 3 | # Shadowsocks-libev is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This is a template unit file. Users may copy and rename the file into 9 | # config directories to make new service instances. See systemd.unit(5) 10 | # for details. 11 | 12 | [Unit] 13 | Description=Shadowsocks-Libev Custom Client Service Redir Mode for %I 14 | Documentation=man:ss-redir(1) 15 | After=network.target 16 | 17 | [Service] 18 | Type=simple 19 | CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE 20 | ExecStart=/usr/bin/ss-redir -c /etc/shadowsocks-libev/%i.json 21 | 22 | [Install] 23 | WantedBy=multi-user.target 24 | 25 | -------------------------------------------------------------------------------- /debian/shadowsocks-libev-server@.service: -------------------------------------------------------------------------------- 1 | # This file is part of shadowsocks-libev. 2 | # 3 | # Shadowsocks-libev is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This is a template unit file. Users may copy and rename the file into 9 | # config directories to make new service instances. See systemd.unit(5) 10 | # for details. 11 | 12 | [Unit] 13 | Description=Shadowsocks-Libev Custom Server Service for %I 14 | Documentation=man:ss-server(1) 15 | After=network.target 16 | 17 | [Service] 18 | Type=simple 19 | CapabilityBoundingSet=CAP_NET_BIND_SERVICE 20 | ExecStart=/usr/bin/ss-server -c /etc/shadowsocks-libev/%i.json 21 | 22 | [Install] 23 | WantedBy=multi-user.target 24 | 25 | -------------------------------------------------------------------------------- /debian/shadowsocks-libev-tunnel@.service: -------------------------------------------------------------------------------- 1 | # This file is part of shadowsocks-libev. 2 | # 3 | # Shadowsocks-libev is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This is a template unit file. Users may copy and rename the file into 9 | # config directories to make new service instances. See systemd.unit(5) 10 | # for details. 11 | 12 | [Unit] 13 | Description=Shadowsocks-Libev Custom Client Service Tunnel Mode for %I 14 | Documentation=man:ss-tunnel(1) 15 | After=network.target 16 | 17 | [Service] 18 | Type=simple 19 | CapabilityBoundingSet=CAP_NET_BIND_SERVICE 20 | ExecStart=/usr/bin/ss-tunnel -c /etc/shadowsocks-libev/%i.json 21 | 22 | [Install] 23 | WantedBy=multi-user.target 24 | 25 | -------------------------------------------------------------------------------- /debian/shadowsocks-libev.default: -------------------------------------------------------------------------------- 1 | # Defaults for shadowsocks initscript 2 | # sourced by /etc/init.d/shadowsocks-libev 3 | # installed at /etc/default/shadowsocks-libev by the maintainer scripts 4 | 5 | # 6 | # This is a POSIX shell fragment 7 | # 8 | # Note: `START', `GROUP' and `MAXFD' options are not recognized by systemd. 9 | # Please change those settings in the corresponding systemd unit file. 10 | 11 | # Enable during startup? 12 | START=yes 13 | 14 | # Configuration file 15 | CONFFILE="/etc/shadowsocks-libev/config.json" 16 | 17 | # Extra command line arguments 18 | DAEMON_ARGS="-u" 19 | 20 | # User and group to run the server as 21 | USER=root 22 | GROUP=root 23 | 24 | # Number of maximum file descriptors 25 | MAXFD=32768 26 | -------------------------------------------------------------------------------- /debian/shadowsocks-libev.docs: -------------------------------------------------------------------------------- 1 | AUTHORS 2 | README.md 3 | debian/copyright.original 4 | -------------------------------------------------------------------------------- /debian/shadowsocks-libev.install: -------------------------------------------------------------------------------- 1 | debian/config.json usr/share/shadowsocks-libev 2 | debian/shadowsocks-libev-*.service lib/systemd/system 3 | usr/bin/ 4 | usr/share/man/ 5 | completions/bash/* usr/share/bash-completion/completions/ 6 | -------------------------------------------------------------------------------- /debian/shadowsocks-libev.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | case "$1" in 6 | configure|reconfigure) 7 | if [ ! -f /etc/shadowsocks-libev/config.json ]; then 8 | passwd=$(apg -n 1 -M ncl) 9 | mkdir -p /etc/shadowsocks-libev 10 | sed "s/barfoo!/$passwd/" /usr/share/shadowsocks-libev/config.json \ 11 | > /etc/shadowsocks-libev/config.json 12 | fi 13 | ;; 14 | abort-upgrade|abort-remove|abort-deconfigure) 15 | exit 0 16 | ;; 17 | *) 18 | echo "postinst called with unknown argument \`$1'" >&2 19 | exit 0 20 | ;; 21 | esac 22 | 23 | #DEBHELPER# 24 | 25 | exit 0 26 | -------------------------------------------------------------------------------- /debian/shadowsocks-libev.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | case "$1" in 6 | purge) 7 | rm -f /etc/shadowsocks-libev/config.json 8 | test -f /etc/shadowsocks-libev/* \ 9 | || rm -r /etc/shadowsocks-libev/ 10 | ;; 11 | remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) 12 | exit 0 13 | ;; 14 | *) 15 | echo "postrm called with unknown argument \`$1'" >&2 16 | exit 0 17 | ;; 18 | esac 19 | 20 | #DEBHELPER# 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /debian/shadowsocks-libev.service: -------------------------------------------------------------------------------- 1 | # This file is part of shadowsocks-libev. 2 | # 3 | # Shadowsocks-libev is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This file is default for Debian packaging. See also 9 | # /etc/default/shadowsocks-libev for environment variables. 10 | 11 | [Unit] 12 | Description=Shadowsocks-libev Default Server Service 13 | Documentation=man:shadowsocks-libev(8) 14 | After=network.target 15 | 16 | [Service] 17 | Type=simple 18 | EnvironmentFile=/etc/default/shadowsocks-libev 19 | User=root 20 | LimitNOFILE=32768 21 | ExecStart=/usr/bin/ss-server -a $USER -c $CONFFILE $DAEMON_ARGS 22 | 23 | [Install] 24 | WantedBy=multi-user.target 25 | 26 | -------------------------------------------------------------------------------- /debian/source.lintian-overrides: -------------------------------------------------------------------------------- 1 | # false positive: #505857 2 | shadowsocks-libev source: debian-watch-file-should-mangle-version 3 | # false positive: #765166 4 | shadowsocks-libev source: license-problem-gfdl-invariants 5 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /debian/watch: -------------------------------------------------------------------------------- 1 | version=4 2 | 3 | opts=" \ 4 | filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%shadowsocks-libev-$1.tar.gz%" \ 5 | https://github.com/shadowsocks/shadowsocks-libev/tags \ 6 | (?:.*?/)?v?(\d[\d.]*)\.tar\.gz debian uupdate 7 | -------------------------------------------------------------------------------- /doc/asciidoc.conf: -------------------------------------------------------------------------------- 1 | [tags] 2 | bracket-emphasis={1?[{1}]}<|> 3 | 4 | [quotes] 5 | <|>=#bracket-emphasis 6 | 7 | [attributes] 8 | asterisk=* 9 | plus=+ 10 | caret=^ 11 | startsb=[ 12 | endsb=] 13 | backslash=\ 14 | tilde=~ 15 | apostrophe=' 16 | backtick=` 17 | litdd=-- 18 | 19 | ifdef::doctype-manpage[] 20 | ifdef::backend-docbook[] 21 | [header] 22 | template::[header-declarations] 23 | 24 | 25 | {mantitle} 26 | {manvolnum} 27 | Shadowsocks-libev 28 | {version} 29 | Shadowsocks-libev Manual 30 | 31 | 32 | {manname} 33 | {manpurpose} 34 | 35 | endif::backend-docbook[] 36 | endif::doctype-manpage[] 37 | -------------------------------------------------------------------------------- /doc/manpage-base.xsl: -------------------------------------------------------------------------------- 1 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 13 | 14 | 18 | 19 | 20 | 21 | sp 22 | 23 | 24 | 25 | 26 | 30 | 31 | 32 | br 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /doc/manpage-bold-literal.xsl: -------------------------------------------------------------------------------- 1 | 3 | 5 | 6 | 9 | 10 | 11 | fB 12 | 13 | 14 | fR 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /doc/manpage-normal.xsl: -------------------------------------------------------------------------------- 1 | 4 | 6 | 7 | 8 | 9 | 10 | \ 11 | . 12 | 13 | 14 | -------------------------------------------------------------------------------- /docker/alpine/docker-compose.yml: -------------------------------------------------------------------------------- 1 | shadowsocks: 2 | image: shadowsocks-libev 3 | ports: 4 | - "8388:8388/tcp" 5 | - "8388:8388/udp" 6 | environment: 7 | - METHOD=aes-256-cfb 8 | - PASSWORD=9MLSpPmNt 9 | restart: always 10 | -------------------------------------------------------------------------------- /docker/ubuntu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:latest 2 | 3 | MAINTAINER Sah Lee 4 | 5 | ENV DEPENDENCIES git-core build-essential autoconf libtool libssl-dev asciidoc xmlto 6 | ENV BASEDIR /tmp/shadowsocks-libev 7 | ENV SERVER_PORT 8338 8 | 9 | # Set up building environment 10 | RUN apt-get update \ 11 | && apt-get install -y $DEPENDENCIES 12 | 13 | # Get the latest code, build and install 14 | RUN git clone https://github.com/shadowsocks/shadowsocks-libev.git $BASEDIR 15 | WORKDIR $BASEDIR 16 | RUN ./configure \ 17 | && make \ 18 | && make install 19 | 20 | # Tear down building environment and delete git repository 21 | WORKDIR / 22 | RUN rm -rf $BASEDIR/shadowsocks-libev\ 23 | && apt-get --purge autoremove -y $DEPENDENCIES 24 | 25 | # Port in the config file won't take affect. Instead we'll use 8388. 26 | EXPOSE $SERVER_PORT 27 | EXPOSE $SERVER_PORT/udp 28 | 29 | # Override the host and port in the config file. 30 | ADD entrypoint / 31 | ENTRYPOINT ["/entrypoint"] 32 | CMD ["-h"] 33 | -------------------------------------------------------------------------------- /libcork/.idea/libcork-develop.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libcork/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /libcork/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /libcork/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libcork.la 2 | 3 | cli_src = cli/commands.c 4 | core_src = core/allocator.c core/error.c core/gc.c \ 5 | core/hash.c core/ip-address.c core/mempool.c \ 6 | core/timestamp.c core/u128.c 7 | ds_src = ds/array.c ds/bitset.c ds/buffer.c ds/dllist.c \ 8 | ds/file-stream.c ds/hash-table.c ds/managed-buffer.c \ 9 | ds/ring-buffer.c ds/slice.c 10 | posix_src = posix/directory-walker.c posix/env.c posix/exec.c \ 11 | posix/files.c posix/process.c posix/subprocess.c 12 | pthreads_src = pthreads/thread.c 13 | 14 | libcork_la_SOURCES = $(cli_src) $(core_src) $(ds_src) \ 15 | $(posix_src) $(pthreads_src) 16 | libcork_la_CFLAGS = -I$(top_srcdir)/libcork/include -DCORK_API=CORK_LOCAL 17 | 18 | libcork_la_LDFLAGS = -static 19 | -------------------------------------------------------------------------------- /libcork/core/hash.c: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2011, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #define CORK_HASH_ATTRIBUTES CORK_API 12 | 13 | #include "libcork/core/hash.h" 14 | #include "libcork/core/types.h" 15 | 16 | /* All of the following functions will be defined for us by libcork/core/hash.h: 17 | * cork_hash_buffer 18 | * cork_big_hash_buffer 19 | * cork_stable_hash_buffer 20 | */ 21 | -------------------------------------------------------------------------------- /libcork/core/version.c: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2015, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license details. 7 | * ---------------------------------------------------------------------- 8 | */ 9 | 10 | #include "libcork/config.h" 11 | #include "libcork/core/api.h" 12 | 13 | 14 | /*----------------------------------------------------------------------- 15 | * Library version 16 | */ 17 | 18 | const char * 19 | cork_version_string(void) 20 | { 21 | return CORK_CONFIG_VERSION_STRING; 22 | } 23 | 24 | const char * 25 | cork_revision_string(void) 26 | { 27 | return CORK_CONFIG_REVISION; 28 | } 29 | -------------------------------------------------------------------------------- /libcork/include/libcork/cli.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2012, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef LIBCORK_CLI_H 12 | #define LIBCORK_CLI_H 13 | 14 | /*** include all of the parts ***/ 15 | 16 | #include 17 | 18 | #endif /* LIBCORK_CLI_H */ 19 | -------------------------------------------------------------------------------- /libcork/include/libcork/config.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2011, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef LIBCORK_CONFIG_H 12 | #define LIBCORK_CONFIG_H 13 | 14 | /*** include all of the parts ***/ 15 | 16 | #include 17 | 18 | #endif /* LIBCORK_CONFIG_H */ 19 | -------------------------------------------------------------------------------- /libcork/include/libcork/config/arch.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2012-2013, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef LIBCORK_CONFIG_ARCH_H 12 | #define LIBCORK_CONFIG_ARCH_H 13 | 14 | 15 | /*----------------------------------------------------------------------- 16 | * Platform 17 | */ 18 | 19 | #if defined(__i386__) || defined(_M_IX86) 20 | #define CORK_CONFIG_ARCH_X86 1 21 | #else 22 | #define CORK_CONFIG_ARCH_X86 0 23 | #endif 24 | 25 | #if defined(__x86_64__) || defined(_M_X64) 26 | #define CORK_CONFIG_ARCH_X64 1 27 | #else 28 | #define CORK_CONFIG_ARCH_X64 0 29 | #endif 30 | 31 | #if defined(__powerpc__) || defined(__ppc__) 32 | /* GCC-ish compiler */ 33 | #define CORK_CONFIG_ARCH_PPC 1 34 | #elif defined(_M_PPC) 35 | /* VS-ish compiler */ 36 | #define CORK_CONFIG_ARCH_PPC 1 37 | #elif defined(_ARCH_PPC) 38 | /* Something called XL C/C++? */ 39 | #define CORK_CONFIG_ARCH_PPC 1 40 | #else 41 | #define CORK_CONFIG_ARCH_PPC 0 42 | #endif 43 | 44 | 45 | #endif /* LIBCORK_CONFIG_ARCH_H */ 46 | -------------------------------------------------------------------------------- /libcork/include/libcork/config/bsd.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2013, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef LIBCORK_CONFIG_BSD_H 12 | #define LIBCORK_CONFIG_BSD_H 13 | 14 | /*----------------------------------------------------------------------- 15 | * Endianness 16 | */ 17 | 18 | #include 19 | 20 | #if BYTE_ORDER == BIG_ENDIAN 21 | #define CORK_CONFIG_IS_BIG_ENDIAN 1 22 | #define CORK_CONFIG_IS_LITTLE_ENDIAN 0 23 | #elif BYTE_ORDER == LITTLE_ENDIAN 24 | #define CORK_CONFIG_IS_BIG_ENDIAN 0 25 | #define CORK_CONFIG_IS_LITTLE_ENDIAN 1 26 | #else 27 | #error "Cannot determine system endianness" 28 | #endif 29 | 30 | #define CORK_HAVE_REALLOCF 1 31 | #define CORK_HAVE_PTHREADS 1 32 | 33 | 34 | #endif /* LIBCORK_CONFIG_BSD_H */ 35 | -------------------------------------------------------------------------------- /libcork/include/libcork/config/linux.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2011, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef LIBCORK_CONFIG_LINUX_H 12 | #define LIBCORK_CONFIG_LINUX_H 13 | 14 | /*----------------------------------------------------------------------- 15 | * Endianness 16 | */ 17 | 18 | #include 19 | 20 | #if __BYTE_ORDER == __BIG_ENDIAN 21 | #define CORK_CONFIG_IS_BIG_ENDIAN 1 22 | #define CORK_CONFIG_IS_LITTLE_ENDIAN 0 23 | #elif __BYTE_ORDER == __LITTLE_ENDIAN 24 | #define CORK_CONFIG_IS_BIG_ENDIAN 0 25 | #define CORK_CONFIG_IS_LITTLE_ENDIAN 1 26 | #else 27 | #error "Cannot determine system endianness" 28 | #endif 29 | 30 | #define CORK_HAVE_REALLOCF 0 31 | #define CORK_HAVE_PTHREADS 1 32 | 33 | 34 | #endif /* LIBCORK_CONFIG_LINUX_H */ 35 | -------------------------------------------------------------------------------- /libcork/include/libcork/config/macosx.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2011, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef LIBCORK_CONFIG_MACOSX_H 12 | #define LIBCORK_CONFIG_MACOSX_H 13 | 14 | /*----------------------------------------------------------------------- 15 | * Endianness 16 | */ 17 | 18 | #include 19 | 20 | #if BYTE_ORDER == BIG_ENDIAN 21 | #define CORK_CONFIG_IS_BIG_ENDIAN 1 22 | #define CORK_CONFIG_IS_LITTLE_ENDIAN 0 23 | #elif BYTE_ORDER == LITTLE_ENDIAN 24 | #define CORK_CONFIG_IS_BIG_ENDIAN 0 25 | #define CORK_CONFIG_IS_LITTLE_ENDIAN 1 26 | #else 27 | #error "Cannot determine system endianness" 28 | #endif 29 | 30 | #define CORK_HAVE_REALLOCF 1 31 | #define CORK_HAVE_PTHREADS 1 32 | 33 | 34 | #endif /* LIBCORK_CONFIG_MACOSX_H */ 35 | -------------------------------------------------------------------------------- /libcork/include/libcork/config/mingw32.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2011, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef LIBCORK_CONFIG_MINGW32_H 12 | #define LIBCORK_CONFIG_MINGW32_H 13 | 14 | #include 15 | 16 | /*----------------------------------------------------------------------- 17 | * Endianness 18 | */ 19 | 20 | /* Assume MinGW32 only works on x86 platform */ 21 | 22 | #define CORK_CONFIG_IS_BIG_ENDIAN 0 23 | #define CORK_CONFIG_IS_LITTLE_ENDIAN 1 24 | 25 | #define CORK_HAVE_REALLOCF 0 26 | #define CORK_HAVE_PTHREADS 1 27 | 28 | /* 29 | * File io stuff. Odd that this is not defined by MinGW. 30 | * Maybe there is an M$ish way to do it. 31 | */ 32 | #define F_SETFL 4 33 | #define O_NONBLOCK 0x4000 /* non blocking I/O (POSIX style) */ 34 | 35 | #define F_GETFD 1 36 | #define F_SETFD 2 37 | #define FD_CLOEXEC 0x1 38 | 39 | #define WNOHANG 1 40 | 41 | /* 42 | * simple adaptors 43 | */ 44 | 45 | static inline int mingw_mkdir(const char *path, int mode) 46 | { 47 | return mkdir(path); 48 | } 49 | #define mkdir mingw_mkdir 50 | 51 | #define S_ISLNK(x) 0 52 | 53 | 54 | #endif /* LIBCORK_CONFIG_MINGW32_H */ 55 | -------------------------------------------------------------------------------- /libcork/include/libcork/config/solaris.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2013, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef LIBCORK_CONFIG_SOLARIS_H 12 | #define LIBCORK_CONFIG_SOLARIS_H 13 | 14 | /*----------------------------------------------------------------------- 15 | * Endianness 16 | */ 17 | 18 | #include 19 | 20 | #if defined(_BIG_ENDIAN) 21 | #define CORK_CONFIG_IS_BIG_ENDIAN 1 22 | #define CORK_CONFIG_IS_LITTLE_ENDIAN 0 23 | #elif defined(_LITTLE_ENDIAN) 24 | #define CORK_CONFIG_IS_BIG_ENDIAN 0 25 | #define CORK_CONFIG_IS_LITTLE_ENDIAN 1 26 | #else 27 | #error "Cannot determine system endianness" 28 | #endif 29 | 30 | #define CORK_HAVE_REALLOCF 0 31 | #define CORK_HAVE_PTHREADS 1 32 | 33 | 34 | #endif /* LIBCORK_CONFIG_SOLARIS_H */ 35 | -------------------------------------------------------------------------------- /libcork/include/libcork/config/version.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2015, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license details. 7 | * ---------------------------------------------------------------------- 8 | */ 9 | 10 | #ifndef LIBCORK_CONFIG_VERSION_H 11 | #define LIBCORK_CONFIG_VERSION_H 12 | 13 | 14 | /*----------------------------------------------------------------------- 15 | * Library version 16 | */ 17 | 18 | #define CORK_CONFIG_VERSION_MAJOR 0 19 | #define CORK_CONFIG_VERSION_MINOR 15 20 | #define CORK_CONFIG_VERSION_PATCH 0 21 | #define CORK_CONFIG_VERSION_STRING "0.15.0" 22 | #define CORK_CONFIG_REVISION "d6ecc2cfbcdf5013038a72b4544f7d9e6eb8f92d" 23 | 24 | 25 | #endif /* LIBCORK_CONFIG_VERSION_H */ 26 | -------------------------------------------------------------------------------- /libcork/include/libcork/core.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2011-2013, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license details. 7 | * ---------------------------------------------------------------------- 8 | */ 9 | 10 | #ifndef LIBCORK_CORE_H 11 | #define LIBCORK_CORE_H 12 | 13 | /*** include all of the parts ***/ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #endif /* LIBCORK_CORE_H */ 30 | -------------------------------------------------------------------------------- /libcork/include/libcork/core/callbacks.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2013-2014, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license details. 7 | * ---------------------------------------------------------------------- 8 | */ 9 | 10 | #ifndef LIBCORK_CORE_CALLBACKS_H 11 | #define LIBCORK_CORE_CALLBACKS_H 12 | 13 | 14 | #include 15 | 16 | 17 | typedef int 18 | (*cork_copy_f)(void *user_data, void *dest, const void *src); 19 | 20 | typedef void 21 | (*cork_done_f)(void *user_data, void *value); 22 | 23 | typedef void 24 | (*cork_free_f)(void *value); 25 | 26 | typedef cork_hash 27 | (*cork_hash_f)(void *user_data, const void *value); 28 | 29 | typedef bool 30 | (*cork_equals_f)(void *user_data, const void *value1, const void *value2); 31 | 32 | typedef void 33 | (*cork_init_f)(void *user_data, void *value); 34 | 35 | #define cork_free_user_data(parent) \ 36 | ((parent)->free_user_data == NULL? (void) 0: \ 37 | (parent)->free_user_data((parent)->user_data)) 38 | 39 | typedef void * 40 | (*cork_new_f)(void *user_data); 41 | 42 | typedef int 43 | (*cork_run_f)(void *user_data); 44 | 45 | 46 | #endif /* LIBCORK_CORE_CALLBACKS_H */ 47 | -------------------------------------------------------------------------------- /libcork/include/libcork/core/id.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2013, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license details. 7 | * ---------------------------------------------------------------------- 8 | */ 9 | 10 | #ifndef LIBCORK_CORE_ID_H 11 | #define LIBCORK_CORE_ID_H 12 | 13 | #include 14 | 15 | 16 | struct cork_uid { 17 | const char *name; 18 | }; 19 | 20 | typedef const struct cork_uid *cork_uid; 21 | 22 | #define CORK_UID_NONE ((cork_uid) NULL) 23 | 24 | #define cork_uid_define_named(c_name, name) \ 25 | static const struct cork_uid c_name##__id = { name }; \ 26 | static cork_uid c_name = &c_name##__id; 27 | #define cork_uid_define(c_name) \ 28 | cork_uid_define_named(c_name, #c_name) 29 | 30 | #define cork_uid_equal(id1, id2) ((id1) == (id2)) 31 | #define cork_uid_hash(id) ((cork_hash) (uintptr_t) (id)) 32 | #define cork_uid_name(id) ((id)->name) 33 | 34 | 35 | #endif /* LIBCORK_CORE_ID_H */ 36 | -------------------------------------------------------------------------------- /libcork/include/libcork/ds.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2011, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef LIBCORK_DS_H 12 | #define LIBCORK_DS_H 13 | 14 | /*** include all of the parts ***/ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #endif /* LIBCORK_DS_H */ 27 | -------------------------------------------------------------------------------- /libcork/include/libcork/helpers/gc.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2011-2012, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef LIBCORK_HELPERS_REFCOUNT_H 12 | #define LIBCORK_HELPERS_REFCOUNT_H 13 | 14 | 15 | #include 16 | #include 17 | 18 | 19 | #define _free_(name) \ 20 | static void \ 21 | name##__free(void *obj) 22 | 23 | 24 | #define _recurse_(name) \ 25 | static void \ 26 | name##__recurse(struct cork_gc *gc, void *obj, \ 27 | cork_gc_recurser recurse, void *ud) 28 | 29 | 30 | #define _gc_(name) \ 31 | static struct cork_gc_obj_iface name##__gc = { \ 32 | name##__free, name##__recurse \ 33 | }; 34 | 35 | #define _gc_no_free_(name) \ 36 | static struct cork_gc_obj_iface name##__gc = { \ 37 | NULL, name##__recurse \ 38 | }; 39 | 40 | #define _gc_no_recurse_(name) \ 41 | static struct cork_gc_obj_iface name##__gc = { \ 42 | name##__free, NULL \ 43 | }; 44 | 45 | #define _gc_leaf_(name) \ 46 | static struct cork_gc_obj_iface name##__gc = { \ 47 | NULL, NULL \ 48 | }; 49 | 50 | 51 | #endif /* LIBCORK_HELPERS_REFCOUNT_H */ 52 | -------------------------------------------------------------------------------- /libcork/include/libcork/os.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2012-2013, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef LIBCORK_OS_H 12 | #define LIBCORK_OS_H 13 | 14 | /*** include all of the parts ***/ 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | #endif /* LIBCORK_OS_H */ 21 | -------------------------------------------------------------------------------- /libcork/include/libcork/os/process.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2013, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef LIBCORK_CORE_PROCESS_H 12 | #define LIBCORK_CORE_PROCESS_H 13 | 14 | #include 15 | 16 | 17 | typedef void 18 | (*cork_cleanup_function)(void); 19 | 20 | CORK_API void 21 | cork_cleanup_at_exit_named(const char *name, int priority, 22 | cork_cleanup_function function); 23 | 24 | #define cork_cleanup_at_exit(priority, function) \ 25 | cork_cleanup_at_exit_named(#function, priority, function) 26 | 27 | 28 | #endif /* LIBCORK_CORE_PROCESS_H */ 29 | -------------------------------------------------------------------------------- /libcork/include/libcork/threads.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2012, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the COPYING file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef LIBCORK_THREADS_H 12 | #define LIBCORK_THREADS_H 13 | 14 | /*** include all of the parts ***/ 15 | 16 | #include 17 | #include 18 | 19 | #endif /* LIBCORK_THREADS_H */ 20 | -------------------------------------------------------------------------------- /libev/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2007-2013 LuaDist. 2 | # Created by Peter Drahoš, Peter Kapec 3 | # Redistribution and use of this file is allowed according to the terms of the MIT license. 4 | # For details see the COPYRIGHT file distributed with LuaDist. 5 | # Please note that the package source code is licensed under its own license. 6 | 7 | project ( libev C ) 8 | cmake_minimum_required ( VERSION 2.8 ) 9 | include ( cmake/dist.cmake ) 10 | #include ( configure ) 11 | 12 | #configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ) 13 | include_directories( ${CMAKE_BINARY_DIR} ) 14 | 15 | set ( EV_SRC 16 | ev.c 17 | event.c 18 | ) 19 | 20 | if (CYGWIN) 21 | list ( APPEND EV_LIBS Ws2_32 ) 22 | endif () 23 | 24 | add_library ( ev STATIC ${EV_SRC} ) 25 | target_link_libraries ( ev ${EV_LIBS} ) 26 | 27 | set(libev_include_dirs 28 | ${PROJECT_SOURCE_DIR} 29 | CACHE INTERNAL "libev library" FORCE 30 | ) 31 | -------------------------------------------------------------------------------- /libev/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | VERSION_INFO = 4:0:0 4 | 5 | EXTRA_DIST = LICENSE Changes libev.m4 autogen.sh \ 6 | ev_vars.h ev_wrap.h \ 7 | ev_epoll.c ev_select.c ev_poll.c ev_kqueue.c ev_port.c ev_win32.c \ 8 | ev.3 ev.pod Symbols.ev Symbols.event 9 | 10 | noinst_MANS = ev.3 11 | 12 | noinst_HEADERS = ev.h ev++.h event.h 13 | 14 | noinst_LTLIBRARIES = libev.la 15 | 16 | libev_la_SOURCES = ev.c event.c 17 | libev_la_LDFLAGS = -version-info $(VERSION_INFO) 18 | 19 | ev.3: ev.pod 20 | pod2man -n LIBEV -r "libev-$(VERSION)" -c "libev - high performance full featured event loop" -s3 <$< >$@ 21 | -------------------------------------------------------------------------------- /libev/Symbols.ev: -------------------------------------------------------------------------------- 1 | ev_async_send 2 | ev_async_start 3 | ev_async_stop 4 | ev_backend 5 | ev_break 6 | ev_check_start 7 | ev_check_stop 8 | ev_child_start 9 | ev_child_stop 10 | ev_cleanup_start 11 | ev_cleanup_stop 12 | ev_clear_pending 13 | ev_default_loop 14 | ev_default_loop_ptr 15 | ev_depth 16 | ev_embed_start 17 | ev_embed_stop 18 | ev_embed_sweep 19 | ev_embeddable_backends 20 | ev_feed_event 21 | ev_feed_fd_event 22 | ev_feed_signal 23 | ev_feed_signal_event 24 | ev_fork_start 25 | ev_fork_stop 26 | ev_idle_start 27 | ev_idle_stop 28 | ev_invoke 29 | ev_invoke_pending 30 | ev_io_start 31 | ev_io_stop 32 | ev_iteration 33 | ev_loop_destroy 34 | ev_loop_fork 35 | ev_loop_new 36 | ev_now 37 | ev_now_update 38 | ev_once 39 | ev_pending_count 40 | ev_periodic_again 41 | ev_periodic_start 42 | ev_periodic_stop 43 | ev_prepare_start 44 | ev_prepare_stop 45 | ev_recommended_backends 46 | ev_ref 47 | ev_resume 48 | ev_run 49 | ev_set_allocator 50 | ev_set_invoke_pending_cb 51 | ev_set_io_collect_interval 52 | ev_set_loop_release_cb 53 | ev_set_syserr_cb 54 | ev_set_timeout_collect_interval 55 | ev_set_userdata 56 | ev_signal_start 57 | ev_signal_stop 58 | ev_sleep 59 | ev_stat_start 60 | ev_stat_stat 61 | ev_stat_stop 62 | ev_supported_backends 63 | ev_suspend 64 | ev_time 65 | ev_timer_again 66 | ev_timer_remaining 67 | ev_timer_start 68 | ev_timer_stop 69 | ev_unref 70 | ev_userdata 71 | ev_verify 72 | ev_version_major 73 | ev_version_minor 74 | -------------------------------------------------------------------------------- /libev/Symbols.event: -------------------------------------------------------------------------------- 1 | event_active 2 | event_add 3 | event_base_dispatch 4 | event_base_free 5 | event_base_get_method 6 | event_base_loop 7 | event_base_loopexit 8 | event_base_new 9 | event_base_once 10 | event_base_priority_init 11 | event_base_set 12 | event_del 13 | event_dispatch 14 | event_get_callback 15 | event_get_method 16 | event_get_version 17 | event_init 18 | event_loop 19 | event_loopexit 20 | event_once 21 | event_pending 22 | event_priority_init 23 | event_priority_set 24 | event_set 25 | -------------------------------------------------------------------------------- /libev/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | autoreconf --install --symlink --force 4 | -------------------------------------------------------------------------------- /libev/cmake/dist.cmake: -------------------------------------------------------------------------------- 1 | # LuaDist CMake utility library. 2 | # Provides sane project defaults and macros common to LuaDist CMake builds. 3 | # 4 | # Copyright (C) 2007-2012 LuaDist. 5 | # by David Manura, Peter Drahoš 6 | # Redistribution and use of this file is allowed according to the terms of the MIT license. 7 | # For details see the COPYRIGHT file distributed with LuaDist. 8 | # Please note that the package source code is licensed under its own license. 9 | 10 | 11 | # Tweaks and other defaults 12 | # Setting CMAKE to use loose block and search for find modules in source directory 13 | set ( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true ) 14 | set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH} ) 15 | 16 | # In MSVC, prevent warnings that can occur when using standard libraries. 17 | if ( MSVC ) 18 | add_definitions ( -D_CRT_SECURE_NO_WARNINGS ) 19 | endif () 20 | 21 | -------------------------------------------------------------------------------- /libev/configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT 2 | 3 | orig_CFLAGS="$CFLAGS" 4 | 5 | AC_CONFIG_SRCDIR([ev_epoll.c]) 6 | 7 | dnl also update ev.h! 8 | AM_INIT_AUTOMAKE(libev,4.22) 9 | AC_CONFIG_HEADERS([config.h]) 10 | AM_MAINTAINER_MODE 11 | 12 | AC_PROG_CC 13 | 14 | dnl Supply default CFLAGS, if not specified 15 | if test -z "$orig_CFLAGS"; then 16 | if test x$GCC = xyes; then 17 | CFLAGS="-g -O3" 18 | fi 19 | fi 20 | 21 | AC_PROG_INSTALL 22 | AC_PROG_LIBTOOL 23 | 24 | m4_include([libev.m4]) 25 | 26 | AC_CONFIG_FILES([Makefile]) 27 | AC_OUTPUT 28 | -------------------------------------------------------------------------------- /libipset/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libipset.la 2 | 3 | bdd_src = bdd/assignments.c bdd/basics.c bdd/bdd-iterator.c bdd/expanded.c \ 4 | bdd/reachable.c bdd/read.c bdd/write.c 5 | map_src = map/allocation.c map/inspection.c map/ipv4_map.c map/ipv6_map.c \ 6 | map/storage.c 7 | set_src = set/allocation.c set/inspection.c set/ipv4_set.c set/ipv6_set.c \ 8 | set/iterator.c set/storage.c 9 | 10 | libipset_la_SOURCES = general.c ${bdd_src} ${map_src} ${set_src} 11 | libipset_la_CFLAGS = -I$(top_srcdir)/libipset/include -I$(top_srcdir)/libcork/include 12 | 13 | libipset_la_LDFLAGS = -static 14 | -------------------------------------------------------------------------------- /libipset/README.markdown: -------------------------------------------------------------------------------- 1 | # ipset 2 | 3 | The ipset library provides C data types for storing sets of IP 4 | addresses, and maps of IP addresses to integers. It supports both 5 | IPv4 and IPv6 addresses. It's implemented using [Binary Decision 6 | Diagrams](http://en.wikipedia.org/wiki/Binary_decision_diagram) 7 | (BDDs), which (we hypothesize) makes it space efficient for large 8 | sets. 9 | 10 | Please see the INSTALL file for installation instructions. 11 | -------------------------------------------------------------------------------- /libipset/bdd/Makefile.am: -------------------------------------------------------------------------------- 1 | # This file is part of libasyncns. 2 | # 3 | # Copyright 2005-2008 Lennart Poettering 4 | # 5 | # libasyncns is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU Lesser General Public License as 7 | # published by the Free Software Foundation, either version 2.1 of the 8 | # License, or (at your option) any later version. 9 | # 10 | # libasyncns is distributed in the hope that it will be useful, but 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public 16 | # License along with libasyncns. If not, see 17 | # . 18 | 19 | noinst_LTLIBRARIES = libipset.la 20 | 21 | bdd_src = bdd/assignments.c bdd/basics.c bdd/bdd-iterator.c bdd/expanded.c \ 22 | bdd/reachable.c bdd/read.c bdd/write.c 23 | map_src = map/allocation.c map/inspection.c map/ipv4_map.c map/ipv6_map.c \ 24 | map/storage.c 25 | set_src = set/allocation.c set/inspection.c set/ipv4_set.c set/ipv6_set.c \ 26 | set/iterator.c set/storage.c 27 | 28 | libipset_la_SOURCES = ${bdd_src} ${map_src} ${set_src} 29 | 30 | libipset_la_LDFLAGS = -static 31 | -------------------------------------------------------------------------------- /libipset/bdd/Makefile.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shadowsocksr-rm/shadowsocksr-libev/a32c032cb1e424686748fb4fa3a2beae1b342334/libipset/bdd/Makefile.in -------------------------------------------------------------------------------- /libipset/general.c: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2009-2012, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the LICENSE.txt file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #include 12 | 13 | #include "ipset/bdd/nodes.h" 14 | #include "ipset/ipset.h" 15 | 16 | 17 | int 18 | ipset_init_library() 19 | { 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /libipset/include/ipset/errors.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2012, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the LICENSE.txt file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef IPSET_ERRORS_H 12 | #define IPSET_ERRORS_H 13 | 14 | 15 | #include 16 | 17 | 18 | /*----------------------------------------------------------------------- 19 | * Error reporting 20 | */ 21 | 22 | /* Hash of "ipset.h" */ 23 | #define IPSET_ERROR 0xf2000181 24 | 25 | enum ipset_error { 26 | IPSET_IO_ERROR, 27 | IPSET_PARSE_ERROR 28 | }; 29 | 30 | 31 | #endif /* IPSET_ERRORS_H */ 32 | -------------------------------------------------------------------------------- /libipset/include/ipset/logging.h: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2010-2012, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the LICENSE.txt file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef IPSET_LOGGING_H 12 | #define IPSET_LOGGING_H 13 | 14 | 15 | #if !defined(IPSET_DEBUG) 16 | #define IPSET_DEBUG 0 17 | #endif 18 | 19 | #if IPSET_DEBUG 20 | #include 21 | #define DEBUG(...) \ 22 | do { \ 23 | fprintf(stderr, __VA_ARGS__); \ 24 | fprintf(stderr, "\n"); \ 25 | } while (0) 26 | #else 27 | #define DEBUG(...) /* no debug messages */ 28 | #endif 29 | 30 | 31 | #endif /* IPSET_LOGGING_H */ 32 | -------------------------------------------------------------------------------- /libipset/map/Makefile.am: -------------------------------------------------------------------------------- 1 | # This file is part of libasyncns. 2 | # 3 | # Copyright 2005-2008 Lennart Poettering 4 | # 5 | # libasyncns is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU Lesser General Public License as 7 | # published by the Free Software Foundation, either version 2.1 of the 8 | # License, or (at your option) any later version. 9 | # 10 | # libasyncns is distributed in the hope that it will be useful, but 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public 16 | # License along with libasyncns. If not, see 17 | # . 18 | 19 | noinst_LTLIBRARIES = libipset.la 20 | 21 | bdd_src = bdd/assignments.c bdd/basics.c bdd/bdd-iterator.c bdd/expanded.c \ 22 | bdd/reachable.c bdd/read.c bdd/write.c 23 | map_src = map/allocation.c map/inspection.c map/ipv4_map.c map/ipv6_map.c \ 24 | map/storage.c 25 | set_src = set/allocation.c set/inspection.c set/ipv4_set.c set/ipv6_set.c \ 26 | set/iterator.c set/storage.c 27 | 28 | libipset_la_SOURCES = ${bdd_src} ${map_src} ${set_src} 29 | 30 | libipset_la_LDFLAGS = -static 31 | -------------------------------------------------------------------------------- /libipset/map/Makefile.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shadowsocksr-rm/shadowsocksr-libev/a32c032cb1e424686748fb4fa3a2beae1b342334/libipset/map/Makefile.in -------------------------------------------------------------------------------- /libipset/map/allocation.c: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2009-2012, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the LICENSE.txt file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #include 12 | 13 | #include "ipset/bdd/nodes.h" 14 | #include "ipset/ipset.h" 15 | 16 | 17 | void 18 | ipmap_init(struct ip_map *map, int default_value) 19 | { 20 | /* The map starts empty, so every value assignment should yield the 21 | * default. */ 22 | map->cache = ipset_node_cache_new(); 23 | map->default_bdd = ipset_terminal_node_id(default_value); 24 | map->map_bdd = map->default_bdd; 25 | } 26 | 27 | 28 | struct ip_map * 29 | ipmap_new(int default_value) 30 | { 31 | struct ip_map *result = cork_new(struct ip_map); 32 | ipmap_init(result, default_value); 33 | return result; 34 | } 35 | 36 | 37 | void 38 | ipmap_done(struct ip_map *map) 39 | { 40 | ipset_node_decref(map->cache, map->map_bdd); 41 | ipset_node_cache_free(map->cache); 42 | } 43 | 44 | 45 | void 46 | ipmap_free(struct ip_map *map) 47 | { 48 | ipmap_done(map); 49 | free(map); 50 | } 51 | -------------------------------------------------------------------------------- /libipset/map/ipv4_map.c: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2009-2012, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the LICENSE.txt file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | /* 12 | * The IPv4 and IPv6 map types are basically identical, except for the 13 | * names of the functions, and the size of the values that are being 14 | * stored. Rather than having two mostly duplicate definitions of each 15 | * function, we define “template functions” where anything that depends 16 | * on the size of the IP address is defined using the following macros. 17 | */ 18 | 19 | 20 | /* The name of the cork_ipvX type. */ 21 | #define CORK_IP struct cork_ipv4 22 | 23 | /* The number of bits in an IPvX address. */ 24 | #define IP_BIT_SIZE 32 25 | 26 | /* The value of the discriminator variable for an IPvX address. */ 27 | #define IP_DISCRIMINATOR_VALUE true 28 | 29 | /* Creates a identifier of the form “ipset_ipv4_”. */ 30 | #define IPSET_NAME(basename) ipset_ipv4_##basename 31 | 32 | /* Creates a identifier of the form “ipmap_ipv4_”. */ 33 | #define IPMAP_NAME(basename) ipmap_ipv4_##basename 34 | 35 | 36 | /* Now include all of the templates. */ 37 | #include "inspection-template.c.in" 38 | -------------------------------------------------------------------------------- /libipset/map/ipv6_map.c: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2009-2012, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the LICENSE.txt file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | /* 12 | * The IPv4 and IPv6 map types are basically identical, except for the 13 | * names of the functions, and the size of the values that are being 14 | * stored. Rather than having two mostly duplicate definitions of each 15 | * function, we define “template functions” where anything that depends 16 | * on the size of the IP address is defined using the following macros. 17 | */ 18 | 19 | 20 | /* The name of the cork_ipvX type. */ 21 | #define CORK_IP struct cork_ipv6 22 | 23 | /* The number of bits in an IPvX address. */ 24 | #define IP_BIT_SIZE 128 25 | 26 | /* The value of the discriminator variable for an IPvX address. */ 27 | #define IP_DISCRIMINATOR_VALUE false 28 | 29 | /* Creates a identifier of the form “ipset_ipv6_”. */ 30 | #define IPSET_NAME(basename) ipset_ipv6_##basename 31 | 32 | /* Creates a identifier of the form “ipmap_ipv6_”. */ 33 | #define IPMAP_NAME(basename) ipmap_ipv6_##basename 34 | 35 | 36 | /* Now include all of the templates. */ 37 | #include "inspection-template.c.in" 38 | -------------------------------------------------------------------------------- /libipset/set/Makefile.am: -------------------------------------------------------------------------------- 1 | # This file is part of libasyncns. 2 | # 3 | # Copyright 2005-2008 Lennart Poettering 4 | # 5 | # libasyncns is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU Lesser General Public License as 7 | # published by the Free Software Foundation, either version 2.1 of the 8 | # License, or (at your option) any later version. 9 | # 10 | # libasyncns is distributed in the hope that it will be useful, but 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # Lesser General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU Lesser General Public 16 | # License along with libasyncns. If not, see 17 | # . 18 | 19 | noinst_LTLIBRARIES = libipset.la 20 | 21 | bdd_src = bdd/assignments.c bdd/basics.c bdd/bdd-iterator.c bdd/expanded.c \ 22 | bdd/reachable.c bdd/read.c bdd/write.c 23 | map_src = map/allocation.c map/inspection.c map/ipv4_map.c map/ipv6_map.c \ 24 | map/storage.c 25 | set_src = set/allocation.c set/inspection.c set/ipv4_set.c set/ipv6_set.c \ 26 | set/iterator.c set/storage.c 27 | 28 | libipset_la_SOURCES = ${bdd_src} ${map_src} ${set_src} 29 | 30 | libipset_la_LDFLAGS = -static 31 | -------------------------------------------------------------------------------- /libipset/set/Makefile.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shadowsocksr-rm/shadowsocksr-libev/a32c032cb1e424686748fb4fa3a2beae1b342334/libipset/set/Makefile.in -------------------------------------------------------------------------------- /libipset/set/allocation.c: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2009-2012, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the LICENSE.txt file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | #include 12 | 13 | #include "ipset/bdd/nodes.h" 14 | #include "ipset/ipset.h" 15 | 16 | 17 | void 18 | ipset_init(struct ip_set *set) 19 | { 20 | /* The set starts empty, so every value assignment should yield 21 | * false. */ 22 | set->cache = ipset_node_cache_new(); 23 | set->set_bdd = ipset_terminal_node_id(false); 24 | } 25 | 26 | 27 | struct ip_set * 28 | ipset_new(void) 29 | { 30 | struct ip_set *result = cork_new(struct ip_set); 31 | ipset_init(result); 32 | return result; 33 | } 34 | 35 | 36 | void 37 | ipset_done(struct ip_set *set) 38 | { 39 | ipset_node_decref(set->cache, set->set_bdd); 40 | ipset_node_cache_free(set->cache); 41 | } 42 | 43 | 44 | void 45 | ipset_free(struct ip_set *set) 46 | { 47 | ipset_done(set); 48 | free(set); 49 | } 50 | -------------------------------------------------------------------------------- /libipset/set/ipv4_set.c: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2009-2012, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the LICENSE.txt file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | /* 12 | * The IPv4 and IPv6 set types are basically identical, except for the 13 | * names of the functions, and the size of the values that are being 14 | * stored. Rather than having two mostly duplicate definitions of each 15 | * function, we define “template functions” where anything that depends 16 | * on the size of the IP address is defined using the following macros. 17 | */ 18 | 19 | 20 | /* The name of the cork_ipvX type. */ 21 | #define CORK_IP struct cork_ipv4 22 | 23 | /* The number of bits in an IPvX address. */ 24 | #define IP_BIT_SIZE 32 25 | 26 | /* The value of the discriminator variable for an IPvX address. */ 27 | #define IP_DISCRIMINATOR_VALUE true 28 | 29 | /* Creates a identifier of the form “ipset_ipv4_”. */ 30 | #define IPSET_NAME(basename) ipset_ipv4_##basename 31 | 32 | /* Creates a identifier of the form “ipset__ipv4”. */ 33 | #define IPSET_PRENAME(basename) ipset_##basename##_ipv4 34 | 35 | 36 | /* Now include all of the templates. */ 37 | #include "inspection-template.c.in" 38 | -------------------------------------------------------------------------------- /libipset/set/ipv6_set.c: -------------------------------------------------------------------------------- 1 | /* -*- coding: utf-8 -*- 2 | * ---------------------------------------------------------------------- 3 | * Copyright © 2009-2012, RedJack, LLC. 4 | * All rights reserved. 5 | * 6 | * Please see the LICENSE.txt file in this distribution for license 7 | * details. 8 | * ---------------------------------------------------------------------- 9 | */ 10 | 11 | /* 12 | * The IPv4 and IPv6 set types are basically identical, except for the 13 | * names of the functions, and the size of the values that are being 14 | * stored. Rather than having two mostly duplicate definitions of 15 | * each function, we define “template functions” where anything that 16 | * depends on the size of the IP address is defined using the 17 | * following macros. 18 | */ 19 | 20 | 21 | /* The name of the cork_ipvX type. */ 22 | #define CORK_IP struct cork_ipv6 23 | 24 | /* The number of bits in an IPvX address. */ 25 | #define IP_BIT_SIZE 128 26 | 27 | /* The value of the discriminator variable for an IPvX address. */ 28 | #define IP_DISCRIMINATOR_VALUE false 29 | 30 | /* Creates a identifier of the form “ipset_ipv6_”. */ 31 | #define IPSET_NAME(basename) ipset_ipv6_##basename 32 | 33 | /* Creates a identifier of the form “ipset__ipv6”. */ 34 | #define IPSET_PRENAME(basename) ipset_##basename##_ipv6 35 | 36 | 37 | /* Now include all of the templates. */ 38 | #include "inspection-template.c.in" 39 | -------------------------------------------------------------------------------- /libsodium/.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | os: 4 | - linux 5 | - osx 6 | 7 | compiler: 8 | - clang 9 | - gcc 10 | - g++ 11 | 12 | before_script: 13 | - ./autogen.sh 14 | 15 | script: 16 | - ./configure --disable-dependency-tracking 17 | - make distcheck 18 | - make distclean 19 | - ./configure --disable-dependency-tracking --enable-minimal 20 | - make distcheck 21 | 22 | env: 23 | global: 24 | - secure: "P4qv8aX+nogLlSy0lTMDIR6I5OLXq+qMijB4s+oCLME5BL2xPAn3v0QG5IoHdnU0ncRc1tEYZxN3F48Rp+Q7+wEVqSBLFS3oXzfNHJGEYoiaAcPNWO0R1kF8rcy8AuoAEomNeYS+5vhzQtaXklNtx/250p6MgGuMsdpMsRUKS/U=" 25 | 26 | addons: 27 | coverity_scan: 28 | project: 29 | name: "jedisct1/libsodium" 30 | description: "libsodium" 31 | notification_email: coverityscan@pureftpd.org 32 | build_command_prepend: "./autogen.sh ; ./configure" 33 | build_command: "make -j4" 34 | branch_pattern: coverity_scan 35 | -------------------------------------------------------------------------------- /libsodium/LICENSE: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2015 3 | * Frank Denis 4 | * 5 | * Permission to use, copy, modify, and/or distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | -------------------------------------------------------------------------------- /libsodium/Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | 3 | EXTRA_DIST = \ 4 | autogen.sh \ 5 | libsodium.sln \ 6 | libsodium.vcxproj \ 7 | libsodium.vcxproj.filters \ 8 | LICENSE \ 9 | README.markdown \ 10 | THANKS 11 | 12 | SUBDIRS = \ 13 | src 14 | -------------------------------------------------------------------------------- /libsodium/README: -------------------------------------------------------------------------------- 1 | See README.markdown 2 | -------------------------------------------------------------------------------- /libsodium/README.markdown: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/jedisct1/libsodium.svg?branch=master)](https://travis-ci.org/jedisct1/libsodium?branch=master) 2 | [![Coverity Scan Build Status](https://scan.coverity.com/projects/2397/badge.svg)](https://scan.coverity.com/projects/2397) 3 | 4 | ![libsodium](https://raw.github.com/jedisct1/libsodium/master/logo.png) 5 | ============ 6 | 7 | Sodium is a new, easy-to-use software library for encryption, 8 | decryption, signatures, password hashing and more. 9 | 10 | It is a portable, cross-compilable, installable, packageable 11 | fork of [NaCl](http://nacl.cr.yp.to/), with a compatible API, and an 12 | extended API to improve usability even further. 13 | 14 | Its goal is to provide all of the core operations needed to build 15 | higher-level cryptographic tools. 16 | 17 | Sodium supports a variety of compilers and operating systems, 18 | including Windows (with MingW or Visual Studio, x86 and x64), iOS and Android. 19 | 20 | ## Documentation 21 | 22 | The documentation is a work-in-progress, and is being written using 23 | Gitbook: 24 | 25 | [libsodium documentation](https://download.libsodium.org/doc/) 26 | 27 | ## Community 28 | 29 | A mailing-list is available to discuss libsodium. 30 | 31 | In order to join, just send a random mail to `sodium-subscribe` {at} 32 | `pureftpd` {dot} `org`. 33 | 34 | ## License 35 | 36 | [ISC license](https://en.wikipedia.org/wiki/ISC_license). 37 | -------------------------------------------------------------------------------- /libsodium/THANKS: -------------------------------------------------------------------------------- 1 | @alethia7 2 | @dnaq 3 | @harleqin 4 | @joshjdevl 5 | @jshahbazi 6 | @lvh 7 | @neheb 8 | Amit Murthy (@amitmurthy) 9 | Bruno Oliveira (@abstractj) 10 | Christian Wiese (@morfoh) 11 | Chris Rebert (@cvrebert) 12 | Colm MacCárthaigh (@colmmacc) 13 | Donald Stufft (@dstufft) 14 | Douglas Campos (@qmx) 15 | Drew Crawford (@drewcrawford) 16 | Eric Dong (@quantum1423) 17 | Eric Voskuil (@evoskuil) 18 | Frank Siebenlist (@franks42) 19 | Gabriel Handford (@gabriel) 20 | Jachym Holecek (@freza) 21 | Jan de Muijnck-Hughes (@jfdm) 22 | Jason McCampbell (@jasonmccampbell) 23 | Jeroen Habraken (@VeXocide) 24 | Jesper Louis Andersen (@jlouis) 25 | Joseph Abrahamson (@tel) 26 | Kenneth Ballenegger (@kballenegger) 27 | Loic Maury (@loicmaury) 28 | Michael Gorlick (@mgorlick) 29 | Michael Gregorowicz (@mgregoro) 30 | Omar Ayub (@electricFeel) 31 | Pedro Paixao (@paixaop) 32 | Project ArteMisc (@artemisc) 33 | Ruben De Visscher (@rubendv) 34 | Rudolf Von Krugstein (@rudolfvonkrugstein) 35 | Samuel Neves (@sneves) 36 | Scott Arciszewski (@paragonie-scott) 37 | Stefan Marsiske 38 | Stephan Touset (@stouset) 39 | Steve Gibson (@sggrc) 40 | Tony Arcieri (@bascule) 41 | Tony Garnock-Jones (@tonyg) 42 | Y. T. Chung (@zonyitoo) 43 | 44 | FSF France 45 | Coverity, Inc. 46 | OpenDNS, Inc. 47 | OVH 48 | -------------------------------------------------------------------------------- /libsodium/autogen.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | if glibtoolize --version > /dev/null 2>&1; then 4 | LIBTOOLIZE='glibtoolize' 5 | else 6 | LIBTOOLIZE='libtoolize' 7 | fi 8 | 9 | if [ ! -x "`which $LIBTOOLIZE 2>/dev/null`" ] ; then 10 | echo "libtool is required, but wasn't found on this system" 11 | exit 1 12 | fi 13 | 14 | if [ ! -x "`which autoconf 2>/dev/null`" ] ; then 15 | echo "autoconf is required, but wasn't found on this system" 16 | exit 1 17 | fi 18 | 19 | if [ ! -x "`which automake 2>/dev/null`" ] ; then 20 | echo "automake is required, but wasn't found on this system" 21 | exit 1 22 | fi 23 | 24 | if [ ! -x "`which pkg-config 2>/dev/null`" ] ; then 25 | echo "pkg-config is required, but wasn't found on this system" 26 | exit 1 27 | fi 28 | 29 | if [ -x "`which autoreconf 2>/dev/null`" ] ; then 30 | exec autoreconf -ivf 31 | fi 32 | 33 | $LIBTOOLIZE && \ 34 | aclocal && \ 35 | automake --add-missing --force-missing --include-deps && \ 36 | autoconf 37 | -------------------------------------------------------------------------------- /libsodium/libsodium.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: @PACKAGE_NAME@ 7 | Version: @PACKAGE_VERSION@ 8 | Description: A portable, cross-compilable, installable, packageable fork of NaCl, with a compatible API. 9 | 10 | Libs: -L${libdir} -lsodium 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /libsodium/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shadowsocksr-rm/shadowsocksr-libev/a32c032cb1e424686748fb4fa3a2beae1b342334/libsodium/logo.png -------------------------------------------------------------------------------- /libsodium/m4/ld-output-def.m4: -------------------------------------------------------------------------------- 1 | # ld-output-def.m4 serial 2 2 | dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Simon Josefsson 8 | 9 | # gl_LD_OUTPUT_DEF() 10 | # ------------- 11 | # Check if linker supports -Wl,--output-def and define automake 12 | # conditional HAVE_LD_OUTPUT_DEF if it is. 13 | AC_DEFUN([gl_LD_OUTPUT_DEF], 14 | [ 15 | AC_CACHE_CHECK([if gcc/ld supports -Wl,--output-def], 16 | [gl_cv_ld_output_def], 17 | [if test "$enable_shared" = no; then 18 | gl_cv_ld_output_def="not needed, shared libraries are disabled" 19 | else 20 | gl_ldflags_save=$LDFLAGS 21 | LDFLAGS="-Wl,--output-def,conftest.def" 22 | AC_LINK_IFELSE([AC_LANG_PROGRAM([])], 23 | [gl_cv_ld_output_def=yes], 24 | [gl_cv_ld_output_def=no]) 25 | rm -f conftest.def 26 | LDFLAGS="$gl_ldflags_save" 27 | fi]) 28 | AM_CONDITIONAL([HAVE_LD_OUTPUT_DEF], test "x$gl_cv_ld_output_def" = "xyes") 29 | ]) 30 | -------------------------------------------------------------------------------- /libsodium/packaging/nuget/.gitignore: -------------------------------------------------------------------------------- 1 | *.nupkg 2 | package.nuspec 3 | package.targets 4 | package.xml 5 | -------------------------------------------------------------------------------- /libsodium/packaging/nuget/package.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | ECHO Started nuget packaging build. 3 | ECHO. 4 | REM http://www.nuget.org/packages/gsl 5 | gsl -q -script:package.gsl package.config 6 | ECHO. 7 | REM http://nuget.codeplex.com/releases 8 | nuget pack package.nuspec -verbosity detailed 9 | ECHO. 10 | ECHO NOTE: Ignore warnings not applicable to native code: "Issue: Assembly outside lib folder." 11 | ECHO. 12 | ECHO Completed nuget packaging build. The package is in the following folder: 13 | CD -------------------------------------------------------------------------------- /libsodium/packaging/nuget/package.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /libsodium/packaging/nuget/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /libsodium/src/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | SUBDIRS = \ 3 | libsodium 4 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_auth/crypto_auth.c: -------------------------------------------------------------------------------- 1 | 2 | #include "crypto_auth.h" 3 | 4 | size_t 5 | crypto_auth_bytes(void) 6 | { 7 | return crypto_auth_BYTES; 8 | } 9 | 10 | size_t 11 | crypto_auth_keybytes(void) 12 | { 13 | return crypto_auth_KEYBYTES; 14 | } 15 | 16 | const char * 17 | crypto_auth_primitive(void) 18 | { 19 | return crypto_auth_PRIMITIVE; 20 | } 21 | 22 | int 23 | crypto_auth(unsigned char *out, const unsigned char *in, 24 | unsigned long long inlen, const unsigned char *k) 25 | { 26 | return crypto_auth_hmacsha512256(out, in, inlen, k); 27 | } 28 | 29 | int 30 | crypto_auth_verify(const unsigned char *h, const unsigned char *in, 31 | unsigned long long inlen,const unsigned char *k) 32 | { 33 | return crypto_auth_hmacsha512256_verify(h, in, inlen, k); 34 | } 35 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_auth/hmacsha256/auth_hmacsha256_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_auth_hmacsha256.h" 2 | 3 | size_t 4 | crypto_auth_hmacsha256_bytes(void) { 5 | return crypto_auth_hmacsha256_BYTES; 6 | } 7 | 8 | size_t 9 | crypto_auth_hmacsha256_keybytes(void) { 10 | return crypto_auth_hmacsha256_KEYBYTES; 11 | } 12 | 13 | size_t 14 | crypto_auth_hmacsha256_statebytes(void) { 15 | return sizeof(crypto_auth_hmacsha256_state); 16 | } 17 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_auth/hmacsha256/cp/verify_hmacsha256.c: -------------------------------------------------------------------------------- 1 | #include "crypto_auth_hmacsha256.h" 2 | #include "crypto_verify_32.h" 3 | #include "utils.h" 4 | 5 | int crypto_auth_hmacsha256_verify(const unsigned char *h,const unsigned char *in,unsigned long long inlen,const unsigned char *k) 6 | { 7 | unsigned char correct[32]; 8 | crypto_auth_hmacsha256(correct,in,inlen,k); 9 | return crypto_verify_32(h,correct) | (-(h == correct)) | 10 | sodium_memcmp(correct,h,32); 11 | } 12 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_auth/hmacsha512/auth_hmacsha512_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_auth_hmacsha512.h" 2 | 3 | size_t 4 | crypto_auth_hmacsha512_bytes(void) { 5 | return crypto_auth_hmacsha512_BYTES; 6 | } 7 | 8 | size_t 9 | crypto_auth_hmacsha512_keybytes(void) { 10 | return crypto_auth_hmacsha512_KEYBYTES; 11 | } 12 | 13 | size_t 14 | crypto_auth_hmacsha512_statebytes(void) { 15 | return sizeof(crypto_auth_hmacsha512_state); 16 | } 17 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_auth/hmacsha512/cp/verify_hmacsha512.c: -------------------------------------------------------------------------------- 1 | #include "crypto_auth_hmacsha512.h" 2 | #include "crypto_verify_64.h" 3 | #include "utils.h" 4 | 5 | int crypto_auth_hmacsha512_verify(const unsigned char *h, const unsigned char *in, 6 | unsigned long long inlen, const unsigned char *k) 7 | { 8 | unsigned char correct[64]; 9 | crypto_auth_hmacsha512(correct,in,inlen,k); 10 | return crypto_verify_64(h,correct) | (-(h == correct)) | 11 | sodium_memcmp(correct,h,64); 12 | } 13 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_auth/hmacsha512256/auth_hmacsha512256_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_auth_hmacsha512256.h" 2 | 3 | size_t 4 | crypto_auth_hmacsha512256_bytes(void) { 5 | return crypto_auth_hmacsha512256_BYTES; 6 | } 7 | 8 | size_t 9 | crypto_auth_hmacsha512256_keybytes(void) { 10 | return crypto_auth_hmacsha512256_KEYBYTES; 11 | } 12 | 13 | size_t 14 | crypto_auth_hmacsha512256_statebytes(void) { 15 | return sizeof(crypto_auth_hmacsha512256_state); 16 | } 17 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_auth/hmacsha512256/cp/verify_hmacsha512256.c: -------------------------------------------------------------------------------- 1 | #include "crypto_auth_hmacsha512256.h" 2 | #include "crypto_verify_32.h" 3 | #include "utils.h" 4 | 5 | int crypto_auth_hmacsha512256_verify(const unsigned char *h, 6 | const unsigned char *in, 7 | unsigned long long inlen, 8 | const unsigned char *k) 9 | { 10 | unsigned char correct[32]; 11 | crypto_auth_hmacsha512256(correct,in,inlen,k); 12 | return crypto_verify_32(h,correct) | (-(h == correct)) | 13 | sodium_memcmp(correct,h,32); 14 | } 15 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/box_curve25519xsalsa20poly1305_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_box_curve25519xsalsa20poly1305.h" 2 | 3 | size_t 4 | crypto_box_curve25519xsalsa20poly1305_seedbytes(void) { 5 | return crypto_box_curve25519xsalsa20poly1305_SEEDBYTES; 6 | } 7 | 8 | size_t 9 | crypto_box_curve25519xsalsa20poly1305_publickeybytes(void) { 10 | return crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES; 11 | } 12 | 13 | size_t 14 | crypto_box_curve25519xsalsa20poly1305_secretkeybytes(void) { 15 | return crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES; 16 | } 17 | 18 | size_t 19 | crypto_box_curve25519xsalsa20poly1305_beforenmbytes(void) { 20 | return crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES; 21 | } 22 | 23 | size_t 24 | crypto_box_curve25519xsalsa20poly1305_noncebytes(void) { 25 | return crypto_box_curve25519xsalsa20poly1305_NONCEBYTES; 26 | } 27 | 28 | size_t 29 | crypto_box_curve25519xsalsa20poly1305_zerobytes(void) { 30 | return crypto_box_curve25519xsalsa20poly1305_ZEROBYTES; 31 | } 32 | 33 | size_t 34 | crypto_box_curve25519xsalsa20poly1305_boxzerobytes(void) { 35 | return crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES; 36 | } 37 | 38 | size_t 39 | crypto_box_curve25519xsalsa20poly1305_macbytes(void) { 40 | return crypto_box_curve25519xsalsa20poly1305_MACBYTES; 41 | } 42 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/after_curve25519xsalsa20poly1305.c: -------------------------------------------------------------------------------- 1 | #include "crypto_box_curve25519xsalsa20poly1305.h" 2 | #include "crypto_secretbox_xsalsa20poly1305.h" 3 | 4 | int crypto_box_curve25519xsalsa20poly1305_afternm( 5 | unsigned char *c, 6 | const unsigned char *m,unsigned long long mlen, 7 | const unsigned char *n, 8 | const unsigned char *k 9 | ) 10 | { 11 | return crypto_secretbox_xsalsa20poly1305(c,m,mlen,n,k); 12 | } 13 | 14 | int crypto_box_curve25519xsalsa20poly1305_open_afternm( 15 | unsigned char *m, 16 | const unsigned char *c,unsigned long long clen, 17 | const unsigned char *n, 18 | const unsigned char *k 19 | ) 20 | { 21 | return crypto_secretbox_xsalsa20poly1305_open(m,c,clen,n,k); 22 | } 23 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/before_curve25519xsalsa20poly1305.c: -------------------------------------------------------------------------------- 1 | #include "crypto_box_curve25519xsalsa20poly1305.h" 2 | #include "crypto_core_hsalsa20.h" 3 | #include "crypto_scalarmult_curve25519.h" 4 | 5 | static const unsigned char sigma[16] = { 6 | 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k' 7 | }; 8 | static const unsigned char n[16] = {0}; 9 | 10 | int crypto_box_curve25519xsalsa20poly1305_beforenm( 11 | unsigned char *k, 12 | const unsigned char *pk, 13 | const unsigned char *sk 14 | ) 15 | { 16 | unsigned char s[32]; 17 | if (crypto_scalarmult_curve25519(s,sk,pk) != 0) { 18 | return -1; 19 | } 20 | return crypto_core_hsalsa20(k,n,s,sigma); 21 | } 22 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/box_curve25519xsalsa20poly1305.c: -------------------------------------------------------------------------------- 1 | #include "crypto_box_curve25519xsalsa20poly1305.h" 2 | #include "utils.h" 3 | 4 | int crypto_box_curve25519xsalsa20poly1305( 5 | unsigned char *c, 6 | const unsigned char *m,unsigned long long mlen, 7 | const unsigned char *n, 8 | const unsigned char *pk, 9 | const unsigned char *sk 10 | ) 11 | { 12 | unsigned char k[crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES]; 13 | int ret; 14 | 15 | if (crypto_box_curve25519xsalsa20poly1305_beforenm(k,pk,sk) != 0) { 16 | return -1; 17 | } 18 | ret = crypto_box_curve25519xsalsa20poly1305_afternm(c,m,mlen,n,k); 19 | sodium_memzero(k, sizeof k); 20 | 21 | return ret; 22 | } 23 | 24 | int crypto_box_curve25519xsalsa20poly1305_open( 25 | unsigned char *m, 26 | const unsigned char *c,unsigned long long clen, 27 | const unsigned char *n, 28 | const unsigned char *pk, 29 | const unsigned char *sk 30 | ) 31 | { 32 | unsigned char k[crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES]; 33 | int ret; 34 | 35 | if (crypto_box_curve25519xsalsa20poly1305_beforenm(k,pk,sk) != 0) { 36 | return -1; 37 | } 38 | ret = crypto_box_curve25519xsalsa20poly1305_open_afternm(m,c,clen,n,k); 39 | sodium_memzero(k, sizeof k); 40 | 41 | return ret; 42 | } 43 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_box/curve25519xsalsa20poly1305/ref/keypair_curve25519xsalsa20poly1305.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "crypto_box_curve25519xsalsa20poly1305.h" 4 | #include "crypto_hash_sha512.h" 5 | #include "crypto_scalarmult_curve25519.h" 6 | #include "randombytes.h" 7 | #include "utils.h" 8 | 9 | int crypto_box_curve25519xsalsa20poly1305_seed_keypair( 10 | unsigned char *pk, 11 | unsigned char *sk, 12 | const unsigned char *seed 13 | ) 14 | { 15 | unsigned char hash[64]; 16 | crypto_hash_sha512(hash,seed,32); 17 | memmove(sk,hash,32); 18 | sodium_memzero(hash, sizeof hash); 19 | return crypto_scalarmult_curve25519_base(pk,sk); 20 | } 21 | 22 | int crypto_box_curve25519xsalsa20poly1305_keypair( 23 | unsigned char *pk, 24 | unsigned char *sk 25 | ) 26 | { 27 | randombytes_buf(sk,32); 28 | return crypto_scalarmult_curve25519_base(pk,sk); 29 | } 30 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_core/hsalsa20/core_hsalsa20_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_core_hsalsa20.h" 2 | 3 | size_t 4 | crypto_core_hsalsa20_outputbytes(void) { 5 | return crypto_core_hsalsa20_OUTPUTBYTES; 6 | } 7 | 8 | size_t 9 | crypto_core_hsalsa20_inputbytes(void) { 10 | return crypto_core_hsalsa20_INPUTBYTES; 11 | } 12 | 13 | size_t 14 | crypto_core_hsalsa20_keybytes(void) { 15 | return crypto_core_hsalsa20_KEYBYTES; 16 | } 17 | 18 | size_t 19 | crypto_core_hsalsa20_constbytes(void) { 20 | return crypto_core_hsalsa20_CONSTBYTES; 21 | } 22 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_core/salsa20/core_salsa20_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_core_salsa20.h" 2 | 3 | size_t 4 | crypto_core_salsa20_outputbytes(void) { 5 | return crypto_core_salsa20_OUTPUTBYTES; 6 | } 7 | 8 | size_t 9 | crypto_core_salsa20_inputbytes(void) { 10 | return crypto_core_salsa20_INPUTBYTES; 11 | } 12 | 13 | size_t 14 | crypto_core_salsa20_keybytes(void) { 15 | return crypto_core_salsa20_KEYBYTES; 16 | } 17 | 18 | size_t 19 | crypto_core_salsa20_constbytes(void) { 20 | return crypto_core_salsa20_CONSTBYTES; 21 | } 22 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_core/salsa2012/core_salsa2012_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_core_salsa2012.h" 2 | 3 | size_t 4 | crypto_core_salsa2012_outputbytes(void) { 5 | return crypto_core_salsa2012_OUTPUTBYTES; 6 | } 7 | 8 | size_t 9 | crypto_core_salsa2012_inputbytes(void) { 10 | return crypto_core_salsa2012_INPUTBYTES; 11 | } 12 | 13 | size_t 14 | crypto_core_salsa2012_keybytes(void) { 15 | return crypto_core_salsa2012_KEYBYTES; 16 | } 17 | 18 | size_t 19 | crypto_core_salsa2012_constbytes(void) { 20 | return crypto_core_salsa2012_CONSTBYTES; 21 | } 22 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_core/salsa208/core_salsa208_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_core_salsa208.h" 2 | 3 | size_t 4 | crypto_core_salsa208_outputbytes(void) { 5 | return crypto_core_salsa208_OUTPUTBYTES; 6 | } 7 | 8 | size_t 9 | crypto_core_salsa208_inputbytes(void) { 10 | return crypto_core_salsa208_INPUTBYTES; 11 | } 12 | 13 | size_t 14 | crypto_core_salsa208_keybytes(void) { 15 | return crypto_core_salsa208_KEYBYTES; 16 | } 17 | 18 | size_t 19 | crypto_core_salsa208_constbytes(void) { 20 | return crypto_core_salsa208_CONSTBYTES; 21 | } 22 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_generichash/blake2/generichash_blake2_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_generichash_blake2b.h" 2 | 3 | size_t 4 | crypto_generichash_blake2b_bytes_min(void) { 5 | return crypto_generichash_blake2b_BYTES_MIN; 6 | } 7 | 8 | size_t 9 | crypto_generichash_blake2b_bytes_max(void) { 10 | return crypto_generichash_blake2b_BYTES_MAX; 11 | } 12 | 13 | size_t 14 | crypto_generichash_blake2b_bytes(void) { 15 | return crypto_generichash_blake2b_BYTES; 16 | } 17 | 18 | size_t 19 | crypto_generichash_blake2b_keybytes_min(void) { 20 | return crypto_generichash_blake2b_KEYBYTES_MIN; 21 | } 22 | 23 | size_t 24 | crypto_generichash_blake2b_keybytes_max(void) { 25 | return crypto_generichash_blake2b_KEYBYTES_MAX; 26 | } 27 | 28 | size_t 29 | crypto_generichash_blake2b_keybytes(void) { 30 | return crypto_generichash_blake2b_KEYBYTES; 31 | } 32 | 33 | size_t 34 | crypto_generichash_blake2b_saltbytes(void) { 35 | return crypto_generichash_blake2b_SALTBYTES; 36 | } 37 | 38 | size_t 39 | crypto_generichash_blake2b_personalbytes(void) { 40 | return crypto_generichash_blake2b_PERSONALBYTES; 41 | } 42 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_hash/crypto_hash.c: -------------------------------------------------------------------------------- 1 | 2 | #include "crypto_hash.h" 3 | 4 | size_t 5 | crypto_hash_bytes(void) 6 | { 7 | return crypto_hash_BYTES; 8 | } 9 | 10 | int 11 | crypto_hash(unsigned char *out, const unsigned char *in, 12 | unsigned long long inlen) 13 | { 14 | return crypto_hash_sha512(out, in, inlen); 15 | } 16 | 17 | const char * 18 | crypto_hash_primitive(void) { 19 | return crypto_hash_PRIMITIVE; 20 | } 21 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_hash/sha256/hash_sha256_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_hash_sha256.h" 2 | 3 | size_t 4 | crypto_hash_sha256_bytes(void) { 5 | return crypto_hash_sha256_BYTES; 6 | } 7 | 8 | size_t 9 | crypto_hash_sha256_statebytes(void) { 10 | return sizeof(crypto_hash_sha256_state); 11 | } 12 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_hash/sha512/hash_sha512_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_hash_sha512.h" 2 | 3 | size_t 4 | crypto_hash_sha512_bytes(void) { 5 | return crypto_hash_sha512_BYTES; 6 | } 7 | 8 | size_t 9 | crypto_hash_sha512_statebytes(void) { 10 | return sizeof(crypto_hash_sha512_state); 11 | } 12 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_onetimeauth/poly1305/onetimeauth_poly1305.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef onetimeauth_poly1305_H 3 | #define onetimeauth_poly1305_H 4 | 5 | typedef struct crypto_onetimeauth_poly1305_implementation { 6 | int (*onetimeauth)(unsigned char *out, 7 | const unsigned char *in, 8 | unsigned long long inlen, 9 | const unsigned char *k); 10 | int (*onetimeauth_verify)(const unsigned char *h, 11 | const unsigned char *in, 12 | unsigned long long inlen, 13 | const unsigned char *k); 14 | int (*onetimeauth_init)(crypto_onetimeauth_poly1305_state *state, 15 | const unsigned char *key); 16 | int (*onetimeauth_update)(crypto_onetimeauth_poly1305_state *state, 17 | const unsigned char *in, 18 | unsigned long long inlen); 19 | int (*onetimeauth_final)(crypto_onetimeauth_poly1305_state *state, 20 | unsigned char *out); 21 | } crypto_onetimeauth_poly1305_implementation; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/crypto_scalarmult.c: -------------------------------------------------------------------------------- 1 | 2 | #include "crypto_scalarmult.h" 3 | 4 | const char * 5 | crypto_scalarmult_primitive(void) 6 | { 7 | return crypto_scalarmult_PRIMITIVE; 8 | } 9 | 10 | int 11 | crypto_scalarmult_base(unsigned char *q, const unsigned char *n) 12 | { 13 | return crypto_scalarmult_curve25519_base(q, n); 14 | } 15 | 16 | int 17 | crypto_scalarmult(unsigned char *q, const unsigned char *n, 18 | const unsigned char *p) 19 | { 20 | return crypto_scalarmult_curve25519(q, n, p); 21 | } 22 | 23 | size_t 24 | crypto_scalarmult_bytes(void) 25 | { 26 | return crypto_scalarmult_BYTES; 27 | } 28 | 29 | size_t 30 | crypto_scalarmult_scalarbytes(void) 31 | { 32 | return crypto_scalarmult_SCALARBYTES; 33 | } 34 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/donna_c64/curve25519_donna_c64.h: -------------------------------------------------------------------------------- 1 | #ifndef curve25519_donna_c64_H 2 | #define curve25519_donna_c64_H 3 | 4 | #include "crypto_scalarmult_curve25519.h" 5 | 6 | extern struct crypto_scalarmult_curve25519_implementation 7 | crypto_scalarmult_curve25519_donna_c64_implementation; 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/curve25519_ref10.h: -------------------------------------------------------------------------------- 1 | #ifndef curve25519_ref10_H 2 | #define curve25519_ref10_H 3 | 4 | #include "crypto_scalarmult_curve25519.h" 5 | 6 | extern struct crypto_scalarmult_curve25519_implementation 7 | crypto_scalarmult_curve25519_ref10_implementation; 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_0_curve25519_ref10.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | #ifndef HAVE_TI_MODE 4 | 5 | /* 6 | h = 0 7 | */ 8 | 9 | void fe_0(fe h) 10 | { 11 | h[0] = 0; 12 | h[1] = 0; 13 | h[2] = 0; 14 | h[3] = 0; 15 | h[4] = 0; 16 | h[5] = 0; 17 | h[6] = 0; 18 | h[7] = 0; 19 | h[8] = 0; 20 | h[9] = 0; 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_1_curve25519_ref10.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | #ifndef HAVE_TI_MODE 4 | 5 | /* 6 | h = 1 7 | */ 8 | 9 | void fe_1(fe h) 10 | { 11 | h[0] = 1; 12 | h[1] = 0; 13 | h[2] = 0; 14 | h[3] = 0; 15 | h[4] = 0; 16 | h[5] = 0; 17 | h[6] = 0; 18 | h[7] = 0; 19 | h[8] = 0; 20 | h[9] = 0; 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_copy_curve25519_ref10.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | #ifndef HAVE_TI_MODE 4 | 5 | /* 6 | h = f 7 | */ 8 | 9 | void fe_copy(fe h,fe f) 10 | { 11 | crypto_int32 f0 = f[0]; 12 | crypto_int32 f1 = f[1]; 13 | crypto_int32 f2 = f[2]; 14 | crypto_int32 f3 = f[3]; 15 | crypto_int32 f4 = f[4]; 16 | crypto_int32 f5 = f[5]; 17 | crypto_int32 f6 = f[6]; 18 | crypto_int32 f7 = f[7]; 19 | crypto_int32 f8 = f[8]; 20 | crypto_int32 f9 = f[9]; 21 | h[0] = f0; 22 | h[1] = f1; 23 | h[2] = f2; 24 | h[3] = f3; 25 | h[4] = f4; 26 | h[5] = f5; 27 | h[6] = f6; 28 | h[7] = f7; 29 | h[8] = f8; 30 | h[9] = f9; 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_invert_curve25519_ref10.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | #ifndef HAVE_TI_MODE 4 | 5 | void fe_invert(fe out,fe z) 6 | { 7 | fe t0; 8 | fe t1; 9 | fe t2; 10 | fe t3; 11 | int i; 12 | 13 | #include "pow225521.h" 14 | 15 | return; 16 | } 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/consts.S: -------------------------------------------------------------------------------- 1 | #ifdef IN_SANDY2X 2 | 3 | /* 4 | REDMASK51 is from amd64-51/consts.s. 5 | */ 6 | 7 | #include "consts_namespace.h" 8 | .data 9 | .p2align 4 10 | v0_0: .quad 0, 0 11 | v1_0: .quad 1, 0 12 | v2_1: .quad 2, 1 13 | v9_0: .quad 9, 0 14 | v9_9: .quad 9, 9 15 | v19_19: .quad 19, 19 16 | v38_1: .quad 38, 1 17 | v38_38: .quad 38, 38 18 | v121666_121666: .quad 121666, 121666 19 | m25: .quad 33554431, 33554431 20 | m26: .quad 67108863, 67108863 21 | subc0: .quad 0x07FFFFDA, 0x03FFFFFE 22 | subc2: .quad 0x07FFFFFE, 0x03FFFFFE 23 | REDMASK51: .quad 0x0007FFFFFFFFFFFF 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/consts_namespace.h: -------------------------------------------------------------------------------- 1 | #ifndef consts_namespace_H 2 | #define consts_namespace_H 3 | 4 | #define v0_0 crypto_scalarmult_curve25519_sandy2x_v0_0 5 | #define v1_0 crypto_scalarmult_curve25519_sandy2x_v1_0 6 | #define v2_1 crypto_scalarmult_curve25519_sandy2x_v2_1 7 | #define v9_0 crypto_scalarmult_curve25519_sandy2x_v9_0 8 | #define v9_9 crypto_scalarmult_curve25519_sandy2x_v9_9 9 | #define v19_19 crypto_scalarmult_curve25519_sandy2x_v19_19 10 | #define v38_1 crypto_scalarmult_curve25519_sandy2x_v38_1 11 | #define v38_38 crypto_scalarmult_curve25519_sandy2x_v38_38 12 | #define v121666_121666 crypto_scalarmult_curve25519_sandy2x_v121666_121666 13 | #define m25 crypto_scalarmult_curve25519_sandy2x_m25 14 | #define m26 crypto_scalarmult_curve25519_sandy2x_m26 15 | #define subc0 crypto_scalarmult_curve25519_sandy2x_subc0 16 | #define subc2 crypto_scalarmult_curve25519_sandy2x_subc2 17 | #define REDMASK51 crypto_scalarmult_curve25519_sandy2x_REDMASK51 18 | 19 | #endif //ifndef consts_namespace_H 20 | 21 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/curve25519_sandy2x.h: -------------------------------------------------------------------------------- 1 | #ifndef curve25519_sandy2x_H 2 | #define curve25519_sandy2x_H 3 | 4 | #include "crypto_scalarmult_curve25519.h" 5 | 6 | extern struct crypto_scalarmult_curve25519_implementation 7 | crypto_scalarmult_curve25519_sandy2x_implementation; 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is adapted from ref10/fe.h: 3 | All the redundant functions are removed. 4 | */ 5 | 6 | #ifndef fe_H 7 | #define fe_H 8 | 9 | #include "crypto_uint64.h" 10 | 11 | typedef crypto_uint64 fe[10]; 12 | 13 | /* 14 | fe means field element. 15 | Here the field is \Z/(2^255-19). 16 | An element t, entries t[0]...t[9], represents the integer 17 | t[0]+2^26 t[1]+2^51 t[2]+2^77 t[3]+2^102 t[4]+...+2^230 t[9]. 18 | Bounds on each t[i] vary depending on context. 19 | */ 20 | 21 | #define fe_frombytes crypto_scalarmult_curve25519_sandy2x_fe_frombytes 22 | 23 | extern void fe_frombytes(fe, const unsigned char *); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is adapted from amd64-51/fe25519.h: 3 | 'fe25519' is renamed as 'fe51'; 4 | All the redundant functions are removed; 5 | New function fe51_nsquare is introduced. 6 | */ 7 | 8 | #ifndef fe51_H 9 | #define fe51_H 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #include "crypto_uint64.h" 16 | #include "fe51_namespace.h" 17 | 18 | typedef struct 19 | { 20 | crypto_uint64 v[5]; 21 | } 22 | fe51; 23 | 24 | extern void fe51_pack(unsigned char *, const fe51 *); 25 | extern void fe51_mul(fe51 *, const fe51 *, const fe51 *); 26 | extern void fe51_nsquare(fe51 *, const fe51 *, int); 27 | extern void fe51_invert(fe51 *, const fe51 *); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_namespace.h: -------------------------------------------------------------------------------- 1 | #ifndef fe51_namespace_H 2 | #define fe51_namespace_H 3 | 4 | #define fe51 crypto_scalarmult_curve25519_sandy2x_fe51 5 | #define _fe51 _crypto_scalarmult_curve25519_sandy2x_fe51 6 | #define fe51_pack crypto_scalarmult_curve25519_sandy2x_fe51_pack 7 | #define _fe51_pack _crypto_scalarmult_curve25519_sandy2x_fe51_pack 8 | #define fe51_mul crypto_scalarmult_curve25519_sandy2x_fe51_mul 9 | #define _fe51_mul _crypto_scalarmult_curve25519_sandy2x_fe51_mul 10 | #define fe51_nsquare crypto_scalarmult_curve25519_sandy2x_fe51_nsquare 11 | #define _fe51_nsquare _crypto_scalarmult_curve25519_sandy2x_fe51_nsquare 12 | 13 | #define fe51_invert crypto_scalarmult_curve25519_sandy2x_fe51_invert 14 | 15 | #endif //ifndef fe51_namespace_H 16 | 17 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder.h: -------------------------------------------------------------------------------- 1 | #ifndef ladder_H 2 | #define ladder_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "fe.h" 9 | #include "ladder_namespace.h" 10 | 11 | extern void ladder(fe *, const unsigned char *); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif //ifndef ladder_H 18 | 19 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base.h: -------------------------------------------------------------------------------- 1 | #ifndef ladder_base_H 2 | #define ladder_base_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "fe.h" 9 | #include "ladder_base_namespace.h" 10 | 11 | extern void ladder_base(fe *, const unsigned char *); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif //ifndef ladder_base_H 18 | 19 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_base_namespace.h: -------------------------------------------------------------------------------- 1 | #ifndef ladder_base_namespace_H 2 | #define ladder_base_namespace_H 3 | 4 | #define ladder_base crypto_scalarmult_curve25519_sandy2x_ladder_base 5 | #define _ladder_base _crypto_scalarmult_curve25519_sandy2x_ladder_base 6 | 7 | #endif //ifndef ladder_base_namespace_H 8 | 9 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/ladder_namespace.h: -------------------------------------------------------------------------------- 1 | #ifndef ladder_namespace_H 2 | #define ladder_namespace_H 3 | 4 | #define ladder crypto_scalarmult_curve25519_sandy2x_ladder 5 | #define _ladder _crypto_scalarmult_curve25519_sandy2x_ladder 6 | 7 | #endif //ifndef ladder_namespace_H 8 | 9 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/sandy2x.S: -------------------------------------------------------------------------------- 1 | 2 | #ifdef HAVE_AVX_ASM 3 | 4 | #define IN_SANDY2X 5 | 6 | #include "consts.S" 7 | #include "fe51_mul.S" 8 | #include "fe51_nsquare.S" 9 | #include "fe51_pack.S" 10 | #include "ladder.S" 11 | #include "ladder_base.S" 12 | 13 | #if defined(__linux__) && defined(__ELF__) 14 | .section .note.GNU-stack,"",%progbits 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef scalarmult_poly1305_H 3 | #define scalarmult_poly1305_H 4 | 5 | typedef struct crypto_scalarmult_curve25519_implementation { 6 | int (*mult)(unsigned char *q, const unsigned char *n, 7 | const unsigned char *p); 8 | int (*mult_base)(unsigned char *q, const unsigned char *n); 9 | } crypto_scalarmult_curve25519_implementation; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_secretbox/crypto_secretbox.c: -------------------------------------------------------------------------------- 1 | 2 | #include "crypto_secretbox.h" 3 | 4 | size_t 5 | crypto_secretbox_keybytes(void) 6 | { 7 | return crypto_secretbox_KEYBYTES; 8 | } 9 | 10 | size_t 11 | crypto_secretbox_noncebytes(void) 12 | { 13 | return crypto_secretbox_NONCEBYTES; 14 | } 15 | 16 | size_t 17 | crypto_secretbox_zerobytes(void) 18 | { 19 | return crypto_secretbox_ZEROBYTES; 20 | } 21 | 22 | size_t 23 | crypto_secretbox_boxzerobytes(void) 24 | { 25 | return crypto_secretbox_BOXZEROBYTES; 26 | } 27 | 28 | size_t 29 | crypto_secretbox_macbytes(void) 30 | { 31 | return crypto_secretbox_MACBYTES; 32 | } 33 | 34 | const char * 35 | crypto_secretbox_primitive(void) 36 | { 37 | return crypto_secretbox_PRIMITIVE; 38 | } 39 | 40 | int 41 | crypto_secretbox(unsigned char *c, const unsigned char *m, 42 | unsigned long long mlen, const unsigned char *n, 43 | const unsigned char *k) 44 | { 45 | return crypto_secretbox_xsalsa20poly1305(c, m, mlen, n, k); 46 | } 47 | 48 | int 49 | crypto_secretbox_open(unsigned char *m, const unsigned char *c, 50 | unsigned long long clen, const unsigned char *n, 51 | const unsigned char *k) 52 | { 53 | return crypto_secretbox_xsalsa20poly1305_open(m, c, clen, n, k); 54 | } 55 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/ref/box_xsalsa20poly1305.c: -------------------------------------------------------------------------------- 1 | #include "crypto_onetimeauth_poly1305.h" 2 | #include "crypto_secretbox_xsalsa20poly1305.h" 3 | #include "crypto_stream_xsalsa20.h" 4 | 5 | int crypto_secretbox_xsalsa20poly1305( 6 | unsigned char *c, 7 | const unsigned char *m,unsigned long long mlen, 8 | const unsigned char *n, 9 | const unsigned char *k 10 | ) 11 | { 12 | int i; 13 | if (mlen < 32) return -1; 14 | crypto_stream_xsalsa20_xor(c,m,mlen,n,k); 15 | crypto_onetimeauth_poly1305(c + 16,c + 32,mlen - 32,c); 16 | for (i = 0;i < 16;++i) c[i] = 0; 17 | return 0; 18 | } 19 | 20 | int crypto_secretbox_xsalsa20poly1305_open( 21 | unsigned char *m, 22 | const unsigned char *c,unsigned long long clen, 23 | const unsigned char *n, 24 | const unsigned char *k 25 | ) 26 | { 27 | int i; 28 | unsigned char subkey[32]; 29 | if (clen < 32) return -1; 30 | crypto_stream_xsalsa20(subkey,32,n,k); 31 | if (crypto_onetimeauth_poly1305_verify(c + 16,c + 32,clen - 32,subkey) != 0) return -1; 32 | crypto_stream_xsalsa20_xor(m,c,clen,n,k); 33 | for (i = 0;i < 32;++i) m[i] = 0; 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_secretbox/xsalsa20poly1305/secretbox_xsalsa20poly1305_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_secretbox_xsalsa20poly1305.h" 2 | 3 | size_t 4 | crypto_secretbox_xsalsa20poly1305_keybytes(void) { 5 | return crypto_secretbox_xsalsa20poly1305_KEYBYTES; 6 | } 7 | 8 | size_t 9 | crypto_secretbox_xsalsa20poly1305_noncebytes(void) { 10 | return crypto_secretbox_xsalsa20poly1305_NONCEBYTES; 11 | } 12 | 13 | size_t 14 | crypto_secretbox_xsalsa20poly1305_zerobytes(void) { 15 | return crypto_secretbox_xsalsa20poly1305_ZEROBYTES; 16 | } 17 | 18 | size_t 19 | crypto_secretbox_xsalsa20poly1305_boxzerobytes(void) { 20 | return crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES; 21 | } 22 | 23 | size_t 24 | crypto_secretbox_xsalsa20poly1305_macbytes(void) { 25 | return crypto_secretbox_xsalsa20poly1305_MACBYTES; 26 | } 27 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_shorthash/crypto_shorthash.c: -------------------------------------------------------------------------------- 1 | 2 | #include "crypto_shorthash.h" 3 | 4 | size_t 5 | crypto_shorthash_bytes(void) 6 | { 7 | return crypto_shorthash_BYTES; 8 | } 9 | 10 | size_t 11 | crypto_shorthash_keybytes(void) 12 | { 13 | return crypto_shorthash_KEYBYTES; 14 | } 15 | 16 | const char * 17 | crypto_shorthash_primitive(void) 18 | { 19 | return crypto_shorthash_PRIMITIVE; 20 | } 21 | 22 | int 23 | crypto_shorthash(unsigned char *out, const unsigned char *in, 24 | unsigned long long inlen, const unsigned char *k) 25 | { 26 | return crypto_shorthash_siphash24(out, in, inlen, k); 27 | } 28 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_shorthash/siphash24/shorthash_siphash24_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_shorthash_siphash24.h" 2 | 3 | size_t 4 | crypto_shorthash_siphash24_bytes(void) { 5 | return crypto_shorthash_siphash24_BYTES; 6 | } 7 | 8 | size_t 9 | crypto_shorthash_siphash24_keybytes(void) { 10 | return crypto_shorthash_siphash24_KEYBYTES; 11 | } 12 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/description: -------------------------------------------------------------------------------- 1 | EdDSA signatures using Curve25519 2 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/d.h: -------------------------------------------------------------------------------- 1 | -10913610,13857413,-15372611,6949391,114729,-8787816,-6275908,-3247719,-18696448,-12055116 2 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/d2.h: -------------------------------------------------------------------------------- 1 | -21827239,-5839606,-30745221,13898782,229458,15978800,-12551817,-6495438,29715968,9444199 2 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_0.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | /* 4 | h = 0 5 | */ 6 | 7 | void fe_0(fe h) 8 | { 9 | h[0] = 0; 10 | h[1] = 0; 11 | h[2] = 0; 12 | h[3] = 0; 13 | h[4] = 0; 14 | h[5] = 0; 15 | h[6] = 0; 16 | h[7] = 0; 17 | h[8] = 0; 18 | h[9] = 0; 19 | } 20 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_1.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | /* 4 | h = 1 5 | */ 6 | 7 | void fe_1(fe h) 8 | { 9 | h[0] = 1; 10 | h[1] = 0; 11 | h[2] = 0; 12 | h[3] = 0; 13 | h[4] = 0; 14 | h[5] = 0; 15 | h[6] = 0; 16 | h[7] = 0; 17 | h[8] = 0; 18 | h[9] = 0; 19 | } 20 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_copy.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | /* 4 | h = f 5 | */ 6 | 7 | void fe_copy(fe h,const fe f) 8 | { 9 | crypto_int32 f0 = f[0]; 10 | crypto_int32 f1 = f[1]; 11 | crypto_int32 f2 = f[2]; 12 | crypto_int32 f3 = f[3]; 13 | crypto_int32 f4 = f[4]; 14 | crypto_int32 f5 = f[5]; 15 | crypto_int32 f6 = f[6]; 16 | crypto_int32 f7 = f[7]; 17 | crypto_int32 f8 = f[8]; 18 | crypto_int32 f9 = f[9]; 19 | h[0] = f0; 20 | h[1] = f1; 21 | h[2] = f2; 22 | h[3] = f3; 23 | h[4] = f4; 24 | h[5] = f5; 25 | h[6] = f6; 26 | h[7] = f7; 27 | h[8] = f8; 28 | h[9] = f9; 29 | } 30 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_invert.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | void fe_invert(fe out,const fe z) 4 | { 5 | fe t0; 6 | fe t1; 7 | fe t2; 8 | fe t3; 9 | int i; 10 | 11 | #include "pow225521.h" 12 | 13 | return; 14 | } 15 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_isnegative.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | /* 4 | return 1 if f is in {1,3,5,...,q-2} 5 | return 0 if f is in {0,2,4,...,q-1} 6 | 7 | Preconditions: 8 | |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. 9 | */ 10 | 11 | int fe_isnegative(const fe f) 12 | { 13 | unsigned char s[32]; 14 | fe_tobytes(s,f); 15 | return s[0] & 1; 16 | } 17 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_isnonzero.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | #include "crypto_verify_32.h" 3 | 4 | /* 5 | return 1 if f == 0 6 | return 0 if f != 0 7 | 8 | Preconditions: 9 | |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. 10 | */ 11 | 12 | static unsigned char zero[32]; 13 | 14 | int fe_isnonzero(const fe f) 15 | { 16 | unsigned char s[32]; 17 | fe_tobytes(s,f); 18 | return crypto_verify_32(s,zero); 19 | } 20 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_neg.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | /* 4 | h = -f 5 | 6 | Preconditions: 7 | |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. 8 | 9 | Postconditions: 10 | |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. 11 | */ 12 | 13 | void fe_neg(fe h,const fe f) 14 | { 15 | crypto_int32 f0 = f[0]; 16 | crypto_int32 f1 = f[1]; 17 | crypto_int32 f2 = f[2]; 18 | crypto_int32 f3 = f[3]; 19 | crypto_int32 f4 = f[4]; 20 | crypto_int32 f5 = f[5]; 21 | crypto_int32 f6 = f[6]; 22 | crypto_int32 f7 = f[7]; 23 | crypto_int32 f8 = f[8]; 24 | crypto_int32 f9 = f[9]; 25 | crypto_int32 h0 = -f0; 26 | crypto_int32 h1 = -f1; 27 | crypto_int32 h2 = -f2; 28 | crypto_int32 h3 = -f3; 29 | crypto_int32 h4 = -f4; 30 | crypto_int32 h5 = -f5; 31 | crypto_int32 h6 = -f6; 32 | crypto_int32 h7 = -f7; 33 | crypto_int32 h8 = -f8; 34 | crypto_int32 h9 = -f9; 35 | h[0] = h0; 36 | h[1] = h1; 37 | h[2] = h2; 38 | h[3] = h3; 39 | h[4] = h4; 40 | h[5] = h5; 41 | h[6] = h6; 42 | h[7] = h7; 43 | h[8] = h8; 44 | h[9] = h9; 45 | } 46 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_pow22523.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | void fe_pow22523(fe out,const fe z) 4 | { 5 | fe t0; 6 | fe t1; 7 | fe t2; 8 | int i; 9 | 10 | #include "pow22523.h" 11 | 12 | return; 13 | } 14 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_add.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = p + q 5 | */ 6 | 7 | void ge_add(ge_p1p1 *r,const ge_p3 *p,const ge_cached *q) 8 | { 9 | fe t0; 10 | #include "ge_add.h" 11 | } 12 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_frombytes.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | static const fe d = { 4 | #include "d.h" 5 | } ; 6 | 7 | static const fe sqrtm1 = { 8 | #include "sqrtm1.h" 9 | } ; 10 | 11 | int ge_frombytes_negate_vartime(ge_p3 *h,const unsigned char *s) 12 | { 13 | fe u; 14 | fe v; 15 | fe v3; 16 | fe vxx; 17 | fe check; 18 | 19 | fe_frombytes(h->Y,s); 20 | fe_1(h->Z); 21 | fe_sq(u,h->Y); 22 | fe_mul(v,u,d); 23 | fe_sub(u,u,h->Z); /* u = y^2-1 */ 24 | fe_add(v,v,h->Z); /* v = dy^2+1 */ 25 | 26 | fe_sq(v3,v); 27 | fe_mul(v3,v3,v); /* v3 = v^3 */ 28 | fe_sq(h->X,v3); 29 | fe_mul(h->X,h->X,v); 30 | fe_mul(h->X,h->X,u); /* x = uv^7 */ 31 | 32 | fe_pow22523(h->X,h->X); /* x = (uv^7)^((q-5)/8) */ 33 | fe_mul(h->X,h->X,v3); 34 | fe_mul(h->X,h->X,u); /* x = uv^3(uv^7)^((q-5)/8) */ 35 | 36 | fe_sq(vxx,h->X); 37 | fe_mul(vxx,vxx,v); 38 | fe_sub(check,vxx,u); /* vx^2-u */ 39 | if (fe_isnonzero(check)) { 40 | fe_add(check,vxx,u); /* vx^2+u */ 41 | if (fe_isnonzero(check)) return -1; 42 | fe_mul(h->X,h->X,sqrtm1); 43 | } 44 | 45 | if (fe_isnegative(h->X) == (s[31] >> 7)) 46 | fe_neg(h->X,h->X); 47 | 48 | fe_mul(h->T,h->X,h->Y); 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_madd.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = p + q 5 | */ 6 | 7 | void ge_madd(ge_p1p1 *r,const ge_p3 *p,const ge_precomp *q) 8 | { 9 | fe t0; 10 | #include "ge_madd.h" 11 | } 12 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_msub.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = p - q 5 | */ 6 | 7 | void ge_msub(ge_p1p1 *r,const ge_p3 *p,const ge_precomp *q) 8 | { 9 | fe t0; 10 | #include "ge_msub.h" 11 | } 12 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p1p1_to_p2.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = p 5 | */ 6 | 7 | extern void ge_p1p1_to_p2(ge_p2 *r,const ge_p1p1 *p) 8 | { 9 | fe_mul(r->X,p->X,p->T); 10 | fe_mul(r->Y,p->Y,p->Z); 11 | fe_mul(r->Z,p->Z,p->T); 12 | } 13 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p1p1_to_p3.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = p 5 | */ 6 | 7 | extern void ge_p1p1_to_p3(ge_p3 *r,const ge_p1p1 *p) 8 | { 9 | fe_mul(r->X,p->X,p->T); 10 | fe_mul(r->Y,p->Y,p->Z); 11 | fe_mul(r->Z,p->Z,p->T); 12 | fe_mul(r->T,p->X,p->Y); 13 | } 14 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p2_0.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | void ge_p2_0(ge_p2 *h) 4 | { 5 | fe_0(h->X); 6 | fe_1(h->Y); 7 | fe_1(h->Z); 8 | } 9 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p2_dbl.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = 2 * p 5 | */ 6 | 7 | void ge_p2_dbl(ge_p1p1 *r,const ge_p2 *p) 8 | { 9 | fe t0; 10 | #include "ge_p2_dbl.h" 11 | } 12 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_0.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | void ge_p3_0(ge_p3 *h) 4 | { 5 | fe_0(h->X); 6 | fe_1(h->Y); 7 | fe_1(h->Z); 8 | fe_0(h->T); 9 | } 10 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_dbl.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = 2 * p 5 | */ 6 | 7 | void ge_p3_dbl(ge_p1p1 *r,const ge_p3 *p) 8 | { 9 | ge_p2 q; 10 | ge_p3_to_p2(&q,p); 11 | ge_p2_dbl(r,&q); 12 | } 13 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_to_cached.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = p 5 | */ 6 | 7 | static const fe d2 = { 8 | #include "d2.h" 9 | } ; 10 | 11 | extern void ge_p3_to_cached(ge_cached *r,const ge_p3 *p) 12 | { 13 | fe_add(r->YplusX,p->Y,p->X); 14 | fe_sub(r->YminusX,p->Y,p->X); 15 | fe_copy(r->Z,p->Z); 16 | fe_mul(r->T2d,p->T,d2); 17 | } 18 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_to_p2.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = p 5 | */ 6 | 7 | extern void ge_p3_to_p2(ge_p2 *r,const ge_p3 *p) 8 | { 9 | fe_copy(r->X,p->X); 10 | fe_copy(r->Y,p->Y); 11 | fe_copy(r->Z,p->Z); 12 | } 13 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_p3_tobytes.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | void ge_p3_tobytes(unsigned char *s,const ge_p3 *h) 4 | { 5 | fe recip; 6 | fe x; 7 | fe y; 8 | 9 | fe_invert(recip,h->Z); 10 | fe_mul(x,h->X,recip); 11 | fe_mul(y,h->Y,recip); 12 | fe_tobytes(s,y); 13 | s[31] ^= fe_isnegative(x) << 7; 14 | } 15 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_precomp_0.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | void ge_precomp_0(ge_precomp *h) 4 | { 5 | fe_1(h->yplusx); 6 | fe_1(h->yminusx); 7 | fe_0(h->xy2d); 8 | } 9 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_sub.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = p - q 5 | */ 6 | 7 | void ge_sub(ge_p1p1 *r,const ge_p3 *p,const ge_cached *q) 8 | { 9 | fe t0; 10 | #include "ge_sub.h" 11 | } 12 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/ge_tobytes.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | void ge_tobytes(unsigned char *s,const ge_p2 *h) 4 | { 5 | fe recip; 6 | fe x; 7 | fe y; 8 | 9 | fe_invert(recip,h->Z); 10 | fe_mul(x,h->X,recip); 11 | fe_mul(y,h->Y,recip); 12 | fe_tobytes(s,y); 13 | s[31] ^= fe_isnegative(x) << 7; 14 | } 15 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/sc.h: -------------------------------------------------------------------------------- 1 | #ifndef SC_H 2 | #define SC_H 3 | 4 | /* 5 | The set of scalars is \Z/l 6 | where l = 2^252 + 27742317777372353535851937790883648493. 7 | */ 8 | 9 | #define sc_reduce crypto_sign_ed25519_ref10_sc_reduce 10 | #define sc_muladd crypto_sign_ed25519_ref10_sc_muladd 11 | 12 | extern void sc_reduce(unsigned char *); 13 | extern void sc_muladd(unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/sqrtm1.h: -------------------------------------------------------------------------------- 1 | -32595792,-7943725,9377950,3500415,12389472,-272473,-25146209,-2005654,326686,11406482 2 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/sign_ed25519_api.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "crypto_sign_ed25519.h" 5 | 6 | size_t 7 | crypto_sign_ed25519_bytes(void) { 8 | return crypto_sign_ed25519_BYTES; 9 | } 10 | 11 | size_t 12 | crypto_sign_ed25519_seedbytes(void) { 13 | return crypto_sign_ed25519_SEEDBYTES; 14 | } 15 | 16 | size_t 17 | crypto_sign_ed25519_publickeybytes(void) { 18 | return crypto_sign_ed25519_PUBLICKEYBYTES; 19 | } 20 | 21 | size_t 22 | crypto_sign_ed25519_secretkeybytes(void) { 23 | return crypto_sign_ed25519_SECRETKEYBYTES; 24 | } 25 | 26 | int 27 | crypto_sign_ed25519_sk_to_seed(unsigned char *seed, const unsigned char *sk) 28 | { 29 | memmove(seed, sk, crypto_sign_ed25519_SEEDBYTES); 30 | return 0; 31 | } 32 | 33 | int 34 | crypto_sign_ed25519_sk_to_pk(unsigned char *pk, const unsigned char *sk) 35 | { 36 | memmove(pk, sk + crypto_sign_ed25519_SEEDBYTES, 37 | crypto_sign_ed25519_PUBLICKEYBYTES); 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/aes128ctr/portable/consts.h: -------------------------------------------------------------------------------- 1 | #ifndef CONSTS_H 2 | #define CONSTS_H 3 | 4 | #include "int128.h" 5 | 6 | #define ROTB crypto_stream_aes128ctr_portable_ROTB 7 | #define M0 crypto_stream_aes128ctr_portable_M0 8 | #define EXPB0 crypto_stream_aes128ctr_portable_EXPB0 9 | #define SWAP32 crypto_stream_aes128ctr_portable_SWAP32 10 | #define M0SWAP crypto_stream_aes128ctr_portable_M0SWAP 11 | #define SR crypto_stream_aes128ctr_portable_SR 12 | #define SRM0 crypto_stream_aes128ctr_portable_SRM0 13 | #define BS0 crypto_stream_aes128ctr_portable_BS0 14 | #define BS1 crypto_stream_aes128ctr_portable_BS1 15 | #define BS2 crypto_stream_aes128ctr_portable_BS2 16 | 17 | extern const unsigned char ROTB[16]; 18 | extern const unsigned char M0[16]; 19 | extern const unsigned char EXPB0[16]; 20 | extern const unsigned char SWAP32[16]; 21 | extern const unsigned char M0SWAP[16]; 22 | extern const unsigned char SR[16]; 23 | extern const unsigned char SRM0[16]; 24 | extern const int128 BS0; 25 | extern const int128 BS1; 26 | extern const int128 BS2; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/aes128ctr/portable/consts_aes128ctr.c: -------------------------------------------------------------------------------- 1 | #include "consts.h" 2 | 3 | const unsigned char ROTB[16] = {0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08}; 4 | const unsigned char M0[16] = {0x0f, 0x0b, 0x07, 0x03, 0x0e, 0x0a, 0x06, 0x02, 0x0d, 0x09, 0x05, 0x01, 0x0c, 0x08, 0x04, 0x00}; 5 | const unsigned char EXPB0[16] = {0x03, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, 0x0b, 0x0b, 0x0b, 0x0b, 0x0f, 0x0f, 0x0f, 0x0f}; 6 | 7 | const unsigned char SWAP32[16] = {0x03, 0x02, 0x01, 0x00, 0x07, 0x06, 0x05, 0x04, 0x0b, 0x0a, 0x09, 0x08, 0x0f, 0x0e, 0x0d, 0x0c}; 8 | const unsigned char M0SWAP[16] = {0x0c, 0x08, 0x04, 0x00, 0x0d, 0x09, 0x05, 0x01, 0x0e, 0x0a, 0x06, 0x02, 0x0f, 0x0b, 0x07, 0x03}; 9 | const unsigned char SR[16] = {0x01, 0x02, 0x03, 0x00, 0x06, 0x07, 0x04, 0x05, 0x0b, 0x08, 0x09, 0x0a, 0x0c, 0x0d, 0x0e, 0x0f}; 10 | const unsigned char SRM0[16] = {0x0f, 0x0a, 0x05, 0x00, 0x0e, 0x09, 0x04, 0x03, 0x0d, 0x08, 0x07, 0x02, 0x0c, 0x0b, 0x06, 0x01}; 11 | 12 | const int128 BS0 = {{0x5555555555555555ULL, 0x5555555555555555ULL}}; 13 | const int128 BS1 = {{0x3333333333333333ULL, 0x3333333333333333ULL}}; 14 | const int128 BS2 = {{0x0f0f0f0f0f0f0f0fULL, 0x0f0f0f0f0f0f0f0fULL}}; 15 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/aes128ctr/portable/stream_aes128ctr.c: -------------------------------------------------------------------------------- 1 | 2 | #include "crypto_stream_aes128ctr.h" 3 | 4 | int crypto_stream_aes128ctr( 5 | unsigned char *out, 6 | unsigned long long outlen, 7 | const unsigned char *n, 8 | const unsigned char *k 9 | ) 10 | { 11 | unsigned char d[crypto_stream_aes128ctr_BEFORENMBYTES]; 12 | crypto_stream_aes128ctr_beforenm(d, k); 13 | crypto_stream_aes128ctr_afternm(out, outlen, n, d); 14 | return 0; 15 | } 16 | 17 | int crypto_stream_aes128ctr_xor( 18 | unsigned char *out, 19 | const unsigned char *in, 20 | unsigned long long inlen, 21 | const unsigned char *n, 22 | const unsigned char *k 23 | ) 24 | { 25 | unsigned char d[crypto_stream_aes128ctr_BEFORENMBYTES]; 26 | crypto_stream_aes128ctr_beforenm(d, k); 27 | crypto_stream_aes128ctr_xor_afternm(out, in, inlen, n, d); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/aes128ctr/portable/types.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_H 2 | #define TYPES_H 3 | 4 | #include "crypto_uint32.h" 5 | typedef crypto_uint32 uint32; 6 | 7 | #include "crypto_uint64.h" 8 | typedef crypto_uint64 uint64; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/aes128ctr/stream_aes128ctr_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_stream_aes128ctr.h" 2 | 3 | size_t 4 | crypto_stream_aes128ctr_keybytes(void) { 5 | return crypto_stream_aes128ctr_KEYBYTES; 6 | } 7 | 8 | size_t 9 | crypto_stream_aes128ctr_noncebytes(void) { 10 | return crypto_stream_aes128ctr_NONCEBYTES; 11 | } 12 | 13 | size_t 14 | crypto_stream_aes128ctr_beforenmbytes(void) { 15 | return crypto_stream_aes128ctr_BEFORENMBYTES; 16 | } 17 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/chacha20/ref/stream_chacha20_ref.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "crypto_stream_chacha20.h" 5 | 6 | extern struct crypto_stream_chacha20_implementation 7 | crypto_stream_chacha20_ref_implementation; 8 | 9 | int 10 | crypto_stream_chacha20_ref(unsigned char *c, unsigned long long clen, 11 | const unsigned char *n, const unsigned char *k); 12 | 13 | int 14 | crypto_stream_chacha20_ref_xor_ic(unsigned char *c, const unsigned char *m, 15 | unsigned long long mlen, 16 | const unsigned char *n, uint64_t ic, 17 | const unsigned char *k); 18 | 19 | int 20 | crypto_stream_chacha20_ietf_ref(unsigned char *c, unsigned long long clen, 21 | const unsigned char *n, const unsigned char *k); 22 | 23 | int 24 | crypto_stream_chacha20_ietf_ref_xor_ic(unsigned char *c, const unsigned char *m, 25 | unsigned long long mlen, 26 | const unsigned char *n, uint32_t ic, 27 | const unsigned char *k); 28 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/chacha20/stream_chacha20.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef stream_chacha20_H 3 | #define stream_chacha20_H 4 | 5 | #include 6 | 7 | typedef struct crypto_stream_chacha20_implementation { 8 | int (*stream)(unsigned char *c, unsigned long long clen, 9 | const unsigned char *n, const unsigned char *k); 10 | int (*stream_ietf)(unsigned char *c, unsigned long long clen, 11 | const unsigned char *n, const unsigned char *k); 12 | int (*stream_xor_ic)(unsigned char *c, const unsigned char *m, 13 | unsigned long long mlen, 14 | const unsigned char *n, uint64_t ic, 15 | const unsigned char *k); 16 | int (*stream_ietf_xor_ic)(unsigned char *c, const unsigned char *m, 17 | unsigned long long mlen, 18 | const unsigned char *n, uint32_t ic, 19 | const unsigned char *k); 20 | } crypto_stream_chacha20_implementation; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/chacha20/vec/stream_chacha20_vec.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include "crypto_stream_chacha20.h" 5 | 6 | extern struct crypto_stream_chacha20_implementation 7 | crypto_stream_chacha20_vec_implementation; 8 | 9 | int 10 | crypto_stream_chacha20_vec(unsigned char *c, unsigned long long clen, 11 | const unsigned char *n, const unsigned char *k); 12 | 13 | int 14 | crypto_stream_chacha20_vec_xor_ic(unsigned char *c, const unsigned char *m, 15 | unsigned long long mlen, 16 | const unsigned char *n, uint64_t ic, 17 | const unsigned char *k); 18 | 19 | int 20 | crypto_stream_chacha20_ietf_vec(unsigned char *c, unsigned long long clen, 21 | const unsigned char *n, const unsigned char *k); 22 | 23 | int 24 | crypto_stream_chacha20_ietf_vec_xor_ic(unsigned char *c, const unsigned char *m, 25 | unsigned long long mlen, 26 | const unsigned char *n, uint32_t ic, 27 | const unsigned char *k); 28 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/crypto_stream.c: -------------------------------------------------------------------------------- 1 | 2 | #include "crypto_stream.h" 3 | 4 | size_t 5 | crypto_stream_keybytes(void) 6 | { 7 | return crypto_stream_KEYBYTES; 8 | } 9 | 10 | size_t 11 | crypto_stream_noncebytes(void) 12 | { 13 | return crypto_stream_NONCEBYTES; 14 | } 15 | 16 | const char * 17 | crypto_stream_primitive(void) 18 | { 19 | return crypto_stream_PRIMITIVE; 20 | } 21 | 22 | int 23 | crypto_stream(unsigned char *c, unsigned long long clen, 24 | const unsigned char *n, const unsigned char *k) 25 | { 26 | return crypto_stream_xsalsa20(c, clen, n, k); 27 | } 28 | 29 | 30 | int 31 | crypto_stream_xor(unsigned char *c, const unsigned char *m, 32 | unsigned long long mlen, const unsigned char *n, 33 | const unsigned char *k) 34 | { 35 | return crypto_stream_xsalsa20_xor(c, m, mlen, n, k); 36 | } 37 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/salsa20/stream_salsa20_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_stream_salsa20.h" 2 | 3 | size_t 4 | crypto_stream_salsa20_keybytes(void) { 5 | return crypto_stream_salsa20_KEYBYTES; 6 | } 7 | 8 | size_t 9 | crypto_stream_salsa20_noncebytes(void) { 10 | return crypto_stream_salsa20_NONCEBYTES; 11 | } 12 | 13 | int 14 | crypto_stream_salsa20_xor(unsigned char *c, const unsigned char *m, 15 | unsigned long long mlen, const unsigned char *n, 16 | const unsigned char *k) 17 | { 18 | return crypto_stream_salsa20_xor_ic(c, m, mlen, n, 0U, k); 19 | } 20 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/salsa2012/ref/stream_salsa2012.c: -------------------------------------------------------------------------------- 1 | /* 2 | version 20140420 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #include "crypto_core_salsa2012.h" 8 | #include "crypto_stream_salsa2012.h" 9 | #include "utils.h" 10 | 11 | typedef unsigned int uint32; 12 | 13 | static const unsigned char sigma[16] = { 14 | 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k' 15 | }; 16 | 17 | int crypto_stream_salsa2012( 18 | unsigned char *c,unsigned long long clen, 19 | const unsigned char *n, 20 | const unsigned char *k 21 | ) 22 | { 23 | unsigned char in[16]; 24 | unsigned char block[64]; 25 | unsigned char kcopy[32]; 26 | unsigned int i; 27 | unsigned int u; 28 | 29 | if (!clen) return 0; 30 | 31 | for (i = 0;i < 32;++i) kcopy[i] = k[i]; 32 | for (i = 0;i < 8;++i) in[i] = n[i]; 33 | for (i = 8;i < 16;++i) in[i] = 0; 34 | 35 | while (clen >= 64) { 36 | crypto_core_salsa2012(c,in,kcopy,sigma); 37 | 38 | u = 1; 39 | for (i = 8;i < 16;++i) { 40 | u += (unsigned int) in[i]; 41 | in[i] = u; 42 | u >>= 8; 43 | } 44 | 45 | clen -= 64; 46 | c += 64; 47 | } 48 | 49 | if (clen) { 50 | crypto_core_salsa2012(block,in,kcopy,sigma); 51 | for (i = 0;i < (unsigned int) clen;++i) c[i] = block[i]; 52 | } 53 | sodium_memzero(block, sizeof block); 54 | sodium_memzero(kcopy, sizeof kcopy); 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/salsa2012/stream_salsa2012_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_stream_salsa2012.h" 2 | 3 | size_t 4 | crypto_stream_salsa2012_keybytes(void) { 5 | return crypto_stream_salsa2012_KEYBYTES; 6 | } 7 | 8 | size_t 9 | crypto_stream_salsa2012_noncebytes(void) { 10 | return crypto_stream_salsa2012_NONCEBYTES; 11 | } 12 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/salsa208/stream_salsa208_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_stream_salsa208.h" 2 | 3 | size_t 4 | crypto_stream_salsa208_keybytes(void) { 5 | return crypto_stream_salsa208_KEYBYTES; 6 | } 7 | 8 | size_t 9 | crypto_stream_salsa208_noncebytes(void) { 10 | return crypto_stream_salsa208_NONCEBYTES; 11 | } 12 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/xsalsa20/ref/stream_xsalsa20.c: -------------------------------------------------------------------------------- 1 | /* 2 | version 20080914 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #include "crypto_core_hsalsa20.h" 8 | #include "crypto_stream_salsa20.h" 9 | #include "crypto_stream_xsalsa20.h" 10 | #include "utils.h" 11 | 12 | static const unsigned char sigma[16] = { 13 | 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k' 14 | }; 15 | 16 | int crypto_stream_xsalsa20( 17 | unsigned char *c,unsigned long long clen, 18 | const unsigned char *n, 19 | const unsigned char *k 20 | ) 21 | { 22 | unsigned char subkey[32]; 23 | int ret; 24 | crypto_core_hsalsa20(subkey,n,k,sigma); 25 | ret = crypto_stream_salsa20(c,clen,n + 16,subkey); 26 | sodium_memzero(subkey, sizeof subkey); 27 | return ret; 28 | } 29 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/xsalsa20/ref/xor_xsalsa20.c: -------------------------------------------------------------------------------- 1 | /* 2 | version 20080913 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #include "crypto_core_hsalsa20.h" 8 | #include "crypto_stream_salsa20.h" 9 | #include "crypto_stream_xsalsa20.h" 10 | #include "utils.h" 11 | 12 | static const unsigned char sigma[16] = { 13 | 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k' 14 | }; 15 | 16 | int crypto_stream_xsalsa20_xor_ic( 17 | unsigned char *c, 18 | const unsigned char *m,unsigned long long mlen, 19 | const unsigned char *n,uint64_t ic, 20 | const unsigned char *k 21 | ) 22 | { 23 | unsigned char subkey[32]; 24 | int ret; 25 | crypto_core_hsalsa20(subkey,n,k,sigma); 26 | ret = crypto_stream_salsa20_xor_ic(c,m,mlen,n + 16,ic,subkey); 27 | sodium_memzero(subkey, sizeof subkey); 28 | return ret; 29 | } 30 | 31 | int crypto_stream_xsalsa20_xor( 32 | unsigned char *c, 33 | const unsigned char *m,unsigned long long mlen, 34 | const unsigned char *n, 35 | const unsigned char *k 36 | ) 37 | { 38 | return crypto_stream_xsalsa20_xor_ic(c, m, mlen, n, 0ULL, k); 39 | } 40 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/xsalsa20/stream_xsalsa20_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_stream_xsalsa20.h" 2 | 3 | size_t 4 | crypto_stream_xsalsa20_keybytes(void) { 5 | return crypto_stream_xsalsa20_KEYBYTES; 6 | } 7 | 8 | size_t 9 | crypto_stream_xsalsa20_noncebytes(void) { 10 | return crypto_stream_xsalsa20_NONCEBYTES; 11 | } 12 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_verify/16/ref/verify_16.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include "crypto_verify_16.h" 6 | 7 | int 8 | crypto_verify_16(const unsigned char *x, const unsigned char *y) 9 | { 10 | uint_fast16_t d = 0U; 11 | int i; 12 | 13 | for (i = 0; i < 16; i++) { 14 | d |= x[i] ^ y[i]; 15 | } 16 | return (1 & ((d - 1) >> 8)) - 1; 17 | } 18 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_verify/16/verify_16_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_verify_16.h" 2 | 3 | size_t 4 | crypto_verify_16_bytes(void) { 5 | return crypto_verify_16_BYTES; 6 | } 7 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_verify/32/ref/verify_32.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include "crypto_verify_32.h" 6 | 7 | int 8 | crypto_verify_32(const unsigned char *x, const unsigned char *y) 9 | { 10 | uint_fast16_t d = 0U; 11 | int i; 12 | 13 | for (i = 0; i < 32; i++) { 14 | d |= x[i] ^ y[i]; 15 | } 16 | return (1 & ((d - 1) >> 8)) - 1; 17 | } 18 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_verify/32/verify_32_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_verify_32.h" 2 | 3 | size_t 4 | crypto_verify_32_bytes(void) { 5 | return crypto_verify_32_BYTES; 6 | } 7 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_verify/64/ref/verify_64.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include "crypto_verify_64.h" 6 | 7 | int 8 | crypto_verify_64(const unsigned char *x, const unsigned char *y) 9 | { 10 | uint_fast16_t d = 0U; 11 | int i; 12 | 13 | for (i = 0; i < 64; i++) { 14 | d |= x[i] ^ y[i]; 15 | } 16 | return (1 & ((d - 1) >> 8)) - 1; 17 | } 18 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_verify/64/verify_64_api.c: -------------------------------------------------------------------------------- 1 | #include "crypto_verify_64.h" 2 | 3 | size_t 4 | crypto_verify_64_bytes(void) { 5 | return crypto_verify_64_BYTES; 6 | } 7 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/core.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef sodium_core_H 3 | #define sodium_core_H 4 | 5 | #include "export.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | SODIUM_EXPORT 12 | int sodium_init(void) 13 | __attribute__ ((warn_unused_result)); 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_auth.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_auth_H 2 | #define crypto_auth_H 3 | 4 | #include 5 | 6 | #include "crypto_auth_hmacsha512256.h" 7 | #include "export.h" 8 | 9 | #ifdef __cplusplus 10 | # if __GNUC__ 11 | # pragma GCC diagnostic ignored "-Wlong-long" 12 | # endif 13 | extern "C" { 14 | #endif 15 | 16 | #define crypto_auth_BYTES crypto_auth_hmacsha512256_BYTES 17 | SODIUM_EXPORT 18 | size_t crypto_auth_bytes(void); 19 | 20 | #define crypto_auth_KEYBYTES crypto_auth_hmacsha512256_KEYBYTES 21 | SODIUM_EXPORT 22 | size_t crypto_auth_keybytes(void); 23 | 24 | #define crypto_auth_PRIMITIVE "hmacsha512256" 25 | SODIUM_EXPORT 26 | const char *crypto_auth_primitive(void); 27 | 28 | SODIUM_EXPORT 29 | int crypto_auth(unsigned char *out, const unsigned char *in, 30 | unsigned long long inlen, const unsigned char *k); 31 | 32 | SODIUM_EXPORT 33 | int crypto_auth_verify(const unsigned char *h, const unsigned char *in, 34 | unsigned long long inlen, const unsigned char *k) 35 | __attribute__ ((warn_unused_result)); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_core_hsalsa20.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_core_hsalsa20_H 2 | #define crypto_core_hsalsa20_H 3 | 4 | #include 5 | #include "export.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #define crypto_core_hsalsa20_OUTPUTBYTES 32U 12 | SODIUM_EXPORT 13 | size_t crypto_core_hsalsa20_outputbytes(void); 14 | 15 | #define crypto_core_hsalsa20_INPUTBYTES 16U 16 | SODIUM_EXPORT 17 | size_t crypto_core_hsalsa20_inputbytes(void); 18 | 19 | #define crypto_core_hsalsa20_KEYBYTES 32U 20 | SODIUM_EXPORT 21 | size_t crypto_core_hsalsa20_keybytes(void); 22 | 23 | #define crypto_core_hsalsa20_CONSTBYTES 16U 24 | SODIUM_EXPORT 25 | size_t crypto_core_hsalsa20_constbytes(void); 26 | 27 | SODIUM_EXPORT 28 | int crypto_core_hsalsa20(unsigned char *out, const unsigned char *in, 29 | const unsigned char *k, const unsigned char *c); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_core_salsa20.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_core_salsa20_H 2 | #define crypto_core_salsa20_H 3 | 4 | #include 5 | #include "export.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #define crypto_core_salsa20_OUTPUTBYTES 64U 12 | SODIUM_EXPORT 13 | size_t crypto_core_salsa20_outputbytes(void); 14 | 15 | #define crypto_core_salsa20_INPUTBYTES 16U 16 | SODIUM_EXPORT 17 | size_t crypto_core_salsa20_inputbytes(void); 18 | 19 | #define crypto_core_salsa20_KEYBYTES 32U 20 | SODIUM_EXPORT 21 | size_t crypto_core_salsa20_keybytes(void); 22 | 23 | #define crypto_core_salsa20_CONSTBYTES 16U 24 | SODIUM_EXPORT 25 | size_t crypto_core_salsa20_constbytes(void); 26 | 27 | SODIUM_EXPORT 28 | int crypto_core_salsa20(unsigned char *out, const unsigned char *in, 29 | const unsigned char *k, const unsigned char *c); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_core_salsa2012.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_core_salsa2012_H 2 | #define crypto_core_salsa2012_H 3 | 4 | #include 5 | #include "export.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #define crypto_core_salsa2012_OUTPUTBYTES 64U 12 | SODIUM_EXPORT 13 | size_t crypto_core_salsa2012_outputbytes(void); 14 | 15 | #define crypto_core_salsa2012_INPUTBYTES 16U 16 | SODIUM_EXPORT 17 | size_t crypto_core_salsa2012_inputbytes(void); 18 | 19 | #define crypto_core_salsa2012_KEYBYTES 32U 20 | SODIUM_EXPORT 21 | size_t crypto_core_salsa2012_keybytes(void); 22 | 23 | #define crypto_core_salsa2012_CONSTBYTES 16U 24 | SODIUM_EXPORT 25 | size_t crypto_core_salsa2012_constbytes(void); 26 | 27 | SODIUM_EXPORT 28 | int crypto_core_salsa2012(unsigned char *out, const unsigned char *in, 29 | const unsigned char *k, const unsigned char *c); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_core_salsa208.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_core_salsa208_H 2 | #define crypto_core_salsa208_H 3 | 4 | #include 5 | #include "export.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #define crypto_core_salsa208_OUTPUTBYTES 64U 12 | SODIUM_EXPORT 13 | size_t crypto_core_salsa208_outputbytes(void); 14 | 15 | #define crypto_core_salsa208_INPUTBYTES 16U 16 | SODIUM_EXPORT 17 | size_t crypto_core_salsa208_inputbytes(void); 18 | 19 | #define crypto_core_salsa208_KEYBYTES 32U 20 | SODIUM_EXPORT 21 | size_t crypto_core_salsa208_keybytes(void); 22 | 23 | #define crypto_core_salsa208_CONSTBYTES 16U 24 | SODIUM_EXPORT 25 | size_t crypto_core_salsa208_constbytes(void); 26 | 27 | SODIUM_EXPORT 28 | int crypto_core_salsa208(unsigned char *out, const unsigned char *in, 29 | const unsigned char *k, const unsigned char *c); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_hash.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_hash_H 2 | #define crypto_hash_H 3 | 4 | /* 5 | * WARNING: Unless you absolutely need to use SHA512 for interoperatibility, 6 | * purposes, you might want to consider crypto_generichash() instead. 7 | * Unlike SHA512, crypto_generichash() is not vulnerable to length 8 | * extension attacks. 9 | */ 10 | 11 | #include 12 | 13 | #include "crypto_hash_sha512.h" 14 | #include "export.h" 15 | 16 | #ifdef __cplusplus 17 | # if __GNUC__ 18 | # pragma GCC diagnostic ignored "-Wlong-long" 19 | # endif 20 | extern "C" { 21 | #endif 22 | 23 | #define crypto_hash_BYTES crypto_hash_sha512_BYTES 24 | SODIUM_EXPORT 25 | size_t crypto_hash_bytes(void); 26 | 27 | SODIUM_EXPORT 28 | int crypto_hash(unsigned char *out, const unsigned char *in, 29 | unsigned long long inlen); 30 | 31 | #define crypto_hash_PRIMITIVE "sha512" 32 | SODIUM_EXPORT 33 | const char *crypto_hash_primitive(void) 34 | __attribute__ ((warn_unused_result)); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_int32.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_int32_H 2 | #define crypto_int32_H 3 | 4 | #include 5 | 6 | typedef int32_t crypto_int32; 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_int64.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_int64_H 2 | #define crypto_int64_H 3 | 4 | #include 5 | 6 | typedef int64_t crypto_int64; 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_scalarmult.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_scalarmult_H 2 | #define crypto_scalarmult_H 3 | 4 | #include 5 | 6 | #include "crypto_scalarmult_curve25519.h" 7 | #include "export.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | #define crypto_scalarmult_BYTES crypto_scalarmult_curve25519_BYTES 14 | SODIUM_EXPORT 15 | size_t crypto_scalarmult_bytes(void); 16 | 17 | #define crypto_scalarmult_SCALARBYTES crypto_scalarmult_curve25519_SCALARBYTES 18 | SODIUM_EXPORT 19 | size_t crypto_scalarmult_scalarbytes(void); 20 | 21 | #define crypto_scalarmult_PRIMITIVE "curve25519" 22 | SODIUM_EXPORT 23 | const char *crypto_scalarmult_primitive(void); 24 | 25 | SODIUM_EXPORT 26 | int crypto_scalarmult_base(unsigned char *q, const unsigned char *n); 27 | 28 | SODIUM_EXPORT 29 | int crypto_scalarmult(unsigned char *q, const unsigned char *n, 30 | const unsigned char *p) 31 | __attribute__ ((warn_unused_result)); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_scalarmult_curve25519.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_scalarmult_curve25519_H 2 | #define crypto_scalarmult_curve25519_H 3 | 4 | #include 5 | 6 | #include "export.h" 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #define crypto_scalarmult_curve25519_BYTES 32U 13 | SODIUM_EXPORT 14 | size_t crypto_scalarmult_curve25519_bytes(void); 15 | 16 | #define crypto_scalarmult_curve25519_SCALARBYTES 32U 17 | SODIUM_EXPORT 18 | size_t crypto_scalarmult_curve25519_scalarbytes(void); 19 | 20 | SODIUM_EXPORT 21 | int crypto_scalarmult_curve25519(unsigned char *q, const unsigned char *n, 22 | const unsigned char *p) 23 | __attribute__ ((warn_unused_result)); 24 | 25 | SODIUM_EXPORT 26 | int crypto_scalarmult_curve25519_base(unsigned char *q, const unsigned char *n); 27 | 28 | /* ------------------------------------------------------------------------- */ 29 | 30 | int _crypto_scalarmult_curve25519_pick_best_implementation(void); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_shorthash.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_shorthash_H 2 | #define crypto_shorthash_H 3 | 4 | #include 5 | 6 | #include "crypto_shorthash_siphash24.h" 7 | #include "export.h" 8 | 9 | #ifdef __cplusplus 10 | # if __GNUC__ 11 | # pragma GCC diagnostic ignored "-Wlong-long" 12 | # endif 13 | extern "C" { 14 | #endif 15 | 16 | #define crypto_shorthash_BYTES crypto_shorthash_siphash24_BYTES 17 | SODIUM_EXPORT 18 | size_t crypto_shorthash_bytes(void); 19 | 20 | #define crypto_shorthash_KEYBYTES crypto_shorthash_siphash24_KEYBYTES 21 | SODIUM_EXPORT 22 | size_t crypto_shorthash_keybytes(void); 23 | 24 | #define crypto_shorthash_PRIMITIVE "siphash24" 25 | SODIUM_EXPORT 26 | const char *crypto_shorthash_primitive(void); 27 | 28 | SODIUM_EXPORT 29 | int crypto_shorthash(unsigned char *out, const unsigned char *in, 30 | unsigned long long inlen, const unsigned char *k); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_shorthash_siphash24.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_shorthash_siphash24_H 2 | #define crypto_shorthash_siphash24_H 3 | 4 | #include 5 | #include "export.h" 6 | 7 | #ifdef __cplusplus 8 | # if __GNUC__ 9 | # pragma GCC diagnostic ignored "-Wlong-long" 10 | # endif 11 | extern "C" { 12 | #endif 13 | 14 | #define crypto_shorthash_siphash24_BYTES 8U 15 | SODIUM_EXPORT 16 | size_t crypto_shorthash_siphash24_bytes(void); 17 | 18 | #define crypto_shorthash_siphash24_KEYBYTES 16U 19 | SODIUM_EXPORT 20 | size_t crypto_shorthash_siphash24_keybytes(void); 21 | 22 | SODIUM_EXPORT 23 | int crypto_shorthash_siphash24(unsigned char *out, const unsigned char *in, 24 | unsigned long long inlen, const unsigned char *k); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_stream_salsa2012.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_stream_salsa2012_H 2 | #define crypto_stream_salsa2012_H 3 | 4 | /* 5 | * WARNING: This is just a stream cipher. It is NOT authenticated encryption. 6 | * While it provides some protection against eavesdropping, it does NOT 7 | * provide any security against active attacks. 8 | * Unless you know what you're doing, what you are looking for is probably 9 | * the crypto_box functions. 10 | */ 11 | 12 | #include 13 | #include "export.h" 14 | 15 | #ifdef __cplusplus 16 | # if __GNUC__ 17 | # pragma GCC diagnostic ignored "-Wlong-long" 18 | # endif 19 | extern "C" { 20 | #endif 21 | 22 | #define crypto_stream_salsa2012_KEYBYTES 32U 23 | SODIUM_EXPORT 24 | size_t crypto_stream_salsa2012_keybytes(void); 25 | 26 | #define crypto_stream_salsa2012_NONCEBYTES 8U 27 | SODIUM_EXPORT 28 | size_t crypto_stream_salsa2012_noncebytes(void); 29 | 30 | SODIUM_EXPORT 31 | int crypto_stream_salsa2012(unsigned char *c, unsigned long long clen, 32 | const unsigned char *n, const unsigned char *k); 33 | 34 | SODIUM_EXPORT 35 | int crypto_stream_salsa2012_xor(unsigned char *c, const unsigned char *m, 36 | unsigned long long mlen, const unsigned char *n, 37 | const unsigned char *k); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_stream_salsa208.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_stream_salsa208_H 2 | #define crypto_stream_salsa208_H 3 | 4 | /* 5 | * WARNING: This is just a stream cipher. It is NOT authenticated encryption. 6 | * While it provides some protection against eavesdropping, it does NOT 7 | * provide any security against active attacks. 8 | * Unless you know what you're doing, what you are looking for is probably 9 | * the crypto_box functions. 10 | */ 11 | 12 | #include 13 | #include "export.h" 14 | 15 | #ifdef __cplusplus 16 | # if __GNUC__ 17 | # pragma GCC diagnostic ignored "-Wlong-long" 18 | # endif 19 | extern "C" { 20 | #endif 21 | 22 | #define crypto_stream_salsa208_KEYBYTES 32U 23 | SODIUM_EXPORT 24 | size_t crypto_stream_salsa208_keybytes(void); 25 | 26 | #define crypto_stream_salsa208_NONCEBYTES 8U 27 | SODIUM_EXPORT 28 | size_t crypto_stream_salsa208_noncebytes(void); 29 | 30 | SODIUM_EXPORT 31 | int crypto_stream_salsa208(unsigned char *c, unsigned long long clen, 32 | const unsigned char *n, const unsigned char *k); 33 | 34 | SODIUM_EXPORT 35 | int crypto_stream_salsa208_xor(unsigned char *c, const unsigned char *m, 36 | unsigned long long mlen, const unsigned char *n, 37 | const unsigned char *k); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_uint16.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_uint16_H 2 | #define crypto_uint16_H 3 | 4 | #include 5 | 6 | typedef uint16_t crypto_uint16; 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_uint32.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_uint32_H 2 | #define crypto_uint32_H 3 | 4 | #include 5 | 6 | typedef uint32_t crypto_uint32; 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_uint64.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_uint64_H 2 | #define crypto_uint64_H 3 | 4 | #include 5 | 6 | typedef uint64_t crypto_uint64; 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_uint8.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_uint8_H 2 | #define crypto_uint8_H 3 | 4 | #include 5 | 6 | typedef uint8_t crypto_uint8; 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_verify_16.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_verify_16_H 2 | #define crypto_verify_16_H 3 | 4 | #include 5 | #include "export.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #define crypto_verify_16_BYTES 16U 12 | SODIUM_EXPORT 13 | size_t crypto_verify_16_bytes(void); 14 | 15 | SODIUM_EXPORT 16 | int crypto_verify_16(const unsigned char *x, const unsigned char *y) 17 | __attribute__ ((warn_unused_result)); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_verify_32.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_verify_32_H 2 | #define crypto_verify_32_H 3 | 4 | #include 5 | #include "export.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #define crypto_verify_32_BYTES 32U 12 | SODIUM_EXPORT 13 | size_t crypto_verify_32_bytes(void); 14 | 15 | SODIUM_EXPORT 16 | int crypto_verify_32(const unsigned char *x, const unsigned char *y) 17 | __attribute__ ((warn_unused_result)); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_verify_64.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_verify_64_H 2 | #define crypto_verify_64_H 3 | 4 | #include 5 | #include "export.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #define crypto_verify_64_BYTES 64U 12 | SODIUM_EXPORT 13 | size_t crypto_verify_64_bytes(void); 14 | 15 | SODIUM_EXPORT 16 | int crypto_verify_64(const unsigned char *x, const unsigned char *y) 17 | __attribute__ ((warn_unused_result)); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/export.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef sodium_export_H 3 | #define sodium_export_H 4 | 5 | #ifndef __GNUC__ 6 | # ifdef __attribute__ 7 | # undef __attribute__ 8 | # endif 9 | # define __attribute__(a) 10 | #endif 11 | 12 | #ifdef SODIUM_STATIC 13 | # define SODIUM_EXPORT 14 | #else 15 | # if defined(_MSC_VER) 16 | # ifdef SODIUM_DLL_EXPORT 17 | # define SODIUM_EXPORT __declspec(dllexport) 18 | # else 19 | # define SODIUM_EXPORT __declspec(dllimport) 20 | # endif 21 | # else 22 | # if defined(__SUNPRO_C) 23 | # ifndef __GNU_C__ 24 | # define SODIUM_EXPORT __attribute__(visibility(__global)) 25 | # else 26 | # define SODIUM_EXPORT __attribute__ __global 27 | # endif 28 | # elif defined(_MSG_VER) 29 | # define SODIUM_EXPORT extern __declspec(dllexport) 30 | # else 31 | # define SODIUM_EXPORT __attribute__ ((visibility ("default"))) 32 | # endif 33 | # endif 34 | #endif 35 | 36 | #ifndef CRYPTO_ALIGN 37 | # if defined(__INTEL_COMPILER) || defined(_MSC_VER) 38 | # define CRYPTO_ALIGN(x) __declspec(align(x)) 39 | # else 40 | # define CRYPTO_ALIGN(x) __attribute__((aligned(x))) 41 | # endif 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/randombytes_nativeclient.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef randombytes_nativeclient_H 3 | #define randombytes_nativeclient_H 4 | 5 | #ifdef __native_client__ 6 | 7 | # include "export.h" 8 | # include "randombytes.h" 9 | 10 | # ifdef __cplusplus 11 | extern "C" { 12 | # endif 13 | 14 | SODIUM_EXPORT 15 | extern struct randombytes_implementation randombytes_nativeclient_implementation; 16 | 17 | # ifdef __cplusplus 18 | } 19 | # endif 20 | 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/randombytes_salsa20_random.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef randombytes_salsa20_random_H 3 | #define randombytes_salsa20_random_H 4 | 5 | #include "export.h" 6 | #include "randombytes.h" 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | SODIUM_EXPORT 13 | extern struct randombytes_implementation randombytes_salsa20_implementation; 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/randombytes_sysrandom.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef randombytes_sysrandom_H 3 | #define randombytes_sysrandom_H 4 | 5 | #include "export.h" 6 | #include "randombytes.h" 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | SODIUM_EXPORT 13 | extern struct randombytes_implementation randombytes_sysrandom_implementation; 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/runtime.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef sodium_runtime_H 3 | #define sodium_runtime_H 4 | 5 | #include "export.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | SODIUM_EXPORT 12 | int sodium_runtime_has_neon(void); 13 | 14 | SODIUM_EXPORT 15 | int sodium_runtime_has_sse2(void); 16 | 17 | SODIUM_EXPORT 18 | int sodium_runtime_has_sse3(void); 19 | 20 | SODIUM_EXPORT 21 | int sodium_runtime_has_ssse3(void); 22 | 23 | SODIUM_EXPORT 24 | int sodium_runtime_has_sse41(void); 25 | 26 | SODIUM_EXPORT 27 | int sodium_runtime_has_avx(void); 28 | 29 | SODIUM_EXPORT 30 | int sodium_runtime_has_pclmul(void); 31 | 32 | SODIUM_EXPORT 33 | int sodium_runtime_has_aesni(void); 34 | 35 | /* ------------------------------------------------------------------------- */ 36 | 37 | int _sodium_runtime_get_cpu_features(void); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/version.h.in: -------------------------------------------------------------------------------- 1 | 2 | #ifndef sodium_version_H 3 | #define sodium_version_H 4 | 5 | #include "export.h" 6 | 7 | #define SODIUM_VERSION_STRING "@VERSION@" 8 | 9 | #define SODIUM_LIBRARY_VERSION_MAJOR @SODIUM_LIBRARY_VERSION_MAJOR@ 10 | #define SODIUM_LIBRARY_VERSION_MINOR @SODIUM_LIBRARY_VERSION_MINOR@ 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | SODIUM_EXPORT 17 | const char *sodium_version_string(void); 18 | 19 | SODIUM_EXPORT 20 | int sodium_library_version_major(void); 21 | 22 | SODIUM_EXPORT 23 | int sodium_library_version_minor(void); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/randombytes/nativeclient/randombytes_nativeclient.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #ifdef __native_client__ 7 | # include 8 | 9 | # include "utils.h" 10 | # include "randombytes.h" 11 | # include "randombytes_nativeclient.h" 12 | 13 | static void 14 | randombytes_nativeclient_buf(void * const buf, const size_t size) 15 | { 16 | size_t readnb; 17 | 18 | if (nacl_secure_random(buf, size, &readnb) != 0) { 19 | abort(); 20 | } 21 | assert(readnb == size); 22 | } 23 | 24 | static uint32_t 25 | randombytes_nativeclient_random(void) 26 | { 27 | uint32_t r; 28 | 29 | randombytes_nativeclient_buf(&r, sizeof r); 30 | 31 | return r; 32 | } 33 | 34 | static const char * 35 | randombytes_nativeclient_implementation_name(void) 36 | { 37 | return "nativeclient"; 38 | } 39 | 40 | struct randombytes_implementation randombytes_nativeclient_implementation = { 41 | SODIUM_C99(.implementation_name =) randombytes_nativeclient_implementation_name, 42 | SODIUM_C99(.random =) randombytes_nativeclient_random, 43 | SODIUM_C99(.stir =) NULL, 44 | SODIUM_C99(.uniform =) NULL, 45 | SODIUM_C99(.buf =) randombytes_nativeclient_buf, 46 | SODIUM_C99(.close =) NULL 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/sodium/core.c: -------------------------------------------------------------------------------- 1 | 2 | #include "core.h" 3 | #include "crypto_generichash.h" 4 | #include "crypto_onetimeauth.h" 5 | #include "crypto_scalarmult.h" 6 | #include "crypto_stream_chacha20.h" 7 | #include "randombytes.h" 8 | #include "runtime.h" 9 | #include "utils.h" 10 | 11 | static int initialized; 12 | 13 | int 14 | sodium_init(void) 15 | { 16 | if (initialized != 0) { 17 | return 1; 18 | } 19 | _sodium_runtime_get_cpu_features(); 20 | randombytes_stir(); 21 | _sodium_alloc_init(); 22 | _crypto_generichash_blake2b_pick_best_implementation(); 23 | _crypto_onetimeauth_poly1305_pick_best_implementation(); 24 | _crypto_scalarmult_curve25519_pick_best_implementation(); 25 | _crypto_stream_chacha20_pick_best_implementation(); 26 | initialized = 1; 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/sodium/version.c: -------------------------------------------------------------------------------- 1 | 2 | #include "version.h" 3 | 4 | const char * 5 | sodium_version_string(void) 6 | { 7 | return SODIUM_VERSION_STRING; 8 | } 9 | 10 | int 11 | sodium_library_version_major(void) 12 | { 13 | return SODIUM_LIBRARY_VERSION_MAJOR; 14 | } 15 | 16 | int 17 | sodium_library_version_minor(void) 18 | { 19 | return SODIUM_LIBRARY_VERSION_MINOR; 20 | } 21 | -------------------------------------------------------------------------------- /libsodium/test/HAVE_AMD64_ASM.c: -------------------------------------------------------------------------------- 1 | #if defined(__amd64) || defined(__amd64__) || defined(__x86_64__) 2 | # if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) || defined(_WIN32) || defined(_WIN64) 3 | # error Windows x86_64 calling conventions are not supported yet 4 | # endif 5 | /* neat */ 6 | #else 7 | # error !x86_64 8 | #endif 9 | void main() { 10 | __asm__("pxor %xmm12,%xmm6"); 11 | } -------------------------------------------------------------------------------- /libsodium/test/HAVE_CPUID.c: -------------------------------------------------------------------------------- 1 | 2 | void main(){ 3 | unsigned int cpu_info[4]; 4 | __asm__ __volatile__ ("xchgl %%ebx, %k1; cpuid; xchgl %%ebx, %k1" : 5 | "=a" (cpu_info[0]), "=&r" (cpu_info[1]), 6 | "=c" (cpu_info[2]), "=d" (cpu_info[3]) : 7 | "0" (0U), "2" (0U)); 8 | } -------------------------------------------------------------------------------- /libsodium/test/HAVE_TI_MODE.c: -------------------------------------------------------------------------------- 1 | #ifndef __GNUC__ 2 | # error mode(TI) is a gcc extension 3 | #endif 4 | #if defined(__clang__) && !defined(__x86_64__) 5 | # error clang doesn't properly compile smult_curve25519_donna_c64.c 6 | #endif 7 | #ifndef NATIVE_LITTLE_ENDIAN 8 | # error donna_c64 currently requires a little endian CPU 9 | #endif 10 | #ifdef EMSCRIPTEN 11 | # error emscripten currently supports only shift operations on integers \ 12 | # larger than 64 bits 13 | #endif 14 | #include 15 | typedef unsigned uint128_t __attribute__((mode(TI))); 16 | void fcontract(uint128_t *t) { 17 | *t += 0x8000000000000 - 1; 18 | } 19 | 20 | void main(){ 21 | (void) fcontract; 22 | } -------------------------------------------------------------------------------- /libsodium/test/HAVE_WEAK_SYMBOLS.c: -------------------------------------------------------------------------------- 1 | __attribute__((weak)) void __dummy(void *x) { } 2 | void f(void *x) { __dummy(x); } -------------------------------------------------------------------------------- /libsodium/test/IS_STDC_LIMIT_MACROS_NEEDED.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void main(){ 5 | (void) SIZE_MAX; 6 | (void) UINT64_MAX; 7 | } -------------------------------------------------------------------------------- /libsodium/test/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = \ 2 | default 3 | 4 | EXTRA_DIST = \ 5 | quirks/quirks.h 6 | -------------------------------------------------------------------------------- /libsodium/test/default/auth2.c: -------------------------------------------------------------------------------- 1 | /* "Test Case AUTH256-4" from RFC 4868 */ 2 | 3 | #define TEST_NAME "auth2" 4 | #include "cmptest.h" 5 | 6 | unsigned char key[32] 7 | = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 8 | 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 9 | 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20 }; 10 | 11 | unsigned char c[50] 12 | = { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 13 | 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 14 | 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 15 | 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 16 | 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd }; 17 | 18 | unsigned char a[32]; 19 | 20 | int main(void) 21 | { 22 | int i; 23 | 24 | crypto_auth_hmacsha256(a, c, sizeof c, key); 25 | for (i = 0; i < 32; ++i) { 26 | printf(",0x%02x", (unsigned int)a[i]); 27 | if (i % 8 == 7) 28 | printf("\n"); 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /libsodium/test/default/auth3.c: -------------------------------------------------------------------------------- 1 | /* "Test Case AUTH256-4" from RFC 4868 */ 2 | 3 | #define TEST_NAME "auth3" 4 | #include "cmptest.h" 5 | 6 | unsigned char key[32] 7 | = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 8 | 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 9 | 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20 }; 10 | 11 | unsigned char c[50] 12 | = { 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 13 | 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 14 | 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 15 | 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 16 | 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd }; 17 | 18 | unsigned char a[32] 19 | = { 0x37, 0x2e, 0xfc, 0xf9, 0xb4, 0x0b, 0x35, 0xc2, 0x11, 0x5b, 0x13, 20 | 0x46, 0x90, 0x3d, 0x2e, 0xf4, 0x2f, 0xce, 0xd4, 0x6f, 0x08, 0x46, 21 | 0xe7, 0x25, 0x7b, 0xb1, 0x56, 0xd3, 0xd7, 0xb3, 0x0d, 0x3f }; 22 | 23 | int main(void) 24 | { 25 | printf("%d\n", crypto_auth_hmacsha256_verify(a, c, sizeof c, key)); 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /libsodium/test/default/auth5.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "auth5" 3 | #include "cmptest.h" 4 | 5 | unsigned char key[32]; 6 | unsigned char c[10000]; 7 | unsigned char a[32]; 8 | 9 | int main(void) 10 | { 11 | size_t clen; 12 | 13 | for (clen = 0; clen < 10000; ++clen) { 14 | randombytes_buf(key, sizeof key); 15 | randombytes_buf(c, clen); 16 | crypto_auth(a, c, clen, key); 17 | if (crypto_auth_verify(a, c, clen, key) != 0) { 18 | printf("fail %u\n", (unsigned int) clen); 19 | return 100; 20 | } 21 | if (clen > 0) { 22 | c[rand() % clen] += 1 + (rand() % 255); 23 | if (crypto_auth_verify(a, c, clen, key) == 0) { 24 | printf("forgery %u\n", (unsigned int) clen); 25 | return 100; 26 | } 27 | a[rand() % sizeof a] += 1 + (rand() % 255); 28 | if (crypto_auth_verify(a, c, clen, key) == 0) { 29 | printf("forgery %u\n", (unsigned int) clen); 30 | return 100; 31 | } 32 | } 33 | } 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /libsodium/test/default/auth6.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "auth6" 3 | #include "cmptest.h" 4 | 5 | /* "Test Case 2" from RFC 4231 */ 6 | unsigned char key[32] = "Jefe"; 7 | unsigned char c[] = "what do ya want for nothing?"; 8 | 9 | unsigned char a[64]; 10 | 11 | int main(void) 12 | { 13 | int i; 14 | 15 | crypto_auth_hmacsha512(a, c, sizeof c - 1U, key); 16 | for (i = 0; i < 64; ++i) { 17 | printf(",0x%02x", (unsigned int)a[i]); 18 | if (i % 8 == 7) 19 | printf("\n"); 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /libsodium/test/default/auth7.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "auth7" 3 | #include "cmptest.h" 4 | 5 | unsigned char key[32]; 6 | unsigned char c[10000]; 7 | unsigned char a[64]; 8 | 9 | int main(void) 10 | { 11 | int clen; 12 | 13 | for (clen = 0; clen < 10000; ++clen) { 14 | randombytes_buf(key, sizeof key); 15 | randombytes_buf(c, clen); 16 | crypto_auth_hmacsha512(a, c, clen, key); 17 | if (crypto_auth_hmacsha512_verify(a, c, clen, key) != 0) { 18 | printf("fail %d\n", clen); 19 | return 100; 20 | } 21 | if (clen > 0) { 22 | c[rand() % clen] += 1 + (rand() % 255); 23 | if (crypto_auth_hmacsha512_verify(a, c, clen, key) == 0) { 24 | printf("forgery %d\n", clen); 25 | return 100; 26 | } 27 | a[rand() % sizeof a] += 1 + (rand() % 255); 28 | if (crypto_auth_hmacsha512_verify(a, c, clen, key) == 0) { 29 | printf("forgery %d\n", clen); 30 | return 100; 31 | } 32 | } 33 | } 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /libsodium/test/default/box7.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "box7" 3 | #include "cmptest.h" 4 | 5 | unsigned char alicesk[crypto_box_SECRETKEYBYTES]; 6 | unsigned char alicepk[crypto_box_PUBLICKEYBYTES]; 7 | unsigned char bobsk[crypto_box_SECRETKEYBYTES]; 8 | unsigned char bobpk[crypto_box_PUBLICKEYBYTES]; 9 | unsigned char n[crypto_box_NONCEBYTES]; 10 | unsigned char m[10000]; 11 | unsigned char c[10000]; 12 | unsigned char m2[10000]; 13 | 14 | int main(void) 15 | { 16 | size_t mlen; 17 | size_t i; 18 | 19 | for (mlen = 0; mlen < 1000 && mlen + crypto_box_ZEROBYTES < sizeof m; 20 | ++mlen) { 21 | crypto_box_keypair(alicepk, alicesk); 22 | crypto_box_keypair(bobpk, bobsk); 23 | randombytes_buf(n, crypto_box_NONCEBYTES); 24 | randombytes_buf(m + crypto_box_ZEROBYTES, mlen); 25 | crypto_box(c, m, mlen + crypto_box_ZEROBYTES, n, bobpk, alicesk); 26 | if (crypto_box_open(m2, c, mlen + crypto_box_ZEROBYTES, n, alicepk, 27 | bobsk) == 0) { 28 | for (i = 0; i < mlen + crypto_box_ZEROBYTES; ++i) { 29 | if (m2[i] != m[i]) { 30 | printf("bad decryption\n"); 31 | break; 32 | } 33 | } 34 | } else { 35 | printf("ciphertext fails verification\n"); 36 | } 37 | } 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /libsodium/test/default/box_seal.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "box_seal" 3 | #include "cmptest.h" 4 | 5 | int main(void) 6 | { 7 | unsigned char pk[crypto_box_PUBLICKEYBYTES]; 8 | unsigned char sk[crypto_box_SECRETKEYBYTES]; 9 | unsigned char *c; 10 | unsigned char *m; 11 | unsigned char *m2; 12 | size_t m_len; 13 | size_t c_len; 14 | 15 | crypto_box_keypair(pk, sk); 16 | m_len = (size_t) randombytes_uniform(1000); 17 | c_len = crypto_box_SEALBYTES + m_len; 18 | m = (unsigned char *) sodium_malloc(m_len); 19 | m2 = (unsigned char *) sodium_malloc(m_len); 20 | c = (unsigned char *) sodium_malloc(c_len); 21 | randombytes_buf(m, m_len); 22 | if (crypto_box_seal(c, m, m_len, pk) != 0) { 23 | printf("crypto_box_seal() failure\n"); 24 | return 1; 25 | } 26 | if (crypto_box_seal_open(m2, c, c_len, pk, sk) != 0) { 27 | printf("crypto_box_seal_open() failure\n"); 28 | return 1; 29 | } 30 | printf("%d\n", memcmp(m, m2, m_len)); 31 | 32 | printf("%d\n", crypto_box_seal_open(m, c, 0U, pk, sk)); 33 | printf("%d\n", crypto_box_seal_open(m, c, c_len - 1U, pk, sk)); 34 | printf("%d\n", crypto_box_seal_open(m, c, c_len, sk, pk)); 35 | 36 | sodium_free(c); 37 | sodium_free(m); 38 | sodium_free(m2); 39 | 40 | assert(crypto_box_sealbytes() == crypto_box_SEALBYTES); 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /libsodium/test/default/box_seed.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "box_seed" 3 | #include "cmptest.h" 4 | 5 | unsigned char seed[32] 6 | = { 0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d, 0x3c, 0x16, 0xc1, 7 | 0x72, 0x51, 0xb2, 0x66, 0x45, 0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0, 8 | 0x99, 0x2a, 0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a }; 9 | 10 | int main(void) 11 | { 12 | int i; 13 | unsigned char sk[32]; 14 | unsigned char pk[32]; 15 | 16 | crypto_box_seed_keypair(pk, sk, seed); 17 | for (i = 0; i < 32; ++i) { 18 | printf(",0x%02x", (unsigned int)pk[i]); 19 | if (i % 8 == 7) 20 | printf("\n"); 21 | } 22 | for (i = 0; i < 32; ++i) { 23 | printf(",0x%02x", (unsigned int)sk[i]); 24 | if (i % 8 == 7) 25 | printf("\n"); 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /libsodium/test/default/core1.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "core1" 3 | #include "cmptest.h" 4 | 5 | unsigned char shared[32] 6 | = { 0x4a, 0x5d, 0x9d, 0x5b, 0xa4, 0xce, 0x2d, 0xe1, 0x72, 0x8e, 0x3b, 7 | 0xf4, 0x80, 0x35, 0x0f, 0x25, 0xe0, 0x7e, 0x21, 0xc9, 0x47, 0xd1, 8 | 0x9e, 0x33, 0x76, 0xf0, 0x9b, 0x3c, 0x1e, 0x16, 0x17, 0x42 }; 9 | 10 | unsigned char zero[32] = { 0 }; 11 | 12 | unsigned char c[16] = { 0x65, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x20, 0x33, 13 | 0x32, 0x2d, 0x62, 0x79, 0x74, 0x65, 0x20, 0x6b }; 14 | 15 | unsigned char firstkey[32]; 16 | 17 | int main(void) 18 | { 19 | int i; 20 | 21 | crypto_core_hsalsa20(firstkey, zero, shared, c); 22 | for (i = 0; i < 32; ++i) { 23 | if (i > 0) { 24 | printf(","); 25 | } else { 26 | printf(" "); 27 | } 28 | printf("0x%02x", (unsigned int)firstkey[i]); 29 | if (i % 8 == 7) { 30 | printf("\n"); 31 | } 32 | } 33 | assert(crypto_core_hsalsa20_outputbytes() > 0U); 34 | assert(crypto_core_hsalsa20_inputbytes() > 0U); 35 | assert(crypto_core_hsalsa20_keybytes() > 0U); 36 | assert(crypto_core_hsalsa20_constbytes() > 0U); 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /libsodium/test/default/core2.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "core2" 3 | #include "cmptest.h" 4 | 5 | unsigned char firstkey[32] 6 | = { 0x1b, 0x27, 0x55, 0x64, 0x73, 0xe9, 0x85, 0xd4, 0x62, 0xcd, 0x51, 7 | 0x19, 0x7a, 0x9a, 0x46, 0xc7, 0x60, 0x09, 0x54, 0x9e, 0xac, 0x64, 8 | 0x74, 0xf2, 0x06, 0xc4, 0xee, 0x08, 0x44, 0xf6, 0x83, 0x89 }; 9 | 10 | unsigned char nonceprefix[16] 11 | = { 0x69, 0x69, 0x6e, 0xe9, 0x55, 0xb6, 0x2b, 0x73, 12 | 0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6 }; 13 | 14 | unsigned char c[16] = { 0x65, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x20, 0x33, 15 | 0x32, 0x2d, 0x62, 0x79, 0x74, 0x65, 0x20, 0x6b }; 16 | 17 | unsigned char secondkey[32]; 18 | 19 | int main(void) 20 | { 21 | int i; 22 | 23 | crypto_core_hsalsa20(secondkey, nonceprefix, firstkey, c); 24 | for (i = 0; i < 32; ++i) { 25 | if (i > 0) { 26 | printf(","); 27 | } else { 28 | printf(" "); 29 | } 30 | printf("0x%02x", (unsigned int)secondkey[i]); 31 | if (i % 8 == 7) { 32 | printf("\n"); 33 | } 34 | } 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /libsodium/test/default/core4.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "core4" 3 | #include "cmptest.h" 4 | 5 | unsigned char k[32] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 6 | 12, 13, 14, 15, 16, 201, 202, 203, 204, 205, 206, 7 | 207, 208, 209, 210, 211, 212, 213, 214, 215, 216 }; 8 | 9 | unsigned char in[16] = { 101, 102, 103, 104, 105, 106, 107, 108, 10 | 109, 110, 111, 112, 113, 114, 115, 116 }; 11 | 12 | unsigned char c[16] = { 101, 120, 112, 97, 110, 100, 32, 51, 13 | 50, 45, 98, 121, 116, 101, 32, 107 }; 14 | 15 | unsigned char out[64]; 16 | 17 | int main(void) 18 | { 19 | int i; 20 | 21 | crypto_core_salsa20(out, in, k, c); 22 | for (i = 0; i < 64; ++i) { 23 | if (i > 0) { 24 | printf(","); 25 | } else { 26 | printf(" "); 27 | } 28 | printf("%3d", (unsigned int)out[i]); 29 | if (i % 8 == 7) { 30 | printf("\n"); 31 | } 32 | } 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /libsodium/test/default/core5.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "core5" 3 | #include "cmptest.h" 4 | 5 | unsigned char k[32] 6 | = { 0xee, 0x30, 0x4f, 0xca, 0x27, 0x00, 0x8d, 0x8c, 0x12, 0x6f, 0x90, 7 | 0x02, 0x79, 0x01, 0xd8, 0x0f, 0x7f, 0x1d, 0x8b, 0x8d, 0xc9, 0x36, 8 | 0xcf, 0x3b, 0x9f, 0x81, 0x96, 0x92, 0x82, 0x7e, 0x57, 0x77 }; 9 | 10 | unsigned char in[16] = { 0x81, 0x91, 0x8e, 0xf2, 0xa5, 0xe0, 0xda, 0x9b, 11 | 0x3e, 0x90, 0x60, 0x52, 0x1e, 0x4b, 0xb3, 0x52 }; 12 | 13 | unsigned char c[16] = { 101, 120, 112, 97, 110, 100, 32, 51, 14 | 50, 45, 98, 121, 116, 101, 32, 107 }; 15 | 16 | unsigned char out[32]; 17 | 18 | int main(void) 19 | { 20 | int i; 21 | 22 | crypto_core_hsalsa20(out, in, k, c); 23 | for (i = 0; i < 32; ++i) { 24 | printf(",0x%02x", (unsigned int)out[i]); 25 | if (i % 8 == 7) { 26 | printf("\n"); 27 | } 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /libsodium/test/default/hash3.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "hash3" 3 | #include "cmptest.h" 4 | 5 | unsigned char x[] = "testing\n"; 6 | unsigned char h[crypto_hash_BYTES]; 7 | 8 | int main(void) 9 | { 10 | size_t i; 11 | 12 | crypto_hash(h, x, sizeof x - 1U); 13 | for (i = 0; i < crypto_hash_BYTES; ++i) { 14 | printf("%02x", (unsigned int)h[i]); 15 | } 16 | printf("\n"); 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /libsodium/test/default/onetimeauth7.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "onetimeauth7" 3 | #include "cmptest.h" 4 | 5 | unsigned char key[32]; 6 | unsigned char c[10000]; 7 | unsigned char a[16]; 8 | 9 | int main(void) 10 | { 11 | int clen; 12 | 13 | for (clen = 0; clen < 10000; ++clen) { 14 | randombytes_buf(key, sizeof key); 15 | randombytes_buf(c, clen); 16 | crypto_onetimeauth(a, c, clen, key); 17 | if (crypto_onetimeauth_verify(a, c, clen, key) != 0) { 18 | printf("fail %d\n", clen); 19 | return 100; 20 | } 21 | if (clen > 0) { 22 | c[rand() % clen] += 1 + (rand() % 255); 23 | if (crypto_onetimeauth_verify(a, c, clen, key) == 0) { 24 | printf("forgery %d\n", clen); 25 | return 100; 26 | } 27 | a[rand() % sizeof a] += 1 + (rand() % 255); 28 | if (crypto_onetimeauth_verify(a, c, clen, key) == 0) { 29 | printf("forgery %d\n", clen); 30 | return 100; 31 | } 32 | } 33 | } 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /libsodium/test/default/pre.js.inc: -------------------------------------------------------------------------------- 1 | try { 2 | this['Module'] = Module; 3 | Module.test; 4 | } catch(e) { 5 | this['Module'] = Module = {}; 6 | } 7 | Module['preRun'] = Module['preRun'] || []; 8 | Module['preRun'].push(function(){ 9 | FS.init(); 10 | FS.mkdir('/test-data'); 11 | FS.mount(NODEFS, { root: '.' }, '/test-data'); 12 | }); 13 | -------------------------------------------------------------------------------- /libsodium/test/default/scalarmult.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "scalarmult" 3 | #include "cmptest.h" 4 | 5 | unsigned char alicesk[32] 6 | = { 0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d, 0x3c, 0x16, 0xc1, 7 | 0x72, 0x51, 0xb2, 0x66, 0x45, 0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0, 8 | 0x99, 0x2a, 0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a }; 9 | 10 | unsigned char alicepk[32]; 11 | 12 | int main(void) 13 | { 14 | int i; 15 | 16 | crypto_scalarmult_base(alicepk, alicesk); 17 | 18 | for (i = 0; i < 32; ++i) { 19 | if (i > 0) { 20 | printf(","); 21 | } else { 22 | printf(" "); 23 | } 24 | printf("0x%02x", (unsigned int)alicepk[i]); 25 | if (i % 8 == 7) { 26 | printf("\n"); 27 | } 28 | } 29 | assert(crypto_scalarmult_bytes() > 0U); 30 | assert(crypto_scalarmult_scalarbytes() > 0U); 31 | assert(strcmp(crypto_scalarmult_primitive(), "curve25519") == 0); 32 | assert(crypto_scalarmult_bytes() == crypto_scalarmult_curve25519_bytes()); 33 | assert(crypto_scalarmult_scalarbytes() 34 | == crypto_scalarmult_curve25519_scalarbytes()); 35 | assert(crypto_scalarmult_bytes() == crypto_scalarmult_scalarbytes()); 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /libsodium/test/default/scalarmult2.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "scalarmult2" 3 | #include "cmptest.h" 4 | 5 | unsigned char bobsk[32] 6 | = { 0x5d, 0xab, 0x08, 0x7e, 0x62, 0x4a, 0x8a, 0x4b, 0x79, 0xe1, 0x7f, 7 | 0x8b, 0x83, 0x80, 0x0e, 0xe6, 0x6f, 0x3b, 0xb1, 0x29, 0x26, 0x18, 8 | 0xb6, 0xfd, 0x1c, 0x2f, 0x8b, 0x27, 0xff, 0x88, 0xe0, 0xeb }; 9 | 10 | unsigned char bobpk[32]; 11 | 12 | int main(void) 13 | { 14 | int i; 15 | 16 | crypto_scalarmult_base(bobpk, bobsk); 17 | 18 | for (i = 0; i < 32; ++i) { 19 | if (i > 0) { 20 | printf(","); 21 | } else { 22 | printf(" "); 23 | } 24 | printf("0x%02x", (unsigned int)bobpk[i]); 25 | if (i % 8 == 7) { 26 | printf("\n"); 27 | } 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /libsodium/test/default/scalarmult5.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "scalarmult5" 3 | #include "cmptest.h" 4 | 5 | unsigned char alicesk[32] 6 | = { 0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d, 0x3c, 0x16, 0xc1, 7 | 0x72, 0x51, 0xb2, 0x66, 0x45, 0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0, 8 | 0x99, 0x2a, 0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a }; 9 | 10 | unsigned char bobpk[32] 11 | = { 0xde, 0x9e, 0xdb, 0x7d, 0x7b, 0x7d, 0xc1, 0xb4, 0xd3, 0x5b, 0x61, 12 | 0xc2, 0xec, 0xe4, 0x35, 0x37, 0x3f, 0x83, 0x43, 0xc8, 0x5b, 0x78, 13 | 0x67, 0x4d, 0xad, 0xfc, 0x7e, 0x14, 0x6f, 0x88, 0x2b, 0x4f }; 14 | 15 | unsigned char k[32]; 16 | 17 | int main(void) 18 | { 19 | int i; 20 | 21 | crypto_scalarmult(k, alicesk, bobpk); 22 | 23 | for (i = 0; i < 32; ++i) { 24 | if (i > 0) { 25 | printf(","); 26 | } else { 27 | printf(" "); 28 | } 29 | printf("0x%02x", (unsigned int)k[i]); 30 | if (i % 8 == 7) { 31 | printf("\n"); 32 | } 33 | } 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /libsodium/test/default/scalarmult7.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "scalarmult7" 3 | #include "cmptest.h" 4 | 5 | unsigned char p1[32] = { 6 | 0x72, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 7 | 0x74, 0x8b, 0x7d, 0xdc, 0xb4, 0x3e, 0xf7, 0x5a, 8 | 0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38, 0x1a, 0xf4, 9 | 0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0xea 10 | }; 11 | 12 | unsigned char p2[32] = { 13 | 0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 14 | 0x74, 0x8b, 0x7d, 0xdc, 0xb4, 0x3e, 0xf7, 0x5a, 15 | 0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38, 0x1a, 0xf4, 16 | 0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a 17 | }; 18 | 19 | unsigned char scalar[32]; 20 | unsigned char out1[32]; 21 | unsigned char out2[32]; 22 | 23 | int main(void) 24 | { 25 | scalar[0] = 1U; 26 | crypto_scalarmult_curve25519(out1, scalar, p1); 27 | crypto_scalarmult_curve25519(out2, scalar, p2); 28 | printf("%d\n", !!memcmp(out1, out2, 32)); 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /libsodium/test/default/secretbox7.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "secretbox7" 3 | #include "cmptest.h" 4 | 5 | unsigned char k[crypto_secretbox_KEYBYTES]; 6 | unsigned char n[crypto_secretbox_NONCEBYTES]; 7 | unsigned char m[10000]; 8 | unsigned char c[10000]; 9 | unsigned char m2[10000]; 10 | 11 | int main(void) 12 | { 13 | size_t mlen; 14 | size_t i; 15 | 16 | for (mlen = 0; mlen < 1000 && mlen + crypto_secretbox_ZEROBYTES < sizeof m; 17 | ++mlen) { 18 | randombytes_buf(k, crypto_secretbox_KEYBYTES); 19 | randombytes_buf(n, crypto_secretbox_NONCEBYTES); 20 | randombytes_buf(m + crypto_secretbox_ZEROBYTES, mlen); 21 | crypto_secretbox(c, m, mlen + crypto_secretbox_ZEROBYTES, n, k); 22 | if (crypto_secretbox_open(m2, c, mlen + crypto_secretbox_ZEROBYTES, n, 23 | k) == 0) { 24 | for (i = 0; i < mlen + crypto_secretbox_ZEROBYTES; ++i) { 25 | if (m2[i] != m[i]) { 26 | printf("bad decryption\n"); 27 | break; 28 | } 29 | } 30 | } else { 31 | printf("ciphertext fails verification\n"); 32 | } 33 | } 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /libsodium/test/default/secretbox8.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "secretbox8" 3 | #include "cmptest.h" 4 | 5 | unsigned char k[crypto_secretbox_KEYBYTES]; 6 | unsigned char n[crypto_secretbox_NONCEBYTES]; 7 | unsigned char m[10000]; 8 | unsigned char c[10000]; 9 | unsigned char m2[10000]; 10 | 11 | int main(void) 12 | { 13 | size_t mlen; 14 | size_t i; 15 | int caught; 16 | 17 | for (mlen = 0; mlen < 1000 && mlen + crypto_secretbox_ZEROBYTES < sizeof m; 18 | ++mlen) { 19 | randombytes_buf(k, crypto_secretbox_KEYBYTES); 20 | randombytes_buf(n, crypto_secretbox_NONCEBYTES); 21 | randombytes_buf(m + crypto_secretbox_ZEROBYTES, mlen); 22 | crypto_secretbox(c, m, mlen + crypto_secretbox_ZEROBYTES, n, k); 23 | caught = 0; 24 | while (caught < 10) { 25 | c[rand() % (mlen + crypto_secretbox_ZEROBYTES)] = rand(); 26 | if (crypto_secretbox_open(m2, c, mlen + crypto_secretbox_ZEROBYTES, 27 | n, k) == 0) { 28 | for (i = 0; i < mlen + crypto_secretbox_ZEROBYTES; ++i) { 29 | if (m2[i] != m[i]) { 30 | printf("forgery\n"); 31 | return 100; 32 | } 33 | } 34 | } else { 35 | ++caught; 36 | } 37 | } 38 | } 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /libsodium/test/default/shorthash.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "shorthash" 3 | #include "cmptest.h" 4 | 5 | #define MAXLEN 64 6 | 7 | int main(void) 8 | { 9 | unsigned char in[MAXLEN]; 10 | unsigned char out[crypto_shorthash_BYTES]; 11 | unsigned char k[crypto_shorthash_KEYBYTES]; 12 | size_t i; 13 | size_t j; 14 | 15 | for (i = 0; i < crypto_shorthash_KEYBYTES; ++i) { 16 | k[i] = (unsigned char) i; 17 | } 18 | 19 | for (i = 0; i < MAXLEN; ++i) { 20 | in[i] = (unsigned char) i; 21 | crypto_shorthash(out, in, (unsigned long long) i, k); 22 | for (j = 0; j < crypto_shorthash_BYTES; ++j) { 23 | printf("%02x", (unsigned int) out[j]); 24 | } 25 | printf("\n"); 26 | } 27 | assert(crypto_shorthash_bytes() > 0); 28 | assert(crypto_shorthash_keybytes() > 0); 29 | assert(strcmp(crypto_shorthash_primitive(), "siphash24") == 0); 30 | assert(crypto_shorthash_bytes() == crypto_shorthash_siphash24_bytes()); 31 | assert(crypto_shorthash_keybytes() 32 | == crypto_shorthash_siphash24_keybytes()); 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /libsodium/test/default/sodium_core.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "sodium_core" 3 | #include "cmptest.h" 4 | 5 | int main(void) 6 | { 7 | printf("%d\n", sodium_init()); 8 | 9 | (void)sodium_runtime_has_neon(); 10 | (void)sodium_runtime_has_sse2(); 11 | (void)sodium_runtime_has_sse3(); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /libsodium/test/default/sodium_utils3.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #define TEST_NAME "sodium_utils3" 8 | #include "cmptest.h" 9 | 10 | #ifdef __SANITIZE_ADDRESS__ 11 | # warning The sodium_utils3 test is expected to fail with address sanitizer 12 | #endif 13 | 14 | static void segv_handler(int sig) 15 | { 16 | printf("Intentional segfault / bus error caught\n"); 17 | printf("OK\n"); 18 | #ifdef SIGSEGV 19 | signal(SIGSEGV, SIG_DFL); 20 | #endif 21 | #ifdef SIGBUS 22 | signal(SIGBUS, SIG_DFL); 23 | #endif 24 | #ifdef SIGABRT 25 | signal(SIGABRT, SIG_DFL); 26 | #endif 27 | exit(0); 28 | } 29 | 30 | int main(void) 31 | { 32 | void *buf; 33 | size_t size; 34 | 35 | #ifdef SIGSEGV 36 | signal(SIGSEGV, segv_handler); 37 | #endif 38 | #ifdef SIGBUS 39 | signal(SIGBUS, segv_handler); 40 | #endif 41 | #ifdef SIGABRT 42 | signal(SIGABRT, segv_handler); 43 | #endif 44 | size = randombytes_uniform(100000U); 45 | buf = sodium_malloc(size); 46 | assert(buf != NULL); 47 | sodium_mprotect_noaccess(buf); 48 | sodium_mprotect_readwrite(buf); 49 | #ifndef __EMSCRIPTEN__ 50 | sodium_memzero(((unsigned char *)buf) - 8, 8U); 51 | sodium_mprotect_readonly(buf); 52 | sodium_free(buf); 53 | printf("Underflow not caught\n"); 54 | #endif 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /libsodium/test/default/sodium_version.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "sodium_version" 3 | #include "cmptest.h" 4 | 5 | int main(void) 6 | { 7 | printf("%d\n", sodium_version_string() != NULL); 8 | printf("%d\n", sodium_library_version_major() > 0); 9 | printf("%d\n", sodium_library_version_minor() >= 0); 10 | 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /libsodium/test/default/stream2.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "stream2" 3 | #include "cmptest.h" 4 | 5 | unsigned char secondkey[32] 6 | = { 0xdc, 0x90, 0x8d, 0xda, 0x0b, 0x93, 0x44, 0xa9, 0x53, 0x62, 0x9b, 7 | 0x73, 0x38, 0x20, 0x77, 0x88, 0x80, 0xf3, 0xce, 0xb4, 0x21, 0xbb, 8 | 0x61, 0xb9, 0x1c, 0xbd, 0x4c, 0x3e, 0x66, 0x25, 0x6c, 0xe4 }; 9 | 10 | unsigned char noncesuffix[8] 11 | = { 0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 }; 12 | 13 | unsigned char output[4194304]; 14 | 15 | unsigned char h[32]; 16 | 17 | int main(void) 18 | { 19 | int i; 20 | crypto_stream_salsa20(output, sizeof output, noncesuffix, secondkey); 21 | crypto_hash_sha256(h, output, sizeof output); 22 | for (i = 0; i < 32; ++i) 23 | printf("%02x", h[i]); 24 | printf("\n"); 25 | 26 | assert(sizeof output > 4000); 27 | 28 | crypto_stream_salsa20_xor_ic(output, output, 4000, noncesuffix, 0U, secondkey); 29 | for (i = 0; i < 4000; ++i) 30 | assert(output[i] == 0); 31 | 32 | crypto_stream_salsa20_xor_ic(output, output, 4000, noncesuffix, 1U, secondkey); 33 | crypto_hash_sha256(h, output, sizeof output); 34 | for (i = 0; i < 32; ++i) 35 | printf("%02x", h[i]); 36 | printf("\n"); 37 | 38 | assert(crypto_stream_salsa20_keybytes() > 0U); 39 | assert(crypto_stream_salsa20_noncebytes() > 0U); 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /libsodium/test/default/stream3.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "stream3" 3 | #include "cmptest.h" 4 | 5 | unsigned char firstkey[32] 6 | = { 0x1b, 0x27, 0x55, 0x64, 0x73, 0xe9, 0x85, 0xd4, 0x62, 0xcd, 0x51, 7 | 0x19, 0x7a, 0x9a, 0x46, 0xc7, 0x60, 0x09, 0x54, 0x9e, 0xac, 0x64, 8 | 0x74, 0xf2, 0x06, 0xc4, 0xee, 0x08, 0x44, 0xf6, 0x83, 0x89 }; 9 | 10 | unsigned char nonce[24] = { 0x69, 0x69, 0x6e, 0xe9, 0x55, 0xb6, 0x2b, 0x73, 11 | 0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6, 12 | 0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37 }; 13 | 14 | unsigned char rs[32]; 15 | 16 | int main(void) 17 | { 18 | int i; 19 | 20 | crypto_stream(rs, 32, nonce, firstkey); 21 | 22 | for (i = 0; i < 32; ++i) { 23 | printf(",0x%02x", (unsigned int)rs[i]); 24 | if (i % 8 == 7) 25 | printf("\n"); 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /libsodium/test/default/verify1.c: -------------------------------------------------------------------------------- 1 | 2 | #define TEST_NAME "verify1" 3 | #include "cmptest.h" 4 | 5 | unsigned char v16[16], v16x[16]; 6 | unsigned char v32[32], v32x[32]; 7 | unsigned char v64[64], v64x[64]; 8 | 9 | int main(void) 10 | { 11 | randombytes_buf(v16, sizeof v16); 12 | randombytes_buf(v32, sizeof v32); 13 | randombytes_buf(v64, sizeof v64); 14 | 15 | memcpy(v16x, v16, sizeof v16); 16 | memcpy(v32x, v32, sizeof v32); 17 | memcpy(v64x, v64, sizeof v64); 18 | 19 | printf("%d\n", crypto_verify_16(v16, v16x)); 20 | printf("%d\n", crypto_verify_32(v32, v32x)); 21 | printf("%d\n", crypto_verify_64(v64, v64x)); 22 | 23 | v16x[randombytes_random() & 15U]++; 24 | v32x[randombytes_random() & 31U]++; 25 | v64x[randombytes_random() & 63U]++; 26 | 27 | printf("%d\n", crypto_verify_16(v16, v16x)); 28 | printf("%d\n", crypto_verify_32(v32, v32x)); 29 | printf("%d\n", crypto_verify_64(v64, v64x)); 30 | 31 | assert(crypto_verify_16_bytes() == 16U); 32 | assert(crypto_verify_32_bytes() == 32U); 33 | assert(crypto_verify_64_bytes() == 64U); 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /libsodium/test/quirks/quirks.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #ifdef __EMSCRIPTEN__ 5 | # define strcmp(s1, s2) xstrcmp(s1, s2) 6 | 7 | int 8 | strcmp(const char *s1, const char *s2) { 9 | while (*s1 == *s2++) { if (*s1++ == 0) return 0; } 10 | return *(unsigned char *) s1 - *(unsigned char *) --s2; 11 | } 12 | #endif 13 | 14 | #ifdef _WIN32 15 | static void 16 | srandom(unsigned seed) 17 | { 18 | srand(seed); 19 | } 20 | 21 | static long 22 | random(void) 23 | { 24 | return (long) rand(); 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /libudns/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2007-2013 LuaDist. 2 | # Created by Peter Drahoš, Peter Kapec 3 | # Redistribution and use of this file is allowed according to the terms of the MIT license. 4 | # For details see the COPYRIGHT file distributed with LuaDist. 5 | # Please note that the package source code is licensed under its own license. 6 | 7 | project ( libudns ) 8 | cmake_minimum_required ( VERSION 2.8 ) 9 | 10 | include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) 11 | 12 | set ( UDNS_SRC 13 | udns_dn.c udns_dntosp.c udns_parse.c udns_resolver.c udns_init.c 14 | udns_misc.c udns_XtoX.c 15 | udns_rr_a.c udns_rr_ptr.c udns_rr_mx.c udns_rr_txt.c udns_bl.c 16 | udns_rr_srv.c udns_rr_naptr.c udns_codes.c udns_jran.c 17 | ) 18 | 19 | if (WIN32) 20 | list ( APPEND UDNS_LIBS Ws2_32 ) 21 | endif () 22 | 23 | add_library ( udns STATIC ${UDNS_SRC} ) 24 | target_link_libraries ( udns ${UDNS_LIBS} ) 25 | 26 | set(libudns_include_dirs 27 | ${PROJECT_SOURCE_DIR} 28 | ${PROJECT_BINARY_DIR} 29 | CACHE INTERNAL "libudns library" FORCE 30 | ) 31 | -------------------------------------------------------------------------------- /libudns/Makefile.am: -------------------------------------------------------------------------------- 1 | SRCS = udns_dn.c udns_dntosp.c udns_parse.c udns_resolver.c udns_init.c \ 2 | udns_misc.c udns_XtoX.c \ 3 | udns_rr_a.c udns_rr_ptr.c udns_rr_mx.c udns_rr_txt.c udns_bl.c \ 4 | udns_rr_srv.c udns_rr_naptr.c udns_codes.c udns_jran.c 5 | 6 | noinst_LTLIBRARIES=libudns.la 7 | libudns_la_SOURCES= ${SRCS} 8 | libudns_la_LDFLAGS= -static 9 | -------------------------------------------------------------------------------- /libudns/udns_dntosp.c: -------------------------------------------------------------------------------- 1 | /* udns_dntosp.c 2 | dns_dntosp() = convert DN to asciiz string using static buffer 3 | 4 | Copyright (C) 2005 Michael Tokarev 5 | This file is part of UDNS library, an async DNS stub resolver. 6 | 7 | This library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | This library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this library, in file named COPYING.LGPL; if not, 19 | write to the Free Software Foundation, Inc., 59 Temple Place, 20 | Suite 330, Boston, MA 02111-1307 USA 21 | 22 | */ 23 | 24 | #include "udns.h" 25 | 26 | static char name[DNS_MAXNAME]; 27 | 28 | const char *dns_dntosp(dnscc_t *dn) { 29 | return dns_dntop(dn, name, sizeof(name)) > 0 ? name : 0; 30 | } 31 | -------------------------------------------------------------------------------- /m4/inet_ntop.m4: -------------------------------------------------------------------------------- 1 | # inet_ntop.m4 serial 19 2 | dnl Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([ss_FUNC_INET_NTOP], 8 | [ 9 | AC_REQUIRE([AC_C_RESTRICT]) 10 | 11 | dnl Most platforms that provide inet_ntop define it in libc. 12 | dnl Solaris 8..10 provide inet_ntop in libnsl instead. 13 | dnl Solaris 2.6..7 provide inet_ntop in libresolv instead. 14 | HAVE_INET_NTOP=1 15 | INET_NTOP_LIB= 16 | ss_save_LIBS=$LIBS 17 | AC_SEARCH_LIBS([inet_ntop], [nsl resolv], [], 18 | [AC_CHECK_FUNCS([inet_ntop]) 19 | if test $ac_cv_func_inet_ntop = no; then 20 | HAVE_INET_NTOP=0 21 | fi 22 | ]) 23 | LIBS=$ss_save_LIBS 24 | 25 | if test "$ac_cv_search_inet_ntop" != "no" \ 26 | && test "$ac_cv_search_inet_ntop" != "none required"; then 27 | INET_NTOP_LIB="$ac_cv_search_inet_ntop" 28 | fi 29 | 30 | AC_CHECK_HEADERS_ONCE([netdb.h]) 31 | AC_CHECK_DECLS([inet_ntop],,, 32 | [[#include 33 | #if HAVE_NETDB_H 34 | # include 35 | #endif 36 | ]]) 37 | if test $ac_cv_have_decl_inet_ntop = no; then 38 | HAVE_DECL_INET_NTOP=0 39 | fi 40 | AC_SUBST([INET_NTOP_LIB]) 41 | ]) 42 | -------------------------------------------------------------------------------- /m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # @configure_input@ 11 | 12 | # serial 3337 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.4.2]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3337]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.4.2' 20 | macro_revision='1.3337' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /m4/polarssl.m4: -------------------------------------------------------------------------------- 1 | dnl Check to find the PolarSSL headers/libraries 2 | 3 | AC_DEFUN([ss_POLARSSL], 4 | [ 5 | 6 | AC_ARG_WITH(polarssl, 7 | AS_HELP_STRING([--with-polarssl=DIR], [PolarSSL base directory, or:]), 8 | [polarssl="$withval" 9 | CFLAGS="$CFLAGS -I$withval/include" 10 | LDFLAGS="$LDFLAGS -L$withval/lib"] 11 | ) 12 | 13 | AC_ARG_WITH(polarssl-include, 14 | AS_HELP_STRING([--with-polarssl-include=DIR], [PolarSSL headers directory (without trailing /polarssl)]), 15 | [polarssl_include="$withval" 16 | CFLAGS="$CFLAGS -I$withval"] 17 | ) 18 | 19 | AC_ARG_WITH(polarssl-lib, 20 | AS_HELP_STRING([--with-polarssl-lib=DIR], [PolarSSL library directory]), 21 | [polarssl_lib="$withval" 22 | LDFLAGS="$LDFLAGS -L$withval"] 23 | ) 24 | 25 | AC_CHECK_LIB(polarssl, cipher_init_ctx, 26 | [LIBS="-lpolarssl $LIBS"], 27 | [AC_MSG_ERROR([PolarSSL libraries not found.])] 28 | ) 29 | 30 | AC_MSG_CHECKING([polarssl version]) 31 | AC_COMPILE_IFELSE( 32 | [AC_LANG_PROGRAM( 33 | [[ 34 | #include 35 | ]], 36 | [[ 37 | #if POLARSSL_VERSION_NUMBER < 0x01020500 38 | #error invalid version 39 | #endif 40 | ]] 41 | )], 42 | [AC_MSG_RESULT([ok])], 43 | [AC_MSG_ERROR([PolarSSL 1.2.5 or newer required])] 44 | ) 45 | ]) 46 | -------------------------------------------------------------------------------- /m4/zlib.m4: -------------------------------------------------------------------------------- 1 | dnl Check to find the zlib headers/libraries 2 | 3 | AC_DEFUN([ss_ZLIB], 4 | [ 5 | AC_ARG_ENABLE([zlib], 6 | AS_HELP_STRING([--disable-zlib], [disable zlib compression support])) 7 | AS_IF([test "x$enable_zlib" != "xno"], [ 8 | AC_DEFINE(HAVE_ZLIB, 1, [have zlib compression support]) 9 | AC_ARG_WITH(zlib, 10 | AS_HELP_STRING([--with-zlib=DIR], [zlib base directory, or:]), 11 | [zlib="$withval" 12 | CPPFLAGS="$CPPFLAGS -I$withval/include" 13 | LDFLAGS="$LDFLAGS -L$withval/lib"] 14 | ) 15 | 16 | AC_ARG_WITH(zlib-include, 17 | AS_HELP_STRING([--with-zlib-include=DIR], [zlib headers directory]), 18 | [zlib_include="$withval" 19 | CPPFLAGS="$CPPFLAGS -I$withval"] 20 | ) 21 | 22 | AC_ARG_WITH(zlib-lib, 23 | AS_HELP_STRING([--with-zlib-lib=DIR], [zlib library directory]), 24 | [zlib_lib="$withval" 25 | LDFLAGS="$LDFLAGS -L$withval"] 26 | ) 27 | 28 | AC_CHECK_HEADERS(zlib.h, 29 | [], 30 | [AC_MSG_ERROR("zlib header files not found."); break] 31 | ) 32 | 33 | AC_CHECK_LIB(z, compress2, 34 | [LIBS="$LIBS -lz"], 35 | [AC_MSG_ERROR("zlib libraries not found.")] 36 | ) 37 | ]) 38 | ]) 39 | -------------------------------------------------------------------------------- /shadowsocks-libev.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: shadowsocks-libev 7 | Description: a lightweight secured socks5 proxy 8 | URL: http://shadowsocks.org 9 | Version: @VERSION@ 10 | Requires: 11 | Cflags: -I${includedir} 12 | Libs: -L${libdir} -lshadowsocks-libev -lcrypto 13 | -------------------------------------------------------------------------------- /src/includeobfs.h: -------------------------------------------------------------------------------- 1 | #ifndef _INCLUDEOBFSOBFS_H 2 | #define _INCLUDEOBFSOBFS_H 3 | 4 | #include "obfs/auth_chain.c" 5 | #include "obfs/auth.c" 6 | #include "obfs/tls1.2_ticket.c" 7 | #include "obfs/verify.c" 8 | #include "obfs/http_simple.c" 9 | #include "obfs/obfsutil.c" 10 | #include "obfs/base64.c" 11 | #include "obfs/crc32.c" 12 | #include "obfs/obfs.c" 13 | 14 | #endif // _INCLUDEOBFSOBFS_H 15 | -------------------------------------------------------------------------------- /src/obfs/auth_chain.h: -------------------------------------------------------------------------------- 1 | /* 2 | * auth.h - Define shadowsocksR server's buffers and callbacks 3 | * 4 | * Copyright (C) 2015 - 2016, Break Wa11 5 | */ 6 | 7 | #ifndef _OBFS_AUTH_CHAIN_H 8 | #define _OBFS_AUTH_CHAIN_H 9 | 10 | #include "obfs.h" 11 | 12 | void * auth_chain_a_init_data(); 13 | obfs * auth_chain_a_new_obfs(); 14 | void auth_chain_a_dispose(obfs *self); 15 | 16 | 17 | int auth_chain_a_client_pre_encrypt(obfs *self, char **pplaindata, int datalength, size_t* capacity); 18 | int auth_chain_a_client_post_decrypt(obfs *self, char **pplaindata, int datalength, size_t* capacity); 19 | 20 | int auth_chain_a_client_udp_pre_encrypt(obfs *self, char **pplaindata, int datalength, size_t* capacity); 21 | int auth_chain_a_client_udp_post_decrypt(obfs *self, char **pplaindata, int datalength, size_t* capacity); 22 | 23 | int auth_chain_a_get_overhead(obfs *self); 24 | 25 | obfs * auth_chain_b_new_obfs(); 26 | #endif // _OBFS_AUTH_CHAIN_H 27 | -------------------------------------------------------------------------------- /src/obfs/base64.h: -------------------------------------------------------------------------------- 1 | #ifndef _OBFS_BASE64_H 2 | #define _OBFS_BASE64_H 3 | 4 | enum {BASE64_OK = 0, BASE64_INVALID}; 5 | 6 | #define BASE64_ENCODE_OUT_SIZE(s) (((s) + 2) / 3 * 4) 7 | #define BASE64_DECODE_OUT_SIZE(s) (((s)) / 4 * 3) 8 | 9 | int 10 | base64_encode(const unsigned char *in, unsigned int inlen, char *out); 11 | 12 | int 13 | base64_decode(const char *in, unsigned int inlen, unsigned char *out); 14 | 15 | 16 | #endif // _OBFS_BASE64_H 17 | -------------------------------------------------------------------------------- /src/obfs/crc32.h: -------------------------------------------------------------------------------- 1 | #ifndef _OBFS_CRC32_H 2 | #define _OBFS_CRC32_H 3 | 4 | void init_crc32_table(void); 5 | 6 | uint32_t crc32(unsigned char *buffer, unsigned int size); 7 | 8 | void fillcrc32to(unsigned char *buffer, unsigned int size, unsigned char *outbuffer); 9 | 10 | void fillcrc32(unsigned char *buffer, unsigned int size); 11 | 12 | void filladler32(unsigned char *buffer, unsigned int size); 13 | 14 | int checkadler32(unsigned char *buffer, unsigned int size); 15 | 16 | #endif // _OBFS_CRC32_H 17 | -------------------------------------------------------------------------------- /src/obfs/http_simple.h: -------------------------------------------------------------------------------- 1 | /* 2 | * http_simple.h - Define shadowsocksR server's buffers and callbacks 3 | * 4 | * Copyright (C) 2015 - 2016, Break Wa11 5 | */ 6 | 7 | #ifndef _OBFS_HTTP_SIMPLE_H 8 | #define _OBFS_HTTP_SIMPLE_H 9 | 10 | #include "obfs.h" 11 | 12 | obfs * http_simple_new_obfs(); 13 | void http_simple_dispose(obfs *self); 14 | 15 | int http_simple_client_encode(obfs *self, char **pencryptdata, int datalength, size_t* capacity); 16 | int http_simple_client_decode(obfs *self, char **pencryptdata, int datalength, size_t* capacity, int *needsendback); 17 | 18 | int http_post_client_encode(obfs *self, char **pencryptdata, int datalength, size_t* capacity); 19 | 20 | #endif // _OBFS_HTTP_SIMPLE_H 21 | -------------------------------------------------------------------------------- /src/obfs/obfsutil.h: -------------------------------------------------------------------------------- 1 | #ifndef _OBFS_OBFSUTIL_H 2 | #define _OBFS_OBFSUTIL_H 3 | 4 | int get_head_size(char *plaindata, int size, int def_size); 5 | 6 | void init_shift128plus(void); 7 | 8 | uint64_t xorshift128plus(void); 9 | 10 | int ss_md5_hmac(char *auth, char *msg, int msg_len, uint8_t *iv, int enc_iv_len, uint8_t *enc_key, int enc_key_len); 11 | 12 | int ss_sha1_hmac(char *auth, char *msg, int msg_len, uint8_t *iv, int enc_iv_len, uint8_t *enc_key, int enc_key_len); 13 | 14 | void memintcopy_lt(void *mem, uint32_t val); 15 | 16 | #endif // _OBFS_OBFSUTIL_H 17 | -------------------------------------------------------------------------------- /src/obfs/tls1.2_ticket.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tls1.2_ticket.h - Define shadowsocksR server's buffers and callbacks 3 | * 4 | * Copyright (C) 2015 - 2017, Break Wa11 5 | */ 6 | 7 | #ifndef _OBFS_TLS1_2_TICKET_H 8 | #define _OBFS_TLS1_2_TICKET_H 9 | 10 | #include "obfs.h" 11 | 12 | void * tls12_ticket_auth_init_data(); 13 | obfs * tls12_ticket_auth_new_obfs(); 14 | void tls12_ticket_auth_dispose(obfs *self); 15 | 16 | int tls12_ticket_auth_client_encode(obfs *self, char **pencryptdata, int datalength, size_t* capacity); 17 | int tls12_ticket_auth_client_decode(obfs *self, char **pencryptdata, int datalength, size_t* capacity, int *needsendback); 18 | 19 | int tls12_ticket_auth_get_overhead(obfs *self); 20 | #endif // _OBFS_TLS1_2_TICKET_H 21 | -------------------------------------------------------------------------------- /src/obfs/verify.h: -------------------------------------------------------------------------------- 1 | /* 2 | * verify.h - Define shadowsocksR server's buffers and callbacks 3 | * 4 | * Copyright (C) 2015 - 2016, Break Wa11 5 | */ 6 | 7 | #ifndef _OBFS_VERIFY_H 8 | #define _OBFS_VERIFY_H 9 | 10 | #include "obfs.h" 11 | 12 | obfs * verify_simple_new_obfs(); 13 | void verify_simple_dispose(obfs *self); 14 | 15 | int verify_simple_client_pre_encrypt(obfs *self, char **pplaindata, int datalength, size_t* capacity); 16 | int verify_simple_client_post_decrypt(obfs *self, char **pplaindata, int datalength, size_t* capacity); 17 | 18 | #endif // _OBFS_VERIFY_H 19 | --------------------------------------------------------------------------------