
    &g              	           d Z ddlZddlZej        eef         Zdedej        eef         fdZdedededej	        e         fd	Z
dededefd
ZdededefdZdS )z0Functions that load and write PEM-encoded files.    N
pem_markerreturnc                 v    t          | t                    s|                     d          } d| z   dz   d| z   dz   fS )z:
    Returns the start and end PEM markers, as bytes.
    asciis   -----BEGIN s   -----s	   -----END )
isinstancebytesencode)r   s    9/var/www/api/venv/lib/python3.11/site-packages/rsa/pem.py_markersr      sO    
 j%(( 0&&w//
 	#h.z!H,     contents	pem_startpem_endc              #   ,  K   d}d}|                                  D ]P}|                                }|s||k    r|rt          d|z            d}d}8|s;|r
||k    rd} n
d|v rL|V  Q|st          d|z            |rt          d|z            dS )z7Generator over PEM lines between pem_start and pem_end.FzSeen start marker "%r" twiceT   :zNo PEM start marker "%r" foundzNo PEM end marker "%r" foundN)
splitlinesstrip
ValueError)r   r   r   in_pem_partseen_pem_startlines         r
   
_pem_linesr   &   s      KN##%%  zz||  	 9 M !?)!KLLLK!N  	  	47??KE 4<<



  G9IEFFF C7'ABBBC Cr   c                    t          | t                    s|                     d          } t          |          \  }}d t	          | ||          D             }d                    |          }t          j        |          S )a  Loads a PEM file.

    :param contents: the contents of the file to interpret
    :param pem_marker: the marker of the PEM content, such as 'RSA PRIVATE KEY'
        when your file has '-----BEGIN RSA PRIVATE KEY-----' and
        '-----END RSA PRIVATE KEY-----' markers.

    :return: the base64-decoded content between the start and end markers.

    @raise ValueError: when the content is invalid, for example when the start
        marker cannot be found.

    r   c                     g | ]}|S  r   ).0r   s     r
   
<listcomp>zload_pem.<locals>.<listcomp>g   s    KKK$KKKr   r   )r   r   r	   r   r   joinbase64standard_b64decode)r   r   r   r   	pem_linespems         r
   load_pemr#   S   s|      h&& ,??7++#J//YKK*Xy'"J"JKKKI ((9

C$S)))r   c                    t          |          \  }}t          j        |                               dd          }|g}t	          dt          |          d          D ]$}|||dz            }|                    |           %|                    |           |                    d           d                    |          S )aj  Saves a PEM file.

    :param contents: the contents to encode in PEM format
    :param pem_marker: the marker of the PEM content, such as 'RSA PRIVATE KEY'
        when your file has '-----BEGIN RSA PRIVATE KEY-----' and
        '-----END RSA PRIVATE KEY-----' markers.

    :return: the base64-encoded content between the start and end markers, as bytes.

       
r   r   @   )r   r   standard_b64encodereplacerangelenappendr   )r   r   r   r   b64r!   block_startblocks           r
   save_pemr/   n   s     $J//Y

#H
-
-
5
5eS
A
ACIQC"--    K+"223WS::i   r   )__doc__r   typingUnionstrr   	FlexiTextTupler   Iteratorr   r#   r/   r   r   r
   <module>r7      s    7 6   Le$	 v|E5L'A    *C *C5 *C5 *CV_UZE[ *C *C *C *CZ*y *i *E * * * *6!u !) ! ! ! ! ! ! !r   