0?A=$ d Z dgZddlZddlmZ ddlmZmZmZ ddl m
Z
ddlmZ ddl
mZmZ dd lmZmZ dd
lmZ G d de Zd ZdS )
z
EAX mode.
EaxMode N) unhexlify)byte_stringbord_copy_bytes) is_buffer)strxor)
long_to_bytes
bytes_to_long)CMACBLAKE2s)get_random_bytesc V e Zd ZdZd Zd Zd
dZd
dZd Zd Z d Z
d
Zd
dZd
dZ
dS )r a *EAX* mode.
This is an Authenticated Encryption with Associated Data
(`AEAD`_) mode. It provides both confidentiality and authenticity.
The header of the message may be left in the clear, if needed,
and it will still be subject to authentication.
The decryption step tells the receiver if the message comes
from a source that really knowns the secret key.
Additionally, decryption detects if any part of the message -
including the header - has been modified or corrupted.
This mode requires a *nonce*.
This mode is only available for ciphers that operate on 64 or
128 bits blocks.
There are no official standards defining EAX.
The implementation is based on `a proposal`__ that
was presented to NIST.
.. _AEAD: http://blog.cryptographyengineering.com/2012/05/how-to-choose-authenticated-encryption.html
.. __: http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/eax/eax-spec.pdf
:undocumented: __init__
c j _ t dd| _ | _ d _ g d _ d j cxk r j k sn t
d j z t j dk rt
d t | st d fdt dd D _ j d j j d
_
t j d } j j f|dd _ dS )
zEAX cipher modeNupdateencryptdecryptdigestverify z3'mac_len' must be at least 2 and not larger than %dr z!Nonce cannot be empty in EAX modez,nonce must be bytes, bytearray or memoryviewc
g | ];}t j d j dz
z t j d| z