| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "PKCS12_PBE_KEYIVGEN 3SSL" |
| 58 |
.TH PKCS12_PBE_KEYIVGEN 3SSL 2026-04-07 3.6.2 OpenSSL |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
PKCS12_PBE_keyivgen, PKCS12_PBE_keyivgen_ex, |
| 65 |
PKCS12_pbe_crypt, PKCS12_pbe_crypt_ex \- PKCS#12 Password based encryption |
| 66 |
.SH SYNOPSIS |
| 67 |
.IX Header "SYNOPSIS" |
| 68 |
.Vb 1 |
| 69 |
\& #include <openssl/evp.h> |
| 70 |
\& |
| 71 |
\& int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, |
| 72 |
\& ASN1_TYPE *param, const EVP_CIPHER *cipher, |
| 73 |
\& const EVP_MD *md_type, int en_de); |
| 74 |
\& int PKCS12_PBE_keyivgen_ex(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, |
| 75 |
\& ASN1_TYPE *param, const EVP_CIPHER *cipher, |
| 76 |
\& const EVP_MD *md_type, int en_de, |
| 77 |
\& OSSL_LIB_CTX *libctx, const char *propq); |
| 78 |
\& unsigned char *PKCS12_pbe_crypt(const X509_ALGOR *algor, |
| 79 |
\& const char *pass, int passlen, |
| 80 |
\& const unsigned char *in, int inlen, |
| 81 |
\& unsigned char **data, int *datalen, |
| 82 |
\& int en_de); |
| 83 |
\& unsigned char *PKCS12_pbe_crypt_ex(const X509_ALGOR *algor, |
| 84 |
\& const char *pass, int passlen, |
| 85 |
\& const unsigned char *in, int inlen, |
| 86 |
\& unsigned char **data, int *datalen, |
| 87 |
\& int en_de, OSSL_LIB_CTX *libctx, |
| 88 |
\& const char *propq); |
| 89 |
.Ve |
| 90 |
.SH DESCRIPTION |
| 91 |
.IX Header "DESCRIPTION" |
| 92 |
\&\fBPKCS12_PBE_keyivgen()\fR and \fBPKCS12_PBE_keyivgen_ex()\fR take a password \fIpass\fR of |
| 93 |
length \fIpasslen\fR, parameters \fIparam\fR and a message digest function \fImd_type\fR |
| 94 |
and perform a key derivation according to PKCS#12. The resulting key is |
| 95 |
then used to initialise the cipher context \fIctx\fR with a cipher \fIcipher\fR for |
| 96 |
encryption (\fIen_de\fR=1) or decryption (\fIen_de\fR=0). |
| 97 |
.PP |
| 98 |
\&\fBPKCS12_PBE_keyivgen_ex()\fR also allows the application to specify a library context |
| 99 |
\&\fIlibctx\fR and property query \fIpropq\fR to select appropriate algorithm |
| 100 |
implementations. |
| 101 |
.PP |
| 102 |
\&\fBPKCS12_pbe_crypt()\fR and \fBPKCS12_pbe_crypt_ex()\fR will encrypt or decrypt a buffer |
| 103 |
based on the algorithm in \fIalgor\fR and password \fIpass\fR of length \fIpasslen\fR. |
| 104 |
The input is from \fIin\fR of length \fIinlen\fR and output is into a malloc'd buffer |
| 105 |
returned in \fI*data\fR of length \fIdatalen\fR. The operation is determined by \fIen_de\fR, |
| 106 |
encryption (\fIen_de\fR=1) or decryption (\fIen_de\fR=0). |
| 107 |
.PP |
| 108 |
\&\fBPKCS12_pbe_crypt_ex()\fR allows the application to specify a library context |
| 109 |
\&\fIlibctx\fR and property query \fIpropq\fR to select appropriate algorithm |
| 110 |
implementations. |
| 111 |
.PP |
| 112 |
\&\fIpass\fR is the password used in the derivation of length \fIpasslen\fR. \fIpass\fR |
| 113 |
is an optional parameter and can be NULL. If \fIpasslen\fR is \-1, then the |
| 114 |
function will calculate the length of \fIpass\fR using \fBstrlen()\fR. |
| 115 |
.PP |
| 116 |
\&\fIsalt\fR is the salt used in the derivation of length \fIsaltlen\fR. If the |
| 117 |
\&\fIsalt\fR is NULL, then \fIsaltlen\fR must be 0. The function will not |
| 118 |
attempt to calculate the length of the \fIsalt\fR because it is not assumed to |
| 119 |
be NULL terminated. |
| 120 |
.PP |
| 121 |
\&\fIiter\fR is the iteration count and its value should be greater than or |
| 122 |
equal to 1. RFC 2898 suggests an iteration count of at least 1000. Any |
| 123 |
\&\fIiter\fR less than 1 is treated as a single iteration. |
| 124 |
.PP |
| 125 |
\&\fIdigest\fR is the message digest function used in the derivation. |
| 126 |
.PP |
| 127 |
Functions ending in \fB_ex()\fR take optional parameters \fIlibctx\fR and \fIpropq\fR which |
| 128 |
are used to select appropriate algorithm implementations. |
| 129 |
.SH NOTES |
| 130 |
.IX Header "NOTES" |
| 131 |
The functions are typically used in PKCS#12 to encrypt objects. |
| 132 |
.PP |
| 133 |
These functions make no assumption regarding the given password. |
| 134 |
It will simply be treated as a byte sequence. |
| 135 |
.SH "RETURN VALUES" |
| 136 |
.IX Header "RETURN VALUES" |
| 137 |
\&\fBPKCS12_PBE_keyivgen()\fR, \fBPKCS12_PBE_keyivgen_ex()\fR return 1 on success or 0 on error. |
| 138 |
.PP |
| 139 |
\&\fBPKCS12_pbe_crypt()\fR and \fBPKCS12_pbe_crypt_ex()\fR return a buffer containing the |
| 140 |
output or NULL if an error occurred. |
| 141 |
.SH "CONFORMING TO" |
| 142 |
.IX Header "CONFORMING TO" |
| 143 |
IETF RFC 7292 (<https://tools.ietf.org/html/rfc7292>) |
| 144 |
.SH "SEE ALSO" |
| 145 |
.IX Header "SEE ALSO" |
| 146 |
\&\fBEVP_PBE_CipherInit_ex\fR\|(3), |
| 147 |
\&\fBPKCS8_encrypt_ex\fR\|(3), |
| 148 |
\&\fBpassphrase\-encoding\fR\|(7) |
| 149 |
.SH HISTORY |
| 150 |
.IX Header "HISTORY" |
| 151 |
\&\fBPKCS12_PBE_keyivgen_ex()\fR and \fBPKCS12_pbe_crypt_ex()\fR were added in OpenSSL 3.0. |
| 152 |
.SH COPYRIGHT |
| 153 |
.IX Header "COPYRIGHT" |
| 154 |
Copyright 2014\-2021 The OpenSSL Project Authors. All Rights Reserved. |
| 155 |
.PP |
| 156 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 157 |
this file except in compliance with the License. You can obtain a copy |
| 158 |
in the file LICENSE in the source distribution or at |
| 159 |
<https://www.openssl.org/source/license.html>. |