diff --git a/.travis.yml b/.travis.yml index 21260a8..0be4bde 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,9 @@ python: - 2.7 before_install: - sudo apt-get update -qq - - sudo apt-get install -qq build-essential libssl-dev swig libevent-dev python-gevent python-m2crypto - - pip install gevent m2crypto + - sudo apt-get install -qq build-essential libssl-dev swig libevent-dev python-gevent python-m2crypto python-numpy + - pip install gevent m2crypto salsa20 script: - - python test.py + - python test.py -c test/table.json + - python test.py -c test/aes.json + - python test.py -c test/salsa20.json diff --git a/README.md b/README.md index c541a90..356bc57 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Install Shadowsocks. #### Debian / Ubuntu: - apt-get install python-gevent python-m2crypto + apt-get install python-pip python-gevent python-m2crypto pip install shadowsocks #### CentOS: @@ -94,6 +94,20 @@ You can use args to override settings from `config.json`. ssserver -p server_port -k password -m bf-cfb ssserver -c /etc/shadowsocks/config.json +Salsa20 +------- + +Salsa20 is a fast stream cipher. + +Use "salsa20-ctr" in shadowsocks.json. + +And install these packages: + +#### Debian / Ubuntu: + + apt-get install python-numpy + pip install salsa20 + Wiki ---- diff --git a/config.json b/config.json index 5c9656b..026ed38 100644 --- a/config.json +++ b/config.json @@ -4,7 +4,7 @@ "local_port":1080, "password":"barfoo!", "timeout":300, - "method":"table", + "method":"aes-256-cfb", "local_address":"127.0.0.1", "fast_open":false } diff --git a/shadowsocks/encrypt.py b/shadowsocks/encrypt.py index fcaad99..267565c 100644 --- a/shadowsocks/encrypt.py +++ b/shadowsocks/encrypt.py @@ -151,7 +151,8 @@ class Encryptor(object): if m: key, iv_ = EVP_BytesToKey(password, m[0], m[1]) if iv is None: - iv = iv_[:m[1]] + iv = iv_ + iv = iv[:m[1]] if op == 1: self.cipher_iv = iv[:m[1]] # this iv is for cipher not decipher if method != 'salsa20-ctr': diff --git a/test.py b/test.py index e2b6f16..130aee4 100755 --- a/test.py +++ b/test.py @@ -82,9 +82,9 @@ decrypt_table = string.maketrans(encrypt_table, string.maketrans('', '')) for i in range(0, 256): assert(target2[0][i] == ord(encrypt_table[i])) assert(target2[1][i] == ord(decrypt_table[i])) -p1 = Popen(['python', 'shadowsocks/server.py', '-c', 'test/config.json'], shell=False, bufsize=0, stdin=PIPE, +p1 = Popen(['python', 'shadowsocks/server.py', '-c', sys.argv[-1]], shell=False, bufsize=0, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) -p2 = Popen(['python', 'shadowsocks/local.py', '-c', 'test/config.json'], shell=False, bufsize=0, stdin=PIPE, +p2 = Popen(['python', 'shadowsocks/local.py', '-c', sys.argv[-1]], shell=False, bufsize=0, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) p3 = None diff --git a/test/config.json b/test/aes.json similarity index 100% rename from test/config.json rename to test/aes.json diff --git a/test/salsa20.json b/test/salsa20.json new file mode 100644 index 0000000..8035f06 --- /dev/null +++ b/test/salsa20.json @@ -0,0 +1,10 @@ +{ + "server":"127.0.0.1", + "server_port":8388, + "local_port":1080, + "password":"barfoo!", + "timeout":300, + "method":"salsa20-ctr", + "local_address":"127.0.0.1", + "fast_open":false +} diff --git a/test/table.json b/test/table.json new file mode 100644 index 0000000..4b1c984 --- /dev/null +++ b/test/table.json @@ -0,0 +1,10 @@ +{ + "server":"127.0.0.1", + "server_port":8388, + "local_port":1080, + "password":"barfoo!", + "timeout":300, + "method":"table", + "local_address":"127.0.0.1", + "fast_open":false +}