404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.144.45.189: ~ $
3

�k�Z4�@s�ddlZddlZddlZddlmZmZddlmZddlm	Z	m
Z
mZmZm
Z
mZmZmZy�ddlmZddlmZmZmZddlmZmZmZmZmZmZmZmZdd	l m!Z!m"Z"dd
l#m$Z$m%Z%ddl&m'Z'ddl(m)Z)d
Z*Wne+k
r�dZ*YnXe,ddddddddddg
�Z-dd�Z.Gdd�de/�Z0Gdd�de0�Z1Gdd �d e0�Z2e*�r�Gd!d"�d"e0�Z3Gd#d$�d$e0�Z4Gd%d&�d&e3�Z5dS)'�N�)�constant_time_compare�string_types)�InvalidKeyError)�base64url_decode�base64url_encode�der_to_raw_signature�force_bytes�
force_unicode�from_base64url_uint�raw_to_der_signature�to_base64url_uint)�hashes)�load_pem_private_key�load_pem_public_key�load_ssh_public_key)�
RSAPrivateKey�RSAPublicKey�RSAPrivateNumbers�RSAPublicNumbers�rsa_recover_prime_factors�rsa_crt_dmp1�rsa_crt_dmq1�rsa_crt_iqmp)�EllipticCurvePrivateKey�EllipticCurvePublicKey)�ec�padding)�default_backend)�InvalidSignatureTF�RS256�RS384�RS512�ES256�ES384�ES521�ES512�PS256�PS384�PS512cCs�t�ttj�ttj�ttj�d�}tr�|jttj�ttj�ttj�ttj�ttj�ttj�ttj�t	t	j�t	t	j�t	t	j�d�
�|S)zE
    Returns the algorithms that are implemented by the library.
    )ZnoneZHS256ZHS384ZHS512)
r r!r"r#r$r%r&r'r(r))
�
NoneAlgorithm�
HMACAlgorithm�SHA256�SHA384�SHA512�
has_crypto�update�RSAAlgorithm�ECAlgorithm�RSAPSSAlgorithm)Zdefault_algorithms�r4� /usr/lib/python3.6/algorithms.py�get_default_algorithms&s"r6c@s@eZdZdZdd�Zdd�Zdd�Zedd	��Zed
d��Z	dS)
�	AlgorithmzH
    The interface for an algorithm used to sign and verify tokens.
    cCst�dS)z�
        Performs necessary validation and conversions on the key and returns
        the key value in the proper format for sign() and verify().
        N)�NotImplementedError)�self�keyr4r4r5�prepare_keyFszAlgorithm.prepare_keycCst�dS)zn
        Returns a digital signature for the specified message
        using the specified key value.
        N)r8)r9�msgr:r4r4r5�signMszAlgorithm.signcCst�dS)zz
        Verifies that the specified digital signature is valid
        for the specified message and key values.
        N)r8)r9r<r:�sigr4r4r5�verifyTszAlgorithm.verifycCst�dS)z7
        Serializes a given RSA key into a JWK
        N)r8)�key_objr4r4r5�to_jwk[szAlgorithm.to_jwkcCst�dS)zb
        Deserializes a given RSA key from JWK back into a PublicKey or PrivateKey object
        N)r8)�jwkr4r4r5�from_jwkbszAlgorithm.from_jwkN)
�__name__�
__module__�__qualname__�__doc__r;r=r?�staticmethodrArCr4r4r4r5r7Bsr7c@s(eZdZdZdd�Zdd�Zdd�ZdS)	r*zZ
    Placeholder for use when no signing or verification
    operations are required.
    cCs |dkrd}|dk	rtd��|S)N�z*When alg = "none", key value must be None.)r)r9r:r4r4r5r;os
zNoneAlgorithm.prepare_keycCsdS)N�r4)r9r<r:r4r4r5r=xszNoneAlgorithm.signcCsdS)NFr4)r9r<r:r>r4r4r5r?{szNoneAlgorithm.verifyN)rDrErFrGr;r=r?r4r4r4r5r*js	r*c@sZeZdZdZejZejZej	Z
dd�Zdd�Ze
dd��Ze
dd	��Zd
d�Zdd
�ZdS)r+zf
    Performs signing and verification operations using HMAC
    and the specified hash function.
    cCs
||_dS)N)�hash_alg)r9rKr4r4r5�__init__�szHMACAlgorithm.__init__cs6t���ddddg}t�fdd�|D��r2td���S)Ns-----BEGIN PUBLIC KEY-----s-----BEGIN CERTIFICATE-----s-----BEGIN RSA PUBLIC KEY-----sssh-rsacsg|]}|�k�qSr4r4)�.0Zstring_value)r:r4r5�
<listcomp>�sz-HMACAlgorithm.prepare_key.<locals>.<listcomp>zdThe specified key is an asymmetric key or x509 certificate and should not be used as an HMAC secret.)r	�anyr)r9r:Zinvalid_stringsr4)r:r5r;�szHMACAlgorithm.prepare_keycCstjttt|���dd��S)N�oct)�k�kty)�json�dumpsr
rr	)r@r4r4r5rA�szHMACAlgorithm.to_jwkcCs,tj|�}|jd�dkr td��t|d�S)NrRrPzNot an HMAC keyrQ)rS�loads�getrr)rB�objr4r4r5rC�s
zHMACAlgorithm.from_jwkcCstj|||j�j�S)N)�hmac�newrKZdigest)r9r<r:r4r4r5r=�szHMACAlgorithm.signcCst||j||��S)N)rr=)r9r<r:r>r4r4r5r?�szHMACAlgorithm.verifyN)rDrErFrG�hashlibZsha256r,Zsha384r-Zsha512r.rLr;rHrArCr=r?r4r4r4r5r+s	r+c@sZeZdZdZejZejZejZdd�Zdd�Z	e
dd��Ze
dd	��Zd
d�Z
dd
�ZdS)r1z~
        Performs signing and verification operations using
        RSASSA-PKCS-v1_5 and the specified hash function.
        cCs
||_dS)N)rK)r9rKr4r4r5rL�szRSAAlgorithm.__init__cCs�t|t�st|t�r|St|t�r~t|�}y.|jd�rFt|t�d�}nt|dt�d�}Wq�t	k
rzt
|t�d�}Yq�Xntd��|S)Nsssh-rsa)�backend)�passwordr[zExpecting a PEM-formatted key.)�
isinstancerrrr	�
startswithrrr�
ValueErrorr�	TypeError)r9r:r4r4r5r;�s



zRSAAlgorithm.prepare_keycCs�d}t|dd�r�|j�}ddgtt|jj��tt|jj��tt|j��tt|j��tt|j	��tt|j
��tt|j��tt|j��d�
}nBt|dd�r�|j�}ddgtt|j��tt|j��d�}nt
d��tj|�S)N�private_numbers�RSAr=)
rR�key_ops�n�e�d�p�q�dp�dq�qir?)rRrcrdrezNot a public or private key)�getattrrar
r
�public_numbersrdrerfrgrh�dmp1�dmq1�iqmprrSrT)r@rW�numbersr4r4r5rA�s*zRSAAlgorithm.to_jwkc	s�ytj|��Wntk
r*td��YnX�jd�dkrBtd��d�koXd�koXd�k�rfd�krltd	��d
ddd
dg}�fdd�|D�}t|�}|r�t|�r�td��tt�d�t�d��}|�rt	t�d�t�d
�t�d�t�d�t�d
�t�d�|d�}nHt�d�}t
|j||j�\}}t	|||t
||�t||�t||�|d�}|jt��Sd�k�r�d�k�r�tt�d�t�d��}|jt��Std��dS)NzKey is not valid JSONrRrbzNot an RSA keyrfrerdZothz5Unsupported RSA private key: > 2 primes not supportedrgrhrirjrkcsg|]}|�k�qSr4r4)rMZprop)rWr4r5rN	sz)RSAAlgorithm.from_jwk.<locals>.<listcomp>z@RSA key must include all parameters if any are present besides d)rfrgrhrnrorprmzNot a public or private key)rSrUr_rrVrO�allrrrrrdrerrrZprivate_keyrZ
public_key)	rBZother_propsZprops_foundZany_props_foundrmrqrfrgrhr4)rWr5rC�sT






zRSAAlgorithm.from_jwkcCs|j|tj�|j��S)N)r=r�PKCS1v15rK)r9r<r:r4r4r5r=8szRSAAlgorithm.signcCs6y|j||tj�|j��dStk
r0dSXdS)NTF)r?rrsrKr)r9r<r:r>r4r4r5r?;s
zRSAAlgorithm.verifyN)rDrErFrGrr,r-r.rLr;rHrArCr=r?r4r4r4r5r1�s$?r1c@sBeZdZdZejZejZejZdd�Zdd�Z	dd�Z
dd	�Zd
S)r2zr
        Performs signing and verification operations using
        ECDSA and the specified hash function
        cCs
||_dS)N)rK)r9rKr4r4r5rLKszECAlgorithm.__init__cCs�t|t�st|t�r|St|t�r~t|�}y,|jd�rFt|t�d�}nt|t�d�}Wq�t	k
rzt
|dt�d�}Yq�Xntd��|S)Nsecdsa-sha2-)r[)r\r[zExpecting a PEM-formatted key.)r]rrrr	r^rrrr_rr`)r9r:r4r4r5r;Ns



zECAlgorithm.prepare_keycCs"|j|tj|j���}t||j�S)N)r=r�ECDSArKr�curve)r9r<r:�der_sigr4r4r5r=fszECAlgorithm.signcCs\yt||j�}Wntk
r$dSXy|j||tj|j���dStk
rVdSXdS)NFT)rrur_r?rrtrKr)r9r<r:r>rvr4r4r5r?kszECAlgorithm.verifyN)rDrErFrGrr,r-r.rLr;r=r?r4r4r4r5r2Bsr2c@s eZdZdZdd�Zdd�ZdS)r3zA
        Performs a signature using RSASSA-PSS with MGF1
        cCs*|j|tjtj|j��|jjd�|j��S)N)�mgf�salt_length)r=r�PSS�MGF1rK�digest_size)r9r<r:r4r4r5r=|s
zRSAPSSAlgorithm.signc
CsJy0|j||tjtj|j��|jjd�|j��dStk
rDdSXdS)N)rwrxTF)r?rryrzrKr{r)r9r<r:r>r4r4r5r?�s

zRSAPSSAlgorithm.verifyN)rDrErFrGr=r?r4r4r4r5r3ws
r3)6rZrXrS�compatrr�
exceptionsrZutilsrrrr	r
rrr
Zcryptography.hazmat.primitivesrZ,cryptography.hazmat.primitives.serializationrrrZ-cryptography.hazmat.primitives.asymmetric.rsarrrrrrrrZ,cryptography.hazmat.primitives.asymmetric.ecrrZ)cryptography.hazmat.primitives.asymmetricrrZcryptography.hazmat.backendsrZcryptography.exceptionsrr/�ImportError�setZrequires_cryptographyr6�objectr7r*r+r1r2r3r4r4r4r5�<module>s6((
(45

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 1.02 KB 0644
__init__.cpython-36.pyc File 1.02 KB 0644
__main__.cpython-36.opt-1.pyc File 3.48 KB 0644
__main__.cpython-36.pyc File 3.48 KB 0644
algorithms.cpython-36.opt-1.pyc File 10.84 KB 0644
algorithms.cpython-36.pyc File 10.84 KB 0644
api_jws.cpython-36.opt-1.pyc File 6.24 KB 0644
api_jws.cpython-36.pyc File 6.24 KB 0644
api_jwt.cpython-36.opt-1.pyc File 5.85 KB 0644
api_jwt.cpython-36.pyc File 5.85 KB 0644
compat.cpython-36.opt-1.pyc File 1.39 KB 0644
compat.cpython-36.pyc File 1.39 KB 0644
exceptions.cpython-36.opt-1.pyc File 2.05 KB 0644
exceptions.cpython-36.pyc File 2.05 KB 0644
utils.cpython-36.opt-1.pyc File 3.04 KB 0644
utils.cpython-36.pyc File 3.04 KB 0644