RSA_SET_METHOD(3)
π RSA_SET_METHOD(3) β ok so this is the RSA method selection page, bestie
hey so this is from the libcrypto library (that's the manual name, iykyk) and it's all about picking which RSA implementation your keys use π
β¨ NAME β¨
RSA_set_default_method, RSA_get_default_method, RSA_set_method, RSA_get_method, RSA_PKCS1_SSLeay, RSA_flags, RSA_new_method β literally all of these are about selecting the RSA method. that's the whole vibe. π
πΈ SYNOPSIS πΈ
so you're pulling from libcrypto, and you include this:
#include <openssl/rsa.h>
then the functions go like this, no cap:
void
RSA_set_default_method(const RSA_METHOD *meth);
const RSA_METHOD *
RSA_get_default_method(void);
int
RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
const RSA_METHOD *
RSA_get_method(const RSA *rsa);
const RSA_METHOD *
RSA_PKCS1_SSLeay(void);
int
RSA_flags(const RSA *rsa);
RSA *
RSA_new_method(ENGINE *engine);
π¦ DESCRIPTION π¦
ok so picture this: an RSA_METHOD object is basically a little bundle of function pointers β it holds pointers to all the functions used for RSA operations. by default you get the internal implementation that RSA_PKCS1_SSLeay() hands you. but bestie, the whole point is that you can pick another method and get alternative implementations, like hardware accelerators. slay. π₯
RSA_set_default_method()β picksmethas the default method for every single RSA structure created after this call. future keys only, periodt.RSA_get_default_method()β returns a pointer to whatever the current default method is. that's it, that's the function.RSA_set_method()β picksmethto perform all operations using the keyrsa. this replaces the previousRSA_METHODthat the RSA key was using, and it calls the finish function (the one you set up withRSA_meth_set_finish(3), if any). and ifmethhas an init function set up withRSA_meth_set_init(3), that function gets called right beforeRSA_set_method()returns. β¨RSA_get_method()β returns a pointer to theRSA_METHODthatrsais currently using.
β οΈ okay so this is important: it's totally possible to have RSA keys that only work with certainRSA_METHODimplementations. so if you try to switch theRSA_METHODon one of those keys, the results can be unexpected. not me warning you twice π
RSA_flags()β and here's the tea: this function is misleadingly named π what it actually returns is the flags set for the currentRSA_METHODofrsaβ not the flags ofrsaitself. if you wanna test the flags used byrsaitself, useRSA_test_flags(3)instead. more on this mess in the βBUGSβ section below, iykyk.RSA_new_method()β allocates and initializes anRSAstructure. plot twist: theengineargument is ignored, and it just uses the default method controlled byRSA_set_default_method(). π«
and one more thing β the initial flags get copied from the RSA_METHOD object that's being used, and they will not be affected by later changes to that object. they can however be modified by the optional init function, which may have been set up with RSA_meth_set_init(3) and which is called just before RSA_new_method() returns. π«Ά
π RETURN VALUES π
RSA_PKCS1_SSLeay(),RSA_get_default_method(), andRSA_get_method()β return pointers to the respectiveRSA_METHOD. simple.RSA_set_method()β returns1on success or0on failure. though fr fr, currently it cannot fail. πRSA_new_method()β returnsNULLand sets an error code (grab it withERR_get_error(3)) if the allocation fails. otherwise it returns a pointer to the newly allocated structure. π
π SEE ALSO π
go read those next bestie, they're the supporting cast π
β HISTORY β
ok so the lore:
RSA_set_default_method(),RSA_PKCS1_SSLeay(), andRSA_new_method()first appeared in SSLeay 0.8.0.RSA_flags()first appeared in SSLeay 0.9.0.- all of these have been available since OpenBSD 2.4. iconic longevity honestly π
then later:
RSA_get_default_method(),RSA_set_method(), andRSA_get_method(), plus thersa_signandrsa_verifycomponents ofRSA_METHOD, first appeared in OpenSSL 0.9.4 and have been available since OpenBSD 2.6.
π BUGS π
so the behaviour of RSA_flags() is a misfeature β it's been left exactly as-is for now, purely to avoid creating compatibility problems. π
here's the situation: RSA functionality (stuff like the encryption functions) is controlled by the flags value in the RSA key itself, not by the flags value in the RSA_METHOD attached to the RSA key β and that method flags value is what this function returns. so if the flags element of an RSA key gets changed, RSA functionality will honour those changes, but the return value of RSA_flags() will not reflect them. π
in effect, RSA_flags() behaves more like a hypothetical RSA_default_flags() function β which, as of right now, does not exist. and that's the whole mess, no notes. π
and that's the page, bestie πβ¨ this one came from the Debian build, dated June 8, 2025 β go off and pick your RSA methods wisely, mwah ππ¦
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2000, 2002, 2007, 2014 The OpenSSL Project
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms