]> git.ipfire.org Git - thirdparty/openssl.git/blob - doc/man3/PKCS12_create.pod
Update copyright year
[thirdparty/openssl.git] / doc / man3 / PKCS12_create.pod
1 =pod
2
3 =head1 NAME
4
5 PKCS12_create - create a PKCS#12 structure
6
7 =head1 SYNOPSIS
8
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
15 =head1 DESCRIPTION
16
17 PKCS12_create() creates a PKCS#12 structure.
18
19 I<pass> is the passphrase to use. I<name> is the B<friendlyName> to use for
20 the supplied certificate and key. I<pkey> is the private key to include in
21 the structure and I<cert> its corresponding certificates. I<ca>, if not NULL
22 is an optional set of certificates to also include in the structure.
23
24 I<nid_key> and I<nid_cert> are the encryption algorithms that should be used
25 for the key and certificate respectively. The modes
26 GCM, CCM, XTS, and OCB are unsupported. I<iter> is the encryption algorithm
27 iteration count to use and I<mac_iter> is the MAC iteration count to use.
28 I<keytype> is the type of key.
29
30 =head1 NOTES
31
32 The parameters I<nid_key>, I<nid_cert>, I<iter>, I<mac_iter> and I<keytype>
33 can all be set to zero and sensible defaults will be used.
34
35 These defaults are: AES password based encryption (PBES2 with PBKDF2 and
36 AES-256-CBC) for private keys and certificates, the PBKDF2 and MAC key
37 derivation iteration count of B<PKCS12_DEFAULT_ITER> (currently 2048), and
38 MAC algorithm HMAC with SHA2-256.
39
40 I<keytype> adds a flag to the store private key. This is a non standard extension
41 that is only currently interpreted by MSIE. If set to zero the flag is omitted,
42 if set to B<KEY_SIG> the key can be used for signing only, if set to B<KEY_EX>
43 it can be used for signing and encryption. This option was useful for old
44 export grade software which could use signing only keys of arbitrary size but
45 had restrictions on the permissible sizes of keys which could be used for
46 encryption.
47
48 If a certificate contains an I<alias> or I<keyid> then this will be
49 used for the corresponding B<friendlyName> or B<localKeyID> in the
50 PKCS12 structure.
51
52 Either I<pkey>, I<cert> or both can be NULL to indicate that no key or
53 certificate is required. In previous versions both had to be present or
54 a fatal error is returned.
55
56 I<nid_key> or I<nid_cert> can be set to -1 indicating that no encryption
57 should be used.
58
59 I<mac_iter> can be set to -1 and the MAC will then be omitted entirely.
60
61 PKCS12_create() makes assumptions regarding the encoding of the given pass
62 phrase.
63 See L<passphrase-encoding(7)> for more information.
64
65 =head1 RETURN VALUES
66
67 PKCS12_create() returns a valid B<PKCS12> structure or NULL if an error occurred.
68
69 =head1 SEE ALSO
70
71 L<d2i_PKCS12(3)>,
72 L<passphrase-encoding(7)>
73
74 =head1 HISTORY
75
76 The defaults for encryption algorithms, MAC algorithm, and the MAC key
77 derivation iteration count were changed in OpenSSL 3.0 to more modern
78 standards.
79
80 =head1 COPYRIGHT
81
82 Copyright 2002-2021 The OpenSSL Project Authors. All Rights Reserved.
83
84 Licensed under the Apache License 2.0 (the "License"). You may not use
85 this file except in compliance with the License. You can obtain a copy
86 in the file LICENSE in the source distribution or at
87 L<https://www.openssl.org/source/license.html>.
88
89 =cut