Merge bdecdaf546
into 8e8ee5d490
This commit is contained in:
commit
562c55cd20
2 changed files with 19 additions and 2 deletions
2
setup.py
2
setup.py
|
@ -7,7 +7,7 @@ with codecs.open('README.rst', encoding='utf-8') as f:
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="shadowsocks",
|
name="shadowsocks",
|
||||||
version="2.8.2",
|
version="2.9.0",
|
||||||
license='http://www.apache.org/licenses/LICENSE-2.0',
|
license='http://www.apache.org/licenses/LICENSE-2.0',
|
||||||
description="A fast tunnel proxy that help you get through firewalls",
|
description="A fast tunnel proxy that help you get through firewalls",
|
||||||
author='clowwindy',
|
author='clowwindy',
|
||||||
|
|
|
@ -29,7 +29,7 @@ loaded = False
|
||||||
|
|
||||||
buf_size = 2048
|
buf_size = 2048
|
||||||
|
|
||||||
# for salsa20 and chacha20
|
# for salsa20 and chacha20 and chacha20-ietf
|
||||||
BLOCK_SIZE = 64
|
BLOCK_SIZE = 64
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,6 +51,11 @@ def load_libsodium():
|
||||||
c_ulonglong,
|
c_ulonglong,
|
||||||
c_char_p, c_ulonglong,
|
c_char_p, c_ulonglong,
|
||||||
c_char_p)
|
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,
|
||||||
|
c_ulonglong,
|
||||||
|
c_char_p, c_ulong,
|
||||||
|
c_char_p)
|
||||||
|
|
||||||
buf = create_string_buffer(buf_size)
|
buf = create_string_buffer(buf_size)
|
||||||
loaded = True
|
loaded = True
|
||||||
|
@ -68,6 +73,8 @@ class SodiumCrypto(object):
|
||||||
self.cipher = libsodium.crypto_stream_salsa20_xor_ic
|
self.cipher = libsodium.crypto_stream_salsa20_xor_ic
|
||||||
elif cipher_name == 'chacha20':
|
elif cipher_name == 'chacha20':
|
||||||
self.cipher = libsodium.crypto_stream_chacha20_xor_ic
|
self.cipher = libsodium.crypto_stream_chacha20_xor_ic
|
||||||
|
elif cipher_name == 'chacha20-ietf':
|
||||||
|
self.cipher = libsodium.crypto_stream_chacha20_ietf_xor_ic
|
||||||
else:
|
else:
|
||||||
raise Exception('Unknown cipher')
|
raise Exception('Unknown cipher')
|
||||||
# byte counter, not block counter
|
# byte counter, not block counter
|
||||||
|
@ -97,6 +104,7 @@ class SodiumCrypto(object):
|
||||||
ciphers = {
|
ciphers = {
|
||||||
'salsa20': (32, 8, SodiumCrypto),
|
'salsa20': (32, 8, SodiumCrypto),
|
||||||
'chacha20': (32, 8, SodiumCrypto),
|
'chacha20': (32, 8, SodiumCrypto),
|
||||||
|
'chacha20-ietf': (32, 12, SodiumCrypto),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,6 +123,15 @@ def test_chacha20():
|
||||||
util.run_cipher(cipher, decipher)
|
util.run_cipher(cipher, decipher)
|
||||||
|
|
||||||
|
|
||||||
|
def test_chacha20_ietf():
|
||||||
|
|
||||||
|
cipher = SodiumCrypto('chacha20-ietf', b'k' * 32, b'i' * 16, 1)
|
||||||
|
decipher = SodiumCrypto('chacha20-ietf', b'k' * 32, b'i' * 16, 0)
|
||||||
|
|
||||||
|
util.run_cipher(cipher, decipher)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
test_chacha20_ietf()
|
||||||
test_chacha20()
|
test_chacha20()
|
||||||
test_salsa20()
|
test_salsa20()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue