---
name: "libressl-RSA_set_method"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-RSA_set_method"
---

# libressl-RSA\_set\_method(3)

select RSA method

## NAME

**RSA\_set\_default\_method**, **RSA\_get\_default\_method**, **RSA\_set\_method**, **RSA\_get\_method**, **RSA\_PKCS1\_SSLeay**, **RSA\_flags**, **RSA\_new\_method** – select RSA method

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#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 contains pointers to the functions used for RSA operations. By default, the internal implementation returned by **RSA\_PKCS1\_SSLeay**() is used. By selecting another method, alternative implementations such as hardware accelerators may be used.

**RSA\_set\_default\_method**() selects *meth* as the default method for all *RSA* structures created later.

**RSA\_get\_default\_method**() returns a pointer to the current default method.

**RSA\_set\_method**() selects *meth* to perform all operations using the key *rsa*. This replaces the previous *RSA\_METHOD* used by the RSA key, calling the *finish* function set up with RSA\_meth\_set\_finish(3) if any. If *meth* contains an *init* function set up with RSA\_meth\_set\_init(3), that function is called just before returning from **RSA\_set\_method**().

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.

**RSA\_get\_method**() returns a pointer to the *RSA\_METHOD* being used by *rsa*.

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.

**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**(), and **RSA\_get\_method**() return pointers to the respective *RSA\_METHOD*.

**RSA\_set\_method**() returns 1 on success or 0 on failure. Currently, it cannot fail.

**RSA\_new\_method**() returns NULL and sets an error code that can be obtained by ERR\_get\_error(3) if the allocation fails. Otherwise it returns a pointer to the newly allocated structure.

## SEE ALSO

RSA\_meth\_new(3), RSA\_new(3)

## HISTORY

**RSA\_set\_default\_method**(), **RSA\_PKCS1\_SSLeay**(), and **RSA\_new\_method**() first appeared in SSLeay 0.8.0. **RSA\_flags**() first appeared in SSLeay 0.9.0. These functions have been available since OpenBSD 2.4.

**RSA\_get\_default\_method**(), **RSA\_set\_method**(), and **RSA\_get\_method**() as well as the *rsa\_sign* and *rsa\_verify* components of *RSA\_METHOD* first appeared in OpenSSL 0.9.4 and have been available since OpenBSD 2.6.

## BUGS

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