EVP_KDF-ARGON2(7ossl)
π EVP_KDF-ARGON2 β the Argon2 EVP KDF implementation β¨
Okay so bestie, this is page EVP_KDF-ARGON2(7ossl) from the OpenSSL manual, and it's lowkey one of the most important pages you'll read if you care about password hashing. Sit down, grab a strawberry drink π, and let's get into it.
πΈ NAME πΈ
EVP_KDF-ARGON2 β the Argon2 EVP KDF implementation. Periodt. That's the whole name section, she's concise.
β¨ DESCRIPTION β¨
So this is support for computing the argon2 password-based KDF through the EVP_KDF API. That's the whole vibe.
The EVP_KDF-ARGON2 algorithm implements the Argon2 password-based key derivation function, exactly as described in IETF RFC 9106. It's memory-hard, meaning it deliberately requires a significant amount of RAM to compute efficiently β like, it's on purpose, bestie π
. The whole intention here is to make brute forcing passwords on systems that lack large amounts of main memory (thinking GPUs or ASICs, you know the ones) computationally infeasible. It's giving "I will absolutely eat your GPU's lunch" energy.
Quick rundown of the flavors:
- Argon2d uses data-dependent memory access and is primarily there to address trade-off attacks.
- Argon2i uses data-independent memory access and is primarily there to address side-channel attacks.
- Argon2id is a hybrid construction β in the first two slices of the first pass, it generates reference addresses data-independently like Argon2i, whereas in later slices and subsequent passes it generates them data-dependently like Argon2d. Best of both worlds, honestly iconic π.
Heads up: the sbox-hardened version Argon2ds is not supported. Don't come looking for it, she's not here π.
For more information, please refer to RFC 9106.
π Supported parameters π
The supported parameters are:
"pass"(OSSL_KDF_PARAM_PASSWORD) <octet string>"salt"(OSSL_KDF_PARAM_SALT) <octet string>"secret"(OSSL_KDF_PARAM_SECRET) <octet string>"iter"(OSSL_KDF_PARAM_ITER) <unsigned integer>"size"(OSSL_KDF_PARAM_SIZE) <unsigned integer>"properties"(OSSL_KDF_PARAM_PROPERTIES) <UTF8 string>
These parameters work as described in "PARAMETERS" in EVP_KDF(3).
Note that RFC 9106 recommends 128 bits salt for most applications, or 64 bits salt in the case of space constraints. At least 128 bits output length is recommended. Ngl, listen to the RFC, she knows what she's doing π«Ά.
Note that secret (or pepper) is an optional secret data used along the password. It's like a little extra sprinkle of secret on top πΆοΈ.
"threads"(OSSL_KDF_PARAM_THREADS) <unsigned integer> β the number of threads, bounded above by the number of lanes. This can only be used with built-in thread support. Threading must be explicitly enabled. See the EXAMPLES section for more information. Not me flexing extra cores π§"ad"(OSSL_KDF_PARAM_ARGON2_AD) <octet string> β optional associated data, and it may be used to "tag" a group of keys, or tie them to a particular public key, without having to modify salt. Cute little tag-along π"lanes"(OSSL_KDF_PARAM_ARGON2_LANES) <unsigned integer> β Argon2 splits the requested memory size into lanes, each of which is designed to be processed in parallel. For example, on a system withpcores, it's recommended to useplanes. The number of lanes is used to derive the key. It is possible to specify more lanes than the number of available computational threads β and this is especially encouraged if multi-threading is disabled. Go off, specify all the lanes π"memcost"(OSSL_KDF_PARAM_ARGON2_MEMCOST) <unsigned integer> β memory cost parameter (the number of 1k memory blocks used). This is the one that makes your RAM sweat π₯"version"(OSSL_KDF_PARAM_ARGON2_VERSION) <unsigned integer> β Argon2 version. Supported values:0x10,0x13(default). Default queen behavior."early_clean"(OSSL_KDF_PARAM_EARLY_CLEAN) <unsigned integer> β if set (nonzero), password and secret stored in Argon2 context are zeroed early during initial hash computation, as soon as they are not needed. Otherwise, they are zeroed along the rest of Argon2 context data on clear, free, reset. This can be useful if, for example, multiple keys with differentadvalue are to be generated from a single password and secret. Responsible queen behavior π
π EXAMPLES π
Okay so this example uses Argon2d with password "1234567890", salt "saltsalt", using 2 lanes, 2 threads, and memory cost of 65536. Look at her go:
#include <string.h> /* strlen */
#include <openssl/core_names.h> /* OSSL_KDF_* */
#include <openssl/params.h> /* OSSL_PARAM_* */
#include <openssl/thread.h> /* OSSL_set_max_threads */
#include <openssl/kdf.h> /* EVP_KDF_* */
int main(void)
{
int retval = 1;
EVP_KDF *kdf = NULL;
EVP_KDF_CTX *kctx = NULL;
OSSL_PARAM params[6], *p = params;
/* argon2 params, please refer to RFC9106 for recommended defaults */
uint32_t lanes = 2, threads = 2, memcost = 65536;
char pwd[] = "1234567890", salt[] = "saltsalt";
/* derive result */
size_t outlen = 128;
unsigned char result[outlen];
/* required if threads > 1 */
if (OSSL_set_max_threads(NULL, threads) != 1)
goto fail;
p = params;
*p++ = OSSL_PARAM_construct_uint32(OSSL_KDF_PARAM_THREADS, &threads);
*p++ = OSSL_PARAM_construct_uint32(OSSL_KDF_PARAM_ARGON2_LANES,
&lanes);
*p++ = OSSL_PARAM_construct_uint32(OSSL_KDF_PARAM_ARGON2_MEMCOST,
&memcost);
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SALT,
salt,
strlen((const char *)salt));
*p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_PASSWORD,
pwd,
strlen((const char *)pwd));
*p++ = OSSL_PARAM_construct_end();
if ((kdf = EVP_KDF_fetch(NULL, "ARGON2D", NULL)) == NULL)
goto fail;
if ((kctx = EVP_KDF_CTX_new(kdf)) == NULL)
goto fail;
if (EVP_KDF_derive(kctx, &result[0], outlen, params) != 1)
goto fail;
printf("Output = %s\n", OPENSSL_buf2hexstr(result, outlen));
retval = 0;
fail:
EVP_KDF_free(kdf);
EVP_KDF_CTX_free(kctx);
OSSL_set_max_threads(NULL, 0);
return retval;
}
π¦ NOTES π¦
"ARGON2I", "ARGON2D", and "ARGON2ID" are the names for this implementation β it can be used with the EVP_KDF_fetch() function. Three names, one icon π. iykyk.
π CONFORMING TO π
RFC 9106 Argon2, see https://www.rfc-editor.org/rfc/rfc9106.txt. Read it, bestie, it's giving required reading π
π SEE ALSO π
EVP_KDF(3), EVP_KDF_CTX_new(3), EVP_KDF_CTX_free(3), EVP_KDF_CTX_set_params(3), EVP_KDF_derive(3), "PARAMETERS" in EVP_KDF(3)
Go click through those, they're all linked in spirit π«Ά
π HISTORY π
This functionality was added to OpenSSL 3.2. Newer than some of y'all's favorite albums, but she's here now.
π COPYRIGHT π
Copyright 2022-2024 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.
And that's the page, bestie π β OpenSSL 3.5.0, dated 2026-09-25, EVP_KDF-ARGON2(7ossl), signing off. Now go hash some passwords responsibly β¨π
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms