
    uZh                     >    d dl mZmZ  G d d      Z G d de      Zy)   )base64url_encodeensure_binaryc                   P    e Zd ZdZd Zd Zd Zd Zd Zd Z	dd	Z
dd
Zd Zd Zy)Keyz7
    A simple interface for implementing JWK keys.
    c                      y N )selfkey	algorithms      n/var/www/html/wine-match-dev/backend/winematch-backend/venv/lib/python3.12/site-packages/jose/backends/base.py__init__zKey.__init__	   s        c                     t               r   NotImplementedError)r
   msgs     r   signzKey.sign       !##r   c                     t               r   r   )r
   r   sigs      r   verifyz
Key.verify   r   r   c                     t               r   r   r
   s    r   
public_keyzKey.public_key   r   r   c                     t               r   r   r   s    r   to_pemz
Key.to_pem   r   r   c                     t               r   r   r   s    r   to_dictzKey.to_dict   r   r   Nc                     t               )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aads      r   encryptzKey.encrypt   s     "##r   c                     t               )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"   tags        r   decryptzKey.decrypt(   s     "##r   c                     t               )z
        Wrap the the plain text key data

        Args:
            key_data (bytes): Key data to wrap

        Returns:
            bytes: Wrapped key
        r   )r
   key_datas     r   wrap_keyzKey.wrap_key6        "##r   c                     t               )z
        Unwrap the the wrapped key data

        Args:
            wrapped_key (bytes): Wrapped key data to unwrap

        Returns:
            bytes: Unwrapped key
        r   )r
   wrapped_keys     r   
unwrap_keyzKey.unwrap_keyB   r,   r   r   )NNN)__name__
__module____qualname____doc__r   r   r   r   r   r   r#   r(   r+   r/   r	   r   r   r   r      s9    $$$$$$$
$
$r   r   c                       e Zd Zd Zd Zy)DIRKeyc                 2    t        |      | _        || _        y r   )r   _key_alg)r
   r*   r   s      r   r   zDIRKey.__init__P   s    !(+		r   c                 H    | j                   dt        | j                        dS )Noct)algktyk)r8   r   r7   r   s    r   r   zDIRKey.to_dictT   s"    99!$)),
 	
r   N)r0   r1   r2   r   r   r	   r   r   r5   r5   O   s    
r   r5   N)utilsr   r   r   r5   r	   r   r   <module>r?      s!    3H$ H$V

S 

r   