File: //lib/python3.6/site-packages/certbot/__pycache__/crypto_util.cpython-36.opt-1.pyc
3
ߦ)_�K � @ s d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl m
Z
ddlmZ ddlm
Z
ddlmZ dd lmZ dd
lmZ ddlmZ ddlZddlZddlZddlmZ dd
lmZ ddlmZ ddlm Z ddlm!Z! ddl"m#Z# ej$e%�Z&dKdd�Z'dd� Z(dd� Z)dd� Z*dd� Z+dd� Z,dd � Z-d!d"� Z.d#d$� Z/d%d&� Z0d'd(� Z1d)d*� Z2d+d,� Z3ej4fd-d.�Z5ej4fd/d0�Z6ej4fd1d2�Z7d3d4� Z8d5d6� Z9ej4fd7d8�Z:ej4fd9d:�Z;d;d<� Z<d=d>� Z=d?d@� Z>dAdB� Z?ej@dCejA�ZBdDdE� ZCdFdG� ZDdLdIdJ�ZEdS )Mz�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)�x509)�InvalidSignature)�default_backend)�ECDSA)�EllipticCurvePublicKey)�PKCS1v15)�RSAPublicKey)�crypto)�SSL)�crypto_util)�IO)�errors)�
interfaces)�util)�os�key-certbot.pemc C s� yt | �}W n4 tk
r@ } ztjddd� |�W Y dd}~X nX tjjtj�}t j
|d|j� t jt
jj||�dd�\}}|� |j|� W dQ R X tjd| |� t j||�S ) 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: RSA key size in bits
:param str key_dir: Key save directory.
:param str keyname: Filename of key
:returns: Key
:rtype: :class:`certbot.util.Key`
:raises ValueError: If unable to generate the key given key_size.
� T)�exc_infoNi� i� �wbzGenerating key (%d bits): %s)�make_key�
ValueError�logger�error�zope� component�
getUtilityr �IConfigr �make_or_verify_dir�strict_permissions�unique_filer �path�join�write�debugZKey)Zkey_sizeZkey_dirZkeynameZkey_pem�err�configZkey_f�key_path� r'