Skip to content

Commit

Permalink
fix salsa20 for UDP
Browse files Browse the repository at this point in the history
  • Loading branch information
clowwindy committed Jul 11, 2014
1 parent 040c956 commit 2950f99
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions shadowsocks/encrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,12 @@ def encrypt_all(password, method, op, data):
else:
iv = data[:iv_len]
data = data[iv_len:]
cipher = M2Crypto.EVP.Cipher(method.replace('-', '_'), key, iv, op,
key_as_bytes=0, d='md5', salt=None, i=1,
padding=1)
if method != 'salsa20-ctr':
cipher = M2Crypto.EVP.Cipher(method.replace('-', '_'), key, iv,
op, key_as_bytes=0, d='md5',
salt=None, i=1, padding=1)
else:
cipher = encrypt_salsa20.Salsa20Cipher(method, key, iv, op)
result.append(cipher.update(data))
f = cipher.final()
if f:
Expand Down

0 comments on commit 2950f99

Please sign in to comment.