a oe@s\ddlmZddlZddlmZddlmZddlmZej rJddl m Z GdddZ dS) ) annotationsN)utils)AlreadyFinalized)ciphers) _CMACContextc@speZdZUded<ded<ddddddd d Zd dd d dZd dddZd ddddZddddZdS)CMACztyping.Optional[_CMACContext]_ctxzciphers.BlockCipherAlgorithm _algorithmNz typing.AnyNone) algorithmbackendctxreturncCsHt|tjstd||_|dur>ddlm}||j|_n||_dS)Nz*Expected instance of BlockCipherAlgorithm.r)r ) isinstancerZBlockCipherAlgorithm TypeErrorr Z,cryptography.hazmat.backends.openssl.backendr Zcreate_cmac_ctxr)selfr r r ZosslrDC:\Program Files\Certbot\pkgs\cryptography\hazmat\primitives\cmac.py__init__s  z CMAC.__init__bytes)datarcCs.|jdurtdtd||j|dS)NContext was already finalized.r)rrr _check_bytesupdate)rrrrrr(s  z CMAC.update)rcCs&|jdurtd|j}d|_|S)Nr)rrfinalize)rZdigestrrrr/s   z CMAC.finalize) signaturercCs:td||jdurtd|jd}|_||dS)Nrr)rrrrverify)rrr rrrr6s   z CMAC.verifycCs&|jdurtdt|j|jdS)Nr)r )rrrr copy)rrrrr>s z CMAC.copy)NN) __name__ __module__ __qualname____annotations__rrrrrrrrrrs r) Z __future__rtypingZ cryptographyrZcryptography.exceptionsrZcryptography.hazmat.primitivesr TYPE_CHECKINGZ)cryptography.hazmat.backends.openssl.cmacrrrrrrs