xref: /freebsd/contrib/libfido2/src/fido/es256.h (revision 5e3934b15a2741b2de6b217e77dc9d798d740804)
1 /*
2  * Copyright (c) 2018-2021 Yubico AB. All rights reserved.
3  * SPDX-License-Identifier: BSD-2-Clause
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  *    1. Redistributions of source code must retain the above copyright
10  *       notice, this list of conditions and the following disclaimer.
11  *    2. Redistributions in binary form must reproduce the above copyright
12  *       notice, this list of conditions and the following disclaimer in
13  *       the documentation and/or other materials provided with the
14  *       distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _FIDO_ES256_H
30 #define _FIDO_ES256_H
31 
32 #include <openssl/ec.h>
33 
34 #include <stdint.h>
35 #include <stdlib.h>
36 
37 #ifdef _FIDO_INTERNAL
38 #include "types.h"
39 #else
40 #include <fido.h>
41 #endif
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif /* __cplusplus */
46 
47 es256_pk_t *es256_pk_new(void);
48 void es256_pk_free(es256_pk_t **);
49 EVP_PKEY *es256_pk_to_EVP_PKEY(const es256_pk_t *);
50 
51 int es256_pk_from_EC_KEY(es256_pk_t *, const EC_KEY *);
52 int es256_pk_from_EVP_PKEY(es256_pk_t *, const EVP_PKEY *);
53 int es256_pk_from_ptr(es256_pk_t *, const void *, size_t);
54 
55 #ifdef _FIDO_INTERNAL
56 es256_sk_t *es256_sk_new(void);
57 void es256_sk_free(es256_sk_t **);
58 EVP_PKEY *es256_sk_to_EVP_PKEY(const es256_sk_t *);
59 
60 int es256_derive_pk(const es256_sk_t *, es256_pk_t *);
61 int es256_sk_create(es256_sk_t *);
62 
63 int es256_pk_set_x(es256_pk_t *, const unsigned char *);
64 int es256_pk_set_y(es256_pk_t *, const unsigned char *);
65 #endif
66 
67 #ifdef __cplusplus
68 } /* extern "C" */
69 #endif /* __cplusplus */
70 
71 #endif /* !_FIDO_ES256_H */
72