From ddcf7f796f50aa766f22411112c4b5338547f822 Mon Sep 17 00:00:00 2001 From: BreakWa11 Date: Tue, 22 Dec 2015 11:22:46 +0800 Subject: [PATCH] ignore error if not support "chacha20-ietf" --- shadowsocks/crypto/sodium.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/shadowsocks/crypto/sodium.py b/shadowsocks/crypto/sodium.py index fde5b16..ad1f48f 100644 --- a/shadowsocks/crypto/sodium.py +++ b/shadowsocks/crypto/sodium.py @@ -29,7 +29,7 @@ loaded = False buf_size = 2048 -# for salsa20 and chacha20 +# for salsa20 and chacha20 and chacha20-ietf BLOCK_SIZE = 64 @@ -52,11 +52,14 @@ def load_libsodium(): c_char_p, c_ulonglong, c_char_p) - libsodium.crypto_stream_chacha20_ietf_xor_ic.restype = c_int - libsodium.crypto_stream_chacha20_ietf_xor_ic.argtypes = (c_void_p, c_char_p, + try: + libsodium.crypto_stream_chacha20_ietf_xor_ic.restype = c_int + libsodium.crypto_stream_chacha20_ietf_xor_ic.argtypes = (c_void_p, c_char_p, c_ulonglong, c_char_p, c_ulonglong, c_char_p) + except: + pass buf = create_string_buffer(buf_size) loaded = True