3 Te@s|ddlmZmZmZddlmZddlmZmZm Z ddl m Z ddl m Z ddlmZmZejejGdddeZd S) )absolute_importdivisionprint_function)utils)AlreadyFinalizedUnsupportedAlgorithm_Reasons) _get_backend) CMACBackend)ciphersmacc@s6eZdZd ddZddZddZdd Zd d ZdS) CMACNcCsbt|}t|tstdtjt|tjs2td||_ ||_ |dkrX|j j |j |_ n||_ dS)Nz.Backend object does not implement CMACBackend.z*Expected instance of BlockCipherAlgorithm.) r isinstancer rrZBACKEND_MISSING_INTERFACEr ZBlockCipherAlgorithm TypeError _algorithm_backendZcreate_cmac_ctx_ctx)self algorithmbackendctxr/usr/lib64/python3.6/cmac.py__init__s  z CMAC.__init__cCs.|jdkrtdtjd||jj|dS)NzContext was already finalized.data)rrr _check_bytesupdate)rrrrrr&s  z CMAC.updatecCs&|jdkrtd|jj}d|_|S)NzContext was already finalized.)rrfinalize)rZdigestrrrr-s   z CMAC.finalizecCs:tjd||jdkrtd|jd}|_|j|dS)N signaturezContext was already finalized.)rrrrverify)rrrrrrr4s   z CMAC.verifycCs*|jdkrtdt|j|j|jjdS)NzContext was already finalized.)rr)rrr rrcopy)rrrrr <s z CMAC.copy)NN)__name__ __module__ __qualname__rrrrr rrrrr s  r N)Z __future__rrrZ cryptographyrZcryptography.exceptionsrrrZcryptography.hazmat.backendsr Z'cryptography.hazmat.backends.interfacesr Zcryptography.hazmat.primitivesr r Zregister_interfaceZ MACContextobjectr rrrrs