xref: /freebsd/contrib/libfido2/src/fido/eddsa.h (revision 2ccfa855b2fc331819953e3de1b1c15ce5b95a7e)
10afa8e06SEd Maste /*
20afa8e06SEd Maste  * Copyright (c) 2019 Yubico AB. All rights reserved.
3*2ccfa855SEd Maste  * SPDX-License-Identifier: BSD-2-Clause
4*2ccfa855SEd Maste  *
5*2ccfa855SEd Maste  * Redistribution and use in source and binary forms, with or without
6*2ccfa855SEd Maste  * modification, are permitted provided that the following conditions are
7*2ccfa855SEd Maste  * met:
8*2ccfa855SEd Maste  *
9*2ccfa855SEd Maste  *    1. Redistributions of source code must retain the above copyright
10*2ccfa855SEd Maste  *       notice, this list of conditions and the following disclaimer.
11*2ccfa855SEd Maste  *    2. Redistributions in binary form must reproduce the above copyright
12*2ccfa855SEd Maste  *       notice, this list of conditions and the following disclaimer in
13*2ccfa855SEd Maste  *       the documentation and/or other materials provided with the
14*2ccfa855SEd Maste  *       distribution.
15*2ccfa855SEd Maste  *
16*2ccfa855SEd Maste  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17*2ccfa855SEd Maste  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18*2ccfa855SEd Maste  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19*2ccfa855SEd Maste  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20*2ccfa855SEd Maste  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21*2ccfa855SEd Maste  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22*2ccfa855SEd Maste  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23*2ccfa855SEd Maste  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24*2ccfa855SEd Maste  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25*2ccfa855SEd Maste  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26*2ccfa855SEd Maste  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
270afa8e06SEd Maste  */
280afa8e06SEd Maste 
290afa8e06SEd Maste #ifndef _FIDO_EDDSA_H
300afa8e06SEd Maste #define _FIDO_EDDSA_H
310afa8e06SEd Maste 
320afa8e06SEd Maste #include <openssl/ec.h>
330afa8e06SEd Maste 
340afa8e06SEd Maste #include <stdint.h>
350afa8e06SEd Maste #include <stdlib.h>
360afa8e06SEd Maste 
370afa8e06SEd Maste #ifdef _FIDO_INTERNAL
380afa8e06SEd Maste #include "types.h"
390afa8e06SEd Maste #else
400afa8e06SEd Maste #include <fido.h>
410afa8e06SEd Maste #endif
420afa8e06SEd Maste 
430afa8e06SEd Maste #ifdef __cplusplus
440afa8e06SEd Maste extern "C" {
450afa8e06SEd Maste #endif /* __cplusplus */
460afa8e06SEd Maste 
470afa8e06SEd Maste eddsa_pk_t *eddsa_pk_new(void);
480afa8e06SEd Maste void eddsa_pk_free(eddsa_pk_t **);
490afa8e06SEd Maste EVP_PKEY *eddsa_pk_to_EVP_PKEY(const eddsa_pk_t *);
500afa8e06SEd Maste 
510afa8e06SEd Maste int eddsa_pk_from_EVP_PKEY(eddsa_pk_t *, const EVP_PKEY *);
520afa8e06SEd Maste int eddsa_pk_from_ptr(eddsa_pk_t *, const void *, size_t);
530afa8e06SEd Maste 
540afa8e06SEd Maste #ifdef _FIDO_INTERNAL
550afa8e06SEd Maste 
56*2ccfa855SEd Maste #if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x3070000f
570afa8e06SEd Maste #define EVP_PKEY_ED25519 EVP_PKEY_NONE
580afa8e06SEd Maste int EVP_PKEY_get_raw_public_key(const EVP_PKEY *, unsigned char *, size_t *);
590afa8e06SEd Maste EVP_PKEY *EVP_PKEY_new_raw_public_key(int, ENGINE *, const unsigned char *,
600afa8e06SEd Maste     size_t);
610afa8e06SEd Maste int EVP_DigestVerify(EVP_MD_CTX *, const unsigned char *, size_t,
620afa8e06SEd Maste     const unsigned char *, size_t);
63f540a430SEd Maste #endif /* LIBRESSL_VERSION_NUMBER */
640afa8e06SEd Maste 
650afa8e06SEd Maste #endif /* _FIDO_INTERNAL */
660afa8e06SEd Maste 
670afa8e06SEd Maste #ifdef __cplusplus
680afa8e06SEd Maste } /* extern "C" */
690afa8e06SEd Maste #endif /* __cplusplus */
700afa8e06SEd Maste 
710afa8e06SEd Maste #endif /* !_FIDO_EDDSA_H */
72