summaryrefslogtreecommitdiffstats
path: root/src/lib/cryptolink/openssl_compat.h
blob: 33b85e1a22aba0955bb1604a0459659dae0829b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (C) 2016-2022 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

// This file is included by hash and hmac codes so KEA_H* macros
// avoid to define unused inlines.

#ifdef KEA_HASH

#ifndef HAVE_EVP_MD_CTX_NEW
#ifdef HAVE_EVP_MD_CTX_CREATE

// EVP_MD_CTX_new() is EVP_MD_CTX_create() in old OpenSSL

inline EVP_MD_CTX* EVP_MD_CTX_new() {
    return (EVP_MD_CTX_create());
}

#else
#error have no EVP_MD_CTX_new() nor EVP_MD_CTX_create()
#endif
#endif

#ifndef HAVE_EVP_MD_CTX_FREE
#ifdef HAVE_EVP_MD_CTX_DESTROY

// EVP_MD_CTX_free(ctx) is EVP_MD_CTX_destroy(ctx) in old OpenSSL

inline void EVP_MD_CTX_free(EVP_MD_CTX* ctx) {
    EVP_MD_CTX_destroy(ctx);
}

#else
#error have no EVP_MD_CTX_free() nor EVP_MD_CTX_destroy()
#endif
#endif

#endif

#ifdef KEA_HMAC

#ifndef HAVE_EVP_PKEY_NEW_RAW_PRIVATE_KEY
#ifdef HAVE_EVP_PKEY_NEW_MAC_KEY

// EVP_PKEY_new_raw_private_key(type, e, key, keylen) is
// EVP_PKEY_new_mac_key(type, e, key, (int)keylen) in old OpenSSL

inline EVP_PKEY* EVP_PKEY_new_raw_private_key(int type, ENGINE* e,
                                              const unsigned char *key,
                                              size_t keylen) {
    return (EVP_PKEY_new_mac_key(type, e, key, static_cast<int>(keylen)));
}

#else
#error have no EVP_PKEY_new_raw_private_key() nor EVP_PKEY_new_mac_key()
#endif
#endif

#endif