
    Mh                        d Z ddlZddlZddlZddlmZmZmZmZ ddl	Z	dZ
dZ	 	 	 ddeeej        f         ded	eeef         d
eeeef                  deeeef                  deddfdZ	 ddeeej        f         dedeeeef                  deeef         fdZdeeej        f         deeee         f         fdZddeeej        f         deeef         fdZg dZdS )z10MQ authentication related functions and classes.    N)DictOptionalTupleUnionz#   ****  Generated on {0} by pyzmq  ****
#   ZeroMQ CURVE **Secret** Certificate
#   DO NOT PROVIDE THIS FILE TO OTHER USERS nor change its permissions.

a
  #   ****  Generated on {0} by pyzmq  ****
#   ZeroMQ CURVE Public Certificate
#   Exchange securely, or use a secure mechanism to verify the contents
#   of this file after exchange. Store public certificates in your home
#   directory, in the .curve subdirectory.

utf-8key_filenamebanner
public_key
secret_keymetadataencodingreturnc           	      `   t          |t                    r|                    |          }t          |t                    r|                    |          }t          | dd          5 }|                    |                    t          j                                                             |                    d           |r|                                D ]u\  }}t          |t                    r|                    |          }t          |t                    r|                    |          }|                    d| d| d           v|                    d           |                    d	| d
           |r|                    d| d
           ddd           dS # 1 swxY w Y   dS )zCreate a certificate filewutf8)r   z	metadata
z    z = 
zcurve
z    public-key = "z"
z    secret-key = "N)	
isinstancebytesdecodeopenwriteformatdatetimenowitems)	r   r	   r
   r   r   r   fkvs	            N/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/zmq/auth/certs.py_write_key_filer       s    *e$$ 1&&x00
*e$$ 1&&x00
	lC&	1	1	1 <Q	h/335566777	 	, (( , ,1a'' +**Aa'' +**A*q**Q***++++			6j666777 	<GG:*:::;;;!< < < < < < < < < < < < < < < < < <s   'D/F##F'*F'key_dirnamec                 p   t          j                    \  }}t          j                            | |          }| d}| d}t
          j                                        }t          |t          	                    |          |           t          |t          	                    |          |||           ||fS )zeCreate zmq certificates.

    Returns the file paths to the public and secret certificate files.
    z.key_secretz.key)r   r   )zmqcurve_keypairospathjoinr   r   r    _cert_public_bannerr   _cert_secret_banner)	r!   r"   r   r
   r   base_filenamesecret_key_filepublic_key_filer   s	            r   create_certificatesr.   =   s     !.00J
GLL$//M&333O&,,,O




!
!CO%8%?%?%D%DjQQQ""3''    O++    filenamec                 f   d}d}t           j                            |           st          d|            t	          | d          5 }|D ]}|                                }|                    d          r,|                    d          r/|                    dd          d                             d          }|                    d	          r/|                    dd          d                             d          }|r|r nddd           n# 1 swxY w Y   |t          d
|            ||fS )a  Load public and secret key from a zmq certificate.

    Returns (public_key, secret_key)

    If the certificate file only contains the public key,
    secret_key will be None.

    If there is no public key found in the file, ValueError will be raised.
    NzInvalid certificate file: rb   #s
   public-key   =   s    	'"s
   secret-keyzNo public key found in )	r&   r'   existsOSErrorr   strip
startswithsplit
ValueError)r0   r
   r   r   lines        r   load_certificater=   Y   s    JJ7>>(## ?=8==>>>	h		 
 		 		D::<<Dt$$ }-- E!ZZa00399)DD
}-- E!ZZa00399)DD
 j 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 =8==>>>z!!s   B>DDD.	directoryc                    i }t           j                            |           st          d|            t           j                            | d          }t          j        |          }|D ]}t          |          \  }}|rd||<   |S )z5Load public keys from all certificates in a directoryzInvalid certificate directory: z*.keyT)r&   r'   isdirr7   r(   globr=   )r?   certsglob_string
cert_files	cert_filer
   _s          r   load_certificatesrH   |   s    E7==## EC	CCDDD',,y'22K;''J % %	(33
A 	% $E*Lr/   )r.   r=   rH   )NNr   )N)r>   )__doc__r   rB   r&   typingr   r   r   r   r$   r*   r)   strPathLiker   r    r.   r=   boolrH   __all__ r/   r   <module>rP      s   7 7
   				 / / / / / / / / / / / / 



   /3)-< <R[()<< c5j!< sEz*+	<
 tCH~&< < 
< < < <F *., ,3#$,
, tCH~&, 38_	, , , ,8 "C$% "
5(5/!" "  "  "  "F sBK'7!8 4tCT      K
J
Jr/   