HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/cryptography/hazmat/backends/openssl/__pycache__/cmac.cpython-310.pyc
o

-&%a�@sLddlmZddlmZmZmZddlmZddlm	Z	Gdd�de
�ZdS)�)�utils)�InvalidSignature�UnsupportedAlgorithm�_Reasons)�
constant_time)�CBCc@s\eZdZddd�Ze�d�Zdeddfdd�Zdefd	d
�Z	ddd�Z
d
eddfdd�ZdS)�_CMACContextNc	Cs�|�|�stdtj��||_|j|_||_|jd|_	|duro|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.��)�cmac_algorithm_supportedrr�UNSUPPORTED_CIPHER�_backend�key�_key�
_algorithm�
block_size�_output_length�_cipher_registry�typer�_lib�CMAC_CTX_new�openssl_assert�_ffi�NULL�gc�
CMAC_CTX_free�from_buffer�	CMAC_Init�len�_ctx)	�self�backend�	algorithm�ctx�registry�adapter�
evp_cipher�key_ptr�res�r)�K/usr/lib/python3/dist-packages/cryptography/hazmat/backends/openssl/cmac.py�__init__s4
��
z_CMACContext.__init__r�data�returncCs,|jj�|j|t|��}|j�|dk�dS)Nr
)r
r�CMAC_Updaterrr)r r,r(r)r)r*�update6sz_CMACContext.updatecCsd|jj�d|j�}|jj�d|j�}|jj�|j||�}|j�|dk�d|_|jj�|�dd�S)Nzunsigned char[]zsize_t *r
)	r
r�newrr�
CMAC_Finalrr�buffer)r �buf�lengthr(r)r)r*�finalize:sz_CMACContext.finalizecCsV|jj��}|jj�||jjj�}|jj�||j�}|j�|dk�t	|j|j
|d�S)Nr
)r#)r
rrrrr�
CMAC_CTX_copyrrrr)r �
copied_ctxr(r)r)r*�copyDs
�z_CMACContext.copy�	signaturecCs |��}t�||�std��dS)NzSignature did not match digest.)r5r�bytes_eqr)r r9�digestr)r)r*�verifyMs�z_CMACContext.verify)N)r-r)�__name__�
__module__�__qualname__r+r�read_only_propertyr"�bytesr/r5r8r<r)r)r)r*rs

#

	rN)�cryptographyr�cryptography.exceptionsrrr�cryptography.hazmat.primitivesr�,cryptography.hazmat.primitives.ciphers.modesr�objectrr)r)r)r*�<module>s