3 y�_s �@sHddlmZmZmZddlmZddlmZdZdZ Gdd�de �Z dS) �)�absolute_import�division�print_function)�InvalidSignature)� constant_time�� c@s,eZdZdd�Zdd�Zdd�Zdd�Zd S) �_Poly1305ContextcCs�||_|jjj|�}|jjj|jjj|jjj|t|��}|jj||jjjk�|jjj ||jjj �|_ |jjj �}|jj||jjjk�|jjj ||jjj �|_|jjj|j|jjj|jjj|jjj|j �}|jj|dk�dS)N�)�_backend�_ffi� from_buffer�_libZEVP_PKEY_new_raw_private_keyZ NID_poly1305ZNULL�len�openssl_assert�gcZ EVP_PKEY_freeZ _evp_pkeyZCryptography_EVP_MD_CTX_newZCryptography_EVP_MD_CTX_free�_ctxZEVP_DigestSignInit)�selfZbackend�keyZkey_ptrZevp_pkeyZctx�res�r� /usr/lib64/python3.6/poly1305.py�__init__s*  z_Poly1305Context.__init__cCs:|jjj|�}|jjj|j|t|��}|jj|dk�dS)Nr)r r r rZEVP_DigestSignUpdaterrr)r�dataZdata_ptrrrrr�update/sz_Poly1305Context.updatecCsp|jjjdt�}|jjjd�}|jjj|j||�}|jj|dk�|jj|dtk�|jjj|�d|d�S)Nzunsigned char[]zsize_t *r) r r �new�_POLY1305_TAG_SIZErZEVP_DigestSignFinalrr�buffer)rZbufZoutlenrrrr�finalize6s z_Poly1305Context.finalizecCs |j�}tj||�std��dS)Nz!Value did not match computed tag.)rrZbytes_eqr)r�tagZmacrrr�verify>s z_Poly1305Context.verifyN)�__name__� __module__� __qualname__rrrr rrrrr sr N) Z __future__rrrZcryptography.exceptionsrZcryptography.hazmat.primitivesrrZ_POLY1305_KEY_SIZE�objectr rrrr�s