← Back
Editing: crypto_util.cpython-312.pyc
� 4��j�_ � � � d Z ddlZddlZddlZddlZddlZddlmZ ddlmZ ddlm Z ddl Z ddlmZ ddl mZ ddl mZ dd lmZ dd lmZ ddlmZ ddlmZ dd lmZ ddlmZ ddlmZ ddlmZ ddlmZmZm Z ddl!m"Z"m#Z# ddl$m%Z% ddl&m'Z' ddl(m)Z) ddl(m*Z* ddl(m+Z+ ddl,m-Z- ddl.m/Z0 ddl1m2Z2 ddl1m3Z3 ddl1m4Z4 ddl5m6Z6 erddl7m8Z8 ddl9m:Z: dd l;m<Z< dd!l=m>Z> ej~ e@� ZA d]d"eBd#eeC d$eCd%eCd&eCd'eDd(e4j� fd)�ZF d^d*e4j� d+e eGeC eHeC f d,eeC d-eDd'eDd.eGej� ej� z dz d(e4j� fd/�ZLd0eMd(eDfd1�ZNd0eMd*eMd(eDfd2�ZOd3eCd4eMd(e4j� fd5�ZPd3eCd4eMd(eQd6e4j� eGeC f fd7�ZR d_d8eBd$eCd%eeC d(eMfd9�ZSd*e eCeMf d(eDfd:�ZTd;e3j� d(dfd<�ZVd;e3j� d(dfd=�ZWd>e ed?d@eeee e"e#e'dAdBf dCeMdDeMdEej� d(df dF�ZYdGeCdHeCd(dfdI�ZZd;e3j� d(dfdJ�Z[ d`dKeMdLdMd(eGeC fdN�Z\ d`dKeMdLdMd(eGeC fdO�Z] d`d0eMdLdMd(eGeC fdP�Z^dGeCd(ej fdQ�Z_dGeCd(ej fdR�Z`dSeCd(eCfdT�Za ej� dUej� � ZddVeCd(eQeCeCf fdW�ZedGeCd(eBfdX�Zf dadYeGeC dZeCd[eDd(eCfd\�Zgy)bz�Certbot client crypto utility functions. .. todo:: Make the transition to use PSS rather than PKCS1_v1_5 when the server is capable of handling the signatures. � N)�Optional)� TYPE_CHECKING)�Union)�x509)�InvalidSignature)�UnsupportedAlgorithm)�default_backend)�hashes)� serialization)�ec)�rsa)�DSAPublicKey)�ECDSA)�EllipticCurvePublicKey)�MLDSA44PublicKey�MLDSA65PublicKey�MLDSA87PublicKey)�MLKEM768PublicKey�MLKEM1024PublicKey)�PKCS1v15)�RSAPublicKey)�Encoding)�NoEncryption)� PrivateFormat)�SSL)�crypto_util)�errors)� interfaces)�util)�os)�Ed448PublicKey)�Ed25519PublicKey)� X448PublicKey)�X25519PublicKey�key_size�key_dir�key_type�elliptic_curve�keyname�strict_permissions�returnc �D � t | |xs d|�� }d}|r�t j |d|� t j t j j ||� d d � \ } }| 5 | j |� ddd� |dk( rt j d| |� nt j d | |� t j ||� S # t $ r=}t j dd�� t j dt |� � |�d}~ww xY w# 1 sw Y ��xY w)a$ Initializes and saves a privkey. Inits key and saves it in PEM format on the filesystem. .. note:: keyname is the attempted filename, it may be different if a file already exists at the path. :param int key_size: key size in bits if key size is rsa. :param str key_dir: Optional key save directory. :param str key_type: Key Type [rsa, ecdsa] :param str elliptic_curve: Name of the elliptic curve if key type is ecdsa. :param str keyname: Filename of key :param bool strict_permissions: If true and key_dir exists, an exception is raised if the directory doesn't have 0700 permissions or isn't owned by the current user. :returns: Key :rtype: :class:`certbot.util.Key` :raises ValueError: If unable to generate the key given key_size. � secp256r1)�bitsr( r'