Your IP : 216.73.216.213


Current Path : /opt/alt/python36/lib/python3.6/site-packages/wheel/signatures/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib/python3.6/site-packages/wheel/signatures/__pycache__/__init__.cpython-36.pyc

3

Dt�Z��@sbdZddlZddlmZmZmZmZddgZdadZ	dd	�Z
d
d�Zddd
�Zdd�Z
dd�ZdS)z5
Create and verify jws-js format Ed25519 signatures.
�N�)�urlsafe_b64decode�urlsafe_b64encode�native�binary�sign�verifyZEd25519cCs@ts<yddlaWn$ttfk
r4ddlmaYnXt�tS)z&Lazy import-and-test of ed25519 modulerN�)�	ed25519py)�	ed25519ll�ImportError�OSError�r
�test�rr�J/opt/alt/python36/lib/python3.6/site-packages/wheel/signatures/__init__.py�
get_ed25519llsrc	Cs�t�tttt|j��d�d�}tttj|dd���}tttj|dd���}dj||f�}t	j
||j�}|dt	j�}t|�}t|�t|�d�gt|�d�S)	z^Return a JWS-JS format signature given a JSON-serializable payload and
    an Ed25519 keypair.)�kty�vk)�alg�jwkT)�	sort_keys�.N)�header�	signature)�
recipients�payload)
r�ALGrrrr�json�dumps�joinrZcrypto_sign�skZSIGNATUREBYTES)	rZkeypairrZencoded_header�encoded_payload�
secured_input�sig_msgrZencoded_signaturerrrrsrcCs|st|��dS)N)�
ValueError)Z	condition�messagerrr�
assertTrue7sr'cCstt�|d}t|d�}g}�x0|D�]&}tt|�dkdj|��t|d�}t|d�}tjtt|���}t|dt	kdj|d��d|d	kr�d
|d	kr�|d	d|d	d
<t|d	d
t	kdj|d	d
��tt|d	d��}d
j
||f�}	t|�}
|
|	}ttj||��}|j
d�\}
}t|
�}
tt|
��}|jtj|��q&Wt|�}tjtt|���}||fS)z�Return (decoded headers, payload) if all signatures in jwsjs are
    consistent, else raise ValueError.

    Caller must decide whether the keys are actually trusted.rrrzUnknown recipient key {0}rrrzUnexpected algorithm {0}rrzUnexpected key type {0}rr�.)rrr'�len�formatr�loadsrrrr rZcrypto_sign_open�split�append)�jwsjsrr"�headersZ	recipient�h�srrr#�sigr$Zverified_inputZverified_headerZverified_payloadZdecoded_headerrrrrr<s6cCsltj�}ddi}tjtjt||���}t|�|dd7<yt|�Wntk
r^Yn
Xtd��dS)NrZ	onstartupr�xz+No error from bad wheel.signatures payload.)	rZcrypto_sign_keypairrr+rrrr%�RuntimeError)Zkprr.rrrrcsr)r)�__doc__r�utilrrrr�__all__rrrrr'rrrrrr�<module>s
'