| 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 "EVP_KDF-ARGON2 7SSL" |
| 58 |
.TH EVP_KDF-ARGON2 7SSL 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 |
EVP_KDF\-ARGON2 \- The Argon2 EVP KDF implementation |
| 65 |
.SH DESCRIPTION |
| 66 |
.IX Header "DESCRIPTION" |
| 67 |
Support for computing the \fBargon2\fR password-based KDF through the \fBEVP_KDF\fR |
| 68 |
API. |
| 69 |
.PP |
| 70 |
The EVP_KDF\-ARGON2 algorithm implements the Argon2 password-based key |
| 71 |
derivation function, as described in IETF RFC 9106. It is memory-hard in |
| 72 |
the sense that it deliberately requires a significant amount of RAM for efficient |
| 73 |
computation. The intention of this is to render brute forcing of passwords on |
| 74 |
systems that lack large amounts of main memory (such as GPUs or ASICs) |
| 75 |
computationally infeasible. |
| 76 |
.PP |
| 77 |
Argon2d (Argon2i) uses data-dependent (data-independent) memory access and |
| 78 |
primary seek to address trade-off (side-channel) attacks. |
| 79 |
.PP |
| 80 |
Argon2id is a hybrid construction which, in the first two slices of the first |
| 81 |
pass, generates reference addresses data-independently as in Argon2i, whereas |
| 82 |
in later slices and next passes it generates them data-dependently as in |
| 83 |
Argon2d. |
| 84 |
.PP |
| 85 |
Sbox-hardened version Argon2ds is not supported. |
| 86 |
.PP |
| 87 |
For more information, please refer to RFC 9106. |
| 88 |
.SS "Supported parameters" |
| 89 |
.IX Subsection "Supported parameters" |
| 90 |
The supported parameters are: |
| 91 |
.IP """pass"" (\fBOSSL_KDF_PARAM_PASSWORD\fR) <octet string>" 4 |
| 92 |
.IX Item """pass"" (OSSL_KDF_PARAM_PASSWORD) <octet string>" |
| 93 |
.PD 0 |
| 94 |
.IP """salt"" (\fBOSSL_KDF_PARAM_SALT\fR) <octet string>" 4 |
| 95 |
.IX Item """salt"" (OSSL_KDF_PARAM_SALT) <octet string>" |
| 96 |
.IP """secret"" (\fBOSSL_KDF_PARAM_SECRET\fR) <octet string>" 4 |
| 97 |
.IX Item """secret"" (OSSL_KDF_PARAM_SECRET) <octet string>" |
| 98 |
.IP """iter"" (\fBOSSL_KDF_PARAM_ITER\fR) <unsigned integer>" 4 |
| 99 |
.IX Item """iter"" (OSSL_KDF_PARAM_ITER) <unsigned integer>" |
| 100 |
.IP """size"" (\fBOSSL_KDF_PARAM_SIZE\fR) <unsigned integer>" 4 |
| 101 |
.IX Item """size"" (OSSL_KDF_PARAM_SIZE) <unsigned integer>" |
| 102 |
.IP """properties"" (\fBOSSL_KDF_PARAM_PROPERTIES\fR) <UTF8 string>" 4 |
| 103 |
.IX Item """properties"" (OSSL_KDF_PARAM_PROPERTIES) <UTF8 string>" |
| 104 |
.PD |
| 105 |
These parameters work as described in "PARAMETERS" in \fBEVP_KDF\fR\|(3). |
| 106 |
.Sp |
| 107 |
Note that RFC 9106 recommends 128 bits salt for most applications, or 64 bits |
| 108 |
salt in the case of space constraints. At least 128 bits output length is |
| 109 |
recommended. |
| 110 |
.Sp |
| 111 |
Note that secret (or pepper) is an optional secret data used along the |
| 112 |
password. |
| 113 |
.IP """threads"" (\fBOSSL_KDF_PARAM_THREADS\fR) <unsigned integer>" 4 |
| 114 |
.IX Item """threads"" (OSSL_KDF_PARAM_THREADS) <unsigned integer>" |
| 115 |
The number of threads, bounded above by the number of lanes. |
| 116 |
.Sp |
| 117 |
This can only be used with built-in thread support. Threading must be |
| 118 |
explicitly enabled. See EXAMPLES section for more information. |
| 119 |
.IP """ad"" (\fBOSSL_KDF_PARAM_ARGON2_AD\fR) <octet string>" 4 |
| 120 |
.IX Item """ad"" (OSSL_KDF_PARAM_ARGON2_AD) <octet string>" |
| 121 |
Optional associated data, may be used to "tag" a group of keys, or tie them |
| 122 |
to a particular public key, without having to modify salt. |
| 123 |
.IP """lanes"" (\fBOSSL_KDF_PARAM_ARGON2_LANES\fR) <unsigned integer>" 4 |
| 124 |
.IX Item """lanes"" (OSSL_KDF_PARAM_ARGON2_LANES) <unsigned integer>" |
| 125 |
Argon2 splits the requested memory size into lanes, each of which is designed |
| 126 |
to be processed in parallel. For example, on a system with p cores, it's |
| 127 |
recommended to use p lanes. |
| 128 |
.Sp |
| 129 |
The number of lanes is used to derive the key. It is possible to specify |
| 130 |
more lanes than the number of available computational threads. This is |
| 131 |
especially encouraged if multi-threading is disabled. |
| 132 |
.IP """memcost"" (\fBOSSL_KDF_PARAM_ARGON2_MEMCOST\fR) <unsigned integer>" 4 |
| 133 |
.IX Item """memcost"" (OSSL_KDF_PARAM_ARGON2_MEMCOST) <unsigned integer>" |
| 134 |
Memory cost parameter (the number of 1k memory blocks used). |
| 135 |
.IP """version"" (\fBOSSL_KDF_PARAM_ARGON2_VERSION\fR) <unsigned integer>" 4 |
| 136 |
.IX Item """version"" (OSSL_KDF_PARAM_ARGON2_VERSION) <unsigned integer>" |
| 137 |
Argon2 version. Supported values: 0x10, 0x13 (default). |
| 138 |
.IP """early_clean"" (\fBOSSL_KDF_PARAM_EARLY_CLEAN\fR) <unsigned integer>" 4 |
| 139 |
.IX Item """early_clean"" (OSSL_KDF_PARAM_EARLY_CLEAN) <unsigned integer>" |
| 140 |
If set (nonzero), password and secret stored in Argon2 context are zeroed |
| 141 |
early during initial hash computation, as soon as they are not needed. |
| 142 |
Otherwise, they are zeroed along the rest of Argon2 context data on clear, |
| 143 |
free, reset. |
| 144 |
.Sp |
| 145 |
This can be useful if, for example, multiple keys with different ad value |
| 146 |
are to be generated from a single password and secret. |
| 147 |
.SH EXAMPLES |
| 148 |
.IX Header "EXAMPLES" |
| 149 |
This example uses Argon2d with password "1234567890", salt "saltsalt", |
| 150 |
using 2 lanes, 2 threads, and memory cost of 65536: |
| 151 |
.PP |
| 152 |
.Vb 5 |
| 153 |
\& #include <string.h> /* strlen */ |
| 154 |
\& #include <openssl/core_names.h> /* OSSL_KDF_* */ |
| 155 |
\& #include <openssl/params.h> /* OSSL_PARAM_* */ |
| 156 |
\& #include <openssl/thread.h> /* OSSL_set_max_threads */ |
| 157 |
\& #include <openssl/kdf.h> /* EVP_KDF_* */ |
| 158 |
\& |
| 159 |
\& int main(void) |
| 160 |
\& { |
| 161 |
\& int retval = 1; |
| 162 |
\& |
| 163 |
\& EVP_KDF *kdf = NULL; |
| 164 |
\& EVP_KDF_CTX *kctx = NULL; |
| 165 |
\& OSSL_PARAM params[6], *p = params; |
| 166 |
\& |
| 167 |
\& /* argon2 params, please refer to RFC9106 for recommended defaults */ |
| 168 |
\& uint32_t lanes = 2, threads = 2, memcost = 65536; |
| 169 |
\& char pwd[] = "1234567890", salt[] = "saltsalt"; |
| 170 |
\& |
| 171 |
\& /* derive result */ |
| 172 |
\& size_t outlen = 128; |
| 173 |
\& unsigned char result[outlen]; |
| 174 |
\& |
| 175 |
\& /* required if threads > 1 */ |
| 176 |
\& if (OSSL_set_max_threads(NULL, threads) != 1) |
| 177 |
\& goto fail; |
| 178 |
\& |
| 179 |
\& p = params; |
| 180 |
\& *p++ = OSSL_PARAM_construct_uint32(OSSL_KDF_PARAM_THREADS, &threads); |
| 181 |
\& *p++ = OSSL_PARAM_construct_uint32(OSSL_KDF_PARAM_ARGON2_LANES, |
| 182 |
\& &lanes); |
| 183 |
\& *p++ = OSSL_PARAM_construct_uint32(OSSL_KDF_PARAM_ARGON2_MEMCOST, |
| 184 |
\& &memcost); |
| 185 |
\& *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT, |
| 186 |
\& salt, |
| 187 |
\& strlen((const char *)salt)); |
| 188 |
\& *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_PASSWORD, |
| 189 |
\& pwd, |
| 190 |
\& strlen((const char *)pwd)); |
| 191 |
\& *p++ = OSSL_PARAM_construct_end(); |
| 192 |
\& |
| 193 |
\& if ((kdf = EVP_KDF_fetch(NULL, "ARGON2D", NULL)) == NULL) |
| 194 |
\& goto fail; |
| 195 |
\& if ((kctx = EVP_KDF_CTX_new(kdf)) == NULL) |
| 196 |
\& goto fail; |
| 197 |
\& if (EVP_KDF_derive(kctx, &result[0], outlen, params) != 1) |
| 198 |
\& goto fail; |
| 199 |
\& |
| 200 |
\& printf("Output = %s\en", OPENSSL_buf2hexstr(result, outlen)); |
| 201 |
\& retval = 0; |
| 202 |
\& |
| 203 |
\& fail: |
| 204 |
\& EVP_KDF_free(kdf); |
| 205 |
\& EVP_KDF_CTX_free(kctx); |
| 206 |
\& OSSL_set_max_threads(NULL, 0); |
| 207 |
\& |
| 208 |
\& return retval; |
| 209 |
\& } |
| 210 |
.Ve |
| 211 |
.SH NOTES |
| 212 |
.IX Header "NOTES" |
| 213 |
"ARGON2I", "ARGON2D", and "ARGON2ID" are the names for this implementation; it |
| 214 |
can be used with the \fBEVP_KDF_fetch()\fR function. |
| 215 |
.SH "CONFORMING TO" |
| 216 |
.IX Header "CONFORMING TO" |
| 217 |
RFC 9106 Argon2, see <https://www.rfc\-editor.org/rfc/rfc9106.txt>. |
| 218 |
.SH "SEE ALSO" |
| 219 |
.IX Header "SEE ALSO" |
| 220 |
\&\fBEVP_KDF\fR\|(3), |
| 221 |
\&\fBEVP_KDF_CTX_new\fR\|(3), |
| 222 |
\&\fBEVP_KDF_CTX_free\fR\|(3), |
| 223 |
\&\fBEVP_KDF_CTX_set_params\fR\|(3), |
| 224 |
\&\fBEVP_KDF_derive\fR\|(3), |
| 225 |
"PARAMETERS" in \fBEVP_KDF\fR\|(3) |
| 226 |
.SH HISTORY |
| 227 |
.IX Header "HISTORY" |
| 228 |
This functionality was added to OpenSSL 3.2. |
| 229 |
.SH COPYRIGHT |
| 230 |
.IX Header "COPYRIGHT" |
| 231 |
Copyright 2022\-2024 The OpenSSL Project Authors. All Rights Reserved. |
| 232 |
.PP |
| 233 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 234 |
this file except in compliance with the License. You can obtain a copy |
| 235 |
in the file LICENSE in the source distribution or at |
| 236 |
<https://www.openssl.org/source/license.html>. |