CasperSecurity

Current Path : /lib/python3/dist-packages/josepy/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/josepy/__pycache__/util.cpython-310.pyc

o

h9Ra(�@sdZddlZddlmZddlmZmZmZmZm	Z	m
Z
mZddlm
Z
mZddlZddlZddlmZddlmZmZded	efd
d�ZGdd
�d
�ZGdd�d�ZGdd�de�ZGdd�de�ZGdd�dee
�ZGdd�dee
�ZGdd�d�Zeeeeje ��eje <dS)zJOSE utilities.�N)�
ModuleType)�Union�Any�Callable�Iterator�Tuple�List�cast)�Hashable�Mapping)�crypto)�ec�rsa�func�returncCstt�|��S�N)�classmethod�abc�abstractmethod)r�r�-/usr/lib/python3/dist-packages/josepy/util.py�abstractclassmethod�rc@s�eZdZdZdeejejfddfdd�Zde	de
fdd	�Zejfd
e
defdd�Zd
e
defdd�Zde
fdd�Zde	fdd�ZdS)�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`.

    �wrappedrNcCs&t|tj�st|tj�sJ�||_dSr)�
isinstancer�X509�X509Reqr��selfrrrr�__init__s�
zComparableX509.__init__�namecC�t|j|�Sr)�getattrr�rr!rrr�__getattr__�zComparableX509.__getattr__�filetypecCs*t|jtj�rt�||j�St�||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

        )rrrr�dump_certificate�dump_certificate_request)rr'rrr�_dump"szComparableX509._dump�othercCs t||j�stS|��|��kSr)r�	__class__�NotImplementedr*�rr+rrr�__eq__4szComparableX509.__eq__cCst|j|��f�Sr)�hashr,r*�rrrr�__hash__:�zComparableX509.__hash__cC�d�|jj|j�S�Nz<{0}({1!r})>)�formatr,�__name__rr1rrr�__repr__=r3zComparableX509.__repr__)r7�
__module__�__qualname__�__doc__rrrrr �strrr%�
FILETYPE_ASN1�int�bytesr*�boolr/r2r8rrrrrsrc@s�eZdZUdZeZegefed<de	e
je
je
je
jffdd�Zdedefdd	�Zd
edefdd�Zdefd
d�Zddd�ZdS)�
ComparableKeyznComparable wrapper for ``cryptography`` keys.

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

    r2rcCs
||_dSr)�_wrappedrrrrr Is
zComparableKey.__init__r!rcCr"r)r#rBr$rrrr%Qr&zComparableKey.__getattr__r+cCs\t||j�r|jj|jjurtSt|jd�r|��|��kSt|jd�r,|��|��kStS)N�private_numbers�public_numbers)rr,rBr-�hasattrrCrDr.rrrr/TszComparableKey.__eq__cCr4r5)r6r,r7rBr1rrrr8`r3zComparableKey.__repr__cCs(t|jtjtjf�r|S|�|j���S)zGet wrapped public key.)rrBr�RSAPublicKeyWithSerializationr
�'EllipticCurvePublicKeyWithSerializationr,�
public_keyr1rrrrHcs

�zComparableKey.public_keyN)rrA)r7r9r:r;r-r2rr>�__annotations__rr�RSAPrivateKeyWithSerializationrFr
�(EllipticCurvePrivateKeyWithSerializationrGr r<rr%r@r/r8rHrrrrrAAs 
��
�rAc@�eZdZdZdefdd�ZdS)�ComparableRSAKeyz�Wrapper for ``cryptography`` RSA keys.

    Wraps around:

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

    rc	Cstt|jtj�r"|��}|j}t|j|j|j	|j
