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 ES256_PK_NEW 3 300afa8e06SEd Maste.Os 310afa8e06SEd Maste.Sh NAME 320afa8e06SEd Maste.Nm es256_pk_new , 330afa8e06SEd Maste.Nm es256_pk_free , 340afa8e06SEd Maste.Nm es256_pk_from_EC_KEY , 353e696dfbSEd Maste.Nm es256_pk_from_EVP_PKEY , 360afa8e06SEd Maste.Nm es256_pk_from_ptr , 370afa8e06SEd Maste.Nm es256_pk_to_EVP_PKEY 380afa8e06SEd Maste.Nd FIDO2 COSE ES256 API 390afa8e06SEd Maste.Sh SYNOPSIS 400afa8e06SEd Maste.In openssl/ec.h 410afa8e06SEd Maste.In fido/es256.h 420afa8e06SEd Maste.Ft es256_pk_t * 430afa8e06SEd Maste.Fn es256_pk_new "void" 440afa8e06SEd Maste.Ft void 450afa8e06SEd Maste.Fn es256_pk_free "es256_pk_t **pkp" 460afa8e06SEd Maste.Ft int 470afa8e06SEd Maste.Fn es256_pk_from_EC_KEY "es256_pk_t *pk" "const EC_KEY *ec" 480afa8e06SEd Maste.Ft int 49f540a430SEd Maste.Fn es256_pk_from_EVP_PKEY "es256_pk_t *pk" "const EVP_PKEY *pkey" 50f540a430SEd Maste.Ft int 510afa8e06SEd Maste.Fn es256_pk_from_ptr "es256_pk_t *pk" "const void *ptr" "size_t len" 520afa8e06SEd Maste.Ft EVP_PKEY * 530afa8e06SEd Maste.Fn es256_pk_to_EVP_PKEY "const es256_pk_t *pk" 540afa8e06SEd Maste.Sh DESCRIPTION 550afa8e06SEd MasteES256 is the name given in the CBOR Object Signing and Encryption 560afa8e06SEd Maste(COSE) RFC to ECDSA over P-256 with SHA-256. 570afa8e06SEd MasteThe COSE ES256 API of 580afa8e06SEd Maste.Em libfido2 590afa8e06SEd Masteis an auxiliary API with routines to convert between the different 600afa8e06SEd MasteECDSA 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 MasteES256 public keys are abstracted by the 680afa8e06SEd Maste.Vt es256_pk_t 690afa8e06SEd Mastetype. 700afa8e06SEd Maste.Pp 710afa8e06SEd MasteThe 720afa8e06SEd Maste.Fn es256_pk_new 730afa8e06SEd Mastefunction returns a pointer to a newly allocated, empty 740afa8e06SEd Maste.Vt es256_pk_t 750afa8e06SEd Mastetype. 760afa8e06SEd MasteIf memory cannot be allocated, NULL is returned. 770afa8e06SEd Maste.Pp 780afa8e06SEd MasteThe 790afa8e06SEd Maste.Fn es256_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 es256_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 es256_pk_free 950afa8e06SEd Masteis a NOP. 960afa8e06SEd Maste.Pp 970afa8e06SEd MasteThe 980afa8e06SEd Maste.Fn es256_pk_from_EC_KEY 990afa8e06SEd Mastefunction fills 1000afa8e06SEd Maste.Fa pk 1010afa8e06SEd Mastewith the contents of 1020afa8e06SEd Maste.Fa ec . 1030afa8e06SEd MasteNo references to 1040afa8e06SEd Maste.Fa ec 1050afa8e06SEd Masteare kept. 1060afa8e06SEd Maste.Pp 1070afa8e06SEd MasteThe 1083e696dfbSEd Maste.Fn es256_pk_from_EVP_PKEY 109f540a430SEd Mastefunction fills 110f540a430SEd Maste.Fa pk 111f540a430SEd Mastewith the contents of 112f540a430SEd Maste.Fa pkey . 113f540a430SEd MasteNo references to 114f540a430SEd Maste.Fa pkey 115f540a430SEd Masteare kept. 116f540a430SEd Maste.Pp 117f540a430SEd MasteThe 1180afa8e06SEd Maste.Fn es256_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 MasteThe 1290afa8e06SEd Maste.Fa ptr 1300afa8e06SEd Mastepointer may point to an uncompressed point, or to the 1310afa8e06SEd Masteconcatenation of the x and y coordinates. 1320afa8e06SEd MasteNo references to 1330afa8e06SEd Maste.Fa ptr 1340afa8e06SEd Masteare kept. 1350afa8e06SEd Maste.Pp 1360afa8e06SEd MasteThe 1370afa8e06SEd Maste.Fn es256_pk_to_EVP_PKEY 1380afa8e06SEd Mastefunction converts 1390afa8e06SEd Maste.Fa pk 1400afa8e06SEd Masteto a newly allocated 1410afa8e06SEd Maste.Fa EVP_PKEY 1420afa8e06SEd Mastetype with a reference count of 1. 1430afa8e06SEd MasteNo internal references to the returned pointer are kept. 1440afa8e06SEd MasteIf an error occurs, 1450afa8e06SEd Maste.Fn es256_pk_to_EVP_PKEY 1460afa8e06SEd Mastereturns NULL. 1470afa8e06SEd Maste.Sh RETURN VALUES 1480afa8e06SEd MasteThe 149f540a430SEd Maste.Fn es256_pk_from_EC_KEY , 1503e696dfbSEd Maste.Fn es256_pk_from_EVP_PKEY , 1510afa8e06SEd Masteand 1520afa8e06SEd Maste.Fn es256_pk_from_ptr 1530afa8e06SEd Mastefunctions return 1540afa8e06SEd Maste.Dv FIDO_OK 1550afa8e06SEd Masteon success. 1560afa8e06SEd MasteOn error, a different error code defined in 1570afa8e06SEd Maste.In fido/err.h 1580afa8e06SEd Masteis returned. 1590afa8e06SEd Maste.Sh SEE ALSO 1600afa8e06SEd Maste.Xr eddsa_pk_new 3 , 161*2ccfa855SEd Maste.Xr es384_pk_new 3 , 1620afa8e06SEd Maste.Xr fido_assert_verify 3 , 1630afa8e06SEd Maste.Xr fido_cred_pubkey_ptr 3 , 1640afa8e06SEd Maste.Xr rs256_pk_new 3 165