File: //proc/self/root/usr/lib/python3.6/site-packages/rsa/__pycache__/pkcs1_v2.cpython-36.opt-1.pyc
3
%
�a�
� @ s� d Z ddlmZmZmZ deeeed�dd�ZdgZ e
dkr�ed� dd lZx>e
d
�D ]2Zej� \ZZerlP ed dkrVerVede � qVW ed
� d S )z�Functions for PKCS#1 version 2 encryption and signing
This module implements certain functionality from PKCS#1 version 2. Main
documentation is RFC 2437: https://tools.ietf.org/html/rfc2437
� )�common�pkcs1� transform�SHA-1)�seed�length�hasher�returnc s� yt j� � j}W nD tk
rV } z(tdjdjtt jj� ��d��|�W Y dd}~X nX |d
| krvt dj|� d���d j� �fd
d�t
tj||�d �D ��}|d|� S )a�
MGF1 is a Mask Generation Function based on a hash function.
A mask generation function takes an octet string of variable length and a
desired output length as input, and outputs an octet string of the desired
length. The plaintext-awareness of RSAES-OAEP relies on the random nature of
the output of the mask generation function, which in turn relies on the
random nature of the underlying hash.
:param bytes seed: seed from which mask is generated, an octet string
:param int length: intended length in octets of the mask, at most 2^32(hLen)
:param str hasher: hash function (hLen denotes the length in octets of the hash
function output)
:return: mask, an octet string of length `length`
:rtype: bytes
:raise OverflowError: when `length` is too large for the specified `hasher`
:raise ValueError: when specified `hasher` is invalid
z=Invalid `hasher` specified. Please select one of: {hash_list}z, )Z hash_listN� � zmDesired length should be at most 2**32 times the hasher's output length ({hash_length} for {hasher} function))�hash_lengthr � c 3 s* | ]"}t j�tj|d d� � d�V qdS )� )Z fill_size)Zmethod_nameN)r Zcompute_hashr Z int2bytes)�.0Zcounter)r r � �/usr/lib/python3.6/pkcs1_v2.py� <genexpr>I s zmgf1.<locals>.<genexpr>� l )
r ZHASH_METHODSZdigest_size�KeyError�
ValueError�format�join�sorted�keys�
OverflowError�ranger Zceil_div)r r r r Zex�outputr )r r r �mgf1 s
r �__main__z'Running doctests 1000x or until failureNi� �d z%i timesz
Doctests done)r )�__doc__Zrsar r r �bytes�int�strr �__all__�__name__�printZdoctestr �countZtestmodZfailuresZtestsr r r r �<module> s 9