From f8fe525f3868134cd876defd8b1657664c0afe59 Mon Sep 17 00:00:00 2001
From: gpotter2 <gabriel@potter.fr>
Date: Tue, 22 Aug 2017 20:33:04 +0200
Subject: [PATCH] Fix Exception format

---
 scapy/ansmachine.py                      |  2 +-
 scapy/layers/tls/crypto/cipher_aead.py   | 16 ++++++++--------
 scapy/layers/tls/crypto/cipher_block.py  |  4 ++--
 scapy/layers/tls/crypto/cipher_stream.py |  4 ++--
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/scapy/ansmachine.py b/scapy/ansmachine.py
index 8c4e511c..ddc3a935 100644
--- a/scapy/ansmachine.py
+++ b/scapy/ansmachine.py
@@ -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)
diff --git a/scapy/layers/tls/crypto/cipher_aead.py b/scapy/layers/tls/crypto/cipher_aead.py
index 50dd862a..8efc1f8b 100644
--- a/scapy/layers/tls/crypto/cipher_aead.py
+++ b/scapy/layers/tls/crypto/cipher_aead.py
@@ -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):
diff --git a/scapy/layers/tls/crypto/cipher_block.py b/scapy/layers/tls/crypto/cipher_block.py
index 33cc6448..bd2b04f0 100644
--- a/scapy/layers/tls/crypto/cipher_block.py
+++ b/scapy/layers/tls/crypto/cipher_block.py
@@ -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:]
diff --git a/scapy/layers/tls/crypto/cipher_stream.py b/scapy/layers/tls/crypto/cipher_stream.py
index 26d85d39..484d52ad 100644
--- a/scapy/layers/tls/crypto/cipher_stream.py
+++ b/scapy/layers/tls/crypto/cipher_stream.py
@@ -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)
 
-- 
GitLab