%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/josepy/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/josepy/__pycache__/jwa.cpython-312.pyc

�

���e<���dZddlZddlZddlmZddlmZmZmZddl	Z
ddlmZddl
mZmZddlmZmZmZddlmZmZdd	lmZdd
lmZmZmZej:e�ZGd�dej@�Z!Gd
�de!e�Z"Gd�de"�Z#Gd�d�Z$Gd�de$e"�Z%Gd�de$e"�Z&Gd�de"�Z'e"jQe#dejR��Z*e"jQe#dejV��Z,e"jQe#dejZ��Z.e"jQe%dejR��Z/e"jQe%dejV��Z0e"jQe%dejZ��Z1e"jQe&dejR��Z2e"jQe&d ejV��Z3e"jQe&d!ejZ��Z4e"jQe'd"ejR��Z5e"jQe'd#ejV��Z6e"jQe'd$ejZ��Z7y)%zZJSON Web Algorithms.

https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40

�N)�Hashable)�Any�Callable�Dict)�default_backend)�hashes�hmac)�ec�padding�rsa)�decode_dss_signature�encode_dss_signature)�
HashAlgorithm)�errors�
interfaces�jwkc��eZdZdZy)�JWAzJSON Web Algorithm.N)�__name__�
__module__�__qualname__�__doc__���,/usr/lib/python3/dist-packages/josepy/jwa.pyrrs��rrc	��eZdZUdZiZeedfed<eed<deddfd�Z	dede
fd	�Zdefd
�Z
edd��Zdefd�Zed
eddfd��Zej&dededefd��Zej&dededede
fd��Zdefd�Zy)�JWASignaturez-Base class for JSON Web Signature Algorithms.�
SIGNATURES�kty�name�returnNc��||_y�N�r )�selfr s  r�__init__zJWASignature.__init__&s	����	r�otherc�`�t|t�stS|j|jk(Sr#)�
isinstancer�NotImplementedr )r%r's  r�__eq__zJWASignature.__eq__)s%���%��.�!�!��y�y�E�J�J�&�&rc�D�t|j|jf�Sr#)�hash�	__class__r �r%s r�__hash__zJWASignature.__hash__.s���T�^�^�T�Y�Y�/�0�0rc�8�||j|j<|S)z(Register class for JSON deserialization.)rr )�cls�
signature_clss  r�registerzJWASignature.register1s��.;����}�)�)�*��rc��|jSr#r$r/s r�to_partial_jsonzJWASignature.to_partial_json7����y�y�r�jobjc� �|j|Sr#)r)r2r8s  r�	from_jsonzJWASignature.from_json:s���~�~�d�#�#r�key�msgc��t��)�Sign the ``msg`` using ``key``.��NotImplementedError)r%r;r<s   r�signzJWASignature.sign>�
��"�#�#r�sigc��t��)z-Verify the ``msg`` and ``sig`` using ``key``.r?)r%r;r<rCs    r�verifyzJWASignature.verifyCrBrc��|jSr#r$r/s r�__repr__zJWASignature.__repr__Hr7r)r3rr!r)rrrrrr�str�__annotations__rr&�boolr+�intr0�classmethodr4r6r:�abc�abstractmethod�bytesrArErGrrrrr s��7�,.�J��S�.�(�)�.�	�H��S��T��'�C�'�D�'�
1�#�1�����
����$�S�$�^�$��$�	���$��$�%�$�E�$��$�	���$�#�$�E�$��$�$�$��$��#�rrc�v��eZdZejZdedegeff�fd�Z	de
de
de
fd�Zde
de
de
defd	�Z
�xZS)
�_JWAHSr �hash_c�<��t�|�|�|�|_yr#��superr&r-�r%r rRr.s   �rr&z_JWAHS.__init__O����
������G��	rr;r<r!c��tj||jt���}|j	|�|j�S)N��backend)r	�HMACr-r�update�finalize)r%r;r<�signers    rrAz_JWAHS.signSs4�����3��	�	�?�3D�E���
�
�c����� � rrCc� �tj||jt���}|j	|�	|j|�y#tjj$r!}tj|d��Yd}~yd}~wwxYw)NrYT��exc_infoF)r	r[r-rr\rE�cryptography�
exceptions�InvalidSignature�logger�debug)r%r;r<rC�verifier�errors      rrEz
_JWAHS.verifyXsn���9�9�S�$�)�)�_�5F�G�������	��O�O�C� �
��	�&�&�7�7�	��L�L���L�.���	�s�A�B
�,B�B
)rrrr�JWKOctrrHrrr&rOrArJrE�
__classcell__�r.s@rrQrQLsd���

�*�*�C��S���"�m�2C�)D��!��!�E�!�e�!�
	�%�	�e�	�%�	�D�	rrQc��eZdZUejZeZee	d<eZ
ee	d<dejdedefd�Zdej dededefd�Zy	)
�_JWARSArr-r;r<r!c�N�	|j||j|j�S#t$r1}tj|d��t
jd��d}~wt$r:}tj|d��t
jt|���d}~wwxYw)r>Tr`�%Public key cannot be used for signingN)
rArr-�AttributeErrorrerfr�Error�
ValueErrorrH�r%r;r<rhs    rrAz_JWARSA.signis��	+��8�8�C����t�y�y�9�9���	H��L�L���L�.��,�,�F�G�G���	+��L�L���L�.��,�,�s�5�z�*�*��	+�s �&)�	B$�,A�B$�*5B�B$rCc���	|j|||j|j�y#tjj
$r!}tj|d��Yd}~yd}~wwxYw)�,Verify the ``msg` and ``sig`` using ``key``.Tr`NF)rErr-rbrcrdrerf)r%r;r<rCrhs     rrEz_JWARSA.verifytsW��	��J�J�s�C����t�y�y�9�
��	�&�&�7�7�	��L�L���L�.���	�s�(+�A)�A$�$A)N)rrrr�JWKRSArr*rrrIr-rr�
RSAPrivateKeyrOrA�RSAPublicKeyrJrErrrrmrmdsf��

