EVP_PKEY_CTX_...PSS_KEYGEN_MD(3SSL)
π NAME π
okay bestie, listen up β these are the functions that make the whole RSA-PSS(7) thing go:
EVP_PKEY_CTX_set_rsa_pss_keygen_mdEVP_PKEY_CTX_set_rsa_pss_keygen_md_nameEVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_mdEVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md_nameEVP_PKEY_CTX_set_rsa_pss_keygen_saltlen
they're the EVP_PKEY RSA-PSS algorithm support functions, and yes they live in the 3SSL manual, section 3, OpenSSL girlies only π
β¨ SYNOPSIS β¨
#include <openssl/rsa.h>
int EVP_PKEY_CTX_set_rsa_pss_keygen_md(EVP_PKEY_CTX *pctx,
const EVP_MD *md);
int EVP_PKEY_CTX_set_rsa_pss_keygen_md_name(EVP_PKEY_CTX *ctx,
const char *mdname,
const char *mdprops);
int EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(EVP_PKEY_CTX *pctx,
const EVP_MD *md);
int EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md_name(EVP_PKEY_CTX *pctx,
const char *mdname);
int EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(EVP_PKEY_CTX *pctx,
int saltlen);
look at all those <italic>pctx</italic>es bestie, we are SO back π«Ά
πΈ DESCRIPTION πΈ
These are literally the functions that implement RSA-PSS(7). no cap.
π Signing and Verification π
The macro EVP_PKEY_CTX_set_rsa_padding() is supported β but it's giving strict: if you even try to set the padding mode to anything other than PSS, it returns an error. periodt. other than that it's just like the RSA version, no notes.
The EVP_PKEY_CTX_set_rsa_pss_saltlen() macro sets the salt length. β¨ heads up though β¨ β if the key has usage restrictions and you try to set the salt length below the minimum value, you get an error, sorry babe π. otherwise it's the same as the RSA operation, except that detecting the salt length (using RSA_PSS_SALTLEN_AUTO) is not supported for verification when the key has usage restrictions. so don't try it π
EVP_PKEY_CTX_set_signature_md(3) and EVP_PKEY_CTX_set_rsa_mgf1_md(3) set the digest and MGF1 algorithms respectively. if the key has usage restrictions and you try to set the digest to anything other than the restricted value β error, bestie. otherwise? same as the RSA versions, iconic behavior.
π¦ Key Generation π¦
Just like RSA key generation, EVP_PKEY_CTX_set_rsa_keygen_bits() and EVP_PKEY_CTX_set_rsa_keygen_pubexp() are supported for RSA-PSS β they mean exactly the same thing as they do for the RSA algorithm. fr fr. no extra lore.
You can also set optional parameter restrictions when generating a PSS key π. here's the tea though: if any restrictions are set at all (using the macros described below) then all parameters get restricted. like, setting a minimum salt length also restricts the digest and MGF1 algorithms. and if any restrictions are in place, they show up reflected in the corresponding parameters of the public key when (for example) a certificate request gets signed.
EVP_PKEY_CTX_set_rsa_pss_keygen_md()restricts the digest algorithm the generated key can use to md.EVP_PKEY_CTX_set_rsa_pss_keygen_md_name()does the exact same thing, but passes the algorithm by name instead of byEVP_MD.EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md()restricts the MGF1 algorithm the generated key can use to md.EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md_name()same energy, but again, by name rather than byEVP_MD.EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen()restricts the minimum salt length to saltlen.
π NOTES π
you can get yourself a context for the RSA-PSS algorithm by calling this bad boy:
EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA_PSS, NULL);
go off, main character β¨
π« RETURN VALUES π«
all of these functions return 1 for success, and 0 or a negative value for failure. and specifically, a return value of -2 means the operation is not supported by the public key algorithm. so if you see a -2, it's not you, it's the algorithm π
π₯ SEE ALSO π₯
go read those too, i know you will π«Ά
π COPYRIGHT π
Copyright 2017-2021 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>.
legal bestie said i have to say it: this is OpenSSL 4.0.3, dated 2026-09-2 (the date and the title got mashed together in that footer line, ngl, but that's what it says π). anyway slay, go sign some stuff with PSS. mwah πβ¨ππ¦πΈπ and that's the whole page, 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