Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
Standard preamble:
========================================================================
..
.... \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
. ds C` "" . ds C' "" 'br\} . ds C` . ds C' 'br\}
Escape single quotes in literal strings from groff's Unicode transform.
If the F register is >0, we'll generate index entries on stderr for
titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
entries marked with X<> in POD. Of course, you'll have to process the
output yourself in some meaningful fashion.
Avoid warning from groff about undefined register 'F'.
.. .nr rF 0 . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF ========================================================================
Title "EVP_KDF-ARGON2 7ossl"
way too many mistakes in technical documents.
The EVP_KDF-ARGON2 algorithm implements the Argon2 password-based key derivation function, as described in IETF RFC 9106. It is memory-hard in the sense that it deliberately requires a significant amount of RAM for efficient computation. The intention of this is to render brute forcing of passwords on systems that lack large amounts of main memory (such as GPUs or ASICs) computationally infeasible.
Argon2d (Argon2i) uses data-dependent (data-independent) memory access and primary seek to address trade-off (side-channel) attacks.
Argon2id is a hybrid construction which, in the first two slices of the first pass, generates reference addresses data-independently as in Argon2i, whereas in later slices and next passes it generates them data-dependently as in Argon2d.
Sbox-hardened version Argon2ds is not supported.
For more information, please refer to RFC 9106.
0
These parameters work as described in "PARAMETERS" in EVP_KDF\|(3). .Sp 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. .Sp Note that secret (or pepper) is an optional secret data used along the password.
.Vb 5 #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\en", OPENSSL_buf2hexstr(result, outlen)); retval = 0; \& fail: EVP_KDF_free(kdf); EVP_KDF_CTX_free(kctx); OSSL_set_max_threads(NULL, 0); \& return retval; } .Ve
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>.