1PKCS12_KEY_GEN_UTF8_EX(3ossl) OpenSSL PKCS12_KEY_GEN_UTF8_EX(3ossl)
2
3
4
6 PKCS12_key_gen_asc, PKCS12_key_gen_asc_ex, PKCS12_key_gen_uni,
7 PKCS12_key_gen_uni_ex, PKCS12_key_gen_utf8, PKCS12_key_gen_utf8_ex -
8 PKCS#12 Password based key derivation
9
11 #include <openssl/pkcs12.h>
12
13 int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt,
14 int saltlen, int id, int iter, int n,
15 unsigned char *out, const EVP_MD *md_type);
16 int PKCS12_key_gen_asc_ex(const char *pass, int passlen, unsigned char *salt,
17 int saltlen, int id, int iter, int n,
18 unsigned char *out, const EVP_MD *md_type,
19 OSSL_LIB_CTX *ctx, const char *propq);
20 int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
21 int saltlen, int id, int iter, int n,
22 unsigned char *out, const EVP_MD *md_type);
23 int PKCS12_key_gen_uni_ex(unsigned char *pass, int passlen, unsigned char *salt,
24 int saltlen, int id, int iter, int n,
25 unsigned char *out, const EVP_MD *md_type,
26 OSSL_LIB_CTX *ctx, const char *propq);
27 int PKCS12_key_gen_utf8(const char *pass, int passlen, unsigned char *salt,
28 int saltlen, int id, int iter, int n,
29 unsigned char *out, const EVP_MD *md_type);
30 int PKCS12_key_gen_utf8_ex(const char *pass, int passlen, unsigned char *salt,
31 int saltlen, int id, int iter, int n,
32 unsigned char *out, const EVP_MD *md_type,
33 OSSL_LIB_CTX *ctx, const char *propq);
34
36 These methods perform a key derivation according to PKCS#12 (RFC7292)
37 with an input password pass of length passlen, a salt salt of length
38 saltlen, an iteration count iter and a digest algorithm md_type. The
39 ID byte id determines how the resulting key is intended to be used:
40
41 • If ID=1, then the pseudorandom bits being produced are to be used
42 as key material for performing encryption or decryption.
43
44 • If ID=2, then the pseudorandom bits being produced are to be used
45 as an IV (Initial Value) for encryption or decryption.
46
47 • If ID=3, then the pseudorandom bits being produced are to be used
48 as an integrity key for MACing.
49
50 The intended format of the supplied password is determined by the
51 method chosen:
52
53 • PKCS12_key_gen_asc() and PKCS12_key_gen_asc_ex() expect an ASCII-
54 formatted password.
55
56 • PKCS12_key_gen_uni() and PKCS12_key_gen_uni_ex() expect a Unicode-
57 formatted password.
58
59 • PKCS12_key_gen_utf8() and PKCS12_key_gen_utf8_ex() expect a UTF-8
60 encoded password.
61
62 pass is the password used in the derivation of length passlen. pass is
63 an optional parameter and can be NULL. If passlen is -1, then the
64 function will calculate the length of pass using strlen().
65
66 salt is the salt used in the derivation of length saltlen. If the salt
67 is NULL, then saltlen must be 0. The function will not attempt to
68 calculate the length of the salt because it is not assumed to be NULL
69 terminated.
70
71 iter is the iteration count and its value should be greater than or
72 equal to 1. RFC 2898 suggests an iteration count of at least 1000. Any
73 iter less than 1 is treated as a single iteration.
74
75 digest is the message digest function used in the derivation.
76
77 The derived key will be written to out. The size of the out buffer is
78 specified via n.
79
80 Functions ending in _ex() allow for a library context ctx and property
81 query propq to be used to select algorithm implementations.
82
84 A typical application of this function is to derive keying material for
85 an encryption algorithm from a password in the pass, a salt in salt,
86 and an iteration count.
87
88 Increasing the iter parameter slows down the algorithm which makes it
89 harder for an attacker to perform a brute force attack using a large
90 number of candidate passwords.
91
93 Returns 1 on success or 0 on error.
94
96 IETF RFC 7292 (<https://tools.ietf.org/html/rfc7292>)
97
99 PKCS12_create_ex(3), PKCS12_pbe_crypt_ex(3), passphrase-encoding(7)
100
102 PKCS12_key_gen_asc_ex(), PKCS12_key_gen_uni_ex() and
103 PKCS12_key_gen_utf8_ex() were added in OpenSSL 3.0.
104
106 Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
107
108 Licensed under the Apache License 2.0 (the "License"). You may not use
109 this file except in compliance with the License. You can obtain a copy
110 in the file LICENSE in the source distribution or at
111 <https://www.openssl.org/source/license.html>.
112
113
114
1153.1.1 2023-08-31 PKCS12_KEY_GEN_UTF8_EX(3ossl)