1*2ccfa855SEd Maste.\" Copyright (c) 2018-2022 Yubico AB. All rights reserved. 20afa8e06SEd Maste.\" 3*2ccfa855SEd Maste.\" Redistribution and use in source and binary forms, with or without 4*2ccfa855SEd Maste.\" modification, are permitted provided that the following conditions are 5*2ccfa855SEd Maste.\" met: 6*2ccfa855SEd Maste.\" 7*2ccfa855SEd Maste.\" 1. Redistributions of source code must retain the above copyright 8*2ccfa855SEd Maste.\" notice, this list of conditions and the following disclaimer. 9*2ccfa855SEd Maste.\" 2. Redistributions in binary form must reproduce the above copyright 10*2ccfa855SEd Maste.\" notice, this list of conditions and the following disclaimer in 11*2ccfa855SEd Maste.\" the documentation and/or other materials provided with the 12*2ccfa855SEd Maste.\" distribution. 13*2ccfa855SEd Maste.\" 14*2ccfa855SEd Maste.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15*2ccfa855SEd Maste.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16*2ccfa855SEd Maste.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17*2ccfa855SEd Maste.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18*2ccfa855SEd Maste.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19*2ccfa855SEd Maste.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20*2ccfa855SEd Maste.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21*2ccfa855SEd Maste.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22*2ccfa855SEd Maste.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23*2ccfa855SEd Maste.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24*2ccfa855SEd Maste.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25*2ccfa855SEd Maste.\" 26*2ccfa855SEd Maste.\" SPDX-License-Identifier: BSD-2-Clause 27*2ccfa855SEd Maste.\" 28*2ccfa855SEd Maste.Dd $Mdocdate: July 15 2022 $ 290afa8e06SEd Maste.Dt RS256_PK_NEW 3 300afa8e06SEd Maste.Os 310afa8e06SEd Maste.Sh NAME 320afa8e06SEd Maste.Nm rs256_pk_new , 330afa8e06SEd Maste.Nm rs256_pk_free , 340afa8e06SEd Maste.Nm rs256_pk_from_RSA , 353e696dfbSEd Maste.Nm rs256_pk_from_EVP_PKEY , 360afa8e06SEd Maste.Nm rs256_pk_from_ptr , 370afa8e06SEd Maste.Nm rs256_pk_to_EVP_PKEY 380afa8e06SEd Maste.Nd FIDO2 COSE RS256 API 390afa8e06SEd Maste.Sh SYNOPSIS 400afa8e06SEd Maste.In openssl/rsa.h 410afa8e06SEd Maste.In fido/rs256.h 420afa8e06SEd Maste.Ft rs256_pk_t * 430afa8e06SEd Maste.Fn rs256_pk_new "void" 440afa8e06SEd Maste.Ft void 450afa8e06SEd Maste.Fn rs256_pk_free "rs256_pk_t **pkp" 460afa8e06SEd Maste.Ft int 47f540a430SEd Maste.Fn rs256_pk_from_EVP_PKEY "rs256_pk_t *pk" "const EVP_PKEY *pkey" 48f540a430SEd Maste.Ft int 490afa8e06SEd Maste.Fn rs256_pk_from_RSA "rs256_pk_t *pk" "const RSA *rsa" 500afa8e06SEd Maste.Ft int 510afa8e06SEd Maste.Fn rs256_pk_from_ptr "rs256_pk_t *pk" "const void *ptr" "size_t len" 520afa8e06SEd Maste.Ft EVP_PKEY * 530afa8e06SEd Maste.Fn rs256_pk_to_EVP_PKEY "const rs256_pk_t *pk" 540afa8e06SEd Maste.Sh DESCRIPTION 550afa8e06SEd MasteRS256 is the name given in the CBOR Object Signing and Encryption 560afa8e06SEd Maste(COSE) RFC to PKCS#1.5 2048-bit RSA with SHA-256. 570afa8e06SEd MasteThe COSE RS256 API of 580afa8e06SEd Maste.Em libfido2 590afa8e06SEd Masteis an auxiliary API with routines to convert between the different 600afa8e06SEd MasteRSA public key types used in 610afa8e06SEd Maste.Em libfido2 620afa8e06SEd Masteand 630afa8e06SEd Maste.Em OpenSSL . 640afa8e06SEd Maste.Pp 650afa8e06SEd MasteIn 660afa8e06SEd Maste.Em libfido2 , 670afa8e06SEd MasteRS256 public keys are abstracted by the 680afa8e06SEd Maste.Vt rs256_pk_t 690afa8e06SEd Mastetype. 700afa8e06SEd Maste.Pp 710afa8e06SEd MasteThe 720afa8e06SEd Maste.Fn rs256_pk_new 730afa8e06SEd Mastefunction returns a pointer to a newly allocated, empty 740afa8e06SEd Maste.Vt rs256_pk_t 750afa8e06SEd Mastetype. 760afa8e06SEd MasteIf memory cannot be allocated, NULL is returned. 770afa8e06SEd Maste.Pp 780afa8e06SEd MasteThe 790afa8e06SEd Maste.Fn rs256_pk_free 800afa8e06SEd Mastefunction releases the memory backing 810afa8e06SEd Maste.Fa *pkp , 820afa8e06SEd Mastewhere 830afa8e06SEd Maste.Fa *pkp 840afa8e06SEd Mastemust have been previously allocated by 850afa8e06SEd Maste.Fn rs256_pk_new . 860afa8e06SEd MasteOn return, 870afa8e06SEd Maste.Fa *pkp 880afa8e06SEd Masteis set to NULL. 890afa8e06SEd MasteEither 900afa8e06SEd Maste.Fa pkp 910afa8e06SEd Masteor 920afa8e06SEd Maste.Fa *pkp 930afa8e06SEd Mastemay be NULL, in which case 940afa8e06SEd Maste.Fn rs256_pk_free 950afa8e06SEd Masteis a NOP. 960afa8e06SEd Maste.Pp 970afa8e06SEd MasteThe 98f540a430SEd Maste.Fn rs256_pk_from_EVP_PKEY 99f540a430SEd Mastefunction fills 100f540a430SEd Maste.Fa pk 101f540a430SEd Mastewith the contents of 102f540a430SEd Maste.Fa pkey . 103f540a430SEd MasteNo references to 104f540a430SEd Maste.Fa pkey 105f540a430SEd Masteare kept. 106f540a430SEd Maste.Pp 107f540a430SEd MasteThe 1080afa8e06SEd Maste.Fn rs256_pk_from_RSA 1090afa8e06SEd Mastefunction fills 1100afa8e06SEd Maste.Fa pk 1110afa8e06SEd Mastewith the contents of 1120afa8e06SEd Maste.Fa rsa . 1130afa8e06SEd MasteNo references to 1140afa8e06SEd Maste.Fa rsa 1150afa8e06SEd Masteare kept. 1160afa8e06SEd Maste.Pp 1170afa8e06SEd MasteThe 1180afa8e06SEd Maste.Fn rs256_pk_from_ptr 1190afa8e06SEd Mastefunction fills 1200afa8e06SEd Maste.Fa pk 1210afa8e06SEd Mastewith the contents of 1220afa8e06SEd Maste.Fa ptr , 1230afa8e06SEd Mastewhere 1240afa8e06SEd Maste.Fa ptr 1250afa8e06SEd Mastepoints to 1260afa8e06SEd Maste.Fa len 1270afa8e06SEd Mastebytes. 1280afa8e06SEd MasteNo references to 1290afa8e06SEd Maste.Fa ptr 1300afa8e06SEd Masteare kept. 1310afa8e06SEd Maste.Pp 1320afa8e06SEd MasteThe 1330afa8e06SEd Maste.Fn rs256_pk_to_EVP_PKEY 1340afa8e06SEd Mastefunction converts 1350afa8e06SEd Maste.Fa pk 1360afa8e06SEd Masteto a newly allocated 1370afa8e06SEd Maste.Fa EVP_PKEY 1380afa8e06SEd Mastetype with a reference count of 1. 1390afa8e06SEd MasteNo internal references to the returned pointer are kept. 1400afa8e06SEd MasteIf an error occurs, 1410afa8e06SEd Maste.Fn rs256_pk_to_EVP_PKEY 1420afa8e06SEd Mastereturns NULL. 1430afa8e06SEd Maste.Sh RETURN VALUES 1440afa8e06SEd MasteThe 145f540a430SEd Maste.Fn rs256_pk_from_EVP_PKEY , 146f540a430SEd Maste.Fn rs256_pk_from_RSA , 1470afa8e06SEd Masteand 1480afa8e06SEd Maste.Fn rs256_pk_from_ptr 1490afa8e06SEd Mastefunctions return 1500afa8e06SEd Maste.Dv FIDO_OK 1510afa8e06SEd Masteon success. 1520afa8e06SEd MasteOn error, a different error code defined in 1530afa8e06SEd Maste.In fido/err.h 1540afa8e06SEd Masteis returned. 1550afa8e06SEd Maste.Sh SEE ALSO 1560afa8e06SEd Maste.Xr eddsa_pk_new 3 , 1570afa8e06SEd Maste.Xr es256_pk_new 3 , 158*2ccfa855SEd Maste.Xr es384_pk_new 3 , 1590afa8e06SEd Maste.Xr fido_assert_verify 3 , 1600afa8e06SEd Maste.Xr fido_cred_pubkey_ptr 3 161