
    ~h	                     D     G d  d      Z  G d de      Z G d de      Zy)c                   2    e Zd ZdZdZdZdZdZd Zd Z	d Z
y)JWSAlgorithmzInterface for JWS algorithm. JWA specification (RFC7518) SHOULD
    implement the algorithms for JWS with this base implementation.
    NJWSalgc                     t               )z0Prepare key for signing and verifying signature.NotImplementedError)selfraw_datas     W/opt/mcp/mcp-sentiment/venv/lib/python3.12/site-packages/authlib/jose/rfc7515/models.pyprepare_keyzJWSAlgorithm.prepare_key   s    !##    c                     t         )zSign the text msg with a private/sign key.

        :param msg: message bytes to be signed
        :param key: private key to sign the message
        :return: bytes
        r   )r	   msgkeys      r   signzJWSAlgorithm.sign   s
     "!r   c                     t         )zVerify the signature of text msg with a public/verify key.

        :param msg: message bytes to be signed
        :param sig: result signature to be compared
        :param key: public key to verify the signature
        :return: boolean
        r   )r	   r   sigr   s       r   verifyzJWSAlgorithm.verify   s
     "!r   )__name__
__module____qualname____doc__namedescriptionalgorithm_typealgorithm_locationr   r   r    r   r   r   r      s-     DKN$""r   r   c                   2     e Zd ZdZ fdZed        Z xZS )	JWSHeadera  Header object for JWS. It combine the protected header and unprotected
    header together. JWSHeader itself is a dict of the combined dict. e.g.

        >>> protected = {"alg": "HS256"}
        >>> header = {"kid": "a"}
        >>> jws_header = JWSHeader(protected, header)
        >>> print(jws_header)
        {'alg': 'HS256', 'kid': 'a'}
        >>> jws_header.protected == protected
        >>> jws_header.header == header

    :param protected: dict of protected header
    :param header: dict of unprotected header
    c                     i }|r|j                  |       |r|j                  |       t        | 	  |       || _        || _        y )N)updatesuper__init__	protectedheader)r	   r$   r%   obj	__class__s       r   r#   zJWSHeader.__init__3   sA    JJy!JJv"r   c                 l    t        ||       r|S  | |j                  d      |j                  d            S )Nr$   r%   )
isinstanceget)clsr&   s     r   	from_dictzJWSHeader.from_dict=   s0    c3J377;'):;;r   )r   r   r   r   r#   classmethodr,   __classcell__r'   s   @r   r   r   #   s!     < <r   r   c                   4     e Zd ZdZd fd	Zed        Z xZS )	JWSObjectz*A dict instance to represent a JWS object.c                 R    t         |   ||       || _        || _        || _        y )N)r%   payload)r"   r#   r%   r3   type)r	   r%   r3   r4   r'   s       r   r#   zJWSObject.__init__G   s2     	 	
 	r   c                 ,    | j                   dk(  r| d   S y)z'Alias of ``header`` for JSON typed JWS.jsonr%   N)r4   )r	   s    r   headerszJWSObject.headersP   s     99>! r   )compact)r   r   r   r   r#   propertyr7   r.   r/   s   @r   r1   r1   D   s    4 " "r   r1   N)r   dictr   r1   r   r   r   <module>r;      s)   " "D< <B" "r   