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