[#PKCS12_add_key_ex]
= PKCS12&lowbar;add&lowbar;key&lowbar;ex
:mrdocs:

Create a key safeBag and append it to a stack of safeBags&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:PKCS12_SAFEBAG.adoc[PKCS12&lowbar;SAFEBAG]*
PKCS12&lowbar;add&lowbar;key&lowbar;ex(
    xref:stack_st_PKCS12_SAFEBAG.adoc[stack&lowbar;st&lowbar;PKCS12&lowbar;SAFEBAG]** pbags,
    xref:EVP_PKEY.adoc[EVP&lowbar;PKEY]* key,
    int key&lowbar;usage,
    int iter,
    int key&lowbar;nid,
    char const* pass,
    xref:OSSL_LIB_CTX.adoc[OSSL&lowbar;LIB&lowbar;CTX]* ctx,
    char const* propq);
----

== Return Value

The new safeBag, or NULL on error&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *pbags*
| Address of safeBag stack pointer (created if &ast;`pbags` is NULL)&period;
| *key*
| Private key to add&period;
| *key&lowbar;usage*
| MS key&hyphen;usage flag (KEY&lowbar;SIG or KEY&lowbar;EX), or 0 to omit&period;
| *iter*
| Iteration count for key encryption, or 0 for default&period;
| *key&lowbar;nid*
| PBE NID for key encryption, or &hyphen;1 for an unencrypted keyBag&period;
| *pass*
| Passphrase when `key&lowbar;nid` selects encryption, or NULL otherwise&period;
| *ctx*
| Library context for algorithm fetching, or NULL for default&period;
| *propq*
| Property query for algorithm fetching, or NULL&period;
|===


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