404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.139.233.121: ~ $
3

�}:a7#�@s�dZddlZddlmZddlmZmZejd�Zejd�Zejd�Z	ej
d�Zej
d	�Zej
d
�Z
Gdd�dej�ZGd
d�dej�ZGdd�dej�ZGdd�dej�Zedkr�ej�dS)zTests for josepy.jwa.�N)�mock)�errors�	test_utilzrsa256_key.pemzrsa512_key.pemzrsa1024_key.pemzec_p256_key.pemzec_p384_key.pemzec_p521_key.pemc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�JWASignatureTestz"Tests for josepy.jwa.JWASignature.cCs4ddlm}Gdd�d|�}|d�|_|d�|_dS)Nr)�JWASignaturec@seZdZdd�Zdd�ZdS)z'JWASignatureTest.setUp.<locals>.MockSigcSs
t��dS)N)�NotImplementedError)�self�key�msg�r�/usr/lib/python3.6/jwa_test.py�signsz,JWASignatureTest.setUp.<locals>.MockSig.signcSs
t��dS)N)r)rr	r
�sigrrr�verifysz.JWASignatureTest.setUp.<locals>.MockSig.verifyN)�__name__�
__module__�__qualname__r
rrrrr�MockSigsr�Sig1�Sig2)�
josepy.jwarrr)rrrrrr�setUps

