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_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

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 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() same energy, but again, by name rather than by EVP_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 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