xref: /freebsd/contrib/libfido2/src/fido/eddsa.h (revision 0afa8e065e14bb8fd338d75690e0238c00167d40)
1*0afa8e06SEd Maste /*
2*0afa8e06SEd Maste  * Copyright (c) 2019 Yubico AB. All rights reserved.
3*0afa8e06SEd Maste  * Use of this source code is governed by a BSD-style
4*0afa8e06SEd Maste  * license that can be found in the LICENSE file.
5*0afa8e06SEd Maste  */
6*0afa8e06SEd Maste 
7*0afa8e06SEd Maste #ifndef _FIDO_EDDSA_H
8*0afa8e06SEd Maste #define _FIDO_EDDSA_H
9*0afa8e06SEd Maste 
10*0afa8e06SEd Maste #include <openssl/ec.h>
11*0afa8e06SEd Maste 
12*0afa8e06SEd Maste #include <stdint.h>
13*0afa8e06SEd Maste #include <stdlib.h>
14*0afa8e06SEd Maste 
15*0afa8e06SEd Maste #ifdef _FIDO_INTERNAL
16*0afa8e06SEd Maste #include "types.h"
17*0afa8e06SEd Maste #else
18*0afa8e06SEd Maste #include <fido.h>
19*0afa8e06SEd Maste #endif
20*0afa8e06SEd Maste 
21*0afa8e06SEd Maste #ifdef __cplusplus
22*0afa8e06SEd Maste extern "C" {
23*0afa8e06SEd Maste #endif /* __cplusplus */
24*0afa8e06SEd Maste 
25*0afa8e06SEd Maste eddsa_pk_t *eddsa_pk_new(void);
26*0afa8e06SEd Maste void eddsa_pk_free(eddsa_pk_t **);
27*0afa8e06SEd Maste EVP_PKEY *eddsa_pk_to_EVP_PKEY(const eddsa_pk_t *);
28*0afa8e06SEd Maste 
29*0afa8e06SEd Maste int eddsa_pk_from_EVP_PKEY(eddsa_pk_t *, const EVP_PKEY *);
30*0afa8e06SEd Maste int eddsa_pk_from_ptr(eddsa_pk_t *, const void *, size_t);
31*0afa8e06SEd Maste 
32*0afa8e06SEd Maste #ifdef _FIDO_INTERNAL
33*0afa8e06SEd Maste 
34*0afa8e06SEd Maste #if defined(LIBRESSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10101000L
35*0afa8e06SEd Maste #define EVP_PKEY_ED25519 EVP_PKEY_NONE
36*0afa8e06SEd Maste int EVP_PKEY_get_raw_public_key(const EVP_PKEY *, unsigned char *, size_t *);
37*0afa8e06SEd Maste EVP_PKEY *EVP_PKEY_new_raw_public_key(int, ENGINE *, const unsigned char *,
38*0afa8e06SEd Maste     size_t);
39*0afa8e06SEd Maste int EVP_DigestVerify(EVP_MD_CTX *, const unsigned char *, size_t,
40*0afa8e06SEd Maste     const unsigned char *, size_t);
41*0afa8e06SEd Maste #endif /* LIBRESSL_VERSION_NUMBER || OPENSSL_VERSION_NUMBER < 0x10101000L */
42*0afa8e06SEd Maste 
43*0afa8e06SEd Maste #if OPENSSL_VERSION_NUMBER < 0x10100000L
44*0afa8e06SEd Maste EVP_MD_CTX *EVP_MD_CTX_new(void);
45*0afa8e06SEd Maste void EVP_MD_CTX_free(EVP_MD_CTX *);
46*0afa8e06SEd Maste #endif
47*0afa8e06SEd Maste 
48*0afa8e06SEd Maste #endif /* _FIDO_INTERNAL */
49*0afa8e06SEd Maste 
50*0afa8e06SEd Maste #ifdef __cplusplus
51*0afa8e06SEd Maste } /* extern "C" */
52*0afa8e06SEd Maste #endif /* __cplusplus */
53*0afa8e06SEd Maste 
54*0afa8e06SEd Maste #endif /* !_FIDO_EDDSA_H */
55