xref: /freebsd/contrib/libfido2/src/fido/eddsa.h (revision a03411e84728e9b267056fd31c7d1d9d1dc1b01e)
1 /*
2  * Copyright (c) 2019 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_EDDSA_H
30 #define _FIDO_EDDSA_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 eddsa_pk_t *eddsa_pk_new(void);
48 void eddsa_pk_free(eddsa_pk_t **);
49 EVP_PKEY *eddsa_pk_to_EVP_PKEY(const eddsa_pk_t *);
50 
51 int eddsa_pk_from_EVP_PKEY(eddsa_pk_t *, const EVP_PKEY *);
52 int eddsa_pk_from_ptr(eddsa_pk_t *, const void *, size_t);
53 
54 #ifdef _FIDO_INTERNAL
55 
56 #if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3070000f
57 #define EVP_PKEY_ED25519 EVP_PKEY_NONE
58 int EVP_PKEY_get_raw_public_key(const EVP_PKEY *, unsigned char *, size_t *);
59 EVP_PKEY *EVP_PKEY_new_raw_public_key(int, ENGINE *, const unsigned char *,
60     size_t);
61 int EVP_DigestVerify(EVP_MD_CTX *, const unsigned char *, size_t,
62     const unsigned char *, size_t);
63 #endif /* LIBRESSL_VERSION_NUMBER */
64 
65 #endif /* _FIDO_INTERNAL */
66 
67 #ifdef __cplusplus
68 } /* extern "C" */
69 #endif /* __cplusplus */
70 
71 #endif /* !_FIDO_EDDSA_H */
72