관리-도구
편집 파일: backend.cpython-311.pyc
� �܋f � �R � d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dlmZm Z d dl mZmZ d dl mZ d dlmZ d dlmZ d d lmZmZ d d lmZmZ d dlmZ d dlmZ d d lmZm Z d dl!m"Z" d dl#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+ d dl,m-Z-m.Z.m/Z/m0Z0 d dl1m2Z2m3Z3 d dl4m5Z5m6Z6 d dl7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZC d dlDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZM d dlNmOZO d dlPmQZQmRZRmSZSmTZTmUZU ejV dddg� � ZW G d� d� � ZX G d� d� � ZY G d� d� � ZZd$d#�Z[ eY� � Z\dS )%� )�annotationsN)�contextmanager)�utils�x509)�UnsupportedAlgorithm�_Reasons)�aead)�_CipherContext��_CMACContext)�_EllipticCurvePrivateKey�_EllipticCurvePublicKey)�_RSAPrivateKey� _RSAPublicKey)�openssl)�binding)�hashes� serialization)�AsymmetricPadding)�dh�dsa�ec�ed448�ed25519�rsa�x448�x25519)�MGF1�OAEP�PSS�PKCS1v15)�PrivateKeyTypes�PublicKeyTypes)�BlockCipherAlgorithm�CipherAlgorithm)�AES�AES128�AES256�ARC4�SM4�Camellia�ChaCha20� TripleDES�_BlowfishInternal�_CAST5Internal� _IDEAInternal� _SEEDInternal) �CBC�CFB�CFB8�CTR�ECB�GCM�OFB�XTS�Mode)�ssh)�PBES�PKCS12Certificate�PKCS12KeyAndCertificates�PKCS12PrivateKeyTypes�_PKCS12CATypes� _MemoryBIO�bio�char_ptrc � � e Zd ZdS )�_RC2N)�__name__� __module__�__qualname__� � �/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib64/python3.11/site-packages/cryptography/hazmat/backends/openssl/backend.pyrE rE \ s � � � � � ��DrJ rE c �� � e Zd ZdZdZh d�ZefZej ej ej ej ej ej ej ej ej ej ej ej fZej ej ej ej fZdZdZddz ZdZdez Z d�d �Z!d�d�Z" d�d�d�Z#d�d�Z$d�d�Z%d�d�Z&d�d�Z'd�d�Z(d�d�Z)d�d�Z*d�d�Z+d�d�Z,d�d"�Z-d�d#�Z.d�d$�Z/d�d&�Z0d�d'�Z1d�d(�Z2d�d*�Z3d�d+�Z4d�d-�Z5d�d1�Z6d�d2�Z7d�d6�Z8d�d9�Z9d:� Z:d;� Z;d�d?�Z<d@� Z=d�dA�Z>d�dC�Z?d�dE�Z@d�dF�ZAd�dI�ZBd�dJ�ZCd�dL�ZDd�dO�ZEd�dP�ZFd�dR�ZGd�dU�ZHd�dW�ZId�dX�ZJd�dY�ZKd�dZ�ZLd�d]�ZMd�d`�ZNd�da�ZOd�dc�ZPd�dd�ZQde� ZRd�df�ZSd�dg�ZTd�dk�ZUd�dm�ZVd�dp�ZWd�dq�ZXd�ds�ZYd�dv�ZZd�dy�Z[�d d{�Z\�dd}�Z]�dd��Z^�dd��Z_�dd��Z`�dd��Za�dd��Zb�dd��Zcd�� Zd�dd��Zeefd�� � � Zg�d d��Zh�d d��Zid�d��Zjd�d��Zk�dd��Zld�d��Zm�dd��Zn�d d��Zo�dd��Zp�dd��Zq�dd��Zr�dd��Zs dܐdd��Ztd�d��Zu�dd��Zv�dd��Zw�dd��Zxd�d��Zy�dd��Zz�dd��Z{�dd��Z|d�d��Z}d�d��Z~�dd��Z�dd��Z��dd��Z�d�d��Z��ddZ��ddĄZ��ddńZ�d�dƄZ��ddȄZ�e�jf dɄ � � Z��d d˄Z��d!d̈́Z��d"dӄZ�d�dԄZ�d�dՄZ��d#dׄZ��d#dZ��d$dلZ�dS (% �Backendz) OpenSSL API binding interfaces. r > � aes-128-ccm� aes-128-gcm� aes-192-ccm� aes-192-gcm� aes-256-ccm� aes-256-gcm� i � �return�Nonec �h � t j � � | _ | j j | _ | j j | _ t j � � | _ i | _ | � � � | j j g| _ | j j r&| j � | j j � � d S d S �N)r �Binding�_binding�ffi�_ffi�lib�_lib�rust_openssl�is_fips_enabled� _fips_enabled�_cipher_registry�_register_default_ciphers�EVP_PKEY_DH� _dh_types�Cryptography_HAS_EVP_PKEY_DHX�append�EVP_PKEY_DHX��selfs rK �__init__zBackend.__init__� s� � ���)�)�� ��M�%�� ��M�%�� �)�9�;�;��� � �� �&�&�(�(�(��)�/�0����9�2� :��N�!�!�$�)�"8�9�9�9�9�9� :� :rJ �strc �r � d� | � � � | j | j j � � S )Nz3<OpenSSLBackend(version: {}, FIPS: {}, Legacy: {})>)�format�openssl_version_textrb r[ �_legacy_provider_loadedrj s rK �__repr__zBackend.__repr__� s7 � �D�K�K��%�%�'�'����M�1� � � rJ N�ok�bool�errors�7typing.Optional[typing.List[rust_openssl.OpenSSLError]]c �: � t j | j ||�� � S )N)ru )r �_openssl_assertr_ )rk rs ru s rK �openssl_assertzBackend.openssl_assert� s � � �&�t�y�"�V�D�D�D�DrJ c � � | j � � � t j � � sJ �t j � � | _ d S rY )r[ �_enable_fipsr` ra rb rj s rK r{ zBackend._enable_fips� sD � � � �"�"�$�$�$��+�-�-�-�-�-�)�9�;�;����rJ c � � | j � | j � | j j � � � � � d� � S )z� Friendly string name of the loaded OpenSSL library. This is not necessarily the same version as it was compiled against. Example: OpenSSL 1.1.1d 10 Sep 2019 �ascii)r] �stringr_ �OpenSSL_version�OPENSSL_VERSION�decoderj s rK rp zBackend.openssl_version_text� sA � � �y����I�%�%�d�i�&?�@�@� � � �&��/�/� rJ �intc �4 � | j � � � S rY )r_ �OpenSSL_version_numrj s rK �openssl_version_numberzBackend.openssl_version_number� s � ��y�,�,�.�.�.rJ � algorithm�hashes.HashAlgorithmc � � |j dk s|j dk r7d� |j |j dz � � � d� � }n|j � d� � }| j � |� � }|S )N�blake2b�blake2sz{}{}� r} )�namero �digest_size�encoder_ �EVP_get_digestbyname)rk r� �alg�evp_mds rK �_evp_md_from_algorithmzBackend._evp_md_from_algorithm� s~ � ��>�Y�&�&�)�.�I�*E�*E��-�-��� � 5�� 9�� ��f�W�o�o� �C� �.�'�'��0�0�C���/�/��4�4��� rJ c �v � | � |� � }| � || j j k � � |S rY )r� ry r] �NULL�rk r� r� s rK �_evp_md_non_null_from_algorithmz'Backend._evp_md_non_null_from_algorithm� s7 � ��,�,�Y�7�7�����F�d�i�n�4�5�5�5�� rJ c � � | j rt || j � � sdS | � |� � }|| j j k S �NF)rb � isinstance�_fips_hashesr� r] r� r� s rK �hash_supportedzBackend.hash_supported� sH � ��� �j��D�<M�&N�&N� ��5��,�,�Y�7�7������'�'rJ c �r � | j rt |t j � � rdS | � |� � S r� �rb r� r �SHA1r� �rk r� s rK �signature_hash_supportedz Backend.signature_hash_supported� s; � � �� �*�Y���"D�"D� ��5��"�"�9�-�-�-rJ c �4 � | j rdS | j j dk S �NFrU )rb r_ �Cryptography_HAS_SCRYPTrj s rK �scrypt_supportedzBackend.scrypt_supported� s"