EVP_PKEY_CTX...SS_KEYGEN_MD(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… EVP_PKEY_CTX...SS_KEYGEN_MD β€” like, the RSA-PSS support functions (manual 3ossl, bestie) πŸŽ€

okay so this page is filed under the 3ossl manual and honestly it's a whole little family of functions that make RSA-PSS ✨work✨. Let's get into it.


🌸 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

…and collectively they are the EVP_PKEY RSA-PSS algorithm support functions. that's the whole squad 🫢


πŸ¦‹ 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);

copy these exactly bestie, every pointer and const is doing its job πŸ’…


πŸ’– DESCRIPTION πŸ’–

These are the functions that implement RSA-PSS(7). like, that's their whole personality.

πŸ”₯ Signing and Verification πŸ”₯

The macro EVP_PKEY_CTX_set_rsa_padding() is supported β€” but it will throw an error if you try to set the padding mode to literally anything other than PSS. no cap. otherwise it behaves like the RSA version.

The EVP_PKEY_CTX_set_rsa_pss_saltlen() macro is the one that sets the salt length. and here's the tea: if the key has usage restrictions, you get an error if you try to set the salt length below the minimum value. otherwise it's just like the RSA operation, except β€” and this is the important bit β€” detection of the salt length (using RSA_PSS_SALTLEN_AUTO) is not supported for verification if the key has usage restrictions. 🫠

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, you get an error if you try to set the digest to anything other than the restricted value. otherwise, yeah, similar to the RSA versions. 🌈

πŸ‘‘ Key Generation πŸ‘‘

Same energy as 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, and they have exactly the same meaning as they do for the RSA algorithm. not a single plot twist there. ⭐

Optional parameter restrictions can be specified when you're generating a PSS key. and here's the thing that lowkey matters most: if any restrictions are set (using the macros described below), then all parameters are restricted. like, that's the whole vibe check. for example, setting a minimum salt length also restricts the digest and MGF1 algorithms. 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 exact 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() β€” 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. yes, minimum. it's giving boundaries 🚧

✨ NOTES ✨

You get yourself a context for the RSA-PSS algorithm by calling this icon right here:

EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA_PSS, NULL);

that's it, that's the ritual πŸ•―οΈ


πŸ“ 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, don't come for the function, it's the algorithm that said no πŸ™ˆ


🌟 SEE ALSO 🌟

go read those, they're all part of the lore πŸ¦‹


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 little gem is from OpenSSL 3.5.6, dated 2026-04-07 β€” screenshot it, cite it, stan it πŸ’–πŸŽ€

πŸ“¦ where this page comes from