Kea 2.0.0
openssl_compat.h
Go to the documentation of this file.
1// Copyright (C) 2016-2017 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#include <openssl/opensslv.h>
8
9#if defined(LIBRESSL_VERSION_NUMBER) || (OPENSSL_VERSION_NUMBER < 0x10100000L)
10
11// This file is included by hash and hmac codes so KEA_H* macros
12// avoid to define unused inlines.
13
14#ifdef KEA_HASH
15
16// EVP_MD_CTX_new() is EVP_MD_CTX_create() in OpenSSL < 1.1
17
18inline EVP_MD_CTX* EVP_MD_CTX_new() {
19 return (EVP_MD_CTX_create());
20}
21
22// EVP_MD_CTX_free(ctx) is EVP_MD_CTX_destroy(ctx) in OpenSSL < 1.1
23
24inline void EVP_MD_CTX_free(EVP_MD_CTX* ctx) {
25 EVP_MD_CTX_destroy(ctx);
26}
27
28#endif
29
30#ifdef KEA_HMAC
31
32// HMAC_CTX_new() implementation for OpenSSL < 1.1
33
34inline HMAC_CTX* HMAC_CTX_new() {
35 HMAC_CTX* ctx = static_cast<HMAC_CTX*>(OPENSSL_malloc(sizeof(HMAC_CTX)));
36 if (ctx != 0) {
37 HMAC_CTX_init(ctx);
38 }
39 return (ctx);
40}
41
42// HMAC_CTX_free() implementation for OpenSSL < 1.1
43
44inline void HMAC_CTX_free(HMAC_CTX* ctx) {
45 if (ctx != 0) {
46 HMAC_CTX_cleanup(ctx);
47 OPENSSL_free(ctx);
48 }
49}
50
51#endif
52
53#endif