404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.117.138.178: ~ $
3

�}:aY7�@s�dZddlZddlZddlZddlZddlmZmZmZm	Z	m
Z
mZGdd�d�ZGdd�dej
�ZGdd	�d	ej
�ZGd
d�dej
�ZGdd
�d
�Zedkr�eej��dS)zJSON Web Signature.�N)�b64�errors�	json_util�jwa�jwk�utilc@s,eZdZdZdZedd��Zedd��ZdS)�	MediaTypez MediaType field encoder/decoder.zapplication/cCs(d|kr$d|krtjd��|j|S|S)zDecoder.�/�;zUnexpected semi-colon)r�DeserializationError�PREFIX)�cls�value�r�/usr/lib/python3.6/jws.py�decodes


zMediaType.decodecCsd|kr|t|j�d�S|S)zEncoder.r
N)�lenr)r
rrrr�encodeszMediaType.encodeN)�__name__�
__module__�__qualname__�__doc__r�classmethodrrrrrrrs
rc@seZdZdZejdejjdd�Z	ejddd�Z
ejdejjdd�Zejddd�Z
ejd	dd�Zejd
dfd�Zejdejdd�Zejd
ejdd�Zejdejejdd�Zejdejejdd�Zejddfd�Zdd�Zdd�Zdd�Zejdd��Zejdd��Zejdd��ZdS)�Headera6JOSE Header.

    .. warning:: This class supports **only** Registered Header
        Parameter Names (as defined in section 4.1 of the
        protocol). If you need Public Header Parameter Names (4.2)
        or Private Header Parameter Names (4.3), you must subclass
        and override :meth:`from_json` and :meth:`to_partial_json`
        appropriately.

    .. warning:: This class does not support any extensions through
        the "crit" (Critical) Header Parameter (4.1.11) and as a
        conforming implementation, :meth:`from_json` treats its
        occurrence as an error. Please subclass if you seek for
        a different behaviour.

    :ivar x5tS256: "x5t#S256"
    :ivar str typ: MIME Media Type, inc. :const:`MediaType.PREFIX`.
    :ivar str cty: Content-Type, inc. :const:`MediaType.PREFIX`.

    �algT)�decoder�	omitempty�jku)rr�kid�x5u�x5c)r�default�x5tzx5t#S256�typ)�encoderrr�cty�critcs�fdd��jj�D�S)z4Fields that would not be omitted in the JSON object.cs,i|]$\}}|jt�|��st�|�|�qSr)Zomit�getattr)�.0�nameZfield)�selfrr�
<dictcomp>Msz&Header.not_omitted.<locals>.<dictcomp>)�_fields�items)r*r)r*r�not_omittedKs
zHeader.not_omittedcCs^t|t|��s tdjt|����|j�}|j�}t|�j|�rFtd��|j|�t|�f|�S)NzHeader cannot be added to: {0}z+Addition of overlapping headers not defined)�
isinstance�type�	TypeError�formatr.�set�intersection�update)r*�otherZnot_omitted_selfZnot_omitted_otherrrr�__add__Qs
zHeader.__add__cCs|jdkrtjd��|jS)z�Find key based on header.

        .. todo:: Supports only "jwk" header parameter lookup.

        :returns: (Public) key found in the header.
        :rtype: .JWK

        :raises josepy.errors.Error: if key could not be found

        NzNo key found)rr�Error)r*rrr�find_key_s

zHeader.find_keycCstjd��dS)Nz("crit" is not supported, please subclass)rr)Zunused_valuerrrr&nszHeader.critcCsdd�|D�S)NcSs&g|]}tjtjjtjj|j���qSr)�base64�	b64encode�OpenSSL�cryptoZdump_certificate�
FILETYPE_ASN1�wrapped)r(�certrrr�
<listcomp>xszHeader.x5c.<locals>.<listcomp>r)rrrrr vsz
Header.x5ccCsHytdd�|D��Stjjk
rB}ztj|��WYdd}~XnXdS)Ncss,|]$}tjtjjtjjtj|���VqdS)N)rZComparableX509r<r=Zload_certificater>r:�	b64decode)r(r@rrr�	<genexpr>~szHeader.x5c.<locals>.<genexpr>)�tupler<r=r8rr)r�errorrrrr {s

N)rrrrr�Fieldr�JWASignature�	from_jsonrrr�JWKrrr �decode_b64joser"Zx5tS256rrrr#r%r&r.r7r9rr$rrrrr%s.

