JFIF$        dd7 

Viewing File: /usr/lib/python3.9/site-packages/josepy/__pycache__/util.cpython-39.opt-1.pyc

a

�BgA'�@s$dZddlZddlZddlZddlmZmZddlmZddl	m
Z
mZmZm
Z
mZmZmZmZddlmZmZddlmZeed�d	d
�ZGdd�d�ZGd
d�d�ZGdd�de�ZGdd�de�Zeddd�ZGdd�dee�ZGdd�dee�ZGdd�d�Z eee ej!e"��ej!e"<dS)zJOSE utilities.�N)�Hashable�Mapping)�
ModuleType)�Any�Callable�Iterator�List�Tuple�TypeVar�Union�cast)�ec�rsa)�crypto)�func�returncCstt�|��S�N)�classmethod�abc�abstractmethod)r�r�//usr/lib/python3.9/site-packages/josepy/util.py�abstractclassmethodsrc@s~eZdZdZeejejfdd�dd�Ze	e
d�dd�Zejfe
ed	�d
d�Ze
ed�d
d�Ze
d�dd�Ze	d�dd�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`.

    N)�wrappedrcCs
||_dSr�r��selfrrrr�__init__szComparableX509.__init__��namercCst|j|�Sr)�getattrr�rr rrr�__getattr__szComparableX509.__getattr__)�filetypercCs*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

        )�
isinstancerr�X509Zdump_certificateZdump_certificate_request)rr$rrr�_dump!szComparableX509._dump��otherrcCs t||j�stS|��|��kSr)r%�	__class__�NotImplementedr'�rr)rrr�__eq__3szComparableX509.__eq__�rcCst|j|��f�Sr)�hashr*r'�rrrr�__hash__8szComparableX509.__hash__cCsd�|jj|j�S�Nz<{0}({1!r})>)�formatr*�__name__rr0rrr�__repr__;szComparableX509.__repr__)r4�
__module__�__qualname__�__doc__rrr&ZX509Reqr�strrr#Z
FILETYPE_ASN1�int�bytesr'�boolr-r1r5rrrrrsrc@s�eZdZUdZeZegefed<e	e
je
je
je
jfd�dd�Zeed�dd�Zeed	�d
d�Zed�d
d�Zdd�dd�ZdS)�
ComparableKeyznComparable wrapper for ``cryptography`` keys.

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

    r1rcCs
||_dSr)�_wrappedrrrrrHs	zComparableKey.__init__rcCst|j|�Sr)r!r>r"rrrr#SszComparableKey.__getattr__r(cCs`t||j�r|jj|jjur tSt|jd�r<|��|��kSt|jd�rX|��|��kStSdS)N�private_numbers�public_numbers)r%r*r>r+�hasattrr?r@r,rrrr-Vs
��zComparableKey.__eq__r.cCsd�|jj|j�Sr2)r3r*r4r>r0rrrr5cszComparableKey.__repr__cCs(t|jtjtjf�r|S|�|j���S)zGet wrapped public key.)r%r>r�RSAPublicKeyWithSerializationr
�'EllipticCurvePublicKeyWithSerializationr*�
public_keyr0rrrrDfs
�zComparableKey.public_keyN)r4r6r7r8r+r1rr:�__annotations__rr�RSAPrivateKeyWithSerializationrBr
�(EllipticCurvePrivateKeyWithSerializationrCrr9rr#r<r-r5rDrrrrr=?s
���
r=c@seZdZdZed�dd�ZdS)�ComparableRSAKeyz�Wrapper for ``cryptography`` RSA keys.

    Wraps around:

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

    r.c	Csxt|jtj�rD|��}|j}t|j|j|j	|j
