HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/jose/backends/__pycache__/native.cpython-310.pyc
o

�h0�@spddlZddlZddlZddlmZddlmZddlmZddl	m
Z
mZmZm
Z
dd�ZGdd	�d	e�ZdS)
�N)�Key)�
ALGORITHMS)�JWKError)�base64url_decode�base64url_encode�
is_pem_format�
is_ssh_keycCstt�|��S�N)�bytes�os�urandom)�	num_bytes�r�G/usr/local/CyberCP/lib/python3.10/site-packages/jose/backends/native.py�get_random_bytessrc@sTeZdZdZejejejej	ej
ejiZdd�Z
dd�Zdd�Zdd	�Zd
d�ZdS)
�HMACKeyzf
    Performs signing and verification operations using HMAC
    and the specified hash function.
    cCs�|tjvrtd|��||_|j�|�|_t|t�r"|�	|�|_
dSt|t�s0t|t�s0td��t|t�r:|�
d�}t|�sBt|�rFtd��||_
dS)Nz*hash_alg: %s is not a valid hash algorithmz+Expecting a string- or bytes-formatted key.�utf-8zdThe specified key is an asymmetric key or x509 certificate and should not be used as an HMAC secret.)r�HMACr�
_algorithm�HASHES�get�	_hash_alg�
isinstance�dict�_process_jwk�prepared_key�strr
�encoderr)�self�key�	algorithmrrr�__init__s 



�
zHMACKey.__init__cCsH|�d�dkstd|�d���|�d�}|�d�}t|�}t|�}|S)N�kty�octz1Incorrect key type. Expected: 'oct', Received: %s�kr)rrrr
r)r�jwk_dictr$rrrr/s

zHMACKey._process_jwkcCst�|j||j���Sr	)�hmac�newrr�digest)r�msgrrr�sign:szHMACKey.signcCst�||�|��Sr	)r&�compare_digestr*)rr)�sigrrr�verify=szHMACKey.verifycCs|jdt|j��d�d�S)Nr#�ASCII)�algr"r$)rrr�decode)rrrr�to_dict@s�zHMACKey.to_dictN)�__name__�
__module__�__qualname__�__doc__r�HS256�hashlib�sha256�HS384�sha384�HS512�sha512rr!rr*r-r1rrrrrsr)r7r&r�jose.backends.baser�jose.constantsr�jose.exceptionsr�
jose.utilsrrrrrrrrrr�<module>s