1PKCS12_CREATE(3ossl)                OpenSSL               PKCS12_CREATE(3ossl)
2
3
4

NAME

6       PKCS12_create, PKCS12_create_ex - create a PKCS#12 structure
7

SYNOPSIS

9        #include <openssl/pkcs12.h>
10
11        PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey,
12                              X509 *cert, STACK_OF(X509) *ca,
13                              int nid_key, int nid_cert, int iter, int mac_iter, int keytype);
14        PKCS12 *PKCS12_create_ex(const char *pass, const char *name, EVP_PKEY *pkey,
15                                 X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert,
16                                 int iter, int mac_iter, int keytype,
17                                 OSSL_LIB_CTX *ctx, const char *propq);
18

DESCRIPTION

20       PKCS12_create() creates a PKCS#12 structure.
21
22       pass is the passphrase to use. name is the friendlyName to use for the
23       supplied certificate and key. pkey is the private key to include in the
24       structure and cert its corresponding certificates. ca, if not NULL is
25       an optional set of certificates to also include in the structure.
26
27       nid_key and nid_cert are the encryption algorithms that should be used
28       for the key and certificate respectively. The modes GCM, CCM, XTS, and
29       OCB are unsupported. iter is the encryption algorithm iteration count
30       to use and mac_iter is the MAC iteration count to use.  keytype is the
31       type of key.
32
33       PKCS12_create_ex() is identical to PKCS12_create() but allows for a
34       library context ctx and property query propq to be used to select
35       algorithm implementations.
36

NOTES

38       The parameters nid_key, nid_cert, iter, mac_iter and keytype can all be
39       set to zero and sensible defaults will be used.
40
41       These defaults are: AES password based encryption (PBES2 with PBKDF2
42       and AES-256-CBC) for private keys and certificates, the PBKDF2 and MAC
43       key derivation iteration count of PKCS12_DEFAULT_ITER (currently 2048),
44       and MAC algorithm HMAC with SHA2-256.
45
46       The default MAC iteration count is 1 in order to retain compatibility
47       with old software which did not interpret MAC iteration counts. If such
48       compatibility is not required then mac_iter should be set to
49       PKCS12_DEFAULT_ITER.
50
51       keytype adds a flag to the store private key. This is a non standard
52       extension that is only currently interpreted by MSIE. If set to zero
53       the flag is omitted, if set to KEY_SIG the key can be used for signing
54       only, if set to KEY_EX it can be used for signing and encryption. This
55       option was useful for old export grade software which could use signing
56       only keys of arbitrary size but had restrictions on the permissible
57       sizes of keys which could be used for encryption.
58
59       If a certificate contains an alias or keyid then this will be used for
60       the corresponding friendlyName or localKeyID in the PKCS12 structure.
61
62       Either pkey, cert or both can be NULL to indicate that no key or
63       certificate is required. In previous versions both had to be present or
64       a fatal error is returned.
65
66       nid_key or nid_cert can be set to -1 indicating that no encryption
67       should be used.
68
69       mac_iter can be set to -1 and the MAC will then be omitted entirely.
70
71       PKCS12_create() makes assumptions regarding the encoding of the given
72       pass phrase.  See passphrase-encoding(7) for more information.
73

RETURN VALUES

75       PKCS12_create() returns a valid PKCS12 structure or NULL if an error
76       occurred.
77

CONFORMING TO

79       IETF RFC 7292 (<https://tools.ietf.org/html/rfc7292>)
80

SEE ALSO

82       d2i_PKCS12(3), passphrase-encoding(7)
83

HISTORY

85       PKCS12_create_ex() was added in OpenSSL 3.0.
86
87       The defaults for encryption algorithms, MAC algorithm, and the MAC key
88       derivation iteration count were changed in OpenSSL 3.0 to more modern
89       standards.
90
92       Copyright 2002-2021 The OpenSSL Project Authors. All Rights Reserved.
93
94       Licensed under the Apache License 2.0 (the "License").  You may not use
95       this file except in compliance with the License.  You can obtain a copy
96       in the file LICENSE in the source distribution or at
97       <https://www.openssl.org/source/license.html>.
98
99
100
1013.0.5                             2022-07-05              PKCS12_CREATE(3ossl)
Impressum