rcs�eZdZdZeZdZejdddd�Z	ejdde�ej
d�Zejd	ejej
d
�Ze	jdd��Z	e	jd
d��Z	�fdd�Zedd��Zedd��Zddd�Zede�fdd��Z�fdd�Ze�fdd��Z�ZS)�	SignatureaJWS Signature.

    :ivar combined: Combined Header (protected and unprotected,
        :class:`Header`).
    :ivar unicode protected: JWS protected header (Jose Base-64 decoded).
    :ivar header: JWS Unprotected Header (:class:`Header`).
    :ivar str signature: The signature.

    �combined�	protectedT�)rr!�header)rr!r�	signature)rr$cCstj|jd��S)Nzutf-8)r�encode_b64joser)rrrrrM�szSignature.protectedcCstj|�jd�S)Nzutf-8)rrJr)rrrrrM�scs$d|kr|j|�}t�jf|�dS)NrL)�_with_combined�super�__init__)r*�kwargs)�	__class__rrrT�s
zSignature.__init__cCsN|jd|jdj�}|jd|jdj�}|r>||jj|�}n|}||d<|S)NrOrMrL)�getr,r!�
header_cls�
json_loads)r
rUrOrMrLrrrrR�szSignature._with_combinedcCstj|jd��dtj|�S)Nzutf-8�.)rr;r)r
rM�payloadrrr�_msg�szSignature._msgNcCs8|dkr|jj�n|}|jjj|j|j|j|j|�d�S)zEVerify.

        :param JWK key: Key used for verification.

        N)�key�sig�msg)rLr9r�verifyr]rPr\rM)r*r[r]rrrr`�szSignature.verifycKs�|}||d<|r|j�|d<i}x"|D]}	|	|kr&|j|	�||	<q&W|rZ|jf|�j�}
nd}
|jf|�}	|j|j|j|
|��}||
|	|d�S)z;Sign.

        :param JWK key: Key for signature.

        rrrN)rMrOrP)�
public_key�poprXZ
json_dumps�signr]r\)r
r[r]rZinclude_jwk�protectrUZ
header_paramsZprotected_paramsrOrMrPrrrrc�s

zSignature.signcs t�j�}|dj�s|d=|S)NrO)rS�fields_to_partial_jsonr.)r*�fields)rVrrre�s
z Signature.fields_to_partial_jsoncs4t�j|�}|j|�}d|dj�kr0tjd��|S)NrrLzalg not present)rS�fields_from_jsonrRr.rr)r
�jobjrfZfields_with_combined)rVrrrg�s


zSignature.fields_from_json)rL)N)rrrrrrX�	__slots__rrFrMrHrOrJrQrPr$rrTrrRr\r`�	frozensetrcrerg�
__classcell__rr)rVrrK�s*	


rKc@sdeZdZdZdZeZddd�Zedd��Z	e
d	d
��Zdd�Zed
d��Z
ddd�Zedd��ZdS)�JWSzgJSON Web Signature.

    :ivar str payload: JWS Payload.
    :ivar str signature: JWS Signatures.

    r[�
signaturesNcst��fdd��jD��S)zVerify.c3s|]}|j�j��VqdS)N)r`r[)r(r^)r]r*rrrCszJWS.verify.<locals>.<genexpr>)�allrm)r*r]r)r]r*rr`sz
JWS.verifycKs |||jjfd|i|��fd�S)zSign.r[)r[rm)�
signature_clsrc)r
r[rUrrrrcszJWS.signcCs
|jdS)zPGet a singleton signature.

        :rtype: :class:`JWS.signature_cls`

        r)rm)r*rrrrPsz
