EVP_PKEY_CTX_SET_SCRYPT_N(3ossl)
π EVP_PKEY_CTX_SET_SCRYPT_N(3ossl) β the scrypt KDF glow-up π
okay so bestie, this is an OpenSSL manual page (that's the 3ossl part, iykyk) and it's literally all about getting the scrypt KDF set up and ready to slay. grab a snack, we're going in π
β¨ 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 whole EVP_PKEY scrypt KDF support function squad π
π SYNOPSIS π
like, this is the important code part, no cap:
#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);
copy it exactly, bestie, don't be creative with the types π
π¦ DESCRIPTION π¦
so these functions are the little setup crew π«Ά β they go and arrange all the necessary data you need before you can actually use the scrypt KDF. if you want the full lore on scrypt itself, go read EVP_KDF-SCRYPT(7), it's giving required reading β¨
EVP_PKEY_CTX_set1_scrypt_salt()β sets the salt value, and that salt is exactlysaltlenbytes long. that's the whole vibe πΈ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, all three, they're a package deal πEVP_PKEY_CTX_set_scrypt_maxmem_bytes()β sets the max amount of RAM (in bytes, fr fr) that key derivation is allowed to use. and listen β if the RAM budget gets blown because the load factors are chosen too high, the key derivation straight up fails π no warning, just fail. so like, maybe don't be greedy with those load factors π
π STRING CTRLS π
plot twist: scrypt also supports string based control operations, via EVP_PKEY_CTX_ctrl_str(3). iconic versatility honestly β¨
so for the salt, you've got two options:
- pass it with the type parameter
"salt"β the normal way π - or hex-encode it and use the
"hexsalt"parameter πΈ
and the work factors N, r and p, plus maxmem_bytes? those get set through the parameters "N", "r", "p" and "maxmem_bytes" respectively. yeah, the names are that obvious, love that for us π
β NOTES β
- there's a newer generic API for KDFs β
EVP_KDF(3)β and it's preferred over the whole EVP_PKEY method. so like, the EVP_PKEY way still works, but the new one is the main character now π - heads up: the scrypt KDF also pulls in
EVP_PKEY_CTX_set1_pbe_pass()and the value from the string controls"pass"and"hexpass". go checkEVP_PKEY_CTX_set1_pbe_pass(3)for the details, bestie π«Ά
π RETURN VALUES π
all of these return 1 for success, and 0 or a negative value when things go wrong. but here's the specific one you need to know:
a return value of -2 means the operation is not supported by the public key algorithm. that's the specific error, not a general fail π
π SEE ALSO π
go read those too, they're the supportive besties of this page π¦
πΈ HISTORY πΈ
fun fact: all the functions described here were converted from macros to functions in OpenSSL 3.0. glow-up era β¨
π 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, mwah π this was OpenSSL 3.5.0, dated 2026-09-25 β go forth and scrypt responsibly, bestie π§π
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 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