B \Úæ` ã@spddlmZmZmZddlmZddlmZmZm Z ddl m Z m Z ddl mZe e j¡Gdd„deƒƒZdS) é)Úabsolute_importÚdivisionÚprint_function)Úutils)ÚInvalidSignatureÚUnsupportedAlgorithmÚ_Reasons)Ú constant_timeÚmac)ÚCBCc@s@eZdZd dd„Ze d¡Zdd„Zdd„Zd d „Z d d „Z dS)Ú _CMACContextNcCsÚ| |¡stdtjƒ‚||_|j|_||_|jd|_ |dkrÐ|jj }|t |ƒt f}||j|t ƒ}|jj  ¡}|j ||jjjk¡|jj ||jj j¡}|jj  ||jt|jƒ||jjj¡}|j |dk¡||_dS)Nz#This backend does not support CMAC.éé)Zcmac_algorithm_supportedrrZUNSUPPORTED_CIPHERÚ_backendÚkeyZ_keyÚ _algorithmZ block_sizeÚ_output_lengthZ_cipher_registryÚtyper Ú_libÚ CMAC_CTX_newÚopenssl_assertÚ_ffiZNULLÚgcÚ CMAC_CTX_freeZ CMAC_InitÚlenÚ_ctx)ÚselfZbackendÚ algorithmÚctxÚregistryZadapterZ evp_cipherÚres©r!ú\/opt/alt/python37/lib64/python3.7/site-packages/cryptography/hazmat/backends/openssl/cmac.pyÚ__init__s&   z_CMACContext.__init__rcCs,|jj |j|t|ƒ¡}|j |dk¡dS)Nr)rrZ CMAC_Updaterrr)rÚdatar r!r!r"Úupdate1sz_CMACContext.updatecCsd|jj d|j¡}|jj d|j¡}|jj |j||¡}|j |dk¡d|_|jj |¡dd…S)Nzunsigned char[]zsize_t *r) rrÚnewrrZ CMAC_FinalrrÚbuffer)rZbufÚlengthr r!r!r"Úfinalize5s z_CMACContext.finalizecCsV|jj ¡}|jj ||jjj¡}|jj ||j¡}|j |dk¡t |j|j |dS)Nr)r) rrrrrrZ CMAC_CTX_copyrrr r)rZ copied_ctxr r!r!r"ÚcopyAs  z_CMACContext.copycCs | ¡}t ||¡stdƒ‚dS)NzSignature did not match digest.)r)r Zbytes_eqr)rZ signatureZdigestr!r!r"ÚverifyNs z_CMACContext.verify)N) Ú__name__Ú __module__Ú __qualname__r#rZread_only_propertyrr%r)r*r+r!r!r!r"r s     r N)Z __future__rrrZ cryptographyrZcryptography.exceptionsrrrZcryptography.hazmat.primitivesr r Z,cryptography.hazmat.primitives.ciphers.modesr Zregister_interfaceZ MACContextÚobjectr r!r!r!r"Ús