Write a private key as PEM PKCS#8 EncryptedPrivateKeyInfo (PKCS#5 v2.0).

Synopsis

Declared in <openssl/pem.h>

int
PEM_write_PKCS8PrivateKey(
    FILE* fp,
    EVP_PKEY const* x,
    EVP_CIPHER const* enc,
    char const* kstr,
    int klen,
    pem_password_cb* cd,
    void* u);

Return Value

1 on success, or 0 on failure.

Parameters

Name

Description

fp

FILE to write to.

x

Private key to encode.

enc

Cipher used at the PKCS#8 level, or NULL for unencrypted PrivateKeyInfo.

kstr

Optional passphrase; if NULL and enc is set, cd is used.

klen

Length of kstr when provided.

cd

Password callback when a passphrase is needed, or NULL.

u

Application data passed to cd.

Created with MrDocs