1PKCS12_CREATE(3) OpenSSL PKCS12_CREATE(3)
2
3
4
6 PKCS12_create - create a PKCS#12 structure
7
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
16 PKCS12_create() creates a PKCS#12 structure.
17
18 pass is the passphrase to use. name is the friendlyName to use for the
19 supplied certificate and key. pkey is the private key to include in the
20 structure and cert its corresponding certificates. ca, if not NULL is
21 an optional set of certificates to also include in the structure.
22
23 nid_key and nid_cert are the encryption algorithms that should be used
24 for the key and certificate respectively. The modes GCM, CCM, XTS, and
25 OCB are unsupported. iter is the encryption algorithm iteration count
26 to use and mac_iter is the MAC iteration count to use. keytype is the
27 type of key.
28
30 The parameters nid_key, nid_cert, iter, mac_iter and keytype can all be
31 set to zero and sensible defaults will be used.
32
33 These defaults are: 40 bit RC2 encryption for certificates, triple DES
34 encryption for private keys, a key iteration count of
35 PKCS12_DEFAULT_ITER (currently 2048) and a MAC iteration count of 1.
36
37 The default MAC iteration count is 1 in order to retain compatibility
38 with old software which did not interpret MAC iteration counts. If such
39 compatibility is not required then mac_iter should be set to
40 PKCS12_DEFAULT_ITER.
41
42 keytype adds a flag to the store private key. This is a non standard
43 extension that is only currently interpreted by MSIE. If set to zero
44 the flag is omitted, if set to KEY_SIG the key can be used for signing
45 only, if set to KEY_EX it can be used for signing and encryption. This
46 option was useful for old export grade software which could use signing
47 only keys of arbitrary size but had restrictions on the permissible
48 sizes of keys which could be used for encryption.
49
50 If a certificate contains an alias or keyid then this will be used for
51 the corresponding friendlyName or localKeyID in the PKCS12 structure.
52
53 Either pkey, cert or both can be NULL to indicate that no key or
54 certificate is required. In previous versions both had to be present or
55 a fatal error is returned.
56
57 nid_key or nid_cert can be set to -1 indicating that no encryption
58 should be used.
59
60 mac_iter can be set to -1 and the MAC will then be omitted entirely.
61
62 PKCS12_create() makes assumptions regarding the encoding of the given
63 pass phrase. See passphrase-encoding(7) for more information.
64
66 PKCS12_create() returns a valid PKCS12 structure or NULL if an error
67 occurred.
68
70 d2i_PKCS12(3), passphrase-encoding(7)
71
73 Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.
74
75 Licensed under the OpenSSL license (the "License"). You may not use
76 this file except in compliance with the License. You can obtain a copy
77 in the file LICENSE in the source distribution or at
78 <https://www.openssl.org/source/license.html>.
79
80
81
821.1.1q 2022-07-21 PKCS12_CREATE(3)