o
    Cji                     @   s2   d dl mZmZ G dd dZG dd deZdS )   )base64url_encodeensure_binaryc                   @   sd   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dddZ
dddZdd Zdd ZdS )Keyz7
    A simple interface for implementing JWK keys.
    c                 C   s   d S N )selfkey	algorithmr   r   i/var/www/html/Resume-Parser/resume-parser-inhouse/venv/lib/python3.10/site-packages/jose/backends/base.py__init__	   s   zKey.__init__c                 C      t  r   NotImplementedError)r   msgr   r   r
   sign      zKey.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   zKey.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   zKey.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   zKey.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   zKey.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      
zKey.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!   zKey.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 Zd Zdd Zdd ZdS )DIRKeyc                 C   s   t || _|| _d S r   )r   _key_alg)r   r   r	   r   r   r
   r   P   s   

zDIRKey.__init__c                 C   s   | j dt| jdS )Noct)algktyk)r*   r   r)   r   r   r   r
   r   T   s   zDIRKey.to_dictN)r$   r%   r&   r   r   r   r   r   r
   r(   O   s    r(   N)utilsr   r   r   r(   r   r   r   r
   <module>   s    K