EVP_PKEY_CTX...SS_KEYGEN_MD(3ossl)
π EVP_PKEY_CTX_set_rsa_pss_keygen_md, ... β the RSA-PSS glow-up functions (from the OpenSSL family π)
okay so bestie, welcome to the OpenSSL manual for these RSA-PSS algorithm support functions. That's the OpenSSL manual set, if you were wondering where we are. Sit down, hydrate, and let's talk about keygen restrictions β¨
π NAME
Here's the whole squad, besties:
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
β and together they're the EVP_PKEY RSA-PSS algorithm support functions. periodt π
β¨ 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);
(and yes, EVP_PKEY_CTX_set_rsa_pss_keygen_md_name really does name its ctx ctx while all its friends use pctx β she's just living her truth, we don't judge π«Ά)
π¦ DESCRIPTION π¦
These are literally the functions that implement RSA-PSS(7). that's the whole vibe π
π Signing and Verification
The macro EVP_PKEY_CTX_set_rsa_padding() is supported β but bestie, if you try to set the padding mode to literally anything other than PSS, you get an error. no exceptions. Aside from that it's similar to the RSA version.
The EVP_PKEY_CTX_set_rsa_pss_saltlen() macro is the one that sets the salt length. If the key has usage restrictions and you try to set the salt length below the minimum value, boom π error. Otherwise it's similar to the RSA operation β except that detection of the salt length (using RSA_PSS_SALTLEN_AUTO) is not supported for verification when the key has usage restrictions. so don't even try it, iykyk π
The EVP_PKEY_CTX_set_signature_md(3) and EVP_PKEY_CTX_set_rsa_mgf1_md(3) functions 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, no cap. Otherwise these are similar to the RSA versions πΈ
π Key Generation
Just like with RSA key generation, the EVP_PKEY_CTX_set_rsa_keygen_bits() and EVP_PKEY_CTX_set_rsa_keygen_pubexp() macros are supported for RSA-PSS β they mean exactly the same thing as they do for the RSA algorithm. iconic behavior, honestly π
You can optionally set parameter restrictions when generating a PSS key. Here's the tea β: if any restrictions are set (using the macros described below), then all parameters are restricted. Like, setting a minimum salt length also restricts the digest and MGF1 algorithms. no half-measures. And if any restrictions are in place, they're reflected in the corresponding parameters of the public key when (for example) a certificate request is signed. so it's visible, it's public, it's giving commitment π
EVP_PKEY_CTX_set_rsa_pss_keygen_md()β restricts the digest algorithm the generated key can use tomd. πEVP_PKEY_CTX_set_rsa_pss_keygen_md_name()β does the same thing, but passes the algorithm by name rather than byEVP_MD.EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md()β restricts the MGF1 algorithm the generated key can use tomd.EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md_name()β does the same thing, but passes the algorithm by name rather than byEVP_MD.EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen()β restricts the minimum salt length tosaltlen.
π NOTES
Wanna get a context for the RSA-PSS algorithm? just call:
EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA_PSS, NULL);
that's it, that's the whole trick, you're welcome bestie π§π
π«Ά RETURN VALUES π«Ά
All these functions return 1 for success, and 0 or a negative value for failure. And here's the important one: a return value of -2 means the operation is not supported by the public key algorithm. noted. memorized. tattooed on the inside of my brain πβ¨
π SEE ALSO π
RSA-PSS(7), EVP_PKEY_CTX_new(3), EVP_PKEY_CTX_ctrl_str(3), EVP_PKEY_derive(3)
π 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>.
okay that's the whole page, bestie β love u, go set some restrictions responsibly π¦π
signing off from version 3.5.0, dated 2026-09-25, still slaying in the OpenSSL 3.x era β¨π
π¦ 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