EVP_PKEY_CTX...SS_KEYGEN_MD(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’… 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_md
  • EVP_PKEY_CTX_set_rsa_pss_keygen_md_name
  • EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md
  • EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md_name
  • EVP_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 to md. πŸ“
  • EVP_PKEY_CTX_set_rsa_pss_keygen_md_name() β€” does the same thing, but passes the algorithm by name rather than by EVP_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() β€” does the same thing, but passes the algorithm by name rather than by EVP_MD.
  • EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen() β€” restricts the minimum salt length to saltlen.

πŸ“ 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 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