Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/OpenSSL/__pycache__/crypto.cpython-39.pyc
Ðазад
a s�h� � @ s� d dl Z d dlmZ d dlmZ d dlmZmZmZm Z m Z mZ d dlm ZmZmZ d dlmZ d dlmZmZ d dlmZmZmZmZ m!Z"m#Z$m%Z&m'Z( g d �Z)ej*Z+ej,Z-d Z.ej/Z0ej1Z2ej3Z4ej5Z6G dd� de7�Z8eee8�Z9e(e8�Z:d d� Z;dd� Z<d\dd�Z=dd� Z>dd� Z?dd� Z@G dd� deA�ZBG dd� deA�ZCG dd� deA�ZDdd � ZEd!d"� ZFG d#d$� d$eA�ZGG d%d&� d&eA�ZHG d'd(� d(eA�ZIG d)d*� d*eA�ZJG d+d,� d,eA�ZKG d-d.� d.eA�ZLG d/d0� d0e7�ZMG d1d2� d2eA�ZNd3d4� ZOd5d6� ZPd7d8� ZQd]d9d:�ZRG d;d<� d<eA�ZSG d=d>� d>eA�ZTG d?d@� d@eA�ZUG dAdB� dBeA�ZVG dCdD� dDeA�ZWG dEdF� dFeA�ZXdGdH� ZYd^dIdJ�ZZdKdL� Z[dMdN� Z\dOdP� Z]dQdR� Z^dSdT� Z_dUdV� Z`dWdX� Zad_dYdZ�Zbe�c� e�d� e�ed[� dS )`� N)� b16encode)�partial)�__eq__�__ne__�__lt__�__le__�__gt__�__ge__)� integer_types� text_type�PY3)�x509)�dsa�rsa)�ffi�lib�exception_from_error_queue�byte_string�native�UNSPECIFIED�text_to_bytes_and_warn�make_assert)$�FILETYPE_PEM� FILETYPE_ASN1� FILETYPE_TEXT�TYPE_RSA�TYPE_DSA�Error�PKey�get_elliptic_curves�get_elliptic_curve�X509Name� X509Extension�X509Req�X509�X509StoreFlags� X509Store�X509StoreContextError�X509StoreContext�load_certificate�dump_certificate�dump_publickey�dump_privatekey�Revoked�CRL�PKCS7�PKCS12�NetscapeSPKI�load_publickey�load_privatekey�dump_certificate_request�load_certificate_request�sign�verify�dump_crl�load_crl�load_pkcs7_data�load_pkcs12i�� c @ s e Zd ZdZdS )r z7 An error occurred in an `OpenSSL.crypto` API. N)�__name__� __module__�__qualname__�__doc__� r@ r@ �~/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/OpenSSL/crypto.pyr M s r c C s ddl m} | S )ap Importing the backend from cryptography has the side effect of activating the osrandom engine. This mutates the global state of OpenSSL in the process and causes issues for various programs that use subinterpreters or embed Python. By putting the import in this function we can avoid triggering this side effect unless _get_backend is called. r ��backend)Z,cryptography.hazmat.backends.openssl.backendrC rB r@ r@ rA �_get_backendW s rD c C s t d| f ��dS )z� An OpenSSL API failed somehow. Additionally, the failure which was encountered isn't one that's exercised by the test suite so future behavior of pyOpenSSL is now somewhat less predictable. zUnknown %s failureN)�RuntimeError)�wherer@ r@ rA �_untested_errorc s rG c C sd | du rt �t �� �}t j}n(t�d| �}t �|t| ��}|fdd�}t|tj k� t� ||�}|S )z� Allocate a new OpenSSL memory BIO. Arrange for the garbage collector to clean it up automatically. :param buffer: None or some bytes to use to put into the BIO so that they can be read out. N�char[]c S s t �| �S �N)�_lib�BIO_free)�bio�refr@ r@ rA �free} s z_new_mem_buf.<locals>.free)rJ �BIO_new� BIO_s_memrK �_ffi�newZBIO_new_mem_buf�len�_openssl_assert�NULL�gc)�bufferrL rN �datar@ r@ rA �_new_mem_bufl s rY c C s. t �d�}t�| |�}t �|d |�dd� S )zO Copy the contents of an OpenSSL BIO object into a Python byte string. zchar**r N)rQ rR rJ ZBIO_get_mem_datarW )rL � result_bufferZ buffer_lengthr@ r@ rA �_bio_to_string� s r[ c C s2 t |t�std��t�| |�}|dkr.td��dS )a� The the time value of an ASN1 time object. @param boundary: An ASN1_TIME pointer (or an object safely castable to that type) which will have its value set. @param when: A string representation of the desired time value. @raise TypeError: If C{when} is not a L{bytes} string. @raise ValueError: If C{when} does not represent a time in the required format. @raise RuntimeError: If the time value cannot be set for some other (unspecified) reason. zwhen must be a byte stringr zInvalid stringN)� isinstance�bytes� TypeErrorrJ ZASN1_TIME_set_string� ValueError)�boundary�when� set_resultr@ r@ rA �_set_asn1_time� s rc c C s� t �d| �}t�|�dkrdS t�|�tjkr>t �t�|��S t �d�}t� | |� |d t j krltd� n6t �d|d �}t�|�}t �|�}t�|d � |S dS )a] Retrieve the time value of an ASN1 time object. @param timestamp: An ASN1_GENERALIZEDTIME* (or an object safely castable to that type) from which the time value will be retrieved. @return: The time value from C{timestamp} as a L{bytes} string in a certain format. Or C{None} if the object contains no time value. �ASN1_STRING*r NzASN1_GENERALIZEDTIME**�ASN1_TIME_to_generalizedtime) rQ �castrJ �ASN1_STRING_lengthZASN1_STRING_typeZV_ASN1_GENERALIZEDTIME�string�ASN1_STRING_datarR re rU rG ZASN1_GENERALIZEDTIME_free)� timestampZstring_timestampZgeneralized_timestampZstring_data� string_resultr@ r@ rA �_get_asn1_time� s"