�*�*�C�!�G�S�!�(�D�-�(�	+��)�)�	+��	+�%�	+��#�*�*����U��t�rrmc�6��eZdZdedegefddf�fd�Z�xZS)�_JWARSr rRr!Nc�n��t�|�|�tj�|_|�|_yr#)rUr&r�PKCS1v15r-rVs   �rr&z_JWARS.__init__�s)���
������'�'�)����G��	r�rrrrHrrr&rjrks@rrzrz�,����S���"�m�2C�)D����rrzc�6��eZdZdedegefddf�fd�Z�xZS)�_JWAPSr rRr!Nc����t�|�|�tjtj|��tjj
��|_|�|_y)N)�mgf�salt_length)rUr&r�PSS�MGF1�
MAX_LENGTHr-rVs   �rr&z_JWAPS.__init__�s@���
������{�{�w�|�|�E�G�'<�'�+�+�J`�J`�a����G��	rr}rks@rr�r��r~rr�c����eZdZejZdedegeff�fd�Z	de
jdedefd�Z
de
jdedefd�Zde
jded	edefd
�Zde
jdededefd�Z�xZS)
�_JWAECr rRc�<��t�|�|�|�|_yr#rTrVs   �rr&z_JWAEC.__init__�rWrr;r<r!c���|j||�}t|�\}}tjj	|j
�}|j
|d��|j
|d��zS)r>�big)�length�	byteorder)�_signr
r�JWKEC�expected_length_for_curve�curve�to_bytes)r%r;r<rC�dr�dsr�s       rrAz_JWAEC.sign�sh���j�j��c�"��%�c�*���B����4�4�S�Y�Y�?���{�{�&�E�{�:�R�[�[��U�>I�>
�
�	
rc�^�	|j|tj|j��S#t$r1}t
j
|d��tjd��d}~wt$r:}t
j
|d��tjt|���d}~wwxYw)NTr`ro)rAr
�ECDSAr-rprerfrrqrrrHrss    rr�z_JWAEC._sign�s���	+��8�8�C����$�)�)�!4�5�5���	H��L�L���L�.��,�,�F�G�G���	+��L�L���L�.��,�,�s�5�z�*�*��	+�s �.1�	B,�,A&�&B,�25B'�'B,rCc��tjj|j�}t	|�d|zk7ryttj|d|d��tj||dd���}|j|||�S)ru�Frr�)r�N)	rr�r�r��lenrrK�
from_bytes�_verify)r%r;r<rC�rlen�asn1sigs      rrEz
_JWAEC.verify�sx���y�y�2�2�3�9�9�=���s�8�q�4�x���&��N�N�3�q��;�%�N�8��N�N�3�t�u�:��N�7�
���|�|�C��g�.�.rr�c���	|j||tj|j��y#tj
j$r!}tj|d��Yd}~yd}~wwxYw)NTr`F)	rEr
r�r-rbrcrdrerf)r%r;r<r�rhs     rr�z_JWAEC._verify�sZ��	��J�J�w��R�X�X�d�i�i�%8�9�
��	�&�&�7�7�	��L�L���L�.���	�s�03�A1�A,�,A1)rrrrr�rrHrrr&r
�EllipticCurvePrivateKeyrOrAr��EllipticCurvePublicKeyrJrEr�rjrks@rr�r��s����

�)�)�C��S���"�m�2C�)D��
��2�2�
��
�5�
�+��3�3�+�%�+�E�+�
/�"�3�3�
/�%�
/�e�
/�PT�
/��2�4�4��5��5��UY�rr��HS256�HS384�HS512�RS256�RS384�RS512�PS256�PS384�PS512�ES256�ES384�ES512)8rrM�logging�collections.abcr�typingrrr�cryptography.exceptionsrb�cryptography.hazmat.backendsr�cryptography.hazmat.primitivesrr	�)cryptography.hazmat.primitives.asymmetricr
rr�/cryptography.hazmat.primitives.asymmetric.utilsr
r�%cryptography.hazmat.primitives.hashesr�josepyrrr�	getLoggerrre�JSONDeSerializablerrrQrmrzr�r�r4�SHA256r��SHA384r��SHA512r�r�r�r�r�r�r�r�r�r�rrr�<module>r�s����
��$�&�&��8�7�F�F��@�*�*�	��	�	�8�	$���*�
'�
'��)�3��)�X�\��0��6�W�l���W�l��-�\�-�b	���f�W�f�m�m�<�=�����f�W�f�m�m�<�=�����f�W�f�m�m�<�=��	���f�W�f�m�m�<�=�����f�W�f�m�m�<�=�����f�W�f�m�m�<�=��	���f�W�f�m�m�<�=�����f�W�f�m�m�<�=�����f�W�f�m�m�<�=��	���f�W�f�m�m�<�=�����f�W�f�m�m�<�=�����f�W�f�m�m�<�=�r

Zerion Mini Shell 1.0