Skip to content

Commit a82393b

Browse files
committed
Reset enc/dec on set_key failure
1 parent b5ab5b0 commit a82393b

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

wolfcrypt/ciphers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ def encrypt(self, string):
191191
self._enc = _ffi.new(self._native_type)
192192
ret = self._set_key(_ENCRYPTION)
193193
if ret < 0: # pragma: no cover
194+
self._enc = None
194195
raise WolfCryptError("Invalid key error (%d)" % ret)
195196

196197
result = _ffi.new("byte[%d]" % len(string))
@@ -224,6 +225,7 @@ def decrypt(self, string):
224225
self._dec = _ffi.new(self._native_type)
225226
ret = self._set_key(_DECRYPTION)
226227
if ret < 0: # pragma: no cover
228+
self._dec = None
227229
raise WolfCryptError("Invalid key error (%d)" % ret)
228230

229231
result = _ffi.new("byte[%d]" % len(string))

0 commit comments

Comments
 (0)