|j|j|j
|jf�St|jtj�r7|��}t|j|j
|jf�St��r)rrBrrJrCrDr0r,�p�q�dmp1�dmq1�iqmp�n�erF�NotImplementedError�r�priv�pubrrrr2vs�zComparableRSAKey.__hash__N�r7r9r:r;r>r2rrrrrMls	rMc@rL)�ComparableECKeyz�Wrapper for ``cryptography`` RSA keys.
    Wraps around:
    - :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey`
    - :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
    rcCspt|jtj�r|��}|j}t|j|jj	|j
|j|jf�St|jtj
�r5|��}t|j|jj	|j
|jf�St��r)rrBr
rKrCrDr0r,�curver!�x�y�
private_valuerGrUrVrrrr2�szComparableECKey.__hash__NrYrrrrrZ�srZc@s�eZdZUdZdZeedfed<	deddfdd	�Z	deddfd
d�Z
dedefd
d�Zdeefdd�Z
defdd�Zdefdd�Zdededdfdd�Zdefdd�ZdS)�ImmutableMapz5Immutable key to value mapping with attribute access.r.�	__slots__�kwargsrNcKs`t|�t|j�krtd�d�|j�|rd�|����d���|jD]}t�|||�|��q!dS)NzA__init__() takes exactly the following arguments: {0} ({1} given)�, �none)�setr`�	TypeErrorr6�join�object�__setattr__�pop)rra�slotrrrr �s����
�zImmutableMap.__init__cKsi|�|�}t|�di|��S)zReturn updated map.Nr)�type)rra�itemsrrr�update�szImmutableMap.update�keycCs$zt||�WStyt|��wr)r#�AttributeError�KeyError�rrnrrr�__getitem__��
�zImmutableMap.__getitem__cC�
t|j�Sr)�iterr`r1rrr�__iter__��
zImmutableMap.__iter__cCrtr)�lenr`r1rrr�__len__�rwzImmutableMap.__len__cstt�fdd��jD���S)Nc3s�|]}t�|�VqdSr)r#)�.0rjr1rr�	<genexpr>�s�z(ImmutableMap.__hash__.<locals>.<genexpr>)r0�tupler`r1rr1rr2�szImmutableMap.__hash__r!�valuecC�td���Nzcan't set attribute�ro�rr!r}rrrrh��zImmutableMap.__setattr__cCs$d�|jjd�dd�|��D���S)Nz{0}({1})rbcs� �|]\}}d�||�VqdS�z	{0}={1!r}N�r6�rzrnr}rrrr{�s
�
�
�z(ImmutableMap.__repr__.<locals>.<genexpr>)r6r,r7rfrlr1rrrr8�s
�zImmutableMap.__repr__)r7r9r:r;r`rr<rIrr rmrrrrvr>ryr2rhr8rrrrr_�s
	r_c@s�eZdZdZdZdededdfdd�Zd	edefd
d�Zde	efdd
�Z
defdd�Zde
e
eefdffdd�Zdefdd�Zdedefdd�Zdededdfdd�Zdefdd�ZdS)�
frozendictzFrozen dictionary.)�_items�_keys�argsrarNcOsh|r	|s	t|�}nt|�dkrt|dt�r|d}nt��t�|d|�t�|dtt|�	����dS)N�rr�r�)
�dictrxrrrergrhr|�sorted�keys)rr�rarlrrrr �s

zfrozendict.__init__rncCs
|j|Sr)r�rqrrrrr�rwzfrozendict.__getitem__cCrtr)rur�r1rrrrv�rwzfrozendict.__iter__cCrtr)rxr�r1rrrry�rwzfrozendict.__len__.cst�fdd��jD��S)Nc3s�|]	}|�|fVqdSrr)rzrnr1rrr{�s�z+frozendict._sorted_items.<locals>.<genexpr>)r|r�r1rr1r�
_sorted_items�szfrozendict._sorted_itemscCst|���Sr)r0r�r1rrrr2�r&zfrozendict.__hash__r!cCs$z|j|WStyt|��wr)r�rpror$rrrr%�rszfrozendict.__getattr__r}cCr~rr�r�rrrrh�r�zfrozendict.__setattr__cCsd�d�dd�|��D���S)Nzfrozendict({0})rbcsr�r�r�r�rrrr{�s���z&frozendict.__repr__.<locals>.<genexpr>)r6rfr�r1rrrr8�s
�zfrozendict.__repr__)r7r9r:r;r`rr r<rrrrvr>ryrr�r2r%rhr8rrrrr��s
r�c@sneZdZdZdeddfdd�Zdedefdd	�Zded
eddfdd�Z	deddfd
d�Z
deefdd�ZdS)�_UtilDeprecationModulez�
    Internal class delegating to a module, and displaying warnings when attributes
    related to the deprecated "abstractclassmethod" attributes in the josepy.util module.
    �modulerNcCs||jd<dS�N�_module)�__dict__)rr�rrrr �rz_UtilDeprecationModule.__init__�attrcCs$|dkrtjdtdd�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��rr�rrrr%s
�z"_UtilDeprecationModule.__getattr__r}cCst|j||�dSr)�setattrr�)rr�r}rrrrh	r3z"_UtilDeprecationModule.__setattr__cCst|j|�dSr)�delattrr�r�rrr�__delattr__�z"_UtilDeprecationModule.__delattr__cCsdgt|j�Sr�)�dirr�r1rrr�__dir__r�z_UtilDeprecationModule.__dir__)
r7r9r:r;rr r<rr%rhr�rr�rrrrr��sr�)!r;r�typesr�typingrrrrrrr	�collections.abcr
r�sysr��OpenSSLr�)cryptography.hazmat.primitives.asymmetricr
rrrrrArMrZr_r�r��modulesr7rrrr�<module>s$$/+-2
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY