コード例 #1
0
    def test_prefix_aes_ecb_decryption(self):
        """Challenge 14"""
        prefix = Crypto.gen_random_key(18)
        target = "This is the target"
        quote = lambda text: text
        oracle, _, _ = Crypto.generate_aes_oracle(prefix, target, AES.MODE_ECB,
                                                  quote)
        self.assertEqual(target, Crypto.decrypts_aes_ecb_byte_wise(oracle))

        target = "A" * 16
        oracle, _, _ = Crypto.generate_aes_oracle(prefix, target, AES.MODE_ECB,
                                                  quote)
        self.assertEqual(target, Crypto.decrypts_aes_ecb_byte_wise(oracle))
コード例 #2
0
 def test_aes_ecb_decryption(self):
     """Challenge 12"""
     data = Crypto.get_lines('data/12.txt')[0]
     target = base64.b64decode(data)
     quote = lambda text: text
     oracle, _, _ = Crypto.generate_aes_oracle('', target, AES.MODE_ECB,
                                               quote)
     text = Crypto.decrypts_aes_ecb_byte_wise(oracle)
     self.assertEqual(target, text)