ff$ddgZddlZddlmZmZmZmZddlmZddl m Z m Z ddl m Z mZmZddlmZdd lmZdd lmZmZdd Zd Zdd ZdS)encodedecodeN) a2b_base64 b2a_base64hexlify unhexlify)MD5)padunpad)DESDES3AES)PBKDF1)get_random_bytes)tobytestostrcZ|t}d|z}|r|d}t||ddt}|t||z|ddtz }tj|tj|}|dt t|zz }| t|j n|tdfdtd td D}|d |z }|d |zz }|S) a4Encode a piece of binary data into PEM format. Args: data (byte string): The piece of binary data to encode. marker (string): The marker for the PEM block (e.g. "PUBLIC KEY"). Note that there is no official master list for all allowed markers. Still, you can refer to the OpenSSL_ source code. passphrase (byte string): If given, the PEM block will be encrypted. The key is derived from the passphrase. randfunc (callable): Random number generation function; it accepts an integer N and returns a byte string of random data, N bytes long. If not given, a new one is instantiated. Returns: The PEM block, as a string. .. _OpenSSL: https://github.com/openssl/openssl/blob/master/include/openssl/pem.h Nz-----BEGIN %s----- z2Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,%s zEmpty passwordc ^g|])}tt||dz*S)0)rr).0idatas o/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/IO/PEM.py zencode..ZsE000JtAa"fH~..//000rrz-----END %s-----)rrr r newMODE_CBCrrupperencryptr block_size ValueErrorrangelenjoin) rmarker passphraserandfuncoutsaltkeyobjencchunkss ` rrr/sA0# 6 )C +x{{Zr1c22 vcJ&aC888#t}d33 F '$--%%'' ( () )~~c$(9::;;  )***0000QD 2..000F2776??C  &&C Jrcdg}|dzdz}t|D]I}tj|d|z|z}||Jd|d|S)Nrr)r&r r digestappendr()rr-key_lendm_nds r_EVP_BytesToKeyr;as~ A 22A 1XX WQrUT\D( ) ) 0 0 2 2  88A;;xx  rc0tjd}||}|std|d}tjd}||}|r|d|krtd|dd}|ddr:|std |d d }t|d ks |d d krtd|dd\}}tt|}d} |dkr3t||d} tj| tj|} n`|dkr3t||d} t!j| t j|} n'|dkr:t||ddd} t#j| t"j|} n|dkr:t||ddd} t#j| t"j|} n|dkr:t||ddd} t#j| t"j|} ng|dkr=t||ddd} t#j| t"j|} d} ntd|z|d d}nd} t)d|dd} d} | rB| r)t-| | | j} n| | } d} | || fS) aDecode a PEM block into binary. Args: pem_data (string): The PEM block. passphrase (byte string): If given and the PEM block is encrypted, the key will be derived from the passphrase. Returns: A tuple with the binary data, the marker string, and a boolean to indicate if decryption was performed. Raises: ValueError: if decoding fails, if the PEM file is encrypted and no passphrase has been provided or if the passphrase is incorrect. z\s*-----BEGIN (.*)-----\s+zNot a valid PEM pre boundaryrz-----END (.*)-----\s*$zNot a valid PEM post boundary rzProc-Type:4,ENCRYPTEDz-PEM is encrypted, but no passphrase available:rzDEK-Infoz$PEM encryption format not supported.,TzDES-CBCrz DES-EDE3-CBCz AES-128-CBCNrz AES-192-CBCz AES-256-CBC z id-aes256-gcm)nonceFz(Unsupport PEM encryption algorithm (%s).r3)recompilematchr%groupsearchreplacesplit startswithr'rrr;r r r!r rlowerMODE_GCMrr(r decryptr$)pem_datar*rr8r)linesDEKalgor-paddingr.objdecrenc_flags rrrjsj( 011A A 97888 WWQZZF ,--A A : f$$8999   S" % % + + - -E Qx233" NLMM MAhnnS!! s88q==CFj00CDD DV\\#&& d'' 9  !*dA66CWS#,55FF ^ # #!*dB77CXc4=$77FF ] " "!*d2A2h;;CWS#,55FF ] " "!*d2A2h;;CWS#,55FF ] " "!*d2A2h;;CWS#,55FF ZZ\\_ , ,!*d2A2h;;CWS#,d;;;FGGG$NOO Oabb  bggeAbDk** + +DH   (--v/@AADD>>$''D &( ##r)NN)N)__all__rDbinasciirrrr Crypto.Hashr Crypto.Util.Paddingr r Crypto.Cipherr r rCrypto.Protocol.KDFr Crypto.RandomrCrypto.Util.py3compatrrrr;rrrr`s D X  ????????????********((((((((((&&&&&&******00000000////d!!!S$S$S$S$S$S$r