zJWASignatureTest.setUpcCs|j|j|j�dS)N)�assertEqualr)rrrr�test_eq"szJWASignatureTest.test_eqcCs|j|j|j�dS)N)�assertNotEqualrr)rrrr�test_ne%szJWASignatureTest.test_necCs|j|jd�dS)N�)rr)rrrr�test_ne_other_type(sz#JWASignatureTest.test_ne_other_typecCs(|jdt|j��|jdt|j��dS)Nrr)r�reprrr)rrrr�	test_repr+szJWASignatureTest.test_reprcCs(|j|jj�d�|j|jj�d�dS)Nrr)rrZto_partial_jsonr)rrrr�test_to_partial_json/sz%JWASignatureTest.test_to_partial_jsoncCs.ddlm}ddlm}|j|jd�|�dS)Nr)r)�RS256r!)rrr!�assertIs�	from_json)rrr!rrr�test_from_json3szJWASignatureTest.test_from_jsonN)rrr�__doc__rrrrrr r$rrrrrsrc@seZdZdd�ZdS)�	JWAHSTestcCsXddlm}d}|j|jdd�|�|j|jdd|�d�|j|jdd|d�d�dS)	Nr)�HS256s �R�͔���A.:'i��
�+��UZԳ�zOssome keysfooT�!F)rr'rr
r"r)rr'rrrr�test_it;s
zJWAHSTest.test_itN)rrrr)rrrrr&9sr&c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�	JWARSTestcCs(ddlm}|jtj|jtj�d�dS)Nr)r!sfoo)rr!�assertRaisesr�Errorr
�
RSA512_KEY�
public_key)rr!rrr�test_sign_no_private_partHsz#JWARSTest.test_sign_no_private_partcCsDddlm}ddlm}|jtj|jtd�|jtj|jtd�dS)Nr)r!)�PS256sfoo)rr!r0r+rr,r
�
RSA256_KEY)rr!r0rrr�test_sign_key_too_smallLsz!JWARSTest.test_sign_key_too_smallcCs`ddlm}d}|j|jtd�|�|j|jtj�d|�d�|j|jtj�d|d�d�dS)Nr)r!s@|Ʋ��(���*:�N&}��O�t��"Y�Y��)����&�ǙS���OV��ҹ.>}�sfooTr(F)rr!rr
r-r"rr.)rr!rrrr�test_rsRszJWARSTest.test_rscCsTddlm}|jtd�}|j|jtj�d|�d�|j|jtj�d|d�d�dS)Nr)r0sfooTr(F)rr0r
�RSA1024_KEYr"rr.)rr0rrrr�test_ps_s
zJWARSTest.test_pscCs4ddlm}tj�}|j|d�|j|jjd�dS)Nr)r!�messageT)rr!r�	MagicMockr
r"�called)rr!r	rrr�test_sign_new_apifszJWARSTest.test_sign_new_apicCsjddlm}tjdgd�}tj�}||j_|j|d�|j|jjd�|j|j	jd�|j|j
jd�dS)Nr)r!�signer)�specr6T)rr!rr7r:�return_valuer
r"r8�update�finalize)rr!r	r:rrr�test_sign_old_apilszJWARSTest.test_sign_old_apicCs6ddlm}tj�}|j|dd�|j|jjd�dS)Nr)r!r6�	signatureT)rr!rr7rr"r8)rr!r	rrr�test_verify_new_apivszJWARSTest.test_verify_new_apicCslddlm}tjdgd�}tj�}||j_|j|dd�|j|jjd�|j|j	jd�|j|jjd�dS)Nr)r!�verifier)r;r6r@T)
rr!rr7rBr<rr"r8r=)rr!r	rBrrr�test_verify_old_api|szJWARSTest.test_verify_old_apiN)rrrr/r2r3r5r9r?rArCrrrrr*Fs

r*c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�	JWAECTestcCs(ddlm}|jtj|jtj�d�dS)Nr)�ES256sfoo)rrEr+rr,r
�EC_P256_KEYr.)rrErrrr/�sz#JWAECTest.test_sign_no_private_partcCs:ddlm}d}|jt|�}|j|jtj�||�d�dS)Nr)rEsfooT)rrEr
rFr"rr.)rrEr6r@rrr�test_es256_sign_and_verify�sz$JWAECTest.test_es256_sign_and_verifycCs:ddlm}d}|jt|�}|j|jtj�||�d�dS)Nr)�ES384sfooT)rrHr
�EC_P384_KEYr"rr.)rrHr6r@rrr�test_es384_sign_and_verify�sz$JWAECTest.test_es384_sign_and_verifycCs>ddlm}m}d}|jt|�}|j|jtj�||�d�dS)Nr)rErHsfooF)	rrErHr
rFr"rrIr.)rrErHr6r@rrr�test_verify_with_wrong_jwa�sz$JWAECTest.test_verify_with_wrong_jwacCsbddlm}ddlm}ddlm}d}|jt|�}|j|j	|��}|j
|j|j�||�d�dS)Nr)rE)�ec)�default_backendsfooF)
rrEZ)cryptography.hazmat.primitives.asymmetricrLZcryptography.hazmat.backendsrMr
rFZgenerate_private_key�	SECP256R1r"rr.)rrErLrMr6r@Z
different_keyrrr�test_verify_with_different_key�sz(JWAECTest.test_verify_with_different_keyc
Csbddlm}ddlm}tj|�d�}tjd��}d|_|j|d�WdQRX|j	|jj
d�dS)	Nr)rE)rN)�curvezjosepy.jwa.decode_dss_signaturer6T)rr)rrE�,cryptography.hazmat.primitives.asymmetric.ecrNrr7�patchr<r
r"r8)rrErNr	�decode_patchrrrr9�szJWAECTest.test_sign_new_apic
Cs�ddlm}ddlm}tjdg|�d�}tj�}||j_tjd��}d	|_|j	|d�WdQRX|j
|jjd�|j
|jjd�|j
|j
jd�dS)
Nr)rE)rNr:)r;rPzjosepy.jwa.decode_dss_signaturer6T)rr)rrErQrNrr7r:r<rRr
r"r8r=r>)rrErNr	r:rSrrrr?�szJWAECTest.test_sign_old_apicCsfddl}ddlm}ddlm}tjd|�d�}|j|dd|j|j	d�d	�|j
|jjd
�dS)Nr)rE)rN�)�key_sizerPr6���T)�mathrrErQrNrr7r�ceilrUr"r8)rrYrErNr	rrrrA�s"zJWAECTest.test_verify_new_apicCs�ddl}ddlm}ddlm}tjdgd|�d�}tj�}||j_|j	|dd|j
|jd	�d
�|j|jj
d�|j|jj
d�|j|j	j
d�dS)Nr)rE)�	SECP521R1rBi	)r;rUrPr6rVrWrXT)rYrrErQr[rr7rBr<rrZrUr"r8r=)rrYrEr[r	rBrrrrC�s"zJWAECTest.test_verify_old_apicCslddlm}ddlm}|jdddddd	��}tjd
��*}d|_|j|j	d�}|j
t|�d�WdQRXdS)Nr)�ES512)�JWKzXAf9KP6DqLRbtit6NS_LRIaCP_-NdC5l5R2ugbILdfpv6dS9R4wUPNxiGw-vVWumA56Yo1oBnEm8ZdR4W-u1lPHw5zXAD4i4STyJ07iZJkHkpKEOuICpn6IHknzwAlrf-1w1a5dqOsRe30EECSN4vFxaeAmtdBSCKBwCq7h1q4bPgMrMUvFZXAHAlXxrabjcx_yBxGObnm_DkEQMJK1E69OHY3x3VxF5VXoKc93CG4GLoaPvphZQvZnt5EfExQoPktwOMIVhBHaFRzP-521ZEC)�d�x�yZcrvZktyzjosepy.jwa.decode_dss_signaturestestrX�B)rr�)rr\Z
josepy.jwkr]r#rrRr<r
r	r�len)rr\r]r	rSrrrr�test_signature_size�s
zJWAECTest.test_signature_sizeN)
rrrr/rGrJrKrOr9r?rArCrdrrrrrD�s
	
rD�__main__)r%ZunittestrZjosepyrrZload_rsa_private_keyr1r-r4Zload_ec_private_keyrFrIZEC_P521_KEYZTestCaserr&r*rDr�mainrrrr�<module>s





*
A^

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 1.95 KB 0644
__init__.cpython-36.pyc File 1.95 KB 0644
b64.cpython-36.opt-1.pyc File 1.56 KB 0644
b64.cpython-36.pyc File 1.56 KB 0644
b64_test.cpython-36.opt-1.pyc File 3.47 KB 0644
b64_test.cpython-36.pyc File 3.47 KB 0644
errors.cpython-36.opt-1.pyc File 1.55 KB 0644
errors.cpython-36.pyc File 1.55 KB 0644
errors_test.cpython-36.opt-1.pyc File 854 B 0644
errors_test.cpython-36.pyc File 854 B 0644
interfaces.cpython-36.opt-1.pyc File 7.93 KB 0644
interfaces.cpython-36.pyc File 7.93 KB 0644
interfaces_test.cpython-36.opt-1.pyc File 5.38 KB 0644
interfaces_test.cpython-36.pyc File 5.38 KB 0644
json_util.cpython-36.opt-1.pyc File 14.93 KB 0644
json_util.cpython-36.pyc File 14.93 KB 0644
json_util_test.cpython-36.opt-1.pyc File 17.19 KB 0644
json_util_test.cpython-36.pyc File 17.19 KB 0644
jwa.cpython-36.opt-1.pyc File 7.73 KB 0644
jwa.cpython-36.pyc File 7.73 KB 0644
jwa_test.cpython-36.opt-1.pyc File 9.67 KB 0644
jwa_test.cpython-36.pyc File 9.67 KB 0644
jwk.cpython-36.opt-1.pyc File 11.66 KB 0644
jwk.cpython-36.pyc File 11.66 KB 0644
jwk_test.cpython-36.opt-1.pyc File 12.73 KB 0644
jwk_test.cpython-36.pyc File 12.73 KB 0644
jws.cpython-36.opt-1.pyc File 12.1 KB 0644
jws.cpython-36.pyc File 12.49 KB 0644
jws_test.cpython-36.opt-1.pyc File 9.4 KB 0644
jws_test.cpython-36.pyc File 9.4 KB 0644
magic_typing.cpython-36.opt-1.pyc File 775 B 0644
magic_typing.cpython-36.pyc File 775 B 0644
magic_typing_test.cpython-36.opt-1.pyc File 1.07 KB 0644
magic_typing_test.cpython-36.pyc File 1.07 KB 0644
test_util.cpython-36.opt-1.pyc File 2.77 KB 0644
test_util.cpython-36.pyc File 2.77 KB 0644
util.cpython-36.opt-1.pyc File 9.76 KB 0644
util.cpython-36.pyc File 9.84 KB 0644
util_test.cpython-36.opt-1.pyc File 11.62 KB 0644
util_test.cpython-36.pyc File 11.62 KB 0644