← Back
Editing: crypto.cpython-38.pyc
U �F\�� � $ @ s� d dl Z d dlmZ d dlmZ d dlmZmZmZm Z m Z mZ d dlm ZmZmZ d dlmZ d dlmZmZ d dlmZ d d lmZmZmZ m!Z"m#Z$m%Z&m'Z(m)Z* d ddd ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-g$Z+ej,Z-ej.Z/d.Z0ej1Z2ej3Z4ej5Z6ej7Z8G d/d� de9�Z:ee e:�Z;e*e:�Z<d0d1� Z=d2d3� Z>dkd4d5�Z?d6d7� Z@d8d9� ZAd:d;� ZBG d<d=� d=eC�ZDG d>d� deC�ZEeeEeFd?eG�ZHG d@dA� dAeC�ZIdBd� ZJdCd� ZKG dDd� deC�ZLeeLeFdEeG�ZMG dFd� deC�ZNeeNeFdGeG�ZOG dHd� deC�ZPeePeFdIeG�ZQG dJd� deC�ZReeReFdKeG�ZSG dLd� deC�ZTG dMd� deC�ZUeeUeFdNeG�ZVG dOd� de9�ZWG dPd� deC�ZXdQd� ZYdRd� ZZdSd� Z[dldTd�Z\G dUd� deC�Z]G dVd � d eC�Z^ee^eFdWeG�Z_G dXd!� d!eC�Z`ee`eFdYeG�ZaG dZd"� d"eC�ZbeebeFd[eG�ZcG d\d#� d#eC�ZdeedeFd]eG�ZeG d^d_� d_eC�Zfd`d$� Zgdmdad%�Zhdbd&� Zidcd'� Zjddd(� Zkded)� Zldfd*� Zmdgd+� Zndhd,� Zodndid-�Zpe�q� e�r� e�sdj� dS )o� N)� b16encode)�partial)�__eq__�__ne__�__lt__�__le__�__gt__�__ge__)� integer_types� text_type�PY3)�x509)�dsa�rsa)� deprecated)�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__� rA rA �0/usr/lib/python3/dist-packages/OpenSSL/crypto.pyr N s 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.backendrD rC rA rA rB �_get_backendX s rE 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)�whererA rA rB �_untested_errord s rH c C sd | dkrt �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�refrA rA rB �free~ s z_new_mem_buf.<locals>.free)rK �BIO_new� BIO_s_memrL �_ffi�newZBIO_new_mem_buf�len�_openssl_assert�NULL�gc)�bufferrM rO �datarA rA rB �_new_mem_bufm s rZ 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)rR rS rK ZBIO_get_mem_datarX )rM � result_bufferZ buffer_lengthrA rA rB �_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� TypeErrorrK ZASN1_TIME_set_string� ValueError)�boundary�when� set_resultrA rA rB �_set_asn1_time� s rd 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) rR �castrK �ASN1_STRING_lengthZASN1_STRING_typeZV_ASN1_GENERALIZEDTIME�string�ASN1_STRING_datarS rf rV rH ZASN1_GENERALIZEDTIME_free)Z timestampZstring_timestampZgeneralized_timestampZstring_data� string_resultrA rA rB �_get_asn1_time� s$ � � rl c @ s$ e Zd Zdd� Zdd� Zdd� ZdS )�_X509NameInvalidatorc C s g | _ d S rJ )�_names��selfrA rA rB �__init__� s z_X509NameInvalidator.__init__c C s | j �|� d S rJ )rn �append�rp �namerA rA rB �add� s z_X509NameInvalidator.addc C s | j D ]}|`qd S rJ )rn �_namers rA rA rB �clear� s z_X509NameInvalidator.clearN)r= r>