%PDF- %PDF-
Mini Shell

Mini Shell

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

�

���eA'���dZddlZddlZddlZddlmZmZddlmZddl	m
Z
mZmZm
Z
mZmZmZmZddlmZmZddlmZded	efd
�ZGd�d�ZGd
�d�ZGd�de�ZGd�de�Zedd��ZGd�dee�ZGd�dee�ZGd�d�Z eee ejBe"��ejBe"<y)zJOSE utilities.�N)�Hashable�Mapping)�
ModuleType)�Any�Callable�Iterator�List�Tuple�TypeVar�Union�cast)�ec�rsa)�crypto�func�returnc�>�ttj|��S�N)�classmethod�abc�abstractmethod)rs �-/usr/lib/python3/dist-packages/josepy/util.py�abstractclassmethodrs���s�)�)�$�/�0�0�c��eZdZdZdeejejfddfd�Zde	de
fd�Zejfde
defd	�Zd
e
defd�Zde
fd�Zde	fd
�Zy)�ComparableX509z�Wrapper for OpenSSL.crypto.X509** objects that supports __eq__.

    :ivar wrapped: Wrapped certificate or certificate request.
    :type wrapped: `OpenSSL.crypto.X509` or `OpenSSL.crypto.X509Req`.

    �wrappedrNc�~�t|tj�st|tj�sJ�||_yr)�
isinstancer�X509�X509Reqr��selfrs  r�__init__zComparableX509.__init__s*���'�6�;�;�/�:�g�v�~�~�3V�V�V���r�namec�.�t|j|�Sr)�getattrr�r#r%s  r�__getattr__zComparableX509.__getattr__s���t�|�|�T�*�*r�filetypec���t|jtj�r tj||j�Stj
||j�S)aNDumps the object into a buffer with the specified encoding.

        :param int filetype: The desired encoding. Should be one of
            `OpenSSL.crypto.FILETYPE_ASN1`,
            `OpenSSL.crypto.FILETYPE_PEM`, or
            `OpenSSL.crypto.FILETYPE_TEXT`.

        :returns: Encoded X509 object.
        :rtype: bytes

        )rrrr �dump_certificate�dump_certificate_request)r#r*s  r�_dumpzComparableX509._dump!sF���d�l�l�F�K�K�0��*�*�8�T�\�\�B�B��.�.�x����F�Fr�otherc�|�t||j�stS|j�|j�k(Sr)r�	__class__�NotImplementedr.�r#r/s  r�__eq__zComparableX509.__eq__3s-���%����0�!�!��z�z�|�u�{�{�}�,�,rc�L�t|j|j�f�Sr)�hashr1r.�r#s r�__hash__zComparableX509.__hash__8s���T�^�^�T�Z�Z�\�2�3�3rc�b�dj|jj|j�S�Nz<{0}({1!r})>)�formatr1�__name__rr7s r�__repr__zComparableX509.__repr__;s#���$�$�T�^�^�%<�%<�d�l�l�K�Kr)r<�
__module__�__qualname__�__doc__rrr r!r$�strrr)�
FILETYPE_ASN1�int�bytesr.�boolr4r8r=�rrrrs������f�k�k�6�>�>�&A� B��t��+��+��+�%+�$8�$8�G�c�G�U�G�$-�C�-�D�-�
4�#�4�L�#�Lrrc���eZdZUdZeZegefed<de	e
je
je
je
jffd�Zdedefd�Zdedefd	�Zdefd
�Zd
d�Zy)�
ComparableKeyznComparable wrapper for ``cryptography`` keys.

    See https://github.com/pyca/cryptography/issues/2122.

    r8rc��||_yr)�_wrappedr"s  rr$zComparableKey.__init__Hs�� ��
rr%rc�.�t|j|�Sr)r'rJr(s  rr)zComparableKey.__getattr__Ss���t�}�}�d�+�+rr/c�z�t||j�r,|jj|jjurtSt	|jd�r!|j�|j�k(St	|jd�r!|j
�|j
�k(StS)N�private_numbers�public_numbers)rr1rJr2�hasattrrMrNr3s  rr4zComparableKey.__eq__Vs����5�$�.�.�1��}�}�&�&�e�n�n�.F�.F�F�!�!�
�T�]�]�$5�
6��'�'�)�U�-B�-B�-D�D�D�
�T�]�]�$4�
5��&�&�(�E�,@�,@�,B�B�B�!�!rc�b�dj|jj|j�Sr:)r;r1r<rJr7s rr=zComparableKey.__repr__cs#���$�$�T�^�^�%<�%<�d�m�m�L�Lrc��t|jtjtj
f�r|S|j
|jj��S)zGet wrapped public key.)rrJr�RSAPublicKeyWithSerializationr�'EllipticCurvePublicKeyWithSerializationr1�
public_keyr7s rrTzComparableKey.public_keyfsH����M�M�
�
.�
.��0Z�0Z�[�
��K��~�~�d�m�m�6�6�8�9�9rN)rrH)r<r>r?r@r2r8rrC�__annotations__rr�RSAPrivateKeyWithSerializationrRr�(EllipticCurvePrivateKeyWithSerializationrSr$rArr)rEr4r=rTrFrrrHrH?s����#1�H�h�r�3�w��0�	 ���.�.��-�-��7�7��6�6�
8�
�	 �,��,��,�"�C�"�D�"�M�#�M�:rrHc��eZdZdZdefd�Zy)�ComparableRSAKeyz�Wrapper for ``cryptography`` RSA keys.

    Wraps around:

    - :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey`
    - :class:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey`

    rc
