%PDF- %PDF-
Mini Shell

Mini Shell

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

�

d��dht����ddlmZddlZddlZddlZddlZddlmZmZddl	m
Z
mZmZm
Z
mZmZmZddlmZddlmZmZddlmZmZmZmZmZmZmZmZmZej@d	k\rdd
l	m!Z!ndd
l"m!Z!	ddl#m$Z$ddl%m&Z&dd
l'm(Z(ddl)m*Z*ddl+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5ddl6m7Z7m8Z8ddl9m:Z:m;Z;ddl<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDddlEmFZFmGZGmHZHmIZImJZJmKZKmLZLdZMe
r3e=e?zZOe2e4zZPe:e;ze7ze8zZQeOePzeQzZRe=e2ze:ze7zZSe?e4ze;ze8zZThd�ZUd&d�ZVGd�de�ZWGd�deW�ZXGd�deW�ZYeMr-Gd�deW�ZZGd �d!eW�Z[Gd"�d#eZ�Z\Gd$�d%eW�Z]yy#eN$rdZMY��wxYw)'�)�annotationsN)�ABC�abstractmethod)�
TYPE_CHECKING�Any�ClassVar�NoReturn�Union�cast�overload���InvalidKeyError)�HashlibHash�JWKDict)	�base64url_decode�base64url_encode�der_to_raw_signature�force_bytes�from_base64url_uint�
is_pem_format�
is_ssh_key�raw_to_der_signature�to_base64url_uint)��)�Literal)�InvalidSignature)�default_backend)�hashes)�padding)
�ECDSA�	SECP256K1�	SECP256R1�	SECP384R1�	SECP521R1�
EllipticCurve�EllipticCurvePrivateKey�EllipticCurvePrivateNumbers�EllipticCurvePublicKey�EllipticCurvePublicNumbers)�Ed448PrivateKey�Ed448PublicKey)�Ed25519PrivateKey�Ed25519PublicKey)�
RSAPrivateKey�RSAPrivateNumbers�RSAPublicKey�RSAPublicNumbers�rsa_crt_dmp1�rsa_crt_dmq1�rsa_crt_iqmp�rsa_recover_prime_factors)�Encoding�NoEncryption�
PrivateFormat�PublicFormat�load_pem_private_key�load_pem_public_key�load_ssh_public_keyTF>�ES256�ES384�ES512�ES521�EdDSA�PS256�PS384�PS512�RS256�RS384�RS512�ES256Kc��t�ttj�ttj�ttj�d�}t
�r#|j
ttj�ttj�ttj�ttj�ttj�ttj�ttj�ttj�ttj�ttj�ttj�t�d��|S)zE
    Returns the algorithms that are implemented by the library.
    )�none�HS256�HS384�HS512)rGrHrIr?rJr@rBrArDrErFrC)�
NoneAlgorithm�
HMACAlgorithm�SHA256�SHA384�SHA512�
has_crypto�update�RSAAlgorithm�ECAlgorithm�RSAPSSAlgorithm�OKPAlgorithm)�default_algorithmss �0/usr/lib/python3/dist-packages/jwt/algorithms.py�get_default_algorithmsr]ps���
���}�3�3�4��}�3�3�4��}�3�3�4�	����!�!�%�l�&9�&9�:�%�l�&9�&9�:�%�l�&9�&9�:�$�[�%7�%7�8�%�k�&8�&8�9�$�[�%7�%7�8�$�[�%7�%7�8�$��&�&��)��)?�)?�@�(��)?�)?�@�(��)?�)?�@�%��
�	
�&��c���eZdZdZdd�Zedd��Zed
d��Zedd��Ze	e
edd����Ze	e
eddd����Ze
eddd���Ze
edd	���Zy
)�	AlgorithmzH
    The interface for an algorithm used to sign and verify tokens.
    c�f�t|dd�}|�t�trxt|t�rht|tj�rNt
j|�t���}|j|�t|j��St||�j��S)z�
        Compute a hash digest using the specified algorithm's hash algorithm.

        If there is no hash algorithm, raises a NotImplementedError.
        �hash_algN)�backend)�getattr�NotImplementedErrorrU�
isinstance�type�
issubclassr �
HashAlgorithm�HashrrV�bytes�finalize�digest)�self�bytestrrbrms    r\�compute_hash_digestzAlgorithm.compute_hash_digest�s����4��T�2����%�%�
��8�T�*��8�V�%9�%9�:��[�[���_�5F�G�F��M�M�'�"�����*�+�+���'�*�1�1�3�4�4r^c��y)z�
        Performs necessary validation and conversions on the key and returns
        the key value in the proper format for sign() and verify().
        N��rn�keys  r\�prepare_keyzAlgorithm.prepare_key���r^c��y)zn
        Returns a digital signature for the specified message
        using the specified key value.
        Nrr�rn�msgrts   r\�signzAlgorithm.sign�rvr^c��y)zz
        Verifies that the specified digital signature is valid
        for the specified message and key values.
        Nrr�rnryrt�sigs    r\�verifyzAlgorithm.verify�rvr^c��y�Nrr��key_obj�as_dicts  r\�to_jwkzAlgorithm.to_jwk����	r^c��yr�rrr�s  r\r�zAlgorithm.to_jwk�r�r^c��y)z3
        Serializes a given key into a JWK
        Nrrr�s  r\r�zAlgorithm.to_jwk�rvr^c��y)zJ
        Deserializes a given key from JWK back into a key object
        Nrr��jwks r\�from_jwkzAlgorithm.from_jwk�rvr^N)rork�returnrk)rtrr�r)ryrkrtrr�rk)ryrkrtrr}rkr��bool)r��
Literal[True]r�r�F)r��Literal[False]r��str)r�r�r��Union[JWKDict, str])r��
str | JWKDictr�r)
�__name__�
__module__�__qualname__�__doc__rprrurzr~r�staticmethodr�r�rrr^r\r`r`�s����5�,����������������������������������
�����r^r`c�N�eZdZdZdd�Zd	d�Zd
d�Zeddd��Zed
d��Z	y)rPzZ
    Placeholder for use when no signing or verification
    operations are required.
    c�.�|dk(rd}|�td��|S)N�z*When alg = "none", key value must be None.rrss  r\ruzNoneAlgorithm.prepare_key�s$���"�9��C��?�!�"N�O�O��
r^c��y)Nr^rrrxs   r\rzzNoneAlgorithm.sign�s��r^c��y)NFrrr|s    r\r~zNoneAlgorithm.verify�s��r^c��t��r��rer�s  r\r�zNoneAlgorithm.to_jwk����!�#�#r^c��t��r�r�r�s r\r�zNoneAlgorithm.from_jwk�r�r^N)rtz
str | Noner��None)ryrkrtr�r�rk)ryrkrtr�r}rkr�r�r�)r�rr�r�r�r	)r�r�r�r	)
r�r�r�r�rurzr~r�r�r�rrr^r\rPrP�s>���
����$��$��$��$r^rPc��eZdZUdZej
Zded<ejZ	ded<ejZded<dd�Zdd�Z
eedd���Zeeddd	���Zeddd
��Zedd��Zdd�Zdd
�Zy)rQzf
    Performs signing and verification operations using HMAC
    and the specified hash function.
    zClassVar[HashlibHash]rRrSrTc��||_yr��rb�rnrbs  r\�__init__zHMACAlgorithm.__init__s	�� ��
r^c�^�t|�}t|�st|�rtd��|S)NzdThe specified key is an asymmetric key or x509 certificate and should not be used as an HMAC secret.)rrrr�rnrt�	key_bytess   r\ruzHMACAlgorithm.prepare_keys5����$�	���#�z�)�'<�!�9��
�
�r^c��yr�rrr�s  r\r�zHMACAlgorithm.to_jwk���	r^c��yr�rrr�s  r\r�zHMACAlgorithm.to_jwkr�r^c�~�tt|��j�dd�}|r|Stj|�S)N�oct)�k�kty)rr�decode�json�dumps)r�r�r�s   r\r�zHMACAlgorithm.to_jwks<��"�+�g�"6�7�>�>�@��
��
��J��:�:�c�?�"r^c��	t|t�rtj|�}nt|t�r|}nt
�|jd�dk7rt
d��t|d�S#t
$rt
d��wxYw)N�Key is not valid JSONr�r�zNot an HMAC keyr�)	rfr�r��loads�dict�
ValueErrorr�getr)r��objs  r\r�zHMACAlgorithm.from_jwk)s}��	;��#�s�#�#�z�z�#����C��&��� � ��7�7�5�>�U�"�!�"3�4�4���C��)�)��
�	;�!�"9�:�:�	;�s�?A.�.Bc�`�tj|||j�j�Sr�)�hmac�newrbrmrxs   r\rzzHMACAlgorithm.sign:s"���x�x��S�$�-�-�0�7�7�9�9r^c�N�tj||j||��Sr�)r��compare_digestrzr|s    r\r~zHMACAlgorithm.verify=s ���"�"�3��	�	�#�s�(;�<�<r^N)rbrr�r�)rt�str | bytesr�rk)r�r�r�r�r�rr�)r�r�r�r�r�r�)r�r�r�r�r�r�)r�r�r�rk)ryrkrtrkr�rk)ryrkrtrkr}rkr�r�)r�r�r�r��hashlib�sha256rR�__annotations__�sha384rS�sha512rTr�rurr�r�r�rzr~rrr^r\rQrQ�s����
%,�N�N�F�!�2�$+�N�N�F�!�2�$+�N�N�F�!�2�!�	��������������	#��	#��*��*� :�=r^rQc��eZdZUdZej
Zded<ejZded<ejZded<dd�Z	dd�Z
eedd���Z
eeddd	���Z
e	d					dd
��Z
edd��Zdd�Zdd
�Zy)rWz~
        Performs signing and verification operations using
        RSASSA-PKCS-v1_5 and the specified hash function.
        �$ClassVar[type[hashes.HashAlgorithm]]rRrSrTc��||_yr�r�r�s  r\r�zRSAAlgorithm.__init__M�	��$�D�Mr^c�f�t|ttf�r|St|ttf�std��t
|�}	|jd�rttt|��Sttt|d���S#t$rttt|��cYSwxYw)N�Expecting a PEM-formatted key.sssh-rsa��password)
rfr0r2rkr��	TypeErrorr�
startswithrr>r<r�r=r�s   r\ruzRSAAlgorithm.prepare_keyPs����#�
�|�<�=��
��c�E�3�<�0�� @�A�A�#�C�(�I�
J��'�'�
�3���.A�)�.L�M�M��%�';�I�PT�'U�����
J��L�*=�i�*H�I�I�
J�s�)B�0B�"B0�/B0c��yr�rrr�s  r\r�zRSAAlgorithm.to_jwkc���
r^c��yr�rrr�s  r\r�zRSAAlgorithm.to_jwkhr�r^c��d}t|d��r;|j�}ddgt|jj�j�t|jj�j�t|j�j�t|j�j�t|j�j�t|j�j�t|j�j�t|j�j�d�
}nrt|d�r[|j�}ddgt|j�j�t|j�j�d�}ntd��|r|Stj|�S)N�private_numbers�RSArz)
r��key_ops�n�e�d�p�q�dp�dq�qir~)r�r�r�r��Not a public or private key)�hasattrr�r�public_numbersr�r�r�r�r�r��dmp1�dmq1�iqmprr�r�)r�r�r��numberss    r\r�zRSAAlgorithm.to_jwkmsd��*.�C��w� 1�2�!�1�1�3��!� &�x�*�7�+A�+A�+C�+C�D�K�K�M�*�7�+A�+A�+C�+C�D�K�K�M�*�7�9�9�5�<�<�>�*�7�9�9�5�<�<�>�*�7�9�9�5�<�<�>�+�G�L�L�9�@�@�B�+�G�L�L�9�@�@�B�+�G�L�L�9�@�@�B�����(�+�!�0�0�2��!� (�z�*�7�9�9�5�<�<�>�*�7�9�9�5�<�<�>�	��&�&C�D�D���
��z�z�#��&r^c�4�	t|t�rtj|�}nt|t�r|}nt
�|jd�dk7rt
d��d|v�rSd|v�rNd|v�rId|vrt
d	��gd
�}|D�cgc]}||v��}}t|�}|rt|�st
d��tt|d�t|d��}|rjtt|d�t|d�t|d
�t|d�t|d�t|d�|��}|j'�St|d�}t|j||j�\}	}
t||	|
t!||	�t#||
�t%|	|
�|��}|j'�Sd|vr6d|vr2tt|d�t|d��j)�St
d��#t
$rt
d��wxYwcc}w)Nr�r�r�zNot an RSA keyr�r�r��othz5Unsupported RSA private key: > 2 primes not supported)r�r�r�r�r�z@RSA key must include all parameters if any are present besides dr�r�r�r�r�)r�r�r�r�r�r�r�r�)rfr�r�r�r�r�rr��any�allr3rr1r7r�r�r4r5r6�private_key�
public_key)r�r��other_props�prop�props_found�any_props_foundr�r�r�r�r�s           r\r�zRSAAlgorithm.from_jwk�s0��
?��c�3�'��*�*�S�/�C���T�*��C�$�$��w�w�u�~��&�%�&6�7�7��c�z�c�S�j�S�C�Z��C�<�)�O���;��7B�C�t�t�s�{�C��C�"%�k�"2��"�3�{�+;�)�Z���"2�'��C��1�'��C��1�"��
#�/�-�c�#�h�7�-�c�#�h�7�-�c�#�h�7�0��T��;�0��T��;�0��T��;�'5��G�2�*�*�,�,�,�C��H�5�A�4�&�(�(�!�^�-=�-=��D�A�q�0����)�!�Q�/�)�!�Q�/�)�!�Q�/�'5��G��*�*�,�,�����s�
�'�'��C��1�'��C��1���*�,��
&�&C�D�D��{�
?�%�&=�>�>�
?��Ds�?G=�H�=Hc�h�|j|tj�|j��Sr�)rzr!�PKCS1v15rbrxs   r\rzzRSAAlgorithm.sign�s$���8�8�C��!1�!1�!3�T�]�]�_�E�Er^c��	|j||tj�|j��y#t$rYywxYw)NTF)r~r!r�rbrr|s    r\r~zRSAAlgorithm.verify�s=��
��
�
�3��W�%5�%5�%7�����I���#�
��
�s�47�	A�AN�rbztype[hashes.HashAlgorithm]r�r�)rtzAllowedRSAKeys | str | bytesr��AllowedRSAKeys)r�r�r�r�r�rr�)r�r�r�r�r�r�)r�r�r�r�r�r�)r�r�r�r��ryrkrtr0r�rk�ryrkrtr2r}rkr�r�)r�r�r�r�r rRr�rSrTr�rurr�r�r�rzr~rrr^r\rWrWCs���	�
8>�}�}��4�D�7=�}�}��4�D�7=�}�}��4�D�	%�	J�&
�	�	�
�
�	�
�	�	�
�
�	�
�5:�&	'�#�&	'�.2�&	'�
 �&	'�
�&	'�P
�E	E�
�E	E�N	F�	r^rWc��eZdZUdZej
Zded<ejZded<ejZded<dd�Z	dd�Z
dd�Zdd	�Ze
edd
���Ze
eddd���Ze	d					dd��Zedd
��Zy)rXzr
        Performs signing and verification operations using
        ECDSA and the specified hash function
        r�rRrSrTc��||_yr�r�r�s  r\r�zECAlgorithm.__init__�r�r^c�Z�t|ttf�r|St|ttf�std��t
|�}	|jd�rt|�}nt|�}t|ttf�std��|S#t$rt|d��}Y�;wxYw)Nr�secdsa-sha2-r�zcExpecting a EllipticCurvePrivateKey/EllipticCurvePublicKey. Wrong key provided for ECDSA algorithms)
rfr(r*rkr�r�rr�r>r=r�r<r)rnrtr��
crypto_keys    r\ruzECAlgorithm.prepare_key�s����#� 7�9O�P�Q��
��c�E�3�<�0�� @�A�A�#�C�(�I�

L��'�'��7�!4�Y�!?�J�!4�Y�!?�J�
��4�6L�M��&�y�������
L�1�)�d�K�
�
L�s�(B�B*�)B*c��|j|t|j���}t||j�Sr�)rzr"rbr�curve)rnryrt�der_sigs    r\rzzECAlgorithm.signs.���h�h�s�E�$�-�-�/�$:�;�G�'�����;�;r^c��	t||j�}	t|t�r|j�n|}|j
||t|j���y#t$rYywxYw#t$rYywxYw)NFT)
rr�r�rfr(r�r~r"rbr)rnryrtr}r�r�s      r\r~zECAlgorithm.verifys���
�.�s�C�I�I�>��	
�"�#�'>�?��N�N�$���
�!�!�'�3��d�m�m�o�0F�G����
��
��$�
��
�s#�A&�AA5�&	A2�1A2�5	B�Bc��yr�rrr�s  r\r�zECAlgorithm.to_jwk)r�r^c��yr�rrr�s  r\r�zECAlgorithm.to_jwk.r�r^c��t|t�r|j�j�}n,t|t�r|j�}ntd��t|jt�rd}not|jt�rd}nRt|jt�rd}n5t|jt�rd}ntd|j����d|t|j�j�t|j�j�d�}t|t�r4t|j�j �j�|d	<|r|St#j$|�S)
Nr��P-256�P-384�P-521�	secp256k1�Invalid curve: �EC)r��crv�x�yr�)rfr(r�r�r*rr�r$r%r&r#rr
r�rr��
private_valuer�r�)r�r�r�r	r�s     r\r�zECAlgorithm.to_jwk3s9���'�#:�;�!(�!3�!3�!5�!D�!D�!F���G�%;�<�!(�!7�!7�!9��%�&C�D�D��'�-�-��3����G�M�M�9�5����G�M�M�9�5����G�M�M�9�5�!��%���
�
��&G�H�H���&�~�'7�'7�8�?�?�A�&�~�'7�'7�8�?�?�A�	#�C��'�#:�;�,��+�+�-�;�;���&�(��C����
��z�z�#��&r^c�h�	t|t�rtj|�}nt|t�r|}nt
�|jd�dk7rt
d��d|vsd|vrt
d��t|jd��}t|jd��}|jd�}|dk(r@t|�t|�cxk(rd	k(rnt
d
��t�}n�t
d
��|dk(r@t|�t|�cxk(rdk(rnt
d
��t�}n�t
d
��|dk(r@t|�t|�cxk(rdk(rnt
d��t�}n^t
d��|dk(r@t|�t|�cxk(rd	k(rnt
d��t�}nt
d��t
d|����ttj!|d��tj!|d��|��}d|vr|j#�St|jd��}t|�t|�k7rt
dt|�|��t%tj!|d��|�j'�S#t
$rt
d��wxYw)Nr�r�rzNot an Elliptic curve keyr
rr	r� z)Coords should be 32 bytes for curve P-256r�0z)Coords should be 48 bytes for curve P-384r�Bz)Coords should be 66 bytes for curve P-521rz-Coords should be 32 bytes for curve secp256k1r�big)�	byteorder)r
rr�r�z!D should be {} bytes for curve {})rfr�r�r�r�r�rr�r�lenr$r%r&r#r+�int�
from_bytesr�r)r�)r�r�r
rr��	curve_objr�r�s        r\r�zECAlgorithm.from_jwkZs~��
?��c�3�'��*�*�S�/�C���T�*��C�$�$��w�w�u�~��%�%�&A�B�B��#�~��C��%�&A�B�B� ������.�A� ������.�A��G�G�E�N�E�����q�6�S��V�)�r�)�*�*U�V�V�!*��I�)�*U�V�V��'�!��q�6�S��V�)�r�)�*�*U�V�V�!*��I�)�*U�V�V��'�!��q�6�S��V�)�r�)�*�*U�V�V�!*��I�)�*U�V�V��+�%��q�6�S��V�)�r�)�*�G���!*��I�)�G���&���w�&?�@�@�7��.�.��e�.�4��.�.��e�.�4���N��#�~�%�0�0�2�2� ������.�A��1�v��Q���%�7��Q�����/����q�E��2�N���k�m�
��o�
?�%�&=�>�>�
?�s�?J�J1Nr�)rtzAllowedECKeys | str | bytesr��
AllowedECKeys)ryrkrtr(r�rk)ryrkrtz'AllowedECKeys'r}rkr�r�)r�rr�r�r�rr�)r�rr�r�r�r�)r�rr�r�r�r�)r�r�r�r)r�r�r�r�r rRr�rSrTr�rurzr~rr�r�r�rrr^r\rXrX�s���	�
8>�}�}��4�D�7=�}�}��4�D�7=�}�}��4�D�	%�	�<	<�
	�"
�	�	�
�
�	�
�	�	�
�
�	�
�49�$	'�"�$	'�-1�$	'�
 �$	'�
�$	'�L
�A	�
�A	r^rXc� �eZdZdZdd�Zdd�Zy)rYzA
        Performs a signature using RSASSA-PSS with MGF1
        c	���|j|tjtj|j	��|j	�j
��|j	��S)N��mgf�salt_length)rzr!�PSS�MGF1rb�digest_sizerxs   r\rzzRSAPSSAlgorithm.sign�sN���8�8��������T�]�]�_�5� $�
�
�� ;� ;���
�
��
�
r^c
��	|j||tjtj|j	��|j	�j
��|j	��y#t$rYywxYw)NrTF)r~r!rrrbrrr|s    r\r~zRSAPSSAlgorithm.verify�sh��
��
�
����K�K�#�L�L�����9�$(�M�M�O�$?�$?���M�M�O����#�
��
�s�A0A3�3	A?�>A?Nr�r�)r�r�r�r�rzr~rrr^r\rYrY�s��	�	�
	r^rYc��eZdZdZdd�Zdd�Z						d
d�Z								dd�Zee	dd���Z
ee	ddd���Z
e	ddd��Z
e	dd	��Zy
)rZz�
        Performs signing and verification operations using EdDSA

        This class requires ``cryptography>=2.6`` to be installed.
        c��yr�rr)rn�kwargss  r\r�zOKPAlgorithm.__init__�s��r^c�~�t|ttf�r{t|t�r|jd�n|}t|t�r|j	d�n|}d|vrt|�}n%d|vrt
|d��}n|dddk(rt|�}t|ttttf�std��|S)	N�utf-8z-----BEGIN PUBLICz-----BEGIN PRIVATEr�r�zssh-zcExpecting a EllipticCurvePrivateKey/EllipticCurvePublicKey. Wrong key provided for EdDSA algorithms)
rfrkr�r��encoder=r<r>r.r/r,r-r)rnrt�key_strr�s    r\ruzOKPAlgorithm.prepare_key�s����#��s�|�,�1;�C��1G�#�*�*�W�-�S��3=�c�3�3G�C�J�J�w�/�S�	�&�'�1�-�i�8�C�)�W�4�.�y�4�H�C��Q�q�\�V�+�-�i�8�C���"�$4�o�~�V��&�y����Jr^c�j�t|t�r|jd�n|}|j|�S)aS
            Sign a message ``msg`` using the EdDSA private key ``key``
            :param str|bytes msg: Message to sign
            :param Ed25519PrivateKey}Ed448PrivateKey key: A :class:`.Ed25519PrivateKey`
                or :class:`.Ed448PrivateKey` isinstance
            :return bytes signature: The signature, as bytes
            r%)rfr�r'rz)rnryrt�	msg_bytess    r\rzzOKPAlgorithm.sign�s,��0:�#�s�/C��
�
�7�+��I��8�8�I�&�&r^c�$�	t|t�r|jd�n|}t|t�r|jd�n|}t|ttf�r|j�n|}|j
||�y#t$rYywxYw)a�
            Verify a given ``msg`` against a signature ``sig`` using the EdDSA key ``key``

            :param str|bytes sig: EdDSA signature to check ``msg`` against
            :param str|bytes msg: Message to sign
            :param Ed25519PrivateKey|Ed25519PublicKey|Ed448PrivateKey|Ed448PublicKey key:
                A private or public EdDSA key instance
            :return bool verified: True if signature is valid, False if not.
            r%TF)rfr�r'r.r,r�r~r)rnryrtr}r*�	sig_bytesr�s       r\r~zOKPAlgorithm.verify�s���
�3=�c�3�3G�C�J�J�w�/�S�	�3=�c�3�3G�C�J�J�w�/�S�	�"�#�(9�?�'K�L��N�N�$���
�!�!�)�Y�7���#�
��
�s�BB�	B�Bc��yr�rr�rtr�s  r\r�zOKPAlgorithm.to_jwkr�r^c��yr�rrr.s  r\r�zOKPAlgorithm.to_jwk	r�r^c�F�t|ttf�r�|jtj
tj
��}t|t�rdnd}tt|��j�d|d�}|r|Stj|�St|ttf�r�|jtj
tj
t!���}|j#�jtj
tj
��}t|t�rdnd}tt|��j�tt|��j�d|d�}|r|Stj|�St%d��)	N)�encoding�format�Ed25519�Ed448�OKP)r
r�r	)r1r2�encryption_algorithm)r
r�r�r	r�)rfr/r-�public_bytesr8�Rawr;rrr�r�r�r.r,�
private_bytesr:r9r�r)rtr�r
r	r�r�s      r\r�zOKPAlgorithm.to_jwks\���#� 0�.�A�B��$�$�%�\�\�'�+�+�%���$.�c�3C�#D�i�'��*�+�a�.�9�@�@�B� ������J��:�:�c�?�*��#� 1�?�C�D��%�%�%�\�\�(�,�,�)5��&����N�N�$�1�1�%�\�\�'�+�+�2���
$.�c�3D�#E�i�7��)�+�a�.�9�@�@�B�)�+�a�.�9�@�@�B� ��	����J��:�:�c�?�*�!�"?�@�@r^c���	t|t�rtj|�}nt|t�r|}nt
�|jd�dk7rt
d��|jd�}|dk7r|dk7rt
d|����d	|vrt
d
��t|jd	��}	d|vr/|dk(rtj|�Stj|�St|jd��}|dk(rtj|�Stj|�S#t
$rt
d��wxYw#t
$r}t
d�|�d}~wwxYw)
Nr�r�r5zNot an Octet Key Pairr	r3r4rr
zOKP should have "x" parameterr�zInvalid key parameter)rfr�r�r�r�r�rr�rr/�from_public_bytesr-r.�from_private_bytesr,)r�r�r�r
r��errs      r\r�zOKPAlgorithm.from_jwk=sU��
?��c�3�'��*�*�S�/�C���T�*��C�$�$��w�w�u�~��&�%�&=�>�>��G�G�E�N�E��	�!�e�w�&6�%���w�&?�@�@��#�~�%�&E�F�F� ������.�A�

H��c�>��	�)�/�A�A�!�D�D�)�;�;�A�>�>�$�S�W�W�S�\�2���I�%�,�?�?��B�B�&�9�9�!�<�<��-�
?�%�&=�>�>�
?��.�
H�%�&=�>�C�G��
H�s5�?D/�3E�E�&3E�E�/E�	E!�E�E!N)r#rr�r�)rtzAllowedOKPKeys | str | bytesr��AllowedOKPKeys)ryr�rtz#Ed25519PrivateKey | Ed448PrivateKeyr�rk)ryr�rtr>r}r�r�r�)rtr>r�r�r�rr�)rtr>r�r�r�r�)rtr>r�r�r�r�)r�r�r�r>)r�r�r�r�r�rurzr~rr�r�r�rrr^r\rZrZ�s���	�	�	�.	'�"�	'�)L�	'�
�	'�	�"�	�)7�	�>I�	�
�	�4
�	�	�
�
�	�
�	�	�
�
�	�
�,	A�
�,	A�\
� 	H�
� 	Hr^rZ)r�zdict[str, Algorithm])^�
__future__rr�r�r��sys�abcrr�typingrrrr	r
rr�
exceptionsr�typesrr�utilsrrrrrrrrr�version_infor�typing_extensions�cryptography.exceptionsr�cryptography.hazmat.backendsr�cryptography.hazmat.primitivesr �)cryptography.hazmat.primitives.asymmetricr!�,cryptography.hazmat.primitives.asymmetric.ecr"r#r$r%r&r'r(r)r*r+�/cryptography.hazmat.primitives.asymmetric.ed448r,r-�1cryptography.hazmat.primitives.asymmetric.ed25519r.r/�-cryptography.hazmat.primitives.asymmetric.rsar0r1r2r3r4r5r6r7�,cryptography.hazmat.primitives.serializationr8r9r:r;r<r=r>rU�ModuleNotFoundErrorr�rr>�AllowedKeys�AllowedPrivateKeys�AllowedPublicKeys�requires_cryptographyr]r`rPrQrWrXrYrZrrr^r\�<module>rVs���"����
�#�P�P�P�'�'�
�
�
����v���)�/�8�<�5�A������	�	�	�����J�
�"�\�1�N�+�.D�D�M��,�,��>��O��!�=�0�>�A�K��/�/�2C�C�o�U��	�-�-�0@�@�>�Q��

�� �DH��H�V$�I�$�<C=�I�C=�L�c�y�c�Jt�i�t�l�,��<bH�y�bH�w��k���J��s�2A(E(�(E2�1E2

Zerion Mini Shell 1.0