EVP_PKEY_CTX_SET_SCRYPT_N(3SSL)
π EVP_PKEY_CTX_set1_scrypt_salt, EVP_PKEY_CTX_set_scrypt_N, EVP_PKEY_CTX_set_scrypt_r, EVP_PKEY_CTX_set_scrypt_p, EVP_PKEY_CTX_set_scrypt_maxmem_bytes β the scrypt KDF glow-up β¨
okay bestie so this is straight out of the OpenSSL 3SSL manual, and it's literally the EVP_PKEY scrypt KDF support functions. yes that's a mouthful, we're gonna get through it together π«Ά
πΈ SYNOPSIS πΈ
#include <openssl/kdf.h>
int EVP_PKEY_CTX_set1_scrypt_salt(EVP_PKEY_CTX *pctx, unsigned char *salt,
int saltlen);
int EVP_PKEY_CTX_set_scrypt_N(EVP_PKEY_CTX *pctx, uint64_t N);
int EVP_PKEY_CTX_set_scrypt_r(EVP_PKEY_CTX *pctx, uint64_t r);
int EVP_PKEY_CTX_set_scrypt_p(EVP_PKEY_CTX *pctx, uint64_t p);
int EVP_PKEY_CTX_set_scrypt_maxmem_bytes(EVP_PKEY_CTX *pctx,
uint64_t maxmem);
like look at her, five little functions, all int-returning, all taking an EVP_PKEY_CTX *pctx first. iconic. π
π¦ DESCRIPTION π¦
so these functions are the setup crew π they set up all the data you need to actually use the scrypt KDF. and if you want the full scrypt lore, go read EVP_KDF-SCRYPT(7). iykyk.
EVP_PKEY_CTX_set1_scrypt_salt()β sets the salt value, and the salt issaltlenbytes long. that's it, that's the whole job. bestie just drops the salt in. π§β¨EVP_PKEY_CTX_set_scrypt_N(),EVP_PKEY_CTX_set_scrypt_r()andEVP_PKEY_CTX_set_scrypt_p()β these three configure the work factorsN,randp. yes they're the main characters of the difficulty dial, respect them. πEVP_PKEY_CTX_set_scrypt_maxmem_bytes()β sets how much RAM key derivation is allowed to use maximally, and it's given in bytes. and here's the part where u need to pay attention fr fr β if the RAM gets exceeded because the load factors are chosen too high, the key derivation will fail. no cap. so don't be greedy with those work factors or she just gives up π
β¨ STRING CTRLS β¨
plot twist: scrypt also supports string based control operations</> through EVP_PKEY_CTX_ctrl_str(3). love that for her π
and similarly (yes we're doing "similarly"), the salt can be specified either:
- using the type parameter
"salt", or - in hex encoding, by using the
"hexsalt"parameter.
the work factors N, r and p, plus maxmem_bytes, can each be set by using the parameters "N", "r", "p" and "maxmem_bytes", respectively. respectively!! she's so organized π
π NOTES π
- real talk: there's a newer generic API for KDFs,
EVP_KDF(3), and it is preferred over theEVP_PKEYmethod. so like⦠if you're starting fresh, that one's the vibe. - the scrypt KDF also uses
EVP_PKEY_CTX_set1_pbe_pass()as well as the value from the string controls"pass"and"hexpass". seeEVP_PKEY_CTX_set1_pbe_pass(3)for the tea. π
β RETURN VALUES β
all of these functions return 1 for success, and 0 or a negative value for failure. simple as. π
and in particular β drumroll pls β a return value of -2 indicates the operation is not supported by the public key algorithm. so if u see that -2, it's not you, it's the algorithm π«Ά
π SEE ALSO π
π HISTORY π
all of the functions described here were converted from macros to functions in OpenSSL 3.0. glow-up arc complete, we love a redemption story β¨
π COPYRIGHT π
Copyright 2017-2020 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>.
okay so that's the whole page bestie π«Ά go forth and derive your keys, but keep an eye on that maxmem_bytes or she WILL fail on you π
and that's a wrap on EVP_PKEY_CTX_SET_SCRYPT_N(3SSL) β this was OpenSSL 4.0.3, dated 2026-09-29. mwah, periodt π
πΈ
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms