Skip to content
Snippets Groups Projects
Commit f8fe525f authored by gpotter2's avatar gpotter2
Browse files

Fix Exception format

parent 3d113a91
No related branches found
No related tags found
No related merge requests found
......@@ -55,7 +55,7 @@ class AnsweringMachine(six.with_metaclass(ReferenceAM, object)):
for d in [self.optam2, self.optam1]:
if attr in d:
return d[attr]
raise AttributeError,attr
raise AttributeError(attr)
def __setattr__(self, attr, val):
mode = self.__dict__.get("mode",0)
......
......@@ -136,7 +136,7 @@ class _AEADCipher(six.with_metaclass(_AEADCipherMetaclass, object)):
actually is a _AEADCipher_TLS13 (even though others are not).
"""
if False in six.itervalues(self.ready):
raise CipherError, (P, A)
raise CipherError(P, A)
if hasattr(self, "pc_cls"):
self._cipher.mode._initialization_vector = self._get_nonce()
......@@ -180,7 +180,7 @@ class _AEADCipher(six.with_metaclass(_AEADCipherMetaclass, object)):
C[-self.tag_len:])
if False in six.itervalues(self.ready):
raise CipherError, (nonce_explicit_str, C, mac)
raise CipherError(nonce_explicit_str, C, mac)
self.nonce_explicit = pkcs_os2ip(nonce_explicit_str)
if add_length:
......@@ -195,7 +195,7 @@ class _AEADCipher(six.with_metaclass(_AEADCipherMetaclass, object)):
try:
decryptor.finalize()
except InvalidTag:
raise AEADTagError, (nonce_explicit_str, P, mac)
raise AEADTagError(nonce_explicit_str, P, mac)
else:
try:
if isinstance(self._cipher, AESCCM):
......@@ -204,7 +204,7 @@ class _AEADCipher(six.with_metaclass(_AEADCipherMetaclass, object)):
else:
P = self._cipher.decrypt(self._get_nonce(), C + mac, A)
except InvalidTag:
raise AEADTagError, (nonce_explicit_str,
raise AEADTagError(nonce_explicit_str,
"<unauthenticated data>",
mac)
return nonce_explicit_str, P, mac
......@@ -308,7 +308,7 @@ class _AEADCipher_TLS13(object):
Note that the cipher's authentication tag must be None when encrypting.
"""
if False in self.ready.itervalues():
raise CipherError, (P, A)
raise CipherError(P, A)
if hasattr(self, "pc_cls"):
self._cipher.mode._tag = None
......@@ -336,7 +336,7 @@ class _AEADCipher_TLS13(object):
"""
C, mac = C[:-self.tag_len], C[-self.tag_len:]
if False in self.ready.itervalues():
raise CipherError, (C, mac)
raise CipherError(C, mac)
if hasattr(self, "pc_cls"):
self._cipher.mode._initialization_vector = self._get_nonce(seq_num)
......@@ -347,7 +347,7 @@ class _AEADCipher_TLS13(object):
try:
decryptor.finalize()
except InvalidTag:
raise AEADTagError, (P, mac)
raise AEADTagError(P, mac)
else:
try:
if (conf.crypto_valid_advanced and
......@@ -360,7 +360,7 @@ class _AEADCipher_TLS13(object):
A += struct.pack("!H", len(C))
P = self._cipher.decrypt(self._get_nonce(seq_num), C + mac, A)
except InvalidTag:
raise AEADTagError, ("<unauthenticated data>", mac)
raise AEADTagError("<unauthenticated data>", mac)
return P, mac
def snapshot(self):
......
......@@ -81,7 +81,7 @@ class _BlockCipher(six.with_metaclass(_BlockCipherMetaclass, object)):
and TLS 1.0. For TLS 1.1/1.2, it is overwritten in TLS.post_build().
"""
if False in six.itervalues(self.ready):
raise CipherError, data
raise CipherError(data)
encryptor = self._cipher.encryptor()
tmp = encryptor.update(data) + encryptor.finalize()
self.iv = tmp[-self.block_size:]
......@@ -94,7 +94,7 @@ class _BlockCipher(six.with_metaclass(_BlockCipherMetaclass, object)):
If we lack the key, we raise a CipherError which contains the input.
"""
if False in six.itervalues(self.ready):
raise CipherError, data
raise CipherError(data)
decryptor = self._cipher.decryptor()
tmp = decryptor.update(data) + decryptor.finalize()
self.iv = data[-self.block_size:]
......
......@@ -82,13 +82,13 @@ class _StreamCipher(six.with_metaclass(_StreamCipherMetaclass, object)):
def encrypt(self, data):
if False in six.itervalues(self.ready):
raise CipherError, data
raise CipherError(data)
self._enc_updated_with += data
return self.encryptor.update(data)
def decrypt(self, data):
if False in six.itervalues(self.ready):
raise CipherError, data
raise CipherError(data)
self._dec_updated_with += data
return self.decryptor.update(data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment