ok

Mini Shell

Direktori : /lib/python3.6/site-packages/josepy/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/josepy/__pycache__/util.cpython-36.pyc

3

�}:a!�@s�dZddlmZmZddlZddlmZddlmZm	Z	Gdd�de
�ZGdd	�d	�ZGd
d�d�Z
Gdd
�d
e
�ZGdd�de
�ZGdd�dee�ZGdd�dee�ZdS)zJOSE utilities.�)�Hashable�MappingN)�default_backend)�ec�rsacs$eZdZdZdZ�fdd�Z�ZS)�abstractclassmethoda�Descriptor for an abstract classmethod.

    It augments the :mod:`abc` framework with an abstract
    classmethod. This is implemented as :class:`abc.abstractclassmethod`
    in the standard Python library starting with version 3.2.

    This implementation is from a StackOverflow answer that was derived from
    the implementation in the Python 3.3 abc library.
    http://stackoverflow.com/questions/11217878/python-2-7-combine-abc-abstractmethod-and-classmethod.

    Tcsd|_t�j|�dS)NT)�__isabstractmethod__�super�__init__)�self�target)�	__class__��/usr/lib/python3.6/util.pyr
szabstractclassmethod.__init__)�__name__�
__module__�__qualname__�__doc__rr
�
__classcell__rr)r
rr	src@sHeZdZdZdd�Zdd�Zejjfdd�Z	dd	�Z
d
d�Zdd
�ZdS)�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`.

    cCs*t|tjj�s t|tjj�s t�||_dS)N)�
isinstance�OpenSSL�crypto�X509ZX509Req�AssertionError�wrapped)rrrrrr
%szComparableX509.__init__cCst|j|�S)N)�getattrr)r�namerrr�__getattr__*szComparableX509.__getattr__cCs.t|jtjj�rtjj}ntjj}|||j�S)aLDumps 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: str

        )rrrrrZdump_certificateZdump_certificate_request)rZfiletype�funcrrr�_dump-s
zComparableX509._dumpcCs t||j�stS|j�|j�kS)N)rr
�NotImplementedr )r�otherrrr�__eq__?szComparableX509.__eq__cCst|j|j�f�S)N)�hashr
r )rrrr�__hash__EszComparableX509.__hash__cCsdj|jj|j�S)Nz<{0}({1!r})>)�formatr
rr)rrrr�__repr__HszComparableX509.__repr__N)
rrrrr
rrrZ
FILETYPE_ASN1r r#r%r'rrrrrsrc@s<eZdZdZeZdd�Zdd�Zdd�Zdd	�Z	d
d�Z
dS)
�
ComparableKeyznComparable wrapper for ``cryptography`` keys.

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

    cCs
||_dS)N)�_wrapped)rrrrrr
TszComparableKey.__init__cCst|j|�S)N)rr))rrrrrrWszComparableKey.__getattr__cCsbt||j�s|jj|jjk	r"tSt|jd�r>|j�|j�kSt|jd�rZ|j�|j�kStSdS)N�private_numbers�public_numbers)rr
r)r!�hasattrr*r+)rr"rrrr#ZszComparableKey.__eq__cCsdj|jj|j�S)Nz<{0}({1!r})>)r&r
rr))rrrrr'fszComparableKey.__repr__cCs|j|jj��S)zGet wrapped public key.)r
r)�
public_key)rrrrr-iszComparableKey.public_keyN)rrrrr!r%r
rr#r'r-rrrrr(Lsr(c@seZdZdZdd�ZdS)�ComparableRSAKeyz�Wrapper for ``cryptography`` RSA keys.

    Wraps around:

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

    c	Csrt|jtj�rD|j�}|j}t|j|j|j	|j
|j|j|j
|jf�St|jtj�rn|j�}t|j|j
|jf�SdS)N)rr)rZRSAPrivateKeyWithSerializationr*r+r$r
�p�qZdmp1Zdmq1Ziqmp�n�eZRSAPublicKeyWithSerialization)r�priv�pubrrrr%xszComparableRSAKey.__hash__N)rrrrr%rrrrr.nsr.c@s eZdZdZdd�Zdd�ZdS)�ComparableECKeyz�Wrapper for ``cryptography`` RSA keys.
    Wraps around:
    - :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey`
    - :class:`~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey`
    cCsnt|jtj�r:|j�}|j}t|j|jj	|j
|j|jf�St|jtj
�rj|j�}t|j|jj	|j
|jf�SdS)N)rr)rZ(EllipticCurvePrivateKeyWithSerializationr*r+r$r
Zcurver�x�yZ
private_valueZ'EllipticCurvePublicKeyWithSerialization)rr3r4rrrr%�szComparableECKey.__hash__cCs4t|jd�r|jj�}n|jj�jt��}|j|�S)zGet wrapped public key.r-)r,r)r-r+rr
)r�keyrrrr-�szComparableECKey.public_keyN)rrrrr%r-rrrrr5�sr5c@sTeZdZdZfZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�ZdS)�ImmutableMapz5Immutable key to value mapping with attribute access.cKs`t|�t|j�kr8tdjdj|j�|r0dj|�nd���x"|jD]}tj|||j|��q@WdS)NzA__init__() takes exactly the following arguments: {0} ({1} given)z, Znone)�set�	__slots__�	TypeErrorr&�join�object�__setattr__�pop)r�kwargs�slotrrrr
�s
zImmutableMap.__init__cKs||�}t|�f|�S)zReturn updated map.)�type)rrA�itemsrrr�update�szImmutableMap.updatecCs,y
t||�Stk
r&t|��YnXdS)N)r�AttributeError�KeyError)rr8rrr�__getitem__�s
zImmutableMap.__getitem__cCs
t|j�S)N)�iterr;)rrrr�__iter__�szImmutableMap.__iter__cCs
t|j�S)N)�lenr;)rrrr�__len__�szImmutableMap.__len__cstt�fdd��jD���S)Nc3s|]}t�|�VqdS)N)r)�.0rB)rrr�	<genexpr>�sz(ImmutableMap.__hash__.<locals>.<genexpr>)r$�tupler;)rr)rrr%�szImmutableMap.__hash__cCstd��dS)Nzcan't set attribute)rF)rr�valuerrrr?�szImmutableMap.__setattr__cCs$dj|jjdjdd�|j�D���S)Nz{0}({1})z, css|]\}}dj||�VqdS)z	{0}={1!r}N)r&)rMr8rPrrrrN�sz(ImmutableMap.__repr__.<locals>.<genexpr>)r&r
rr=rD)rrrrr'�szImmutableMap.__repr__N)
rrrrr;r
rErHrJrLr%r?r'rrrrr9�s	r9c@s\eZdZdZdZdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�
frozendictzFrozen dictionary.�_items�_keyscOsj|r|rt|�}n*t|�dkr8t|dt�r8|d}nt��tj|d|�tj|dtt|j	����dS)N�rrRrS)
�dictrKrrr<r>r?rO�sorted�keys)r�argsrArDrrrr
�s


zfrozendict.__init__cCs
|j|S)N)rR)rr8rrrrH�szfrozendict.__getitem__cCs
t|j�S)N)rIrS)rrrrrJ�szfrozendict.__iter__cCs
t|j�S)N)rKrR)rrrrrL�szfrozendict.__len__cst�fdd��jD��S)Nc3s|]}|�|fVqdS)Nr)rMr8)rrrrN�sz+frozendict._sorted_items.<locals>.<genexpr>)rOrS)rr)rr�
_sorted_items�szfrozendict._sorted_itemscCst|j��S)N)r$rY)rrrrr%�szfrozendict.__hash__cCs,y
|j|Stk
r&t|��YnXdS)N)rRrGrF)rrrrrr�s
zfrozendict.__getattr__cCstd��dS)Nzcan't set attribute)rF)rrrPrrrr?�szfrozendict.__setattr__cCsdjdjdd�|j�D���S)Nzfrozendict({0})z, css|]\}}dj||�VqdS)z	{0}={1!r}N)r&)rMr8rPrrrrN�sz&frozendict.__repr__.<locals>.<genexpr>)r&r=rY)rrrrr'�szfrozendict.__repr__N)rRrS)rrrrr;r
rHrJrLrYr%rr?r'rrrrrQ�srQ)r�collections.abcrrrZcryptography.hazmat.backendsrZ)cryptography.hazmat.primitives.asymmetricrr�classmethodrrr(r.r5r9rQrrrr�<module>s/"-

Zerion Mini Shell 1.0