|j|j|j
|jf�St|jtj�rn|��}t|j|j
|jf�St��dSr)r%r>rrFr?r@r/r*�p�qZdmp1Zdmq1Ziqmp�n�erB�NotImplementedError�rZprivZpubrrrr1{s"�zComparableRSAKey.__hash__N�r4r6r7r8r:r1rrrrrHqs	rHc@seZdZdZed�dd�ZdS)�ComparableECKeyz�Wrapper for ``cryptography`` EC keys.
    Wraps around:
    - :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey`
    - :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
    r.cCstt|jtj�r:|��}|j}t|j|jj	|j
|j|jf�St|jtj
�rj|��}t|j|jj	|j
|jf�St��dSr)r%r>r
rGr?r@r/r*Zcurver �x�yZ
private_valuerCrMrNrrrr1�szComparableECKey.__hash__NrOrrrrrP�srP�GenericImmutableMap�ImmutableMap)�boundc@s�eZdZUdZdZeedfed<edd�dd�Z	e
ee
d	�d
d�Zeed�d
d�Ze
ed�dd�Zed�dd�Zed�dd�Zeedd�dd�Zed�dd�ZdS)rTz5Immutable key to value mapping with attribute access.r.�	__slots__N)�kwargsrcKs\t|�t|j�kr8td�d�|j�|r0d�|�nd���|jD]}t�|||�|��q>dS)NzA__init__() takes exactly the following arguments: {0} ({1} given)�, Znone)�setrV�	TypeErrorr3�join�object�__setattr__�pop)rrW�slotrrrr�s��
zImmutableMap.__init__)rrWrcKsi|�|�}t|�fi|��S)zReturn updated map.)�type)rrW�itemsrrr�update�szImmutableMap.update��keyrcCs,zt||�WSty&t|��Yn0dSr)r!�AttributeError�KeyError�rrdrrr�__getitem__�szImmutableMap.__getitem__r.cCs
t|j�Sr)�iterrVr0rrr�__iter__�szImmutableMap.__iter__cCs
t|j�Sr)�lenrVr0rrr�__len__�szImmutableMap.__len__cstt�fdd��jD���S)Nc3s|]}t�|�VqdSr)r!)�.0r_r0rr�	<genexpr>��z(ImmutableMap.__hash__.<locals>.<genexpr>)r/�tuplerVr0rr0rr1�szImmutableMap.__hash__�r �valuercCstd��dS�Nzcan't set attribute�re�rr rrrrrr]�szImmutableMap.__setattr__cCs$d�|jjd�dd�|��D���S)Nz{0}({1})rXcss|]\}}d�||�VqdS�z	{0}={1!r}N�r3�rmrdrrrrrrn�roz(ImmutableMap.__repr__.<locals>.<genexpr>)r3r*r4r[rar0rrrr5�s�zImmutableMap.__repr__)r4r6r7r8rVr	r9rErrrSrbrhrrjr:rlr1r]r5rrrrrT�s
c@s�eZdZdZdZeedd�dd�Zeed�dd	�Ze	ed
�dd�Z
ed
�d
d�Ze
e
eefdfd
�dd�Zed
�dd�Zeed�dd�Zeedd�dd�Zed
�dd�ZdS)�
frozendictzFrozen dictionary.)�_items�_keysN)�argsrWrcOsh|r|st|�}n*t|�dkr6t|dt�r6|d}nt��t�|d|�t�|dtt|�	����dS)N�rrzr{)
�dictrkr%rrZr\r]rp�sorted�keys)rr|rWrarrrr�s

zfrozendict.__init__rccCs
|j|Sr)rzrgrrrrh�szfrozendict.__getitem__r.cCs
t|j�Sr)rir{r0rrrrj�szfrozendict.__iter__cCs
t|j�Sr)rkrzr0rrrrl�szfrozendict.__len__.cst�fdd��jD��S)Nc3s|]}|�|fVqdSrr)rmrdr0rrrn�roz+frozendict._sorted_items.<locals>.<genexpr>)rpr{r0rr0r�
_sorted_items�szfrozendict._sorted_itemscCst|���Sr)r/r�r0rrrr1�szfrozendict.__hash__rcCs,z|j|WSty&t|��Yn0dSr)rzrfrer"rrrr#�szfrozendict.__getattr__rqcCstd��dSrsrtrurrrr]�szfrozendict.__setattr__cCsd�d�dd�|��D���S)Nzfrozendict({0})rXcss|]\}}d�||�VqdSrvrwrxrrrrn�roz&frozendict.__repr__.<locals>.<genexpr>)r3r[r�r0rrrr5�s�zfrozendict.__repr__)r4r6r7r8rVrrr9rhrrjr:rlr	r�r1r#r]r5rrrrry�s
ryc@sdeZdZdZedd�dd�Zeed�dd�Zeedd	�d
d�Z	edd�dd
�Z
eed�dd�ZdS)�_UtilDeprecationModulez�
    Internal class delegating to a module, and displaying warnings when attributes
    related to the deprecated "abstractclassmethod" attributes in the josepy.util module.
    N)�modulercCs||jd<dS�N�_module)�__dict__)rr�rrrrsz_UtilDeprecationModule.__init__)�attrrcCs$|dkrtjdtdd�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�rrrcCst|j||�dSr)�setattrr�)rr�rrrrrr]sz"_UtilDeprecationModule.__setattr__cCst|j|�dSr)�delattrr�r�rrr�__delattr__sz"_UtilDeprecationModule.__delattr__r.cCsdgt|j�Sr�)�dirr�r0rrr�__dir__sz_UtilDeprecationModule.__dir__)
r4r6r7r8rrr9rr#r]r�rr�rrrrr�sr�)#r8r�sysr��collections.abcrr�typesr�typingrrrrr	r
rrZ)cryptography.hazmat.primitives.asymmetricr
rZOpenSSLrrrrr=rHrPrSrTryr��modulesr4rrrr�<module>s$(-2/3
Back to Directory  nL+D550H?Mx ,D"v]qv;6*Zqn)ZP0!1 A "#a$2Qr D8 a Ri[f\mIykIw0cuFcRı?lO7к_f˓[C$殷WF<_W ԣsKcëIzyQy/_LKℂ;C",pFA:/]=H  ~,ls/9ć:[=/#f;)x{ٛEQ )~ =𘙲r*2~ a _V=' kumFD}KYYC)({ *g&f`툪ry`=^cJ.I](*`wq1dđ#̩͑0;H]u搂@:~וKL Nsh}OIR*8:2 !lDJVo(3=M(zȰ+i*NAr6KnSl)!JJӁ* %݉?|D}d5:eP0R;{$X'xF@.ÊB {,WJuQɲRI;9QE琯62fT.DUJ;*cP A\ILNj!J۱+O\͔]ޒS߼Jȧc%ANolՎprULZԛerE2=XDXgVQeӓk yP7U*omQIs,K`)6\G3t?pgjrmۛجwluGtfh9uyP0D;Uڽ"OXlif$)&|ML0Zrm1[HXPlPR0'G=i2N+0e2]]9VTPO׮7h(F*癈'=QVZDF,d߬~TX G[`le69CR(!S2!P <0x<!1AQ "Raq02Br#SCTb ?Ζ"]mH5WR7k.ۛ!}Q~+yԏz|@T20S~Kek *zFf^2X*(@8r?CIuI|֓>^ExLgNUY+{.RѪ τV׸YTD I62'8Y27'\TP.6d&˦@Vqi|8-OΕ]ʔ U=TL8=;6c| !qfF3aů&~$l}'NWUs$Uk^SV:U# 6w++s&r+nڐ{@29 gL u"TÙM=6(^"7r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