Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
clowwindy committed May 3, 2014
1 parent ed39505 commit fd4efca
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 8 deletions.
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
----

Expand Down
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 2 additions & 1 deletion shadowsocks/encrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ def get_cipher(self, password, method, op, iv=None):
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':
Expand Down
4 changes: 2 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ def get_table(key):
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

Expand Down
File renamed without changes.
10 changes: 10 additions & 0 deletions test/salsa20.json
Original file line number Diff line number Diff line change
@@ -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
}
10 changes: 10 additions & 0 deletions test/table.json
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit fd4efca

Please sign in to comment.