File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/Cryptodome/IO/__pycache__/PKCS8.cpython-310.pyc
Back
o ;j� � @ s` d dl T d dlmZmZmZmZ d dlmZmZm Z ddgZ ddde� dfdd�Zd dd�ZdS ) � )�*)�DerNull�DerSequence�DerObjectId�DerOctetString)�PBES1�PBES2� PbesError�wrap�unwrapNc C s� |du rt t|�g�}nt t|�|g�}t d|t| �g�}|�� } |du r'| S |s-td��t|�}|du r7d}t�| ||||�S )a6 Wrap a private key into a PKCS#8 blob (clear or encrypted). Args: private_key (bytes): The private key encoded in binary form. The actual encoding is algorithm specific. In most cases, it is DER. key_oid (string): The object identifier (OID) of the private key to wrap. It is a dotted string, like ``'1.2.840.113549.1.1.1'`` (for RSA keys) or ``'1.2.840.10045.2.1'`` (for ECC keys). Keyword Args: passphrase (bytes or string): The secret passphrase from which the wrapping key is derived. Set it only if encryption is required. protection (string): The identifier of the algorithm to use for securely wrapping the key. Refer to :ref:`the encryption parameters<enc_params>` . The default value is ``'PBKDF2WithHMAC-SHA1AndDES-EDE3-CBC'``. prot_params (dictionary): Parameters for the key derivation function (KDF). Refer to :ref:`the encryption parameters<enc_params>` . key_params (DER object or None): The ``parameters`` field to use in the ``AlgorithmIdentifier`` SEQUENCE. If ``None``, no ``parameters`` field will be added. By default, the ASN.1 type ``NULL`` is used. randfunc (callable): Random number generation function; it should accept a single integer N and return a string of random data, N bytes long. If not specified, a new RNG will be instantiated from :mod:`Cryptodome.Random`. Returns: bytes: The PKCS#8-wrapped private key (possibly encrypted). Nr zEmpty passphrasez"PBKDF2WithHMAC-SHA1AndDES-EDE3-CBC)r r r �encode� ValueError�tobytesr Zencrypt) �private_keyZkey_oid� passphraseZ protectionZprot_paramsZ key_paramsZrandfunc� algorithm�pk_infoZpk_info_der� r �G/opt/saltstack/salt/lib/python3.10/site-packages/Cryptodome/IO/PKCS8.pyr 2 s&