From 039451bcfbafe657d3cc668ff0dd29aec3408041 Mon Sep 17 00:00:00 2001 From: clowwindy Date: Wed, 5 Nov 2014 18:30:18 +0800 Subject: [PATCH] fix encrypt_all --- shadowsocks/encrypt.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/shadowsocks/encrypt.py b/shadowsocks/encrypt.py index 610fc29..9733bbb 100644 --- a/shadowsocks/encrypt.py +++ b/shadowsocks/encrypt.py @@ -77,7 +77,7 @@ def EVP_BytesToKey(password, key_len, iv_len): key = ms[:key_len] iv = ms[key_len:key_len + iv_len] cached_keys[password] = (key, iv) - return (key, iv) + return key, iv class Encryptor(object): @@ -148,7 +148,10 @@ def encrypt_all(password, method, op, data): result = [] method = method.lower() (key_len, iv_len, m) = method_supported[method] - (key, _) = EVP_BytesToKey(password, key_len, iv_len) + if key_len > 0: + key, _ = EVP_BytesToKey(password, key_len, iv_len) + else: + key = password if op: iv = random_string(iv_len) result.append(iv)