diff --git a/shadowsocks/crypto/openssl.py b/shadowsocks/crypto/openssl.py index f2948ae..6abeaa6 100644 --- a/shadowsocks/crypto/openssl.py +++ b/shadowsocks/crypto/openssl.py @@ -107,8 +107,11 @@ class OpenSSLCryptoBase(object): if not self._ctx: raise Exception('can not create cipher context') - self.encrypt_once = self.update - self.decrypt_once = self.update + def encrypt_once(self, data): + return self.update(data) + + def decrypt_once(self, data): + return self.update(data) def update(self, data): """ @@ -281,8 +284,12 @@ class OpenSSLStreamCrypto(OpenSSLCryptoBase): if not r: self.clean() raise Exception('can not initialize cipher context') - self.encrypt = self.update - self.decrypt = self.update + + def encrypt(self, data): + return self.update(data) + + def decrypt(self, data): + return self.update(data) ciphers = { diff --git a/shadowsocks/crypto/sodium.py b/shadowsocks/crypto/sodium.py index fce65c0..35927e8 100644 --- a/shadowsocks/crypto/sodium.py +++ b/shadowsocks/crypto/sodium.py @@ -192,10 +192,18 @@ class SodiumCrypto(object): raise Exception('Unknown cipher') # byte counter, not block counter self.counter = 0 - self.encrypt = self.update - self.decrypt = self.update - self.encrypt_once = self.update - self.decrypt_once = self.update + + def encrypt(self, data): + return self.update(data) + + def decrypt(self, data): + return self.update(data) + + def encrypt_once(self, data): + return self.update(data) + + def decrypt_once(self, data): + return self.update(data) def update(self, data): global buf_size, buf