��t|jtj�r|j	�}|j
}t
|j|j|j|j|j|j|j|jf�St|jtj�r<|j�}t
|j|j|jf�St!��r)rrJrrVrMrNr6r1�p�q�dmp1�dmq1�iqmp�n�erR�NotImplementedError�r#�priv�pubs   rr8zComparableRSAKey.__hash__{s����d�m�m�S�%G�%G�H��'�'�)�D��%�%�C��������������D�I�I�t�y�y�RU�RW�RW�Y\�Y^�Y^�_��
���
�
�s�'H�'H�
I��%�%�'�C�����������6�7�7�!�#�#rN�r<r>r?r@rCr8rFrrrYrYqs���
$�#�
$rrYc��eZdZdZdefd�Zy)�ComparableECKeyz�Wrapper for ``cryptography`` EC keys.
    Wraps around:
    - :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey`
    - :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
    rc��t|jtj�rh|j	�}|j
}t
|j|jj|j|j|jf�St|jtj�rQ|j�}t
|j|jj|j|jf�St��r)rrJrrWrMrNr6r1�curver%�x�y�
private_valuerSrbrcs   rr8zComparableECKey.__hash__�s����d�m�m�R�%P�%P�Q��'�'�)�D��%�%�C����������������t�GY�GY�Z�[�[�
��
�
�r�'Q�'Q�
R��%�%�'�C����������������F�G�G�!�#�#rNrfrFrrrhrh�s���$�#�$rrh�GenericImmutableMap�ImmutableMap)�boundc��eZdZUdZdZeedfed<	deddfd�Z	d	e
dede
fd
�Zdedefd�Zde
efd
�Zdefd�Zdefd�Zdededdfd�Zdefd�Zy)roz5Immutable key to value mapping with attribute access.rF.�	__slots__�kwargsrNc�R�t|�t|j�k7rOtdjdj	|j�|rdj	|����d���|jD](}t
j
|||j|���*y)NzA__init__() takes exactly the following arguments: {0} ({1} given)�, �none)�setrr�	TypeErrorr;�join�object�__setattr__�pop)r#rs�slots   rr$zImmutableMap.__init__�s����v�;�#�d�n�n�-�-���$�f��I�I�d�n�n�-�F�t�y�y��/@���
�QW���
��N�N�	=�D����t�T�6�:�:�d�+;�<�	=rr#c�0�i|�|�}t|�di|��S)zReturn updated map.rF)�type)r#rs�itemss   r�updatezImmutableMap.update�s%��#5�d�#5�f�#5���t�D�z�"�E�"�"r�keyc�L�	t||�S#t$rt|��wxYwr)r'�AttributeError�KeyError�r#r�s  r�__getitem__zImmutableMap.__getitem__�s-��	 ��4��%�%���	 ��3�-��	 �s��#c�,�t|j�Sr)�iterrrr7s r�__iter__zImmutableMap.__iter__�s���D�N�N�#�#rc�,�t|j�Sr)�lenrrr7s r�__len__zImmutableMap.__len__�s���4�>�>�"�"rc�R��tt�fd��jD���S)Nc3�6�K�|]}t�|����y�wr)r')�.0r}r#s  �r�	<genexpr>z(ImmutableMap.__hash__.<locals>.<genexpr>�s�����I�$�'�$��-�I�s�)r6�tuplerrr7s`rr8zImmutableMap.__hash__�s����E�I�$�.�.�I�I�J�Jrr%�valuec��td���Nzcan't set attribute�r��r#r%r�s   rr{zImmutableMap.__setattr__�����2�3�3rc��dj|jjdjd�|j	�D���S)Nz{0}({1})ruc3�FK�|]\}}dj||����y�w�z	{0}={1!r}N�r;�r�r�r�s   rr�z(ImmutableMap.__repr__.<locals>.<genexpr>�s!����T���e�k�(�(��e�4�T���!)r;r1r<ryr�r7s rr=zImmutableMap.__repr__�s:��� � ��N�N�#�#��I�I�T�t�z�z�|�T�T�
�	
r)r<r>r?r@rrr
rArUrr$rnr�r�rr�rCr�r8r{r=rFrrroro�s���?�!#�I�u�S�#�X��#�+�	=��	=��	=�#�(�#�C�#�<O�#�
 �s� �s� �$�(�3�-�$�#��#�K�#�K�4��4�C�4�D�4�
�#�
rc��eZdZdZdZdededdfd�Zdedefd	�Zde	efd
�Z
defd�Zde
e
eefdffd
�Zdefd�Zdedefd�Zdededdfd�Zdefd�Zy)�
frozendictzFrozen dictionary.)�_items�_keys�argsrsrNc
�"�|r|st|�}n1t|�dk(rt|dt�r|d}n
t	��t
j
|d|�t
j
|dtt|j����y)N�rr�r�)
�dictr�rrrxrzr{r��sorted�keys)r#r�rsr�s    rr$zfrozendict.__init__�so���$���L�E�
��Y�!�^�
�4��7�G� <���G�E��+��	���4��5�1����4��%��u�z�z�|�0D�*E�Frr�c� �|j|Sr)r�r�s  rr�zfrozendict.__getitem__�s���{�{�3��rc�,�t|j�Sr)r�r�r7s rr�zfrozendict.__iter__�s���D�J�J��rc�,�t|j�Sr)r�r�r7s rr�zfrozendict.__len__�s���4�;�;��r.c�@��t�fd��jD��S)Nc3�,�K�|]}|�|f���
y�wrrF)r�r�r#s  �rr�z+frozendict._sorted_items.<locals>.<genexpr>�s�����<�#�c�4��9�%�<�s�)r�r�r7s`r�
_sorted_itemszfrozendict._sorted_items�s����<����<�<�<rc�4�t|j��Sr)r6r�r7s rr8zfrozendict.__hash__�s���D�&�&�(�)�)rr%c�R�	|j|S#t$rt|��wxYwr)r�r�r�r(s  rr)zfrozendict.__getattr__�s0��	'��;�;�t�$�$���	'� ��&�&�	'�s��&r�c��td��r�r�r�s   rr{zfrozendict.__setattr__�r�rc�l�djdjd�|j�D���S)Nzfrozendict({0})ruc3�FK�|]\}}dj||����y�wr�r�r�s   rr�z&frozendict.__repr__.<locals>.<genexpr>�s!����\���e�k�(�(��e�4�\�r�)r;ryr�r7s rr=zfrozendict.__repr__�s0�� �'�'��I�I�\�t�GY�GY�G[�\�\�
�	
r)r<r>r?r@rrrr$rAr�rr�rCr�r
r�r8r)r{r=rFrrr�r��s����#�I�G�c�G�S�G�T�G� �s� �s� � �(�3�-� � �� �=�u�U�3��8�_�c�%9�:�=�*�#�*�'��'��'�4��4�C�4�D�4�
�#�
rr�c�f�eZdZdZdeddfd�Zdedefd�Zdededdfd	�Z	deddfd
�Z
deefd�Zy)�_UtilDeprecationModulez�
    Internal class delegating to a module, and displaying warnings when attributes
    related to the deprecated "abstractclassmethod" attributes in the josepy.util module.
    �modulerNc�"�||jd<y�N�_module)�__dict__)r#r�s  rr$z_UtilDeprecationModule.__init__s��#)��
�
�i� r�attrc�p�|dk(rtjdtd��t|j|�S)Nrz�The abstractclassmethod attribute in josepy.util is deprecated and will be removed soon. Please use the built-in decorators @classmethod and @abc.abstractmethod together instead.�)�
stacklevel)�warnings�warn�DeprecationWarningr'r��r#r�s  rr)z"_UtilDeprecationModule.__getattr__s7���(�(��M�M�8�#��
��t�|�|�T�*�*rr�c�2�t|j||�yr)�setattrr�)r#r�r�s   rr{z"_UtilDeprecationModule.__setattr__s������d�E�*rc�0�t|j|�yr)�delattrr�r�s  r�__delattr__z"_UtilDeprecationModule.__delattr__s������d�#rc�4�dgt|j�zSr�)�dirr�r7s r�__dir__z_UtilDeprecationModule.__dir__s���{�S����.�.�.r)
r<r>r?r@rr$rArr)r{r�r	r�rFrrr�r�sj���
*�z�*�d�*�	+��	+��	+�+��+�C�+�D�+�$��$��$�/��c��/rr�)#r@r�sysr��collections.abcrr�typesr�typingrrrr	r
rrr
�)cryptography.hazmat.primitives.asymmetricrr�OpenSSLrrrrrHrYrhrnror�r��modulesr<rFrr�<module>r�s����
�
��-��M�M�M�=��1�h�1�;�1�*L�*L�Z/:�/:�d$�}�$�4$�m�$�*�3�>�J��,
�7�H�,
�^-
��(�-
�f/�/�>�Z�)?����H�@U�)V�W����H�r

Zerion Mini Shell 1.0