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