Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/Cryptodome/IO/__pycache__/PEM.cpython-39.pyc
Ðазад
a b�h< � @ s� d dgZ ddlZddlmZmZmZmZ ddlmZ ddl m Z mZ ddlm Z mZmZ ddlmZ dd lmZ dd lmZmZ ddd �Zdd � Zddd�ZdS )�encode�decode� N)� a2b_base64� b2a_base64�hexlify� unhexlify)�MD5)�pad�unpad)�DES�DES3�AES)�PBKDF1)�get_random_bytes)�tobytes�tostrc s� |du rt }d| }|r�|d�}t||ddt�}|t|| |ddt�7 }t�|tj|�}|dtt|��� � 7 }|� t � |j��� n|dur�td��� fdd �t d t� �d�D �}|d�|�7 }|d | 7 }|S )a4 Encode 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 s$ g | ]}t t� ||d � ���qS )�0 )r r )�.0�i��data� ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/Cryptodome/IO/PEM.py� <listcomp>Z s �zencode.<locals>.<listcomp>r r � z-----END %s-----)r r r r �new�MODE_CBCr r �upperZencryptr � block_size� ValueError�range�len�join) r �marker� passphraseZrandfunc�out�salt�keyZobjenc�chunksr r r r / s( � �c C sV dg}|d d }t |�D ](}t�|d | | ��� }|�|� qd�|�d |� S )N� � r ���)r# r r �digest�appendr% )r r) Zkey_len�d�m�_�ndr r r �_EVP_BytesToKeya s r5 c C s\ t �d�}|�| �}|s td��|�d�}t �d�}|�| �}|rP|�d�|krXtd��| �dd��� }|d �d��r|s�td ��|d �d�}t |�d ks�|d d kr�td��|d �d�\}}t t|��}d} |dkr�t||d�} t �| t j|�}n�|dk�r"t||d�} t�| tj|�}n�|dk�rRt||dd� d�} t�| tj|�}n�|dk�r�t||dd� d�} t�| tj|�}nv|dk�r�t||dd� d�} t�| tj|�}nF|�� dk�r�t||dd� d�} tj| tj|d�}d} ntd| ��|d d� }nd}td�|dd� ��}d} |�rR| �rDt|�|�|j�}n |�|�}d} ||| fS ) a Decode 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 boundaryr z-----END (.*)-----\s*$zNot a valid PEM post boundary� r zProc-Type:4,ENCRYPTEDz-PEM is encrypted, but no passphrase available� �:r zDEK-Infoz$PEM encryption format not supported.�,TzDES-CBCr zDES-EDE3-CBC� zAES-128-CBCNr zAES-192-CBCzAES-256-CBC� z id-aes256-gcm)�nonceFz(Unsupport PEM encryption algorithm (%s).r. )�re�compile�matchr"