HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //var/opt/nydus/ops/cryptography/hazmat/backends/openssl/__pycache__/cmac.cpython-39.pyc
a

�,�h��@sdddlZddlmZmZmZddlmZddlmZej	rRddlm
Z
ddlmZGdd�d�Z
dS)	�N)�InvalidSignature�UnsupportedAlgorithm�_Reasons)�
constant_time)�CBC)�ciphers)�Backendc@s\eZdZddddd�dd�Zedd�dd	�Zed
�dd�Zdd
�d
d�Zedd�dd�ZdS)�_CMACContextNrzciphers.BlockCipherAlgorithm)�backend�	algorithm�returnc	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�_backend�key�_key�
_algorithm�
block_size�_output_lengthZ_cipher_registry�typer�_lib�CMAC_CTX_new�openssl_assert�_ffiZNULL�gc�
CMAC_CTX_free�from_bufferZ	CMAC_Init�len�_ctx)	�selfr
r�ctx�registry�adapterZ
evp_cipherZkey_ptr�res�r$�\/opt/nydus/tmp/pip-target-wkfpz8uv/lib64/python/cryptography/hazmat/backends/openssl/cmac.py�__init__s4
��z_CMACContext.__init__)�datarcCs,|jj�|j|t|��}|j�|dk�dS)Nr)rrZCMAC_Updaterrr)rr'r#r$r$r%�update=sz_CMACContext.update)rcCsd|jj�d|j�}|jj�d|j�}|jj�|j||�}|j�|dk�d|_|jj�|�dd�S)Nzunsigned char[]zsize_t *r)	rr�newrrZ
CMAC_Finalrr�buffer)r�buf�lengthr#r$r$r%�finalizeAsz_CMACContext.finalizecCsV|jj��}|jj�||jjj�}|jj�||j�}|j�|dk�t	|j|j
|d�S)Nr)r )rrrrrrZ
CMAC_CTX_copyrrr	r)rZ
copied_ctxr#r$r$r%�copyKs
�z_CMACContext.copy)�	signaturercCs |��}t�||�std��dS)NzSignature did not match digest.)r-rZbytes_eqr)rr/�digestr$r$r%�verifyTsz_CMACContext.verify)N)	�__name__�
__module__�__qualname__r&�bytesr(r-r.r1r$r$r$r%r	s��(
	r	)�typingZcryptography.exceptionsrrrZcryptography.hazmat.primitivesrZ,cryptography.hazmat.primitives.ciphers.modesr�
TYPE_CHECKINGrZ,cryptography.hazmat.backends.openssl.backendrr	r$r$r$r%�<module>s