Hacked By AnonymousFox

Current Path : /usr/lib64/python3.6/site-packages/cryptography/hazmat/primitives/ciphers/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/cryptography/hazmat/primitives/ciphers/__pycache__/base.cpython-36.pyc

3

l�_U�@s�ddlmZmZmZddlZddlZddlmZddlm	Z	m
Z
mZmZm
Z
ddlmZddlmZddlmZejej�Gdd	�d	e��Zejej�Gd
d�de��Zejej�Gdd
�d
e��Zejej�Gdd�de��Zejej�Gdd�de��Zejej�Gdd�de��ZGdd�de�Zeje�Gdd�de��Zeje�eje�eje�Gdd�de����Z eje�Gdd�de ��Z!dS)�)�absolute_import�division�print_functionN)�utils)�AlreadyFinalized�AlreadyUpdated�NotYetFinalized�UnsupportedAlgorithm�_Reasons)�_get_backend)�
CipherBackend)�modesc@s(eZdZejdd��Zejdd��ZdS)�CipherAlgorithmcCsdS)zE
        A string naming this mode (e.g. "AES", "Camellia").
        N�)�selfrr�/usr/lib64/python3.6/base.py�nameszCipherAlgorithm.namecCsdS)zW
        The size of the key being used as an integer in bits (e.g. 128, 256).
        Nr)rrrr�key_size szCipherAlgorithm.key_sizeN)�__name__�
__module__�__qualname__�abc�abstractpropertyrrrrrrrsrc@seZdZejdd��ZdS)�BlockCipherAlgorithmcCsdS)zK
        The size of a block as an integer in bits (e.g. 64, 128).
        Nr)rrrr�
block_size)szBlockCipherAlgorithm.block_sizeN)rrrrrrrrrrr'src@s6eZdZejdd��Zejdd��Zejdd��ZdS)�
CipherContextcCsdS)zk
        Processes the provided bytes through the cipher and returns the results
        as bytes.
        Nr)r�datarrr�update2szCipherContext.updatecCsdS)z�
        Processes the provided bytes and writes the resulting data into the
        provided buffer. Returns the number of bytes written.
        Nr)rr�bufrrr�update_into9szCipherContext.update_intocCsdS)zM
        Returns the results of processing the final block as bytes.
        Nr)rrrr�finalize@szCipherContext.finalizeN)rrrr�abstractmethodrrr rrrrr0src@seZdZejdd��ZdS)�AEADCipherContextcCsdS)z3
        Authenticates the provided bytes.
        Nr)rrrrr�authenticate_additional_dataIsz.AEADCipherContext.authenticate_additional_dataN)rrrrr!r#rrrrr"Gsr"c@seZdZejdd��ZdS)�AEADDecryptionContextcCsdS)z�
        Returns the results of processing the final block as bytes and allows
        delayed passing of the authentication tag.
        Nr)r�tagrrr�finalize_with_tagRsz'AEADDecryptionContext.finalize_with_tagN)rrrrr!r&rrrrr$Psr$c@seZdZejdd��ZdS)�AEADEncryptionContextcCsdS)zb
        Returns tag bytes. This is only available after encryption is
        finalized.
        Nr)rrrrr%\szAEADEncryptionContext.tagN)rrrrrr%rrrrr'Zsr'c@s.eZdZd
dd�Zdd�Zdd�Zdd	�ZdS)�CipherNcCsXt|�}t|t�stdtj��t|t�s0td��|dk	rB|j|�||_	||_
||_dS)Nz0Backend object does not implement CipherBackend.z&Expected interface of CipherAlgorithm.)r�
isinstancerr	r
ZBACKEND_MISSING_INTERFACEr�	TypeErrorZvalidate_for_algorithm�	algorithm�mode�_backend)rr+r,Zbackendrrr�__init__es


zCipher.__init__cCsBt|jtj�r"|jjdk	r"td��|jj|j|j�}|j	|dd�S)Nz0Authentication tag must be None when encrypting.T)�encrypt)
r)r,r
�ModeWithAuthenticationTagr%�
ValueErrorr-Zcreate_symmetric_encryption_ctxr+�	_wrap_ctx)r�ctxrrr�	encryptorwszCipher.encryptorcCs |jj|j|j�}|j|dd�S)NF)r/)r-Zcreate_symmetric_decryption_ctxr+r,r2)rr3rrr�	decryptor�szCipher.decryptorcCs0t|jtj�r$|rt|�St|�Snt|�SdS)N)r)r,r
r0�_AEADEncryptionContext�_AEADCipherContext�_CipherContext)rr3r/rrrr2�s

zCipher._wrap_ctx)N)rrrr.r4r5r2rrrrr(ds
r(c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
r8cCs
||_dS)N)�_ctx)rr3rrrr.�sz_CipherContext.__init__cCs|jdkrtd��|jj|�S)NzContext was already finalized.)r9rr)rrrrrr�s
z_CipherContext.updatecCs |jdkrtd��|jj||�S)NzContext was already finalized.)r9rr)rrrrrrr�s
z_CipherContext.update_intocCs&|jdkrtd��|jj�}d|_|S)NzContext was already finalized.)r9rr )rrrrrr �s


z_CipherContext.finalizeN)rrrr.rrr rrrrr8�sr8c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r7cCs"||_d|_d|_d|_d|_dS)NrF)r9�_bytes_processed�_aad_bytes_processed�_tag�_updated)rr3rrrr.�s
z_AEADCipherContext.__init__cCsV|jdkrtd��d|_|j|7_|j|jjjkrRtdj|jjj|jjj���dS)NzContext was already finalized.Tz+{} has a maximum encrypted byte limit of {})	r9rr=r:�_modeZ_MAX_ENCRYPTED_BYTESr1�formatr)rZ	data_sizerrr�_check_limit�s
z_AEADCipherContext._check_limitcCs|jt|��|jj|�S)N)r@�lenr9r)rrrrrr�sz_AEADCipherContext.updatecCs|jt|��|jj||�S)N)r@rAr9r)rrrrrrr�sz_AEADCipherContext.update_intocCs0|jdkrtd��|jj�}|jj|_d|_|S)NzContext was already finalized.)r9rr r%r<)rrrrrr �s


z_AEADCipherContext.finalizecCs2|jdkrtd��|jj|�}|jj|_d|_|S)NzContext was already finalized.)r9rr&r%r<)rr%rrrrr&�s

z$_AEADCipherContext.finalize_with_tagcCsn|jdkrtd��|jr td��|jt|�7_|j|jjjkr^tdj	|jjj
|jjj���|jj|�dS)NzContext was already finalized.z'Update has been called on this context.z%{} has a maximum AAD byte limit of {})r9rr=rr;rAr>Z_MAX_AAD_BYTESr1r?rr#)rrrrrr#�s
z/_AEADCipherContext.authenticate_additional_dataN)
rrrr.r@rrr r&r#rrrrr7�sr7c@seZdZedd��ZdS)r6cCs|jdk	rtd��|jS)Nz4You must finalize encryption before getting the tag.)r9rr<)rrrrr%�s
z_AEADEncryptionContext.tagN)rrr�propertyr%rrrrr6�sr6)"Z
__future__rrrrZsixZcryptographyrZcryptography.exceptionsrrrr	r
Zcryptography.hazmat.backendsrZ'cryptography.hazmat.backends.interfacesrZ&cryptography.hazmat.primitives.ciphersr
Z
add_metaclass�ABCMeta�objectrrrr"r$r'r(Zregister_interfacer8r7r6rrrr�<module>s8		.=

Hacked By AnonymousFox1.0, Coded By AnonymousFox