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__/hmac.cpython-310.pyc
o

�)%au�@sFddlmZddlmZmZmZddlmZmZGdd�dej	�Z
dS)�)�utils)�InvalidSignature�UnsupportedAlgorithm�_Reasons)�
constant_time�hashesc@sjeZdZ	ddedejfdd�Ze�d�Z	ddd	�Z
d
eddfdd�Zdefd
d�Zdeddfdd�Z
dS)�_HMACContextN�key�	algorithmcCs�||_||_|dur\|jj��}|j�||jjjk�|jj�||jjj�}|j�	|�}||jjjkr=t
d�|j�t
j��|jj�|�}|jj�||t|�||jjj�}|j�|dk�||_||_dS)Nz*{} is not a supported hash on this backendr)�
_algorithm�_backend�_lib�HMAC_CTX_new�openssl_assert�_ffi�NULL�gc�
HMAC_CTX_free�_evp_md_from_algorithmr�format�namer�UNSUPPORTED_HASH�from_buffer�HMAC_Init_ex�len�_ctx�_key)�self�backendr	r
�ctx�evp_md�key_ptr�res�r#�K/usr/lib/python3/dist-packages/cryptography/hazmat/backends/openssl/hmac.py�__init__s*���
z_HMACContext.__init__r�returncCsp|jj��}|j�||jjjk�|jj�||jjj�}|jj�||j	�}|j�|dk�t
|j|j|j|d�S)Nr)r)
rr
rrrrrr�
HMAC_CTX_copyrrrr
)r�
copied_ctxr"r#r#r$�copy-s
��z_HMACContext.copy�datacCs:|jj�|�}|jj�|j|t|��}|j�|dk�dS)Nr)rrrr
�HMAC_Updaterrr)rr*�data_ptrr"r#r#r$�update9sz_HMACContext.updatecCsz|jj�d|jjj�}|jj�d�}|jj�|j||�}|j�|dk�|j�|d|jj	k�|jj�
|�d|d�S)Nzunsigned char[]zunsigned int *r)rr�newr
�EVP_MAX_MD_SIZE�
HMAC_Finalrrr
�digest_size�buffer)r�buf�outlenr"r#r#r$�finalize>s
�z_HMACContext.finalize�	signaturecCs |��}t�||�std��dS)NzSignature did not match digest.)r5r�bytes_eqr)rr6�digestr#r#r$�verifyHs�z_HMACContext.verify)N)r&r)�__name__�
__module__�__qualname__�bytesr�
HashAlgorithmr%r�read_only_propertyr
r)r-r5r9r#r#r#r$rs��
�


rN)�cryptographyr�cryptography.exceptionsrrr�cryptography.hazmat.primitivesrr�HashContextrr#r#r#r$�<module>s