Kea 2.7.6
openssl_compat.h
Go to the documentation of this file.
1// Copyright (C) 2016-2022 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7// This file is included by hash and hmac codes so KEA_H* macros
8// avoid to define unused inlines.
9
10#ifdef KEA_HASH
11
12#ifndef HAVE_EVP_MD_CTX_NEW
13#ifdef HAVE_EVP_MD_CTX_CREATE
14
15// EVP_MD_CTX_new() is EVP_MD_CTX_create() in old OpenSSL
16
17inline EVP_MD_CTX* EVP_MD_CTX_new() {
18 return (EVP_MD_CTX_create());
19}
20
21#else
22#error have no EVP_MD_CTX_new() nor EVP_MD_CTX_create()
23#endif
24#endif
25
26#ifndef HAVE_EVP_MD_CTX_FREE
27#ifdef HAVE_EVP_MD_CTX_DESTROY
28
29// EVP_MD_CTX_free(ctx) is EVP_MD_CTX_destroy(ctx) in old OpenSSL
30
31inline void EVP_MD_CTX_free(EVP_MD_CTX* ctx) {
32 EVP_MD_CTX_destroy(ctx);
33}
34
35#else
36#error have no EVP_MD_CTX_free() nor EVP_MD_CTX_destroy()
37#endif
38#endif
39
40#endif
41
42#ifdef KEA_HMAC
43
44#ifndef HAVE_EVP_PKEY_NEW_RAW_PRIVATE_KEY
45#ifdef HAVE_EVP_PKEY_NEW_MAC_KEY
46
47// EVP_PKEY_new_raw_private_key(type, e, key, keylen) is
48// EVP_PKEY_new_mac_key(type, e, key, (int)keylen) in old OpenSSL
49
50inline EVP_PKEY* EVP_PKEY_new_raw_private_key(int type, ENGINE* e,
51 const unsigned char *key,
52 size_t keylen) {
53 return (EVP_PKEY_new_mac_key(type, e, key, static_cast<int>(keylen)));
54}
55
56#else
57#error have no EVP_PKEY_new_raw_private_key() nor EVP_PKEY_new_mac_key()
58#endif
59#endif
60
61#endif