Your IP : 18.118.1.63


Current Path : /lib64/python3.6/site-packages/cryptography/hazmat/backends/openssl/__pycache__/
Upload File :
Current File : //lib64/python3.6/site-packages/cryptography/hazmat/backends/openssl/__pycache__/dsa.cpython-36.pyc

3

l�_4'�@s�ddlmZmZmZddlmZddlmZddlm	Z	m
Z
mZddlm
Z
ddlmZmZmZdd�Zd	d
�Zeje�Gdd�de��Zeje�Gd
d�de��Zejej�Gdd�de��Zejej�Gdd�de��Zejej�Gdd�de��ZdS)�)�absolute_import�division�print_function)�utils)�InvalidSignature)�_calculate_digest_and_algorithm�_check_not_prehashed�_warn_sign_verify_deprecated)�hashes)�AsymmetricSignatureContext�AsymmetricVerificationContext�dsacCsx|jj|j�}|jjd|�}|jjd�}|jjd|t|�|||j�}|j|dk�|j|d�|jj|�d|d�S)Nzunsigned char[]zunsigned int *r�)	�_libZDSA_size�
_dsa_cdata�_ffi�newZDSA_sign�len�openssl_assert�buffer)�backend�private_key�dataZsig_buf_lenZsig_bufZbuflen�res�r�/usr/lib64/python3.6/dsa.py�
_dsa_sig_signsrcCs8|jjd|t|�|t|�|j�}|dkr4|j�t�dS)Nrr)rZ
DSA_verifyrrZ_consume_errorsr)r�
public_key�	signaturerrrrr�_dsa_sig_verify&s
rc@s$eZdZdd�Zdd�Zdd�ZdS)�_DSAVerificationContextcCs.||_||_||_||_tj|j|j�|_dS)N)�_backend�_public_key�
_signature�
_algorithmr
�Hash�	_hash_ctx)�selfrrr�	algorithmrrr�__init__4s
z _DSAVerificationContext.__init__cCs|jj|�dS)N)r&�update)r'rrrrr*<sz_DSAVerificationContext.updatecCs"|jj�}t|j|j|j|�dS)N)r&�finalizerr!r"r#)r'Zdata_to_verifyrrr�verify?s
z_DSAVerificationContext.verifyN)�__name__�
__module__�__qualname__r)r*r,rrrrr 2sr c@s$eZdZdd�Zdd�Zdd�ZdS)�_DSASignatureContextcCs(||_||_||_tj|j|j�|_dS)N)r!�_private_keyr$r
r%r&)r'rrr(rrrr)Isz_DSASignatureContext.__init__cCs|jj|�dS)N)r&r*)r'rrrrr*Osz_DSASignatureContext.updatecCs|jj�}t|j|j|�S)N)r&r+rr!r1)r'Zdata_to_signrrrr+Rs
z_DSASignatureContext.finalizeN)r-r.r/r)r*r+rrrrr0Gsr0c@s$eZdZdd�Zdd�Zdd�ZdS)�_DSAParameterscCs||_||_dS)N)r!r)r'r�	dsa_cdatarrrr)Ysz_DSAParameters.__init__cCs�|jjjd�}|jjjd�}|jjjd�}|jjj|j|||�|jj|d|jjjk�|jj|d|jjjk�|jj|d|jjjk�tj	|jj
|d�|jj
|d�|jj
|d�d�S)Nz	BIGNUM **r)�p�q�g)r!rrr�DSA_get0_pqgrr�NULLr
�DSAParameterNumbers�
_bn_to_int)r'r4r5r6rrr�parameter_numbers]sz _DSAParameters.parameter_numberscCs|jj|�S)N)r!Zgenerate_dsa_private_key)r'rrr�generate_private_keyksz#_DSAParameters.generate_private_keyN)r-r.r/r)r;r<rrrrr2Wsr2c@sNeZdZdd�Zejd�Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�ZdS)�_DSAPrivateKeycCsp||_||_||_|jjjd�}|jjj|||jjj|jjj�|jj|d|jjk�|jjj	|d�|_
dS)Nz	BIGNUM **r)r!r�	_evp_pkeyrrrr7r8r�BN_num_bits�	_key_size)r'rr3�evp_pkeyr4rrrr)qsz_DSAPrivateKey.__init__r@cCst�t|�t|j||�S)N)r	rr0r!)r'�signature_algorithmrrr�signersz_DSAPrivateKey.signercCsR|jjjd�}|jjjd�}|jjjd�}|jjjd�}|jjjd�}|jjj|j|||�|jj|d|jjjk�|jj|d|jjjk�|jj|d|jjjk�|jjj|j||�|jj|d|jjjk�|jj|d|jjjk�t	j
t	jt	j|jj
|d�|jj
|d�|jj
|d�d�|jj
|d�d�|jj
|d�d�S)Nz	BIGNUM **r)r4r5r6)r;�y)�public_numbers�x)r!rrrr7rrr8�DSA_get0_keyr
ZDSAPrivateNumbers�DSAPublicNumbersr9r:)r'r4r5r6�pub_keyZpriv_keyrrr�private_numbers�s(z_DSAPrivateKey.private_numberscCs�|jjj|j�}|jj||jjjk�|jjj||jjj�}|jjj	d�}|jjj
|j||jjj�|jj|d|jjjk�|jjj|d�}|jjj|||jjj�}|jj|dk�|jj
|�}t|j||�S)Nz	BIGNUM **rr)r!r�
DSAparams_duprrrr8�gc�DSA_freerrGZBN_dupZDSA_set0_keyZ_dsa_cdata_to_evp_pkey�
_DSAPublicKey)r'r3rIZpub_key_duprrArrrr�sz_DSAPrivateKey.public_keycCsH|jjj|j�}|jj||jjjk�|jjj||jjj�}t	|j|�S)N)
r!rrKrrrr8rLrMr2)r'r3rrr�
parameters�s
z_DSAPrivateKey.parameterscCs|jj|||||j|j�S)N)r!Z_private_key_bytesr>r)r'�encoding�formatZencryption_algorithmrrr�
private_bytes�sz_DSAPrivateKey.private_bytescCs t|j||�\}}t|j||�S)N)rr!r)r'rr(rrr�sign�sz_DSAPrivateKey.signN)
r-r.r/r)r�read_only_property�key_sizerCrJrrOrRrSrrrrr=os

r=c@sFeZdZdd�Zejd�Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�ZdS)rNcCsp||_||_||_|jjjd�}|jjj|||jjj|jjj�|jj|d|jjk�|jjj	|d�|_
dS)Nz	BIGNUM **r)r!rr>rrrr7r8rr?r@)r'rr3rAr4rrrr)�sz_DSAPublicKey.__init__r@cCs*t�tjd|�t|�t|j|||�S)Nr)r	r�_check_bytesrr r!)r'rrBrrr�verifier�s
z_DSAPublicKey.verifiercCs|jjjd�}|jjjd�}|jjjd�}|jjjd�}|jjj|j|||�|jj|d|jjjk�|jj|d|jjjk�|jj|d|jjjk�|jjj|j||jjj�|jj|d|jjjk�t	j
t	j|jj|d�|jj|d�|jj|d�d�|jj|d�d�S)Nz	BIGNUM **r)r4r5r6)r;rD)
r!rrrr7rrr8rGr
rHr9r:)r'r4r5r6rIrrrrE�s"z_DSAPublicKey.public_numberscCs2|jjj|j�}|jjj||jjj�}t|j|�S)N)r!rrKrrrLrMr2)r'r3rrrrO�sz_DSAPublicKey.parameterscCs|jj||||jd�S)N)r!Z_public_key_bytesr>)r'rPrQrrr�public_bytes�sz_DSAPublicKey.public_bytescCs"t|j||�\}}t|j|||�S)N)rr!r)r'rrr(rrrr,sz_DSAPublicKey.verifyN)r-r.r/r)rrTrUrWrErOrXr,rrrrrN�s
	rNN)Z
__future__rrrZcryptographyrZcryptography.exceptionsrZ*cryptography.hazmat.backends.openssl.utilsrrr	Zcryptography.hazmat.primitivesr
Z)cryptography.hazmat.primitives.asymmetricrrr
rrZregister_interface�objectr r0ZDSAParametersWithNumbersr2ZDSAPrivateKeyWithSerializationr=ZDSAPublicKeyWithSerializationrNrrrr�<module>s"Y

?>