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

# rs256\_pk\_new(3)

FIDO2 COSE RS256 API

## NAME

**rs256\_pk\_new**, **rs256\_pk\_free**, **rs256\_pk\_from\_RSA**, **rs256\_pk\_from\_EVP\_PKEY**, **rs256\_pk\_from\_ptr**, **rs256\_pk\_to\_EVP\_PKEY** – FIDO2 COSE RS256 API

## SYNOPSIS

**#include \<openssl/rsa.h\>**

**#include \<fido/rs256.h\>**

*rs256\_pk\_t* *\**\

**rs256\_pk\_new**(*void*);

*void*\

**rs256\_pk\_free**(*rs256\_pk\_t \*\*pkp*);

*int*\

**rs256\_pk\_from\_EVP\_PKEY**(*rs256\_pk\_t \*pk*, *const EVP\_PKEY \*pkey*);

*int*\

**rs256\_pk\_from\_RSA**(*rs256\_pk\_t \*pk*, *const RSA \*rsa*);

*int*\

**rs256\_pk\_from\_ptr**(*rs256\_pk\_t \*pk*, *const void \*ptr*, *size\_t len*);

*EVP\_PKEY* *\**\

**rs256\_pk\_to\_EVP\_PKEY**(*const rs256\_pk\_t \*pk*);

## DESCRIPTION

RS256 is the name given in the CBOR Object Signing and Encryption (COSE) RFC to PKCS#1.5 2048-bit RSA with SHA-256. The COSE RS256 API of *libfido2* is an auxiliary API with routines to convert between the different RSA public key types used in *libfido2* and *OpenSSL*.

In *libfido2*, RS256 public keys are abstracted by the *rs256\_pk\_t* type.

The **rs256\_pk\_new**() function returns a pointer to a newly allocated, empty *rs256\_pk\_t* type. If memory cannot be allocated, NULL is returned.

The **rs256\_pk\_free**() function releases the memory backing *\*pkp*, where *\*pkp* must have been previously allocated by **rs256\_pk\_new**(). On return, *\*pkp* is set to NULL. Either *pkp* or *\*pkp* may be NULL, in which case **rs256\_pk\_free**() is a NOP.

The **rs256\_pk\_from\_EVP\_PKEY**() function fills *pk* with the contents of *pkey*. No references to *pkey* are kept.

The **rs256\_pk\_from\_RSA**() function fills *pk* with the contents of *rsa*. No references to *rsa* are kept.

The **rs256\_pk\_from\_ptr**() function fills *pk* with the contents of *ptr*, where *ptr* points to *len* bytes. No references to *ptr* are kept.

The **rs256\_pk\_to\_EVP\_PKEY**() function converts *pk* to a newly allocated *EVP\_PKEY* type with a reference count of 1. No internal references to the returned pointer are kept. If an error occurs, **rs256\_pk\_to\_EVP\_PKEY**() returns NULL.

## RETURN VALUES

The **rs256\_pk\_from\_EVP\_PKEY**(), **rs256\_pk\_from\_RSA**(), and **rs256\_pk\_from\_ptr**() functions return FIDO\_OK on success. On error, a different error code defined in ⟨fido/err.h⟩ is returned.

## SEE ALSO

[eddsa\_pk\_new(3)](/eddsa_pk_new/3.md), [es256\_pk\_new(3)](/es256_pk_new/3.md), [es384\_pk\_new(3)](/es384_pk_new/3.md), [fido\_assert\_verify(3)](/fido_assert_verify/3.md), [fido\_cred\_pubkey\_ptr(3)](/fido_cred_pubkey_ptr/3.md)
