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