Browse Source

only test some ciphers

auth
clowwindy 10 years ago
parent
commit
1459282ae6
  1. 15
      shadowsocks/encrypt.py

15
shadowsocks/encrypt.py

@ -165,11 +165,20 @@ def encrypt_all(password, method, op, data):
return b''.join(result) return b''.join(result)
CIPHERS_TO_TEST = [
b'aes-128-cfb',
b'aes-256-cfb',
b'rc4-md5',
b'salsa20',
b'chacha20',
b'table',
]
def test_encryptor(): def test_encryptor():
from os import urandom from os import urandom
plain = urandom(10240) plain = urandom(10240)
for method in method_supported.keys(): for method in CIPHERS_TO_TEST:
logging.warn('testing %s' % method.decode('utf-8'))
encryptor = Encryptor(b'key', method) encryptor = Encryptor(b'key', method)
cipher = encryptor.encrypt(plain) cipher = encryptor.encrypt(plain)
decryptor = Encryptor(b'key', method) decryptor = Encryptor(b'key', method)
@ -180,7 +189,7 @@ def test_encryptor():
def test_encrypt_all(): def test_encrypt_all():
from os import urandom from os import urandom
plain = urandom(10240) plain = urandom(10240)
for method in method_supported.keys(): for method in CIPHERS_TO_TEST:
cipher = encrypt_all(b'key', method, 1, plain) cipher = encrypt_all(b'key', method, 1, plain)
plain2 = encrypt_all(b'key', method, 0, cipher) plain2 = encrypt_all(b'key', method, 0, cipher)
assert plain == plain2 assert plain == plain2

Loading…
Cancel
Save