3 Te1 @sddlmZmZmZddlmZddlmZmZm Z ddl m Z ddl m Z ddlmZmZejejejejGdddeZd S) )absolute_importdivisionprint_function)utils)AlreadyFinalizedUnsupportedAlgorithm_Reasons) _get_backend) HMACBackend)hashesmacc@s@eZdZd ddZejdZddZddZd d Z d d Z dS)HMACNcCsjt|}t|tstdtjt|tjs2td||_ ||_ ||_ |dkr`|j j ||j |_n||_dS)Nz.Backend object does not implement HMACBackend.z*Expected instance of hashes.HashAlgorithm.)r isinstancer rrZBACKEND_MISSING_INTERFACEr Z HashAlgorithm TypeError _algorithm_backend_keyZcreate_hmac_ctx algorithm_ctx)selfkeyrbackendctxr/usr/lib64/python3.6/hmac.py__init__s  z HMAC.__init__rcCs.|jdkrtdtjd||jj|dS)NzContext was already finalized.data)rrrZ_check_byteslikeupdate)rrrrrr*s  z HMAC.updatecCs.|jdkrtdt|j|j|j|jjdS)NzContext was already finalized.)rr)rrr rrrcopy)rrrrr0s z HMAC.copycCs&|jdkrtd|jj}d|_|S)NzContext was already finalized.)rrfinalize)rZdigestrrrr:s   z HMAC.finalizecCs:tjd||jdkrtd|jd}|_|j|dS)N signaturezContext was already finalized.)r _check_bytesrrverify)rr rrrrr"As   z HMAC.verify)NN) __name__ __module__ __qualname__rrZread_only_propertyrrrrr"rrrrr s    r N)Z __future__rrrZ cryptographyrZcryptography.exceptionsrrrZcryptography.hazmat.backendsr Z'cryptography.hazmat.backends.interfacesr Zcryptography.hazmat.primitivesr r Zregister_interfaceZ MACContextZ HashContextobjectr rrrrs