xref: /freebsd/contrib/libfido2/man/es384_pk_new.3 (revision e5b786625f7f82a1fa91e41823332459ea5550f9)
1.\" Copyright (c) 2022 Yubico AB. All rights reserved.
2.\"
3.\" Redistribution and use in source and binary forms, with or without
4.\" modification, are permitted provided that the following conditions are
5.\" met:
6.\"
7.\"    1. Redistributions of source code must retain the above copyright
8.\"       notice, this list of conditions and the following disclaimer.
9.\"    2. Redistributions in binary form must reproduce the above copyright
10.\"       notice, this list of conditions and the following disclaimer in
11.\"       the documentation and/or other materials provided with the
12.\"       distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
18.\" HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
20.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\"
26.\" SPDX-License-Identifier: BSD-2-Clause
27.\"
28.Dd $Mdocdate: July 15 2022 $
29.Dt ES384_PK_NEW 3
30.Os
31.Sh NAME
32.Nm es384_pk_new ,
33.Nm es384_pk_free ,
34.Nm es384_pk_from_EC_KEY ,
35.Nm es384_pk_from_EVP_PKEY ,
36.Nm es384_pk_from_ptr ,
37.Nm es384_pk_to_EVP_PKEY
38.Nd FIDO2 COSE ES384 API
39.Sh SYNOPSIS
40.In openssl/ec.h
41.In fido/es384.h
42.Ft es384_pk_t *
43.Fn es384_pk_new "void"
44.Ft void
45.Fn es384_pk_free "es384_pk_t **pkp"
46.Ft int
47.Fn es384_pk_from_EC_KEY "es384_pk_t *pk" "const EC_KEY *ec"
48.Ft int
49.Fn es384_pk_from_EVP_PKEY "es384_pk_t *pk" "const EVP_PKEY *pkey"
50.Ft int
51.Fn es384_pk_from_ptr "es384_pk_t *pk" "const void *ptr" "size_t len"
52.Ft EVP_PKEY *
53.Fn es384_pk_to_EVP_PKEY "const es384_pk_t *pk"
54.Sh DESCRIPTION
55ES384 is the name given in the CBOR Object Signing and Encryption
56(COSE) RFC to ECDSA over P-384 with SHA-384.
57The COSE ES384 API of
58.Em libfido2
59is an auxiliary API with routines to convert between the different
60ECDSA public key types used in
61.Em libfido2
62and
63.Em OpenSSL .
64.Pp
65In
66.Em libfido2 ,
67ES384 public keys are abstracted by the
68.Vt es384_pk_t
69type.
70.Pp
71The
72.Fn es384_pk_new
73function returns a pointer to a newly allocated, empty
74.Vt es384_pk_t
75type.
76If memory cannot be allocated, NULL is returned.
77.Pp
78The
79.Fn es384_pk_free
80function releases the memory backing
81.Fa *pkp ,
82where
83.Fa *pkp
84must have been previously allocated by
85.Fn es384_pk_new .
86On return,
87.Fa *pkp
88is set to NULL.
89Either
90.Fa pkp
91or
92.Fa *pkp
93may be NULL, in which case
94.Fn es384_pk_free
95is a NOP.
96.Pp
97The
98.Fn es384_pk_from_EC_KEY
99function fills
100.Fa pk
101with the contents of
102.Fa ec .
103No references to
104.Fa ec
105are kept.
106.Pp
107The
108.Fn es384_pk_from_EVP_PKEY
109function fills
110.Fa pk
111with the contents of
112.Fa pkey .
113No references to
114.Fa pkey
115are kept.
116.Pp
117The
118.Fn es384_pk_from_ptr
119function fills
120.Fa pk
121with the contents of
122.Fa ptr ,
123where
124.Fa ptr
125points to
126.Fa len
127bytes.
128The
129.Fa ptr
130pointer may point to an uncompressed point, or to the
131concatenation of the x and y coordinates.
132No references to
133.Fa ptr
134are kept.
135.Pp
136The
137.Fn es384_pk_to_EVP_PKEY
138function converts
139.Fa pk
140to a newly allocated
141.Fa EVP_PKEY
142type with a reference count of 1.
143No internal references to the returned pointer are kept.
144If an error occurs,
145.Fn es384_pk_to_EVP_PKEY
146returns NULL.
147.Sh RETURN VALUES
148The
149.Fn es384_pk_from_EC_KEY ,
150.Fn es384_pk_from_EVP_PKEY ,
151and
152.Fn es384_pk_from_ptr
153functions return
154.Dv FIDO_OK
155on success.
156On error, a different error code defined in
157.In fido/err.h
158is returned.
159.Sh SEE ALSO
160.Xr eddsa_pk_new 3 ,
161.Xr es256_pk_new 3 ,
162.Xr fido_assert_verify 3 ,
163.Xr fido_cred_pubkey_ptr 3 ,
164.Xr rs256_pk_new 3
165