From 2950f99da6c42dd08e8ddabd5d1b62061c18efc5 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Fri, 11 Jul 2014 18:46:26 +0800 Subject: [PATCH] fix salsa20 for UDP --- shadowsocks/encrypt.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/shadowsocks/encrypt.py b/shadowsocks/encrypt.py index fc6b5ce..a590645 100644 --- a/shadowsocks/encrypt.py +++ b/shadowsocks/encrypt.py @@ -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: