EVP_PKEY_CTX...SS_KEYGEN_MD(3ossl)

πŸ’– EVP_PKEY_CTX...SS_KEYGEN_MD(3ossl) πŸ’–

okay bestie, welcome to the OpenSSL manual page for EVP_PKEY_CTX...SS_KEYGEN_MD β€” it's filed under the 3ossl manual section, and it's literally the ✨home✨ of the EVP_PKEY RSA-PSS algorithm support functions. no cap.


🌸 NAME 🌸

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 β€” these are the EVP_PKEY RSA-PSS algorithm support functions. that's the whole vibe. 🫢


✨ 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 signatures just standing there. iconic. πŸ‘‘


πŸ’… DESCRIPTION πŸ’…

these are the functions that implement RSA-PSS(7). slay.

πŸ” Signing and Verification

the macro EVP_PKEY_CTX_set_rsa_padding() is supported, BUT it throws an error if you try to set the padding mode to literally anything other than PSS. otherwise? it's basically the same as the RSA version. no drama.

the EVP_PKEY_CTX_set_rsa_pss_saltlen() macro sets the salt length. and here's the tea: if the key has usage restrictions, setting the salt length below the minimum value returns an error. 😀 otherwise it's like the RSA operation β€” EXCEPT that detecting the salt length (via RSA_PSS_SALTLEN_AUTO) is not supported for verification if the key has usage restrictions. so don't come for that, it's not happening.

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, trying to set the digest to anything other than the restricted value returns an error β€” periodt. otherwise, same as the RSA versions. πŸ’–

πŸ”‘ Key Generation

just like 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. fr fr, identical.

you can also set optional parameter restrictions when generating a PSS key. and here's the key detail bestie: if you set any restrictions (using the macros described below), then ALL parameters are restricted. like, setting a minimum salt length also restricts the digest and MGF1 algorithms. the way that one thing pulls in everything else... πŸ’€ and if any restrictions are in place, they get reflected in the corresponding parameters of the public key when (for example) a certificate request is 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 same thing, but passes the algorithm by name rather than by EVP_MD. iykyk.
  • 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 πŸ“

you can get yourself a context for the RSA-PSS algorithm by calling:

EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA_PSS, NULL);

there you go, that's the one. go off. πŸŽ€


🫢 RETURN VALUES 🫢

all 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, that's what's up.


πŸ”₯ SEE ALSO πŸ”₯

RSA-PSS(7), EVP_PKEY_CTX_new(3), EVP_PKEY_CTX_ctrl_str(3), EVP_PKEY_derive(3)

go read those too, bestie, they're all connected. πŸ¦‹


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


and that's the whole page, bestie!! πŸ’–βœ¨ this was version 3.5.9, dated 2026-09-29, from the OpenSSL crew β€” mwah, no notes, they ate. πŸŒΈπŸŽ€πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from