File: //usr/local/CyberPanel/lib/python3.10/site-packages/jose/backends/__pycache__/base.cpython-310.pyc
o
��h� � @ s2 d dl mZmZ G dd� d�ZG dd� de�ZdS )� )�base64url_encode�
ensure_binaryc @ sd e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z ddd�Z
ddd�Zdd� Zdd� Z
dS )�Keyz7
A simple interface for implementing JWK keys.
c C s d S �N� )�self�key� algorithmr r �H/usr/local/CyberPanel/lib/python3.10/site-packages/jose/backends/base.py�__init__ s zKey.__init__c C � t � �r ��NotImplementedError)r �msgr r r
�sign � zKey.signc C r r r
)r r �sigr r r
�verify r z
Key.verifyc C r r r
�r r r r
�
public_key r zKey.public_keyc C r r r
r r r r
�to_pem r z
Key.to_pemc C r r r
r r r r
�to_dict r zKey.to_dictNc C r )aI
Encrypt the plain text and generate an auth tag if appropriate
Args:
plain_text (bytes): Data to encrypt
aad (bytes, optional): Authenticated Additional Data if key's algorithm supports auth mode
Returns:
(bytes, bytes, bytes): IV, cipher text, and auth tag
r
)r �
plain_text�aadr r r
�encrypt s zKey.encryptc C r )ay
Decrypt the cipher text and validate the auth tag if present
Args:
cipher_text (bytes): Cipher text to decrypt
iv (bytes): IV if block mode
aad (bytes): Additional Authenticated Data to verify if auth mode
tag (bytes): Authentication tag if auth mode
Returns:
bytes: Decrypted value
r
)r �cipher_text�ivr �tagr r r
�decrypt( s zKey.decryptc C r )z�
Wrap the the plain text key data
Args:
key_data (bytes): Key data to wrap
Returns:
bytes: Wrapped key
r
)r �key_datar r r
�wrap_key6 �
zKey.wrap_keyc C r )z�
Unwrap the the wrapped key data
Args:
wrapped_key (bytes): Wrapped key data to unwrap
Returns:
bytes: Unwrapped key
r
)r �wrapped_keyr r r
�
unwrap_keyB r! zKey.unwrap_keyr )NNN)�__name__�
__module__�__qualname__�__doc__r r r r r r r r r r# r r r r
r s
r c @ s e Zd Zdd� Zdd� ZdS )�DIRKeyc C s t |�| _|| _d S r )r �_key�_alg)r r r r r r
r P s
zDIRKey.__init__c C s | j dt| j�d�S )N�oct)�alg�kty�k)r* r r) r r r r
r T s �zDIRKey.to_dictN)r$ r% r&