Пример #1
0
 def test_aes_gcm(self):
     key = b'Sixteen byte key'
     plain_text = b'Attack at dawn'
     hdr = b'To your eyes only'
     nonce, mac, cipher_text = AESHandler.aes_gcm_encrypt(
         plain_text, hdr, key)
     decrypt_out = AESHandler.aes_gcm_decrypt(cipher_text, hdr, nonce, mac,
                                              key)
     self.assertEqual(plain_text, decrypt_out)
Пример #2
0
 def encrypt_with_gcm_mode(plain_text: bytes, hdr: bytes,
                           public_key: bytes):
     aes_key, encode_g_tilde = ECIES.generate_encrypt_aes_key(public_key)
     nonce, mac_tag, cipher_text = AESHandler.aes_gcm_encrypt(
         plain_text, hdr, aes_key)
     return nonce, mac_tag, encode_g_tilde, cipher_text