o
    DfM                     @   s\   d Z ddlZddlmZ ddlZddlmZ ddlm	Z	m
Z
 dZddd	ZedddZdS )z1Utilities used by the message signing serializer.    N)contextmanager)hashes)SecurityErrorreraise)get_digest_algorithmreraise_errorssha256c                 C   s   | dusJ t t|   S )z6Convert string to hash object of cryptography library.N)getattrr   upper)digest r   N/home/ubuntu/webapp/venv/lib/python3.10/site-packages/celery/security/utils.pyr      s   r   {0!r}c              
   c   sh    |du r	t jfn|}zdV  W dS  |y3 } zttt| |t d  W Y d}~dS d}~ww )z8Context reraising crypto errors as :exc:`SecurityError`.N   )cryptography
exceptionsr   r   formatsysexc_info)msgerrorsexcr   r   r   r      s   
r   )r   )r   N)__doc__r   
contextlibr   cryptography.exceptionsr   cryptography.hazmat.primitivesr   celery.exceptionsr   r   __all__r   r   r   r   r   r   <module>   s    
