a ‚oeã@s\ddlmZddlZddlmZddlmZddlmZej rJddl m Z Gdd„dƒZ dS) é)Ú annotationsN)Úutils)ÚAlreadyFinalized)Úciphers)Ú _CMACContextc@speZdZUded<ded<ddddddœd d „Zd dd œd d„Zd dœdd„Zd ddœdd„Zddœdd„ZdS)ÚCMACztyping.Optional[_CMACContext]Ú_ctxzciphers.BlockCipherAlgorithmÚ _algorithmNz typing.AnyÚNone)Ú algorithmÚbackendÚctxÚreturncCsHt|tjƒstdƒ‚||_|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 Zossl©rúDC:\Program Files\Certbot\pkgs\cryptography\hazmat\primitives\cmac.pyÚ__init__s  z CMAC.__init__Úbytes)ÚdatarcCs.|jdurtdƒ‚t d|¡|j |¡dS)NúContext was already finalized.r)rrrÚ _check_bytesÚupdate)rrrrrr(s  z CMAC.update)rcCs&|jdurtdƒ‚|j ¡}d|_|S)Nr)rrÚfinalize)rZdigestrrrr/s   z CMAC.finalize)Ú signaturercCs:t d|¡|jdurtdƒ‚|jd}|_| |¡dS)Nrr)rrrrÚverify)rrr rrrr6s   z CMAC.verifycCs&|jdurtdƒ‚t|j|j ¡d�S)Nr)r )rrrr Úcopy)rrrrr>s z CMAC.copy)NN) Ú__name__Ú __module__Ú __qualname__Ú__annotations__rrrrrrrrrrs ür) Z __future__rÚtypingZ cryptographyrZcryptography.exceptionsrZcryptography.hazmat.primitivesrÚ TYPE_CHECKINGZ)cryptography.hazmat.backends.openssl.cmacrrrrrrÚs