def decrypt(self, msg):
        """decrypt a message"""
        error = False
        signature = msg[0:SHA256.digest_size]
        iv = msg[SHA256.digest_size:SHA256.digest_size + AES.block_size]
        cipher_text = msg[SHA256.digest_size + AES.block_size:]
        if self.sign(iv + cipher_text) != signature:
            error = True
        ctr = Counter.new(AES.block_size * 8, initial_value=self.bin2long(iv))
        cipher = AES.AESCipher(self._cipherkey, AES.MODE_CTR, counter=ctr)
        plain_text = cipher.decrypt(cipher_text)
        if error:
            raise DecryptionError
        return plain_text
def decrypt ( self , msg ) : error = False signature = msg [ 0 : SHA256 . digest_size ] iv = msg [ SHA256 . digest_size : SHA256 . digest_size + AES . block_size ] cipher_text = msg [ SHA256 . digest_size + AES . block_size : ] if self . sign ( iv + cipher_text ) != signature : error = True ctr = Counter . new ( AES . block_size * 8 , initial_value = self . bin2long ( iv ) ) cipher = AES . AESCipher ( self . _cipherkey , AES . MODE_CTR , counter = ctr ) plain_text = cipher . decrypt ( cipher_text ) if error : raise DecryptionError return plain_text
decrypt a message