EVP_PKEY_CTX_SET_SCRYPT_N(3ossl)
π EVP_PKEY_CTX_SET_SCRYPT_N β the scrypt setup girlies β¨
okay so this is the OpenSSL 3ossl manual page for the scrypt KDF support functions, and bestie, if you're here it's because you're doing password hashing the deliberate way and honestly? taste. π
πΈ NAME πΈ
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 EVP_PKEY scrypt KDF support functions, i.e. the whole lil friend group that sets up your scrypt key derivation π«Ά
β¨ SYNOPSIS β¨
like, here's the whole cast, in code, exactly as written, no notes:
#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);
π¦ DESCRIPTION π¦
so these functions exist to set up all the necessary data for using the scrypt KDF. want the full lore on scrypt itself? it's over in EVP_KDF-SCRYPT(7), go read it, it's giving essential reading. π
EVP_PKEY_CTX_set1_scrypt_salt()β sets the salt value, which issaltlenbytes long. literally just the salt. iconic, necessary, do not skip her. π§EVP_PKEY_CTX_set_scrypt_N(),EVP_PKEY_CTX_set_scrypt_r()andEVP_PKEY_CTX_set_scrypt_p()β configure the work factorsN,randp. yes all three, they're a package deal, don't play favorites. π₯EVP_PKEY_CTX_set_scrypt_maxmem_bytes()β sets how much RAM key derivation may maximally use, given in bytes. and bestie listen: if that RAM limit gets exceeded because the load factors were chosen too high, the key derivation will fail. no cap, it just dies. π
π STRING CTRLS π
scrypt also supports string based control operations via EVP_PKEY_CTX_ctrl_str(3). so you've got options, and here's the mapping, memorized:
- the salt can be specified either using the type parameter
"salt"or in hex encoding by using the"hexsalt"parameter. - the work factors
N,randp, as well asmaxmem_bytes, can be set by using the parameters"N","r","p"and"maxmem_bytes", respectively. π
iykyk β stringly-typed control names, the classic.
π NOTES π
okay important heads up, fr fr: there's a newer generic API for KDFs, EVP_KDF(3), and it is preferred over the EVP_PKEY method. so like, if you're starting fresh? go that way. this one's the legacy bestie. π«Ά
also the scrypt KDF uses EVP_PKEY_CTX_set1_pbe_pass() as well as the value from the string controls "pass" and "hexpass". see EVP_PKEY_CTX_set1_pbe_pass(3) for the deets. π
β RETURN VALUES β
all these functions return 1 for success, and 0 or a negative value for failure. and in particular?? a return value of -2 means the operation is not supported by the public key algorithm. so if you see -2, that's not a you problem, that's a "this algorithm doesn't do that" problem. π
π SEE ALSO π
go touch these pages too, they're all linked in the group chat:
EVP_KDF(3) EVP_PKEY_CTX_new(3), EVP_PKEY_CTX_ctrl_str(3), EVP_PKEY_derive(3)
π HISTORY π
all of the functions described here were converted from macros to functions in OpenSSL 3.0. glow-up arc complete, they're real functions now. β¨
πΈ 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 that's the whole page bestie, go hash something responsibly π
sign-off szn: this was 3.5.6, dated 2026-04-07, and the page is EVP_PKEY_CTX_SET_SCRYPT_N(3ossl) β mwah, slay, see u in the man pages π§
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms