Fix memory leak
This commit is contained in:
parent
d5026cf5ef
commit
6b43cbbf93
2 changed files with 23 additions and 8 deletions
|
@ -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 = {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue