RSA_METH_NEW(3)

NAME
RSA_meth_new, RSA_meth_dup, RSA_meth_free, RSA_meth_get_finish, RSA_meth_set1_name, RSA_meth_set_finish, RSA_meth_set_priv_enc, RSA_meth_set_priv_dec - build up RSA methods

SYNOPSIS
#include <openssl/rsa.h>
RSA_METHOD *
RSA_meth_new(const char *name, int flags);
RSA_METHOD *
RSA_meth_dup(const RSA_METHOD *meth);
void
RSA_meth_free(RSA_METHOD *meth);
int
RSA_meth_set1_name(RSA_METHOD *meth, const char *name);
int
(*RSA_meth_get_finish(const RSA_METHOD *meth))(RSA *rsa);
int
RSA_meth_set_finish(RSA_METHOD *meth, int (*finish)(RSA *rsa));
int
RSA_meth_set_priv_enc(RSA_METHOD *meth, int (*priv_enc)(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding));
int
RSA_meth_set_priv_dec(RSA_METHOD *meth, int (*priv_dec)(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding));

DESCRIPTION
The RSA_METHOD structure holds function pointers for custom RSA implementations.

RSA_meth_new() creates a new RSA_METHOD structure. A copy of the NUL-terminated name is stored in the new RSA_METHOD object. Any new RSA object constructed from this RSA_METHOD will have the given flags set by default.

RSA_meth_dup() creates a deep copy of meth. This might be useful for creating a new RSA_METHOD based on an existing one, but with some differences.

RSA_meth_free() destroys meth and frees any memory associated with it.

RSA_meth_set1_name() Stores a copy of the NUL-terminated name in the RSA_METHOD object after freeing the previously stored name.

RSA_meth_get_finish() and RSA_meth_set_finish() get and set an optional function for destroying an RSA object. Unless finish is NULL, it will be called from RSA_free(3). It takes the same argument and is intended to do RSA implementation specific cleanup. The memory used by the RSA object itself should not be freed by the finish function.

RSA_meth_set_priv_enc() and RSA_meth_set_priv_dec() set the functions used for private key encryption and decryption. These functions will be called from RSA_private_decrypt(3) and RSA_private_encrypt(3) and take the same parameters as those.

RETURN VALUES
RSA_meth_new() and RSA_meth_dup() return the newly allocated RSA_METHOD object or NULL on failure.

All RSA_meth_set*() functions return 1 on success or 0 on failure.

SEE ALSO
RSA_new(3), RSA_private_decrypt(3), RSA_private_encrypt(3), RSA_set_method(3)

HISTORY
These functions first appeared in OpenSSL 1.1.0. RSA_meth_get_finish() and RSA_meth_set1_name() have been available since OpenBSD 6.4, all the other functions since OpenBSD 6.3.