관리-도구
편집 파일: hashes.cpython-36.pyc
3 y�_a � @ s\ d dl mZmZmZ d dlmZ d dlmZmZ d dl m Z eje j�G dd� de ��ZdS )� )�absolute_import�division�print_function)�utils)�UnsupportedAlgorithm�_Reasons)�hashesc @ s@ e Zd Zd dd�Zejd�Zdd� Zdd� Zd d � Z dd� Z dS )�_HashContextNc C s� || _ || _|d kr�| jjj� }| jjj|| jjj�}| jj|�}|| jjjkrdt dj |j�tj ��| jjj||| jjj�}| jj|dk� || _d S )Nz+{} is not a supported hash on this backend.r )� _algorithm�_backend�_lib�Cryptography_EVP_MD_CTX_new�_ffi�gc�Cryptography_EVP_MD_CTX_freeZ_evp_md_from_algorithmZNULLr �format�namer ZUNSUPPORTED_HASHZEVP_DigestInit_ex�openssl_assert�_ctx)�selfZbackend� algorithm�ctxZevp_md�res� r �/usr/lib64/python3.6/hashes.py�__init__ s z_HashContext.__init__r c C sV | j jj� }| j jj|| j jj�}| j jj|| j�}| j j|dk� t | j | j |d�S )Nr )r )r r r r r r ZEVP_MD_CTX_copy_exr r r r )r Z copied_ctxr r r r �copy* s z_HashContext.copyc C s: | j jj|�}| j jj| j|t|��}| j j|dk� d S )Nr )r r Zfrom_bufferr ZEVP_DigestUpdater �lenr )r �dataZdata_ptrr r r r �update3 s z_HashContext.updatec C s� t | jtj�r| j� S | jjjd| jjj �}| jjjd�}| jjj | j||�}| jj|dk� | jj|d | jj k� | jjj|�d |d � S d S )Nzunsigned char[]zunsigned int *r )� isinstancer r ZExtendableOutputFunction� _finalize_xofr r �newr ZEVP_MAX_MD_SIZEZEVP_DigestFinal_exr r �digest_size�buffer)r �bufZoutlenr r r r �finalize: s z_HashContext.finalizec C sV | j jjd| jj�}| j jj| j|| jj�}| j j|dk� | j jj |�d | jj� S )Nzunsigned char[]r ) r r r"