RSA_SET_METHOD(3)
π RSA_SET_METHOD(3) β select RSA method π
okay bestie, this is the RSA_SET_METHOD(3) page from the Library Functions Manual, and it's literally all about picking which RSA method does the work. No cap, it's a whole little ecosystem of function pointers and flags, so let's get into it π
π NAME π
Meet the whole squad: RSA_set_default_method, RSA_get_default_method, RSA_set_method, RSA_get_method, RSA_PKCS1_SSLeay, RSA_flags, and RSA_new_method β their collective job is select RSA method β¨.
πΈ SYNOPSIS πΈ
#include <openssl/rsa.h>
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 π¦
An RSA_METHOD object is basically a little bag of function pointers β it contains pointers to the functions used for RSA operations. By default, the internal implementation returned by RSA_PKCS1_SSLeay() is the one in charge. But if you pick another method, alternative implementations such as hardware accelerators may be used π.
RSA_set_default_method()β selects meth as the default method for allRSAstructures created later. Future keys, this is your new normal π«RSA_get_default_method()β returns a pointer to the current default method. Peek at the main character πRSA_set_method()β selects meth to perform all operations using the key rsa. This replaces the previousRSA_METHODused by theRSAkey, calling the finish function set up withRSA_meth_set_finish(3)if any. And if meth contains an init function set up withRSA_meth_set_init(3), that function is called just before returning fromRSA_set_method()π οΈRSA_get_method()β returns a pointer to theRSA_METHODbeing used by rsa. Slay, now you know who's actually doing the work π
Okay important: it is possible to have RSA keys that only work with certain RSA_METHOD implementations, and in such cases attempting to change the RSA_METHOD for the key can have unexpected results π.
The misleadingly named function RSA_flags() returns the flags that are set for the current RSA_METHOD of rsa. The flags used by rsa itself can instead be tested with RSA_test_flags(3). See the BUGS section for more details β it's a whole thing π.
RSA_new_method() allocates and initializes an RSA structure. The engine argument is ignored and the default method controlled by RSA_set_default_method() is used. The initial flags are copied from the RSA_METHOD object used and will not be affected by later changes to that object, but may 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 returning from RSA_new_method() π.
π RETURN VALUES π
RSA_PKCS1_SSLeay(),RSA_get_default_method(), andRSA_get_method()return pointers to the respectiveRSA_METHOD.RSA_set_method()returns1on success or0on failure. Currently, it cannot fail. Iconic, no notes πRSA_new_method()returnsNULLand sets an error code that can be obtained byERR_get_error(3)if the allocation fails. Otherwise it returns a pointer to the newly allocated structure.
π«Ά SEE ALSO π«Ά
β HISTORY β
RSA_set_default_method(),RSA_PKCS1_SSLeay(), andRSA_new_method()first appeared inSSLeay 0.8.0.RSA_flags()first appeared inSSLeay 0.9.0.- These functions have been available since
OpenBSD 2.4. RSA_get_default_method(),RSA_set_method(), andRSA_get_method()as well as thersa_signandrsa_verifycomponents ofRSA_METHODfirst appeared inOpenSSL 0.9.4and have been available sinceOpenBSD 2.6.
π BUGS π
π¨ real talk, bestie: the behaviour of RSA_flags() is a misfeature that is left as-is for now to avoid creating compatibility problems.
RSA functionality, such as the encryption functions, are controlled by the flags value in the RSA key itself β not by the flags value in the RSA_METHOD attached to the RSA key, which is what this function returns. So if the flags element of an RSA key is changed, the changes will be honoured by RSA functionality but will not be reflected in the return value of the RSA_flags() function. In effect, RSA_flags() behaves more like an RSA_default_flags() function, which does not currently exist π΅βπ«.
kisses and clean builds, bestie β this page is from Debian, dated November 19, 2023, and it's literally the RSA_SET_METHOD(3) page ππ«Άπ
π¦ where this page comes from
- opensuse-leap 16.0: libressl-devel-doc 4.1.0-bp160.1.1 Β· 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