Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/wheel/signatures/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/wheel/signatures/__pycache__/__init__.cpython-35.pyc



/U�U��@s�dZddgZddlZddlmZmZmZmZdadZ	dd	�Z
d
d�Zddd
�Zdd�Z
dd�ZdS)z5
Create and verify jws-js format Ed25519 signatures.
�sign�verify�N�)�urlsafe_b64decode�urlsafe_b64encode�native�binaryZEd25519cCsLtsHyddlaWn(ttfk
r@ddlmaYnXt�tS)z&Lazy import-and-test of ed25519 modulerN�)�	ed25519py)�	ed25519ll�ImportError�OSError�r
�test�rr�J/opt/alt/python35/lib/python3.5/site-packages/wheel/signatures/__init__.py�
get_ed25519llsrc		Cs�t�dtddtdtt|j��ii}tttj|dd���}tttj|dd���}dj||f�}t	j
||j�}|dt	j�}t|�}d	d
t|�dt|�igdt|�iS)
z_Return a JWS-JS format signature given a JSON-serializable payload and 
    an Ed25519 keypair.�alg�jwk�kty�vk�	sort_keysT�.N�
recipients�header�	signature�payload)
r�ALGrrrr�json�dumps�joinrZcrypto_sign�skZSIGNATUREBYTES)	rZkeypairrZencoded_header�encoded_payload�
secured_input�sig_msgrZencoded_signaturerrrrs!!rcCs|st|��dS)N)�
ValueError)Z	condition�messagerrr�
assertTrue4sr'cCs�t�|d}t|d�}g}x�|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_headerrrrrr8s6

" 
cCs�tj�}ddi}tjtjt||���}t|�|dd7<yt|�Wntk
rsYn
Xtd��dS)NrZ	onstartupr�xz+No error from bad wheel.signatures payload.)	rZcrypto_sign_keypairrr+rrrr%�RuntimeError)Zkprr.rrrr^s!

r)�__doc__�__all__r�utilrrrrrrrrr'rrrrrr�<module>s"
&