a a @sLddlmZddlmZmZmZddlmZddlm Z Gddde Z dS))utils)InvalidSignatureUnsupportedAlgorithm_Reasons) constant_time)CBCc@s\eZdZdddZedZeddddZedd d Z ddd d Z edd ddZ dS) _CMACContextNc Cs||stdtj||_|j|_||_|jd|_ |dur|jj }|t |t f}||j|t }|jj }|j||jjjk|jj||jj j}|jj|j}|jj ||t|j||jjj}|j|dk||_dS)Nz#This backend does not support CMAC.)Zcmac_algorithm_supportedrrZUNSUPPORTED_CIPHER_backendkeyZ_key _algorithmZ block_size_output_lengthZ_cipher_registrytyper_lib CMAC_CTX_newopenssl_assert_ffiZNULLgc CMAC_CTX_freeZ from_bufferZ CMAC_Initlen_ctx) selfZbackend algorithmctxregistryZadapterZ evp_cipherZkey_ptrresrO/usr/lib64/python3.9/site-packages/cryptography/hazmat/backends/openssl/cmac.py__init__s4   z_CMACContext.__init__r )datareturncCs,|jj|j|t|}|j|dkdS)Nr )r rZ CMAC_Updaterrr)rr rrrrupdate6sz_CMACContext.update)r!cCsd|jjd|j}|jjd|j}|jj|j||}|j|dkd|_|jj|ddS)Nzunsigned char[]zsize_t *r ) r rnewrrZ CMAC_Finalrrbuffer)rbuflengthrrrrfinalize:s z_CMACContext.finalizecCsV|jj}|jj||jjj}|jj||j}|j|dkt |j|j |dS)Nr )r) r rrrrrZ CMAC_CTX_copyrrrr )rZ copied_ctxrrrrcopyDs  z_CMACContext.copy) signaturer!cCs |}t||stddS)NzSignature did not match digest.)r'rZbytes_eqr)rr)ZdigestrrrverifyMs z_CMACContext.verify)N) __name__ __module__ __qualname__rrZread_only_propertyrbytesr"r'r(r*rrrrrs  #   rN) Z cryptographyrZcryptography.exceptionsrrrZcryptography.hazmat.primitivesrZ,cryptography.hazmat.primitives.ciphers.modesrobjectrrrrrs