[#PKCS8_encrypt]
= PKCS8&lowbar;encrypt
:mrdocs:

Encrypt a PKCS&num;8 private key info structure (default library context)&period;

== Synopsis

Declared in `&lt;openssl&sol;pkcs12&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:X509_SIG.adoc[X509&lowbar;SIG]*
PKCS8&lowbar;encrypt(
    int pbe&lowbar;nid,
    xref:EVP_CIPHER-07.adoc[EVP&lowbar;CIPHER] const* cipher,
    char const* pass,
    int passlen,
    unsigned char* salt,
    int saltlen,
    int iter,
    xref:PKCS8_PRIV_KEY_INFO.adoc[PKCS8&lowbar;PRIV&lowbar;KEY&lowbar;INFO]* p8);
----

== Return Value

Encrypted key in an X509&lowbar;SIG, or NULL on error&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *pbe&lowbar;nid*
| PBE algorithm NID&period;
| *cipher*
| Cipher for PBES2, or NULL when `pbe&lowbar;nid` selects a full PBE scheme&period;
| *pass*
| Passphrase for encryption&period;
| *passlen*
| Length of `pass,` or &hyphen;1 to use strlen()&period;
| *salt*
| Salt for key derivation&period;
| *saltlen*
| Length of `salt` in bytes&period;
| *iter*
| Iteration count for key derivation&period;
| *p8*
| Private key info to encrypt&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
