├── auto └── config.rpath ├── debian ├── compat ├── source │ └── format ├── libshadowsocks-libev2.install ├── shadowsocks-libev.docs ├── libshadowsocks-libev-dev.install ├── .gitignore ├── shadowsocks-libev.install ├── config.json ├── source.lintian-overrides ├── watch ├── shadowsocks-libev.postrm ├── copyright.original ├── shadowsocks-libev.postinst ├── rules ├── shadowsocks-libev.default ├── README.Debian ├── shadowsocks-libev.service ├── shadowsocks-libev-local@.service ├── shadowsocks-libev-server@.service ├── shadowsocks-libev-tunnel@.service └── shadowsocks-libev-redir@.service ├── libipset ├── bdd │ ├── Makefile.in │ └── Makefile.am ├── map │ ├── Makefile.in │ ├── allocation.c │ ├── Makefile.am │ ├── ipv4_map.c │ └── ipv6_map.c ├── set │ ├── Makefile.in │ ├── allocation.c │ ├── Makefile.am │ ├── ipv4_set.c │ └── ipv6_set.c ├── README.markdown ├── general.c ├── Makefile.am ├── include │ └── ipset │ │ ├── errors.h │ │ └── logging.h └── LICENSE.txt ├── libsodium ├── README ├── src │ ├── Makefile.am │ └── libsodium │ │ ├── crypto_sign │ │ └── ed25519 │ │ │ ├── description │ │ │ ├── ref10 │ │ │ ├── d.h │ │ │ ├── d2.h │ │ │ ├── sqrtm1.h │ │ │ ├── ge_p2_0.c │ │ │ ├── ge_p3_0.c │ │ │ ├── ge_precomp_0.c │ │ │ ├── ge_p2_dbl.c │ │ │ ├── ge_add.c │ │ │ ├── ge_madd.c │ │ │ ├── ge_msub.c │ │ │ ├── ge_sub.c │ │ │ ├── ge_p3_dbl.c │ │ │ ├── fe_pow22523.c │ │ │ ├── fe_invert.c │ │ │ ├── ge_p3_to_p2.c │ │ │ ├── ge_p1p1_to_p2.c │ │ │ ├── fe_0.c │ │ │ ├── fe_1.c │ │ │ ├── ge_p1p1_to_p3.c │ │ │ ├── ge_tobytes.c │ │ │ ├── ge_p3_tobytes.c │ │ │ ├── ge_p3_to_cached.c │ │ │ ├── fe_isnegative.c │ │ │ ├── fe_isnonzero.c │ │ │ ├── sc.h │ │ │ ├── fe_copy.c │ │ │ ├── fe_neg.c │ │ │ ├── ge_frombytes.c │ │ │ ├── fe_add.c │ │ │ ├── fe_sub.c │ │ │ └── fe_cmov.c │ │ │ └── sign_ed25519_api.c │ │ ├── crypto_verify │ │ ├── 16 │ │ │ ├── verify_16_api.c │ │ │ └── ref │ │ │ │ └── verify_16.c │ │ ├── 32 │ │ │ ├── verify_32_api.c │ │ │ └── ref │ │ │ │ └── verify_32.c │ │ └── 64 │ │ │ ├── verify_64_api.c │ │ │ └── ref │ │ │ └── verify_64.c │ │ ├── include │ │ └── sodium │ │ │ ├── crypto_int32.h │ │ │ ├── crypto_int64.h │ │ │ ├── crypto_uint8.h │ │ │ ├── crypto_uint16.h │ │ │ ├── crypto_uint32.h │ │ │ ├── crypto_uint64.h │ │ │ ├── core.h │ │ │ ├── randombytes_sysrandom.h │ │ │ ├── randombytes_salsa20_random.h │ │ │ ├── randombytes_nativeclient.h │ │ │ ├── crypto_verify_16.h │ │ │ ├── crypto_verify_32.h │ │ │ ├── crypto_verify_64.h │ │ │ ├── version.h.in │ │ │ ├── crypto_shorthash_siphash24.h │ │ │ ├── runtime.h │ │ │ ├── crypto_core_salsa20.h │ │ │ ├── crypto_core_hsalsa20.h │ │ │ ├── crypto_core_salsa208.h │ │ │ ├── crypto_core_salsa2012.h │ │ │ ├── crypto_shorthash.h │ │ │ ├── crypto_scalarmult.h │ │ │ ├── crypto_hash.h │ │ │ ├── crypto_scalarmult_curve25519.h │ │ │ ├── export.h │ │ │ ├── crypto_auth.h │ │ │ ├── crypto_stream_salsa208.h │ │ │ ├── crypto_stream_salsa2012.h │ │ │ ├── crypto_stream.h │ │ │ ├── crypto_hash_sha256.h │ │ │ ├── crypto_hash_sha512.h │ │ │ ├── randombytes.h │ │ │ └── crypto_stream_salsa20.h │ │ ├── crypto_stream │ │ ├── aes128ctr │ │ │ ├── portable │ │ │ │ ├── types.h │ │ │ │ ├── stream_aes128ctr.c │ │ │ │ ├── consts.h │ │ │ │ ├── consts_aes128ctr.c │ │ │ │ └── common_aes128ctr.c │ │ │ └── stream_aes128ctr_api.c │ │ ├── salsa208 │ │ │ ├── stream_salsa208_api.c │ │ │ └── ref │ │ │ │ ├── stream_salsa208.c │ │ │ │ └── xor_salsa208.c │ │ ├── xsalsa20 │ │ │ ├── stream_xsalsa20_api.c │ │ │ └── ref │ │ │ │ ├── stream_xsalsa20.c │ │ │ │ └── xor_xsalsa20.c │ │ ├── salsa2012 │ │ │ ├── stream_salsa2012_api.c │ │ │ └── ref │ │ │ │ ├── stream_salsa2012.c │ │ │ │ └── xor_salsa2012.c │ │ ├── salsa20 │ │ │ ├── stream_salsa20_api.c │ │ │ └── ref │ │ │ │ ├── stream_salsa20_ref.c │ │ │ │ └── xor_salsa20_ref.c │ │ ├── crypto_stream.c │ │ └── chacha20 │ │ │ ├── stream_chacha20.h │ │ │ ├── ref │ │ │ └── stream_chacha20_ref.h │ │ │ └── vec │ │ │ └── stream_chacha20_vec.h │ │ ├── crypto_hash │ │ ├── sha256 │ │ │ └── hash_sha256_api.c │ │ ├── sha512 │ │ │ └── hash_sha512_api.c │ │ └── crypto_hash.c │ │ ├── crypto_scalarmult │ │ ├── curve25519 │ │ │ ├── sandy2x │ │ │ │ ├── ladder_namespace.h │ │ │ │ ├── curve25519_sandy2x.h │ │ │ │ ├── ladder_base_namespace.h │ │ │ │ ├── ladder.h │ │ │ │ ├── ladder_base.h │ │ │ │ ├── sandy2x.S │ │ │ │ ├── consts.S │ │ │ │ ├── fe.h │ │ │ │ ├── fe51.h │ │ │ │ ├── fe51_namespace.h │ │ │ │ ├── consts_namespace.h │ │ │ │ └── fe51_invert.c │ │ │ ├── ref10 │ │ │ │ ├── fe_invert_curve25519_ref10.c │ │ │ │ ├── curve25519_ref10.h │ │ │ │ ├── fe_0_curve25519_ref10.c │ │ │ │ ├── fe_1_curve25519_ref10.c │ │ │ │ ├── fe_copy_curve25519_ref10.c │ │ │ │ ├── fe_add_curve25519_ref10.c │ │ │ │ ├── fe_sub_curve25519_ref10.c │ │ │ │ └── fe.h │ │ │ ├── donna_c64 │ │ │ │ └── curve25519_donna_c64.h │ │ │ └── scalarmult_curve25519.h │ │ └── crypto_scalarmult.c │ │ ├── crypto_shorthash │ │ ├── siphash24 │ │ │ └── shorthash_siphash24_api.c │ │ └── crypto_shorthash.c │ │ ├── sodium │ │ ├── version.c │ │ └── core.c │ │ ├── crypto_auth │ │ ├── hmacsha256 │ │ │ ├── auth_hmacsha256_api.c │ │ │ └── cp │ │ │ │ └── verify_hmacsha256.c │ │ ├── hmacsha512 │ │ │ ├── auth_hmacsha512_api.c │ │ │ └── cp │ │ │ │ └── verify_hmacsha512.c │ │ ├── hmacsha512256 │ │ │ ├── auth_hmacsha512256_api.c │ │ │ └── cp │ │ │ │ └── verify_hmacsha512256.c │ │ └── crypto_auth.c │ │ ├── crypto_core │ │ ├── salsa20 │ │ │ └── core_salsa20_api.c │ │ ├── hsalsa20 │ │ │ └── core_hsalsa20_api.c │ │ ├── salsa208 │ │ │ └── core_salsa208_api.c │ │ └── salsa2012 │ │ │ └── core_salsa2012_api.c │ │ ├── crypto_box │ │ └── curve25519xsalsa20poly1305 │ │ │ ├── ref │ │ │ ├── before_curve25519xsalsa20poly1305.c │ │ │ ├── after_curve25519xsalsa20poly1305.c │ │ │ ├── keypair_curve25519xsalsa20poly1305.c │ │ │ └── box_curve25519xsalsa20poly1305.c │ │ │ └── box_curve25519xsalsa20poly1305_api.c │ │ ├── crypto_secretbox │ │ ├── xsalsa20poly1305 │ │ │ ├── secretbox_xsalsa20poly1305_api.c │ │ │ └── ref │ │ │ │ └── box_xsalsa20poly1305.c │ │ └── crypto_secretbox.c │ │ ├── crypto_generichash │ │ └── blake2 │ │ │ └── generichash_blake2_api.c │ │ ├── crypto_onetimeauth │ │ └── poly1305 │ │ │ ├── onetimeauth_poly1305.h │ │ │ ├── sse2 │ │ │ └── poly1305_sse2.h │ │ │ └── donna │ │ │ └── poly1305_donna.h │ │ └── randombytes │ │ └── nativeclient │ │ └── randombytes_nativeclient.c ├── packaging │ └── nuget │ │ ├── .gitignore │ │ ├── package.config │ │ ├── package.bat │ │ └── package.xml ├── logo.png ├── Makefile.am ├── libsodium.pc.in ├── LICENSE ├── .travis.yml ├── autogen.sh ├── m4 │ └── ld-output-def.m4 ├── THANKS └── README.markdown ├── autogen.sh ├── libev ├── autogen.sh ├── Symbols.event ├── configure.ac ├── Makefile.am └── Symbols.ev ├── acl └── local.acl ├── docker ├── alpine │ └── docker-compose.yml └── ubuntu │ └── Dockerfile ├── Makefile.am ├── libudns ├── Makefile.am └── udns_dntosp.c ├── shadowsocks-libev.pc.in ├── .travis.yml ├── .github └── issue_template.md ├── AUTHORS ├── doc ├── manpage-normal.xsl ├── manpage-bold-literal.xsl ├── asciidoc.conf └── manpage-base.xsl ├── libcork ├── include │ └── libcork │ │ ├── cli.h │ │ ├── config.h │ │ ├── threads.h │ │ ├── os.h │ │ ├── ds.h │ │ ├── os │ │ └── process.h │ │ ├── config │ │ ├── version.h │ │ ├── bsd.h │ │ ├── linux.h │ │ ├── solaris.h │ │ ├── macosx.h │ │ ├── arch.h │ │ └── mingw32.h │ │ ├── core.h │ │ ├── core │ │ ├── id.h │ │ └── callbacks.h │ │ ├── helpers │ │ └── gc.h │ │ └── cli │ │ └── commands.h ├── core │ └── hash.c ├── Makefile.am ├── ds │ └── bitset.c └── COPYING ├── COPYING ├── m4 ├── ltversion.m4 ├── zlib.m4 ├── polarssl.m4 └── inet_ntop.m4 ├── .gitignore ├── rpm └── genrpm.sh └── src ├── tls.h ├── http.h ├── acl.h ├── socks5.h └── protocol.h /auto/config.rpath: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /libipset/bdd/Makefile.in: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libipset/map/Makefile.in: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /libipset/set/Makefile.in: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /libsodium/README: -------------------------------------------------------------------------------- 1 | See README.markdown 2 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | autoreconf --install --force 4 | -------------------------------------------------------------------------------- /libsodium/src/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | SUBDIRS = \ 3 | libsodium 4 | -------------------------------------------------------------------------------- /debian/libshadowsocks-libev2.install: -------------------------------------------------------------------------------- 1 | usr/lib/*/libshadowsocks-libev.so.* 2 | -------------------------------------------------------------------------------- /libev/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | autoreconf --install --symlink --force 4 | -------------------------------------------------------------------------------- /debian/shadowsocks-libev.docs: -------------------------------------------------------------------------------- 1 | AUTHORS 2 | README.md 3 | debian/copyright.original 4 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/description: -------------------------------------------------------------------------------- 1 | EdDSA signatures using Curve25519 2 | -------------------------------------------------------------------------------- /libsodium/packaging/nuget/.gitignore: -------------------------------------------------------------------------------- 1 | *.nupkg 2 | package.nuspec 3 | package.targets 4 | package.xml 5 | -------------------------------------------------------------------------------- /libsodium/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/monkey-wenjun/shadowsocks-libev/master/libsodium/logo.png -------------------------------------------------------------------------------- /debian/libshadowsocks-libev-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/ 2 | usr/lib/*/libshadowsocks-libev.so 3 | usr/lib/*/pkgconfig/ 4 | -------------------------------------------------------------------------------- /debian/.gitignore: -------------------------------------------------------------------------------- 1 | *.substvars 2 | debhelper-build-stamp 3 | libshadowsocks-libev*/ 4 | libshadowsocks-libev-dev/ 5 | tmp/ 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/sqrtm1.h: -------------------------------------------------------------------------------- 1 | -32595792,-7943725,9377950,3500415,12389472,-272473,-25146209,-2005654,326686,11406482 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_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_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/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_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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_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_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_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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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_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_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_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_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/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_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/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/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/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_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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_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_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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/packaging/nuget/package.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /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/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_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/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/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/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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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_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/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/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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_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_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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_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/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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/manpage-normal.xsl: -------------------------------------------------------------------------------- 1 | 4 | 6 | 7 | 8 | 9 | 10 | \ 11 | . 12 | 13 | 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_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_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_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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/manpage-bold-literal.xsl: -------------------------------------------------------------------------------- 1 | 3 | 5 | 6 | 9 | 10 | 11 | fB 12 | 13 | 14 | fR 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_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_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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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-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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/.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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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_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/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/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_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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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_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/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_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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_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/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/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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /libsodium/packaging/nuget/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | 52 | #endif /* LIBCORK_CONFIG_MINGW32_H */ 53 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/salsa208/ref/stream_salsa208.c: -------------------------------------------------------------------------------- 1 | /* 2 | version 20140420 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #include "crypto_core_salsa208.h" 8 | #include "crypto_stream_salsa208.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_salsa208( 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_salsa208(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_salsa208(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/salsa20/ref/stream_salsa20_ref.c: -------------------------------------------------------------------------------- 1 | /* 2 | version 20140420 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #include "crypto_core_salsa20.h" 8 | #include "crypto_stream_salsa20.h" 9 | #include "utils.h" 10 | 11 | #ifndef HAVE_AMD64_ASM 12 | 13 | typedef unsigned int uint32; 14 | 15 | static const unsigned char sigma[16] = { 16 | 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k' 17 | }; 18 | 19 | int crypto_stream_salsa20( 20 | unsigned char *c,unsigned long long clen, 21 | const unsigned char *n, 22 | const unsigned char *k 23 | ) 24 | { 25 | unsigned char in[16]; 26 | unsigned char block[64]; 27 | unsigned char kcopy[32]; 28 | unsigned int i; 29 | unsigned int u; 30 | 31 | if (!clen) return 0; 32 | 33 | for (i = 0;i < 32;++i) kcopy[i] = k[i]; 34 | for (i = 0;i < 8;++i) in[i] = n[i]; 35 | for (i = 8;i < 16;++i) in[i] = 0; 36 | 37 | while (clen >= 64) { 38 | crypto_core_salsa20(c,in,kcopy,sigma); 39 | 40 | u = 1; 41 | for (i = 8;i < 16;++i) { 42 | u += (unsigned int) in[i]; 43 | in[i] = u; 44 | u >>= 8; 45 | } 46 | 47 | clen -= 64; 48 | c += 64; 49 | } 50 | 51 | if (clen) { 52 | crypto_core_salsa20(block,in,kcopy,sigma); 53 | for (i = 0;i < (unsigned int) clen;++i) c[i] = block[i]; 54 | } 55 | sodium_memzero(block, sizeof block); 56 | sodium_memzero(kcopy, sizeof kcopy); 57 | 58 | return 0; 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /libcork/ds/bitset.c: -------------------------------------------------------------------------------- 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 | #include 11 | 12 | #include "libcork/core/allocator.h" 13 | #include "libcork/core/api.h" 14 | #include "libcork/core/types.h" 15 | #include "libcork/ds/bitset.h" 16 | 17 | 18 | static size_t 19 | bytes_needed(size_t bit_count) 20 | { 21 | /* We need one byte for every bit... */ 22 | size_t bytes_needed = bit_count / 8; 23 | /* Plus one extra for the leftovers that don't fit into a whole byte. */ 24 | bytes_needed += ((bit_count % 8) > 0); 25 | return bytes_needed; 26 | } 27 | 28 | struct cork_bitset * 29 | cork_bitset_new(size_t bit_count) 30 | { 31 | struct cork_bitset *set = cork_new(struct cork_bitset); 32 | set->bit_count = bit_count; 33 | set->byte_count = bytes_needed(bit_count); 34 | set->bits = cork_malloc(set->byte_count); 35 | memset(set->bits, 0, set->byte_count); 36 | return set; 37 | } 38 | 39 | void 40 | cork_bitset_free(struct cork_bitset *set) 41 | { 42 | cork_free(set->bits, set->byte_count); 43 | cork_delete(struct cork_bitset, set); 44 | } 45 | 46 | void 47 | cork_bitset_clear(struct cork_bitset *set) 48 | { 49 | memset(set->bits, 0, set->byte_count); 50 | } 51 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_stream.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_stream_H 2 | #define crypto_stream_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 | 14 | #include "crypto_stream_xsalsa20.h" 15 | #include "export.h" 16 | 17 | #ifdef __cplusplus 18 | # if __GNUC__ 19 | # pragma GCC diagnostic ignored "-Wlong-long" 20 | # endif 21 | extern "C" { 22 | #endif 23 | 24 | #define crypto_stream_KEYBYTES crypto_stream_xsalsa20_KEYBYTES 25 | SODIUM_EXPORT 26 | size_t crypto_stream_keybytes(void); 27 | 28 | #define crypto_stream_NONCEBYTES crypto_stream_xsalsa20_NONCEBYTES 29 | SODIUM_EXPORT 30 | size_t crypto_stream_noncebytes(void); 31 | 32 | #define crypto_stream_PRIMITIVE "xsalsa20" 33 | SODIUM_EXPORT 34 | const char *crypto_stream_primitive(void); 35 | 36 | SODIUM_EXPORT 37 | int crypto_stream(unsigned char *c, unsigned long long clen, 38 | const unsigned char *n, const unsigned char *k); 39 | 40 | SODIUM_EXPORT 41 | int crypto_stream_xor(unsigned char *c, const unsigned char *m, 42 | unsigned long long mlen, const unsigned char *n, 43 | const unsigned char *k); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/aes128ctr/portable/common_aes128ctr.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | uint32 load32_bigendian(const unsigned char *x) 4 | { 5 | return 6 | (uint32) (x[3]) \ 7 | | (((uint32) (x[2])) << 8) \ 8 | | (((uint32) (x[1])) << 16) \ 9 | | (((uint32) (x[0])) << 24) 10 | ; 11 | } 12 | 13 | void store32_bigendian(unsigned char *x,uint32 u) 14 | { 15 | x[3] = u; u >>= 8; 16 | x[2] = u; u >>= 8; 17 | x[1] = u; u >>= 8; 18 | x[0] = u; 19 | } 20 | 21 | uint32 load32_littleendian(const unsigned char *x) 22 | { 23 | return 24 | (uint32) (x[0]) \ 25 | | (((uint32) (x[1])) << 8) \ 26 | | (((uint32) (x[2])) << 16) \ 27 | | (((uint32) (x[3])) << 24) 28 | ; 29 | } 30 | 31 | void store32_littleendian(unsigned char *x,uint32 u) 32 | { 33 | x[0] = u; u >>= 8; 34 | x[1] = u; u >>= 8; 35 | x[2] = u; u >>= 8; 36 | x[3] = u; 37 | } 38 | 39 | 40 | uint64 load64_littleendian(const unsigned char *x) 41 | { 42 | return 43 | (uint64) (x[0]) \ 44 | | (((uint64) (x[1])) << 8) \ 45 | | (((uint64) (x[2])) << 16) \ 46 | | (((uint64) (x[3])) << 24) 47 | | (((uint64) (x[4])) << 32) 48 | | (((uint64) (x[5])) << 40) 49 | | (((uint64) (x[6])) << 48) 50 | | (((uint64) (x[7])) << 56) 51 | ; 52 | } 53 | 54 | void store64_littleendian(unsigned char *x,uint64 u) 55 | { 56 | x[0] = u; u >>= 8; 57 | x[1] = u; u >>= 8; 58 | x[2] = u; u >>= 8; 59 | x[3] = u; u >>= 8; 60 | x[4] = u; u >>= 8; 61 | x[5] = u; u >>= 8; 62 | x[6] = u; u >>= 8; 63 | x[7] = u; 64 | } 65 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/salsa208/ref/xor_salsa208.c: -------------------------------------------------------------------------------- 1 | /* 2 | version 20140420 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #include "crypto_core_salsa208.h" 8 | #include "crypto_stream_salsa208.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_salsa208_xor( 18 | unsigned char *c, 19 | const unsigned char *m,unsigned long long mlen, 20 | const unsigned char *n, 21 | const unsigned char *k 22 | ) 23 | { 24 | unsigned char in[16]; 25 | unsigned char block[64]; 26 | unsigned char kcopy[32]; 27 | unsigned int i; 28 | unsigned int u; 29 | 30 | if (!mlen) return 0; 31 | 32 | for (i = 0;i < 32;++i) kcopy[i] = k[i]; 33 | for (i = 0;i < 8;++i) in[i] = n[i]; 34 | for (i = 8;i < 16;++i) in[i] = 0; 35 | 36 | while (mlen >= 64) { 37 | crypto_core_salsa208(block,in,kcopy,sigma); 38 | for (i = 0;i < 64;++i) c[i] = m[i] ^ block[i]; 39 | 40 | u = 1; 41 | for (i = 8;i < 16;++i) { 42 | u += (unsigned int) in[i]; 43 | in[i] = u; 44 | u >>= 8; 45 | } 46 | 47 | mlen -= 64; 48 | c += 64; 49 | m += 64; 50 | } 51 | 52 | if (mlen) { 53 | crypto_core_salsa208(block,in,kcopy,sigma); 54 | for (i = 0;i < (unsigned int) mlen;++i) c[i] = m[i] ^ block[i]; 55 | } 56 | sodium_memzero(block, sizeof block); 57 | sodium_memzero(kcopy, sizeof kcopy); 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_add.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | /* 4 | h = f + g 5 | Can overlap h with f or g. 6 | 7 | Preconditions: 8 | |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. 9 | |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. 10 | 11 | Postconditions: 12 | |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. 13 | */ 14 | 15 | void fe_add(fe h,const fe f,const fe g) 16 | { 17 | crypto_int32 f0 = f[0]; 18 | crypto_int32 f1 = f[1]; 19 | crypto_int32 f2 = f[2]; 20 | crypto_int32 f3 = f[3]; 21 | crypto_int32 f4 = f[4]; 22 | crypto_int32 f5 = f[5]; 23 | crypto_int32 f6 = f[6]; 24 | crypto_int32 f7 = f[7]; 25 | crypto_int32 f8 = f[8]; 26 | crypto_int32 f9 = f[9]; 27 | crypto_int32 g0 = g[0]; 28 | crypto_int32 g1 = g[1]; 29 | crypto_int32 g2 = g[2]; 30 | crypto_int32 g3 = g[3]; 31 | crypto_int32 g4 = g[4]; 32 | crypto_int32 g5 = g[5]; 33 | crypto_int32 g6 = g[6]; 34 | crypto_int32 g7 = g[7]; 35 | crypto_int32 g8 = g[8]; 36 | crypto_int32 g9 = g[9]; 37 | crypto_int32 h0 = f0 + g0; 38 | crypto_int32 h1 = f1 + g1; 39 | crypto_int32 h2 = f2 + g2; 40 | crypto_int32 h3 = f3 + g3; 41 | crypto_int32 h4 = f4 + g4; 42 | crypto_int32 h5 = f5 + g5; 43 | crypto_int32 h6 = f6 + g6; 44 | crypto_int32 h7 = f7 + g7; 45 | crypto_int32 h8 = f8 + g8; 46 | crypto_int32 h9 = f9 + g9; 47 | h[0] = h0; 48 | h[1] = h1; 49 | h[2] = h2; 50 | h[3] = h3; 51 | h[4] = h4; 52 | h[5] = h5; 53 | h[6] = h6; 54 | h[7] = h7; 55 | h[8] = h8; 56 | h[9] = h9; 57 | } 58 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_sub.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | /* 4 | h = f - g 5 | Can overlap h with f or g. 6 | 7 | Preconditions: 8 | |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. 9 | |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. 10 | 11 | Postconditions: 12 | |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. 13 | */ 14 | 15 | void fe_sub(fe h,const fe f,const fe g) 16 | { 17 | crypto_int32 f0 = f[0]; 18 | crypto_int32 f1 = f[1]; 19 | crypto_int32 f2 = f[2]; 20 | crypto_int32 f3 = f[3]; 21 | crypto_int32 f4 = f[4]; 22 | crypto_int32 f5 = f[5]; 23 | crypto_int32 f6 = f[6]; 24 | crypto_int32 f7 = f[7]; 25 | crypto_int32 f8 = f[8]; 26 | crypto_int32 f9 = f[9]; 27 | crypto_int32 g0 = g[0]; 28 | crypto_int32 g1 = g[1]; 29 | crypto_int32 g2 = g[2]; 30 | crypto_int32 g3 = g[3]; 31 | crypto_int32 g4 = g[4]; 32 | crypto_int32 g5 = g[5]; 33 | crypto_int32 g6 = g[6]; 34 | crypto_int32 g7 = g[7]; 35 | crypto_int32 g8 = g[8]; 36 | crypto_int32 g9 = g[9]; 37 | crypto_int32 h0 = f0 - g0; 38 | crypto_int32 h1 = f1 - g1; 39 | crypto_int32 h2 = f2 - g2; 40 | crypto_int32 h3 = f3 - g3; 41 | crypto_int32 h4 = f4 - g4; 42 | crypto_int32 h5 = f5 - g5; 43 | crypto_int32 h6 = f6 - g6; 44 | crypto_int32 h7 = f7 - g7; 45 | crypto_int32 h8 = f8 - g8; 46 | crypto_int32 h9 = f9 - g9; 47 | h[0] = h0; 48 | h[1] = h1; 49 | h[2] = h2; 50 | h[3] = h3; 51 | h[4] = h4; 52 | h[5] = h5; 53 | h[6] = h6; 54 | h[7] = h7; 55 | h[8] = h8; 56 | h[9] = h9; 57 | } 58 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/salsa2012/ref/xor_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_xor( 18 | unsigned char *c, 19 | const unsigned char *m,unsigned long long mlen, 20 | const unsigned char *n, 21 | const unsigned char *k 22 | ) 23 | { 24 | unsigned char in[16]; 25 | unsigned char block[64]; 26 | unsigned char kcopy[32]; 27 | unsigned int i; 28 | unsigned int u; 29 | 30 | if (!mlen) return 0; 31 | 32 | for (i = 0;i < 32;++i) kcopy[i] = k[i]; 33 | for (i = 0;i < 8;++i) in[i] = n[i]; 34 | for (i = 8;i < 16;++i) in[i] = 0; 35 | 36 | while (mlen >= 64) { 37 | crypto_core_salsa2012(block,in,kcopy,sigma); 38 | for (i = 0;i < 64;++i) c[i] = m[i] ^ block[i]; 39 | 40 | u = 1; 41 | for (i = 8;i < 16;++i) { 42 | u += (unsigned int) in[i]; 43 | in[i] = u; 44 | u >>= 8; 45 | } 46 | 47 | mlen -= 64; 48 | c += 64; 49 | m += 64; 50 | } 51 | 52 | if (mlen) { 53 | crypto_core_salsa2012(block,in,kcopy,sigma); 54 | for (i = 0;i < (unsigned int) mlen;++i) c[i] = m[i] ^ block[i]; 55 | } 56 | sodium_memzero(block, sizeof block); 57 | sodium_memzero(kcopy, sizeof kcopy); 58 | 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_onetimeauth/poly1305/sse2/poly1305_sse2.h: -------------------------------------------------------------------------------- 1 | #ifndef poly1305_sse2_H 2 | #define poly1305_sse2_H 3 | 4 | #include 5 | 6 | #include "crypto_onetimeauth_poly1305.h" 7 | 8 | extern struct crypto_onetimeauth_poly1305_implementation 9 | crypto_onetimeauth_poly1305_sse2_implementation; 10 | 11 | static int crypto_onetimeauth_poly1305_sse2(unsigned char *out, 12 | const unsigned char *in, 13 | unsigned long long inlen, 14 | const unsigned char *k); 15 | 16 | static int crypto_onetimeauth_poly1305_sse2_verify(const unsigned char *h, 17 | const unsigned char *in, 18 | unsigned long long inlen, 19 | const unsigned char *k); 20 | 21 | static int crypto_onetimeauth_poly1305_sse2_init(crypto_onetimeauth_poly1305_state *state, 22 | const unsigned char *key); 23 | 24 | static int crypto_onetimeauth_poly1305_sse2_update(crypto_onetimeauth_poly1305_state *state, 25 | const unsigned char *in, 26 | unsigned long long inlen); 27 | 28 | static int crypto_onetimeauth_poly1305_sse2_final(crypto_onetimeauth_poly1305_state *state, 29 | unsigned char *out); 30 | 31 | #endif /* poly1305_sse2_H */ 32 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_onetimeauth/poly1305/donna/poly1305_donna.h: -------------------------------------------------------------------------------- 1 | #ifndef poly1305_donna_H 2 | #define poly1305_donna_H 3 | 4 | #include 5 | 6 | #include "crypto_onetimeauth_poly1305.h" 7 | 8 | extern struct crypto_onetimeauth_poly1305_implementation 9 | crypto_onetimeauth_poly1305_donna_implementation; 10 | 11 | static int crypto_onetimeauth_poly1305_donna(unsigned char *out, 12 | const unsigned char *in, 13 | unsigned long long inlen, 14 | const unsigned char *k); 15 | 16 | static int crypto_onetimeauth_poly1305_donna_verify(const unsigned char *h, 17 | const unsigned char *in, 18 | unsigned long long inlen, 19 | const unsigned char *k); 20 | 21 | static int crypto_onetimeauth_poly1305_donna_init(crypto_onetimeauth_poly1305_state *state, 22 | const unsigned char *key); 23 | 24 | static int crypto_onetimeauth_poly1305_donna_update(crypto_onetimeauth_poly1305_state *state, 25 | const unsigned char *in, 26 | unsigned long long inlen); 27 | 28 | static int crypto_onetimeauth_poly1305_donna_final(crypto_onetimeauth_poly1305_state *state, 29 | unsigned char *out); 30 | 31 | #endif /* poly1305_donna_H */ 32 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_add_curve25519_ref10.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | #ifndef HAVE_TI_MODE 4 | 5 | /* 6 | h = f + g 7 | Can overlap h with f or g. 8 | 9 | Preconditions: 10 | |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. 11 | |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. 12 | 13 | Postconditions: 14 | |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. 15 | */ 16 | 17 | void fe_add(fe h,fe f,fe g) 18 | { 19 | crypto_int32 f0 = f[0]; 20 | crypto_int32 f1 = f[1]; 21 | crypto_int32 f2 = f[2]; 22 | crypto_int32 f3 = f[3]; 23 | crypto_int32 f4 = f[4]; 24 | crypto_int32 f5 = f[5]; 25 | crypto_int32 f6 = f[6]; 26 | crypto_int32 f7 = f[7]; 27 | crypto_int32 f8 = f[8]; 28 | crypto_int32 f9 = f[9]; 29 | crypto_int32 g0 = g[0]; 30 | crypto_int32 g1 = g[1]; 31 | crypto_int32 g2 = g[2]; 32 | crypto_int32 g3 = g[3]; 33 | crypto_int32 g4 = g[4]; 34 | crypto_int32 g5 = g[5]; 35 | crypto_int32 g6 = g[6]; 36 | crypto_int32 g7 = g[7]; 37 | crypto_int32 g8 = g[8]; 38 | crypto_int32 g9 = g[9]; 39 | crypto_int32 h0 = f0 + g0; 40 | crypto_int32 h1 = f1 + g1; 41 | crypto_int32 h2 = f2 + g2; 42 | crypto_int32 h3 = f3 + g3; 43 | crypto_int32 h4 = f4 + g4; 44 | crypto_int32 h5 = f5 + g5; 45 | crypto_int32 h6 = f6 + g6; 46 | crypto_int32 h7 = f7 + g7; 47 | crypto_int32 h8 = f8 + g8; 48 | crypto_int32 h9 = f9 + g9; 49 | h[0] = h0; 50 | h[1] = h1; 51 | h[2] = h2; 52 | h[3] = h3; 53 | h[4] = h4; 54 | h[5] = h5; 55 | h[6] = h6; 56 | h[7] = h7; 57 | h[8] = h8; 58 | h[9] = h9; 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe_sub_curve25519_ref10.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | #ifndef HAVE_TI_MODE 4 | 5 | /* 6 | h = f - g 7 | Can overlap h with f or g. 8 | 9 | Preconditions: 10 | |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. 11 | |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. 12 | 13 | Postconditions: 14 | |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. 15 | */ 16 | 17 | void fe_sub(fe h,fe f,fe g) 18 | { 19 | crypto_int32 f0 = f[0]; 20 | crypto_int32 f1 = f[1]; 21 | crypto_int32 f2 = f[2]; 22 | crypto_int32 f3 = f[3]; 23 | crypto_int32 f4 = f[4]; 24 | crypto_int32 f5 = f[5]; 25 | crypto_int32 f6 = f[6]; 26 | crypto_int32 f7 = f[7]; 27 | crypto_int32 f8 = f[8]; 28 | crypto_int32 f9 = f[9]; 29 | crypto_int32 g0 = g[0]; 30 | crypto_int32 g1 = g[1]; 31 | crypto_int32 g2 = g[2]; 32 | crypto_int32 g3 = g[3]; 33 | crypto_int32 g4 = g[4]; 34 | crypto_int32 g5 = g[5]; 35 | crypto_int32 g6 = g[6]; 36 | crypto_int32 g7 = g[7]; 37 | crypto_int32 g8 = g[8]; 38 | crypto_int32 g9 = g[9]; 39 | crypto_int32 h0 = f0 - g0; 40 | crypto_int32 h1 = f1 - g1; 41 | crypto_int32 h2 = f2 - g2; 42 | crypto_int32 h3 = f3 - g3; 43 | crypto_int32 h4 = f4 - g4; 44 | crypto_int32 h5 = f5 - g5; 45 | crypto_int32 h6 = f6 - g6; 46 | crypto_int32 h7 = f7 - g7; 47 | crypto_int32 h8 = f8 - g8; 48 | crypto_int32 h9 = f9 - g9; 49 | h[0] = h0; 50 | h[1] = h1; 51 | h[2] = h2; 52 | h[3] = h3; 53 | h[4] = h4; 54 | h[5] = h5; 55 | h[6] = h6; 56 | h[7] = h7; 57 | h[8] = h8; 58 | h[9] = h9; 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /rpm/genrpm.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | show_help() 5 | { 6 | echo -e "`basename $0` [option] [argument]" 7 | echo 8 | echo -e "Options:" 9 | echo -e " -h show this help." 10 | echo -e " -v with argument version (2.5.6 by default)." 11 | echo -e " -f with argument format (tar.xz by default) used by git archive." 12 | echo 13 | echo -e "Examples:" 14 | echo -e " to build base on version \`2.4.1' with format \`tar.xz', run:" 15 | echo -e " `basename $0` -f tar.xz -v 2.4.1" 16 | } 17 | 18 | while getopts "hv:f:" opt 19 | do 20 | case ${opt} in 21 | h) 22 | show_help 23 | exit 0 24 | ;; 25 | v) 26 | if [ "${OPTARG}" = v* ]; then 27 | version=${OPTARG#"v"} 28 | else 29 | version=${OPTARG} 30 | fi 31 | ;; 32 | f) 33 | format=${OPTARG} 34 | ;; 35 | *) 36 | exit 1 37 | ;; 38 | esac 39 | done 40 | 41 | : ${version:=2.5.6} 42 | : ${format:=tar.gz} 43 | 44 | name="shadowsocks-libev" 45 | spec_name="shadowsocks-libev.spec" 46 | 47 | pushd `git rev-parse --show-toplevel` 48 | git archive "v${version}" --format="${format}" --prefix="${name}-${version}/" -o rpm/SOURCES/"${name}-${version}.${format}" 49 | pushd rpm 50 | 51 | sed -e "s/^\(Version: \).*$/\1${version}/" \ 52 | -e "s/^\(Source0: \).*$/\1${name}-${version}.${format}/" \ 53 | SPECS/"${spec_name}".in > SPECS/"${spec_name}" 54 | 55 | rpmbuild -bb SPECS/"${spec_name}" --define "%_topdir `pwd`" 56 | -------------------------------------------------------------------------------- /libcork/COPYING: -------------------------------------------------------------------------------- 1 | Copyright © 2011-2012, RedJack, LLC. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | • Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | • Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the 14 | distribution. 15 | 16 | • Neither the name of RedJack Software, LLC nor the names of its 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_sign/ed25519/ref10/fe_cmov.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | /* 4 | Replace (f,g) with (g,g) if b == 1; 5 | replace (f,g) with (f,g) if b == 0. 6 | 7 | Preconditions: b in {0,1}. 8 | */ 9 | 10 | void fe_cmov(fe f,const fe g,unsigned int b) 11 | { 12 | crypto_int32 f0 = f[0]; 13 | crypto_int32 f1 = f[1]; 14 | crypto_int32 f2 = f[2]; 15 | crypto_int32 f3 = f[3]; 16 | crypto_int32 f4 = f[4]; 17 | crypto_int32 f5 = f[5]; 18 | crypto_int32 f6 = f[6]; 19 | crypto_int32 f7 = f[7]; 20 | crypto_int32 f8 = f[8]; 21 | crypto_int32 f9 = f[9]; 22 | crypto_int32 g0 = g[0]; 23 | crypto_int32 g1 = g[1]; 24 | crypto_int32 g2 = g[2]; 25 | crypto_int32 g3 = g[3]; 26 | crypto_int32 g4 = g[4]; 27 | crypto_int32 g5 = g[5]; 28 | crypto_int32 g6 = g[6]; 29 | crypto_int32 g7 = g[7]; 30 | crypto_int32 g8 = g[8]; 31 | crypto_int32 g9 = g[9]; 32 | crypto_int32 x0 = f0 ^ g0; 33 | crypto_int32 x1 = f1 ^ g1; 34 | crypto_int32 x2 = f2 ^ g2; 35 | crypto_int32 x3 = f3 ^ g3; 36 | crypto_int32 x4 = f4 ^ g4; 37 | crypto_int32 x5 = f5 ^ g5; 38 | crypto_int32 x6 = f6 ^ g6; 39 | crypto_int32 x7 = f7 ^ g7; 40 | crypto_int32 x8 = f8 ^ g8; 41 | crypto_int32 x9 = f9 ^ g9; 42 | b = (unsigned int) (- (int) b); 43 | x0 &= b; 44 | x1 &= b; 45 | x2 &= b; 46 | x3 &= b; 47 | x4 &= b; 48 | x5 &= b; 49 | x6 &= b; 50 | x7 &= b; 51 | x8 &= b; 52 | x9 &= b; 53 | f[0] = f0 ^ x0; 54 | f[1] = f1 ^ x1; 55 | f[2] = f2 ^ x2; 56 | f[3] = f3 ^ x3; 57 | f[4] = f4 ^ x4; 58 | f[5] = f5 ^ x5; 59 | f[6] = f6 ^ x6; 60 | f[7] = f7 ^ x7; 61 | f[8] = f8 ^ x8; 62 | f[9] = f9 ^ x9; 63 | } 64 | -------------------------------------------------------------------------------- /src/tls.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 and 2012, Dustin Lundquist 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | #ifndef TLS_H 27 | #define TLS_H 28 | 29 | #include "protocol.h" 30 | 31 | const protocol_t *const tls_protocol; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /libipset/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright © 2009-2013, RedJack, LLC. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | • Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | • Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the 14 | distribution. 15 | 16 | • Neither the name of RedJack Software, LLC nor the names of its 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_hash_sha256.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_hash_sha256_H 2 | #define crypto_hash_sha256_H 3 | 4 | /* 5 | * WARNING: Unless you absolutely need to use SHA256 for interoperatibility, 6 | * purposes, you might want to consider crypto_generichash() instead. 7 | * Unlike SHA256, crypto_generichash() is not vulnerable to length 8 | * extension attacks. 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "export.h" 16 | 17 | #ifdef __cplusplus 18 | # if __GNUC__ 19 | # pragma GCC diagnostic ignored "-Wlong-long" 20 | # endif 21 | extern "C" { 22 | #endif 23 | 24 | typedef struct crypto_hash_sha256_state { 25 | uint32_t state[8]; 26 | uint64_t count; 27 | unsigned char buf[64]; 28 | } crypto_hash_sha256_state; 29 | SODIUM_EXPORT 30 | size_t crypto_hash_sha256_statebytes(void); 31 | 32 | #define crypto_hash_sha256_BYTES 32U 33 | SODIUM_EXPORT 34 | size_t crypto_hash_sha256_bytes(void); 35 | 36 | SODIUM_EXPORT 37 | int crypto_hash_sha256(unsigned char *out, const unsigned char *in, 38 | unsigned long long inlen); 39 | 40 | SODIUM_EXPORT 41 | int crypto_hash_sha256_init(crypto_hash_sha256_state *state); 42 | 43 | SODIUM_EXPORT 44 | int crypto_hash_sha256_update(crypto_hash_sha256_state *state, 45 | const unsigned char *in, 46 | unsigned long long inlen); 47 | 48 | SODIUM_EXPORT 49 | int crypto_hash_sha256_final(crypto_hash_sha256_state *state, 50 | unsigned char *out); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_hash_sha512.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_hash_sha512_H 2 | #define crypto_hash_sha512_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 | #include 13 | #include 14 | 15 | #include "export.h" 16 | 17 | #ifdef __cplusplus 18 | # if __GNUC__ 19 | # pragma GCC diagnostic ignored "-Wlong-long" 20 | # endif 21 | extern "C" { 22 | #endif 23 | 24 | typedef struct crypto_hash_sha512_state { 25 | uint64_t state[8]; 26 | uint64_t count[2]; 27 | unsigned char buf[128]; 28 | } crypto_hash_sha512_state; 29 | SODIUM_EXPORT 30 | size_t crypto_hash_sha512_statebytes(void); 31 | 32 | #define crypto_hash_sha512_BYTES 64U 33 | SODIUM_EXPORT 34 | size_t crypto_hash_sha512_bytes(void); 35 | 36 | SODIUM_EXPORT 37 | int crypto_hash_sha512(unsigned char *out, const unsigned char *in, 38 | unsigned long long inlen); 39 | 40 | SODIUM_EXPORT 41 | int crypto_hash_sha512_init(crypto_hash_sha512_state *state); 42 | 43 | SODIUM_EXPORT 44 | int crypto_hash_sha512_update(crypto_hash_sha512_state *state, 45 | const unsigned char *in, 46 | unsigned long long inlen); 47 | 48 | SODIUM_EXPORT 49 | int crypto_hash_sha512_final(crypto_hash_sha512_state *state, 50 | unsigned char *out); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/randombytes.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef randombytes_H 3 | #define randombytes_H 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include "export.h" 11 | 12 | #ifdef __cplusplus 13 | # if __GNUC__ 14 | # pragma GCC diagnostic ignored "-Wlong-long" 15 | # endif 16 | extern "C" { 17 | #endif 18 | 19 | typedef struct randombytes_implementation { 20 | const char *(*implementation_name)(void); /* required */ 21 | uint32_t (*random)(void); /* required */ 22 | void (*stir)(void); /* optional */ 23 | uint32_t (*uniform)(const uint32_t upper_bound); /* optional, a default implementation will be used if NULL */ 24 | void (*buf)(void * const buf, const size_t size); /* required */ 25 | int (*close)(void); /* optional */ 26 | } randombytes_implementation; 27 | 28 | SODIUM_EXPORT 29 | void randombytes_buf(void * const buf, const size_t size); 30 | 31 | SODIUM_EXPORT 32 | uint32_t randombytes_random(void); 33 | 34 | SODIUM_EXPORT 35 | uint32_t randombytes_uniform(const uint32_t upper_bound); 36 | 37 | SODIUM_EXPORT 38 | void randombytes_stir(void); 39 | 40 | SODIUM_EXPORT 41 | int randombytes_close(void); 42 | 43 | SODIUM_EXPORT 44 | int randombytes_set_implementation(randombytes_implementation *impl); 45 | 46 | SODIUM_EXPORT 47 | const char *randombytes_implementation_name(void); 48 | 49 | /* -- NaCl compatibility interface -- */ 50 | 51 | SODIUM_EXPORT 52 | void randombytes(unsigned char * const buf, const unsigned long long buf_len); 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/http.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 and 2012, Dustin Lundquist 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | #ifndef HTTP_H 27 | #define HTTP_H 28 | 29 | #include 30 | #include "protocol.h" 31 | 32 | const protocol_t *const http_protocol; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/acl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * acl.h - Define the ACL interface 3 | * 4 | * Copyright (C) 2013 - 2016, Max Lv 5 | * 6 | * This file is part of the shadowsocks-libev. 7 | * 8 | * shadowsocks-libev is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * shadowsocks-libev is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with shadowsocks-libev; see the file COPYING. If not, see 20 | * . 21 | */ 22 | 23 | #ifndef _ACL_H 24 | #define _ACL_H 25 | 26 | #define BLACK_LIST 0 27 | #define WHITE_LIST 1 28 | 29 | #define MAX_TRIES 64 30 | #define MALICIOUS 8 31 | #define SUSPICIOUS 4 32 | #define BAD 2 33 | #define MALFORMED 1 34 | 35 | int init_acl(const char *path); 36 | void free_acl(void); 37 | void clear_block_list(void); 38 | 39 | int acl_match_host(const char *ip); 40 | int acl_add_ip(const char *ip); 41 | int acl_remove_ip(const char *ip); 42 | 43 | int get_acl_mode(void); 44 | 45 | void init_block_list(); 46 | void free_block_list(); 47 | int check_block_list(char *addr, int err_level); 48 | int remove_from_block_list(char *addr); 49 | 50 | int outbound_block_match_host(const char *host); 51 | 52 | #endif // _ACL_H 53 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/ref10/fe.h: -------------------------------------------------------------------------------- 1 | #ifndef FE_H 2 | #define FE_H 3 | 4 | #include "crypto_int32.h" 5 | 6 | typedef crypto_int32 fe[10]; 7 | 8 | /* 9 | fe means field element. 10 | Here the field is \Z/(2^255-19). 11 | An element t, entries t[0]...t[9], represents the integer 12 | t[0]+2^26 t[1]+2^51 t[2]+2^77 t[3]+2^102 t[4]+...+2^230 t[9]. 13 | Bounds on each t[i] vary depending on context. 14 | */ 15 | 16 | #define fe_frombytes crypto_scalarmult_curve25519_ref10_fe_frombytes 17 | #define fe_tobytes crypto_scalarmult_curve25519_ref10_fe_tobytes 18 | #define fe_copy crypto_scalarmult_curve25519_ref10_fe_copy 19 | #define fe_0 crypto_scalarmult_curve25519_ref10_fe_0 20 | #define fe_1 crypto_scalarmult_curve25519_ref10_fe_1 21 | #define fe_cswap crypto_scalarmult_curve25519_ref10_fe_cswap 22 | #define fe_add crypto_scalarmult_curve25519_ref10_fe_add 23 | #define fe_sub crypto_scalarmult_curve25519_ref10_fe_sub 24 | #define fe_mul crypto_scalarmult_curve25519_ref10_fe_mul 25 | #define fe_sq crypto_scalarmult_curve25519_ref10_fe_sq 26 | #define fe_mul121666 crypto_scalarmult_curve25519_ref10_fe_mul121666 27 | #define fe_invert crypto_scalarmult_curve25519_ref10_fe_invert 28 | 29 | extern void fe_frombytes(fe,const unsigned char *); 30 | extern void fe_tobytes(unsigned char *,fe); 31 | 32 | extern void fe_copy(fe,fe); 33 | extern void fe_0(fe); 34 | extern void fe_1(fe); 35 | extern void fe_cswap(fe,fe,unsigned int); 36 | 37 | extern void fe_add(fe,fe,fe); 38 | extern void fe_sub(fe,fe,fe); 39 | extern void fe_mul(fe,fe,fe); 40 | extern void fe_sq(fe,fe); 41 | extern void fe_mul121666(fe,fe); 42 | extern void fe_invert(fe,fe); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /libcork/include/libcork/cli/commands.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_COMMANDS_H 12 | #define LIBCORK_COMMANDS_H 13 | 14 | #include 15 | 16 | 17 | typedef void 18 | (*cork_leaf_command_run)(int argc, char **argv); 19 | 20 | typedef int 21 | (*cork_option_parser)(int argc, char **argv); 22 | 23 | enum cork_command_type { 24 | CORK_COMMAND_SET, 25 | CORK_LEAF_COMMAND 26 | }; 27 | 28 | struct cork_command { 29 | enum cork_command_type type; 30 | const char *name; 31 | const char *short_desc; 32 | const char *usage_suffix; 33 | const char *full_help; 34 | 35 | int 36 | (*parse_options)(int argc, char **argv); 37 | 38 | struct cork_command **set; 39 | cork_leaf_command_run run; 40 | }; 41 | 42 | #define cork_command_set(name, sd, parse_options, set) \ 43 | { \ 44 | CORK_COMMAND_SET, name, sd, NULL, NULL, \ 45 | parse_options, set, NULL \ 46 | } 47 | 48 | #define cork_leaf_command(name, sd, us, fh, parse_options, run) \ 49 | { \ 50 | CORK_LEAF_COMMAND, name, sd, us, fh, \ 51 | parse_options, NULL, run \ 52 | } 53 | 54 | CORK_API void 55 | cork_command_show_help(struct cork_command *command, const char *message); 56 | 57 | CORK_API int 58 | cork_command_main(struct cork_command *root, int argc, char **argv); 59 | 60 | 61 | #endif /* LIBCORK_COMMANDS_H */ 62 | -------------------------------------------------------------------------------- /src/socks5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * socks5.h - Define SOCKS5's header 3 | * 4 | * Copyright (C) 2013, clowwindy 5 | * 6 | * This file is part of the shadowsocks-libev. 7 | * 8 | * shadowsocks-libev is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * shadowsocks-libev is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with shadowsocks-libev; see the file COPYING. If not, see 20 | * . 21 | */ 22 | 23 | #ifndef _SOCKS5_H 24 | #define _SOCKS5_H 25 | 26 | #define SVERSION 0x05 27 | #define CONNECT 0x01 28 | #define IPV4 0x01 29 | #define DOMAIN 0x03 30 | #define IPV6 0x04 31 | #define CMD_NOT_SUPPORTED 0x07 32 | 33 | #pragma pack(push) 34 | #pragma pack(1) 35 | 36 | struct method_select_request { 37 | char ver; 38 | char nmethods; 39 | char methods[255]; 40 | }; 41 | 42 | struct method_select_response { 43 | char ver; 44 | char method; 45 | }; 46 | 47 | struct socks5_request { 48 | char ver; 49 | char cmd; 50 | char rsv; 51 | char atyp; 52 | }; 53 | 54 | struct socks5_response { 55 | char ver; 56 | char rep; 57 | char rsv; 58 | char atyp; 59 | }; 60 | 61 | #pragma pack(pop) 62 | 63 | #endif // _SOCKS5_H 64 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_scalarmult/curve25519/sandy2x/fe51_invert.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is adapted from amd64-51/fe25519_invert.c: 3 | Loops of squares are replaced by nsquares for better performance. 4 | */ 5 | 6 | #include "fe51.h" 7 | 8 | #ifdef HAVE_AVX_ASM 9 | 10 | #define fe51_square(x, y) fe51_nsquare(x, y, 1) 11 | 12 | void fe51_invert(fe51 *r, const fe51 *x) 13 | { 14 | fe51 z2; 15 | fe51 z9; 16 | fe51 z11; 17 | fe51 z2_5_0; 18 | fe51 z2_10_0; 19 | fe51 z2_20_0; 20 | fe51 z2_50_0; 21 | fe51 z2_100_0; 22 | fe51 t; 23 | 24 | /* 2 */ fe51_square(&z2,x); 25 | /* 4 */ fe51_square(&t,&z2); 26 | /* 8 */ fe51_square(&t,&t); 27 | /* 9 */ fe51_mul(&z9,&t,x); 28 | /* 11 */ fe51_mul(&z11,&z9,&z2); 29 | /* 22 */ fe51_square(&t,&z11); 30 | /* 2^5 - 2^0 = 31 */ fe51_mul(&z2_5_0,&t,&z9); 31 | 32 | /* 2^10 - 2^5 */ fe51_nsquare(&t,&z2_5_0, 5); 33 | /* 2^10 - 2^0 */ fe51_mul(&z2_10_0,&t,&z2_5_0); 34 | 35 | /* 2^20 - 2^10 */ fe51_nsquare(&t,&z2_10_0, 10); 36 | /* 2^20 - 2^0 */ fe51_mul(&z2_20_0,&t,&z2_10_0); 37 | 38 | /* 2^40 - 2^20 */ fe51_nsquare(&t,&z2_20_0, 20); 39 | /* 2^40 - 2^0 */ fe51_mul(&t,&t,&z2_20_0); 40 | 41 | /* 2^50 - 2^10 */ fe51_nsquare(&t,&t,10); 42 | /* 2^50 - 2^0 */ fe51_mul(&z2_50_0,&t,&z2_10_0); 43 | 44 | /* 2^100 - 2^50 */ fe51_nsquare(&t,&z2_50_0, 50); 45 | /* 2^100 - 2^0 */ fe51_mul(&z2_100_0,&t,&z2_50_0); 46 | 47 | /* 2^200 - 2^100 */ fe51_nsquare(&t,&z2_100_0, 100); 48 | /* 2^200 - 2^0 */ fe51_mul(&t,&t,&z2_100_0); 49 | 50 | /* 2^250 - 2^50 */ fe51_nsquare(&t,&t, 50); 51 | /* 2^250 - 2^0 */ fe51_mul(&t,&t,&z2_50_0); 52 | 53 | /* 2^255 - 2^5 */ fe51_nsquare(&t,&t,5); 54 | /* 2^255 - 21 */ fe51_mul(r,&t,&z11); 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/include/sodium/crypto_stream_salsa20.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_stream_salsa20_H 2 | #define crypto_stream_salsa20_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 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_stream_salsa20_KEYBYTES 32U 24 | SODIUM_EXPORT 25 | size_t crypto_stream_salsa20_keybytes(void); 26 | 27 | #define crypto_stream_salsa20_NONCEBYTES 8U 28 | SODIUM_EXPORT 29 | size_t crypto_stream_salsa20_noncebytes(void); 30 | 31 | SODIUM_EXPORT 32 | int crypto_stream_salsa20(unsigned char *c, unsigned long long clen, 33 | const unsigned char *n, const unsigned char *k); 34 | 35 | SODIUM_EXPORT 36 | int crypto_stream_salsa20_xor(unsigned char *c, const unsigned char *m, 37 | unsigned long long mlen, const unsigned char *n, 38 | const unsigned char *k); 39 | 40 | SODIUM_EXPORT 41 | int crypto_stream_salsa20_xor_ic(unsigned char *c, const unsigned char *m, 42 | unsigned long long mlen, 43 | const unsigned char *n, uint64_t ic, 44 | const unsigned char *k); 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /libsodium/src/libsodium/crypto_stream/salsa20/ref/xor_salsa20_ref.c: -------------------------------------------------------------------------------- 1 | /* 2 | version 20140420 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #include 8 | 9 | #include "crypto_core_salsa20.h" 10 | #include "crypto_stream_salsa20.h" 11 | #include "utils.h" 12 | 13 | #ifndef HAVE_AMD64_ASM 14 | 15 | typedef unsigned int uint32; 16 | 17 | static const unsigned char sigma[16] = { 18 | 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3', '2', '-', 'b', 'y', 't', 'e', ' ', 'k' 19 | }; 20 | 21 | int crypto_stream_salsa20_xor_ic( 22 | unsigned char *c, 23 | const unsigned char *m,unsigned long long mlen, 24 | const unsigned char *n, uint64_t ic, 25 | const unsigned char *k 26 | ) 27 | { 28 | unsigned char in[16]; 29 | unsigned char block[64]; 30 | unsigned char kcopy[32]; 31 | unsigned int i; 32 | unsigned int u; 33 | 34 | if (!mlen) return 0; 35 | 36 | for (i = 0;i < 32;++i) kcopy[i] = k[i]; 37 | for (i = 0;i < 8;++i) in[i] = n[i]; 38 | for (i = 8;i < 16;++i) { 39 | in[i] = (unsigned char) (ic & 0xff); 40 | ic >>= 8; 41 | } 42 | 43 | while (mlen >= 64) { 44 | crypto_core_salsa20(block,in,kcopy,sigma); 45 | for (i = 0;i < 64;++i) c[i] = m[i] ^ block[i]; 46 | 47 | u = 1; 48 | for (i = 8;i < 16;++i) { 49 | u += (unsigned int) in[i]; 50 | in[i] = u; 51 | u >>= 8; 52 | } 53 | 54 | mlen -= 64; 55 | c += 64; 56 | m += 64; 57 | } 58 | 59 | if (mlen) { 60 | crypto_core_salsa20(block,in,kcopy,sigma); 61 | for (i = 0;i < (unsigned int) mlen;++i) c[i] = m[i] ^ block[i]; 62 | } 63 | sodium_memzero(block, sizeof block); 64 | sodium_memzero(kcopy, sizeof kcopy); 65 | 66 | return 0; 67 | } 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/protocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014, Dustin Lundquist 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | #ifndef PROTOCOL_H 27 | #define PROTOCOL_H 28 | 29 | typedef struct protocol { 30 | const int default_port; 31 | int(*const parse_packet)(const char *, size_t, char **); 32 | } protocol_t; 33 | 34 | #endif 35 | --------------------------------------------------------------------------------