def test(): aead = aes_siv.AES_SIV() print("Key: ", hexlify(key), "(%d bytes)" % len(key)) print("AD: ", hexlify(ad), "(%d bytes)" % len(ad)) print("Nonce:", hexlify(nonce), "(%d bytes)" % len(nonce)) print("Plain:", hexlify(plaintext), "(%d bytes)" % len(plaintext)) print() ciphertext = aead.encrypt(key, nonce, plaintext, ad) print() print("Out: ", hexlify(ciphertext), "(%d bytes)" % len(ciphertext)) print()
def get_aead(self): if self.aead is None: self.aead = aes_siv.AES_SIV() return self.aead
def __init__(self): self.aead = aes_siv.AES_SIV()
import binascii import sys def unhexlify(s): return binascii.unhexlify(''.join(s.strip().split())) def hexlify(d): return ' '.join([ binascii.hexlify(d[i:i + 4]).decode('ASCII') for i in range(0, len(d), 4) ]) aead = aes_siv.AES_SIV() def test_encrypt(): print("Key: ", hexlify(key), "(%d bytes)" % len(key)) if nonce is None: print("Nonce:", None) else: print("Nonce:", hexlify(nonce), "(%d bytes)" % len(nonce)) if ad is None: print("AD: ", None) else: print("AD: ", hexlify(ad), "(%d bytes)" % len(ad)) print("Plain:", hexlify(plaintext), "(%d bytes)" % len(plaintext)) print()