JWS.signaturecCs6tj|jjjd��dtj|j�dtj|jj�S)z7Compact serialization.

        :rtype: bytes

        zutf-8rZ)rr;rPrMrr[)r*rrr�
to_compacts&zJWS.to_compactcCshy|jd�\}}}Wntk
r2tjd��YnX|jtj|�jd�tj|�d�}|tj|�|fd�S)zACompact deserialization.

        :param bytes compact:

        rZzOCompact JWS serialization should comprise of exactly 3 dot-separated componentszutf-8)rMrP)r[rm)�split�
ValueErrorrrrorrBr)r
�compactrMr[rPr^rrr�from_compact(szJWS.from_compactTcCsHtj|j�}|r8t|j�dkr8|jdj�}||d<|S||jd�SdS)N�rr[)r[rm)rrQr[rrm�to_partial_json)r*Zflatr[�retrrrrv;szJWS.to_partial_jsoncsvd|krd|krtjd��nVd|krF�tj|jd���jj|�fd�S�tj|d�t�fdd�|dD��d�SdS)NrPrmzFlat mixed with non-flatr[)r[rmc3s|]}�jj|�VqdS)N)rorH)r(r^)r
rrrCRsz JWS.from_json.<locals>.<genexpr>)rrrrJrbrorHrD)r
rhr)r
rrHIsz
JWS.from_json)r[rm)N)T)rrrrrirKror`rrc�propertyrPrprtrvrHrrrrrl�s


rlc@sZeZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	edd
d��Z
dS)�CLIzJWS CLI.cCs�|jjj|jj��}|jj�|jdkr.g|_|jr@|jjd�t	j
tjj�j
�||jt|j�d�}|jr~t|j�jd��nt|j��dS)zSign.Nr)r[r]rrdzutf-8)r�kty�loadr]�read�closerdrs�appendrlrc�sys�stdinrr3�printrprZjson_dumps_pretty)r
�argsr]r^rrrrcYs

zCLI.signcCs�|jrtjtjj�j��}n@ytjtjj��}Wn*tj	k
rZ}zt
|�dSd}~XnX|jdk	r�|jj
|jj��j�}|jj�nd}tjj|j�|j|d�S)zVerify.ruN)r]���)rsrlrtrr�r|rrYrr8r�r]rzr{rar}�stdout�writer[r`)r
r�r^rEr]rrrr`ks
z
CLI.verifycCstjj|�S)N)rrGrH)r
�argrrr�	_alg_type�sz
CLI._alg_typecCs|S)Nr)r
r�rrr�_header_type�szCLI._header_typecCstjj|S)N)rrIZTYPES)r
r�rrr�	_kty_type�sz
CLI._kty_typeNcCs�|dkrtjdd�}tj�}|jddd�|j�}|jd�}|j|jd�|jdd	tj	d
�dd�|jd
d|j
tjd�|jddd|j
d�|jd�}|j|jd�|jdd	tj	d
�dd�|jd|jdd�|j|�}|j|�S)z Parse arguments and sign/verify.Nruz	--compact�
store_true)�actionrc)�funcz-kz--key�rbT)r0Zrequiredz-az--alg)r0r!z-pz	--protectr~)r�r0r`Fz--kty)r�argv�argparse�ArgumentParser�add_argumentZadd_subparsersZ
add_parserZset_defaultsrcZFileTyper�rZRS256r�r`r��
parse_argsr�)r
r��parserZ
subparsersZparser_signZ
parser_verifyZparsedrrr�run�s*


zCLI.run)N)rrrrrrcr`r�r�r�r�rrrrryVsry�__main__)rr�r:rr<ZjosepyrrrrrrrZJSONObjectWithFieldsrrKrlryr�exitr�rrrr�<module>s `r_V

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