o
    éT•js  ã                   @   sJ   d dl Z d dlZd dlZzd dlZW n ey   dZY nw ddd„ZdS )é    NTc                    s   ‡ ‡‡‡fdd„‰ ˆ S )aî  Decorator raising SkipTest if a hashing algorithm is not available

    The hashing algorithm could be missing or blocked by a strict crypto
    policy.

    If 'openssl' is True, then the decorator checks that OpenSSL provides
    the algorithm. Otherwise the check falls back to built-in
    implementations. The usedforsecurity flag is passed to the constructor.

    ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS
    ValueError: unsupported hash type md4
    c                    s|   t ˆ tƒr.ˆ j d¡}|d u r ‡ fdd„}ˆ jd |_ˆ j|_n|j}tˆ|ƒƒ}|ˆ _ˆ S t	 
ˆ ¡‡‡ ‡‡fdd„ƒ}|S )NÚ
setUpClassc                    s   t ˆ | ƒ ¡  d S )N)Úsuperr   )Úcls©Úfunc_or_class© ú2/usr/lib/python3.10/test/support/hashlib_helper.pyr      s   z:requires_hashdigest.<locals>.decorator.<locals>.setUpClassz.setUpClassc                     s^   zˆrt d urt jˆ ˆd� ntjˆ ˆd� W n ty'   t dˆ › d�¡‚w ˆ| i |¤ŽS )N)Úusedforsecurityzhash digest 'z' is not available.)Ú_hashlibÚnewÚhashlibÚ
ValueErrorÚunittestÚSkipTest)ÚargsÚkwargs)Ú
digestnamer   Úopensslr	   r   r   Úwrapper&   s   €
ÿÿz7requires_hashdigest.<locals>.decorator.<locals>.wrapper)Ú
isinstanceÚtypeÚ__dict__ÚgetÚ__qualname__Ú
__module__Ú__func__Úclassmethodr   Ú	functoolsÚwraps)r   r   r   ©Ú	decoratorr   r   r	   r   r   r       s   

z&requires_hashdigest.<locals>.decoratorr   )r   r   r	   r   r   r   Úrequires_hashdigest   s   r!   )NT)r   r   r   r
   ÚImportErrorr!   r   r   r   r   Ú<module>   s    ÿ