OpenVPN 3 Core Library
Loading...
Searching...
No Matches
mbedtls_compat.hpp
Go to the documentation of this file.
1// OpenVPN -- An application to securely tunnel IP networks
2// over a single port, with support for SSL/TLS-based
3// session authentication and key exchange,
4// packet encryption, packet authentication, and
5// packet compression.
6//
7// Copyright (C) 2012- OpenVPN Inc.
8//
9// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10//
11//
12
13#pragma once
14
15
16#include <mbedtls/ctr_drbg.h>
17#include <mbedtls/version.h>
18#include <mbedtls/pem.h>
19
20#if not defined(MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION)
21#define MBEDTLS_ERR_SSL_BAD_PROTOCOL_VERSION MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION
22#endif
23
24#if not defined(MBEDTLS_OID_X509_EXT_EXTENDED_KEY_USAGE)
25#define MBEDTLS_OID_X509_EXT_EXTENDED_KEY_USAGE MBEDTLS_X509_EXT_KEY_USAGE
26#endif
27
28#if MBEDTLS_VERSION_NUMBER < 0x03000000
29static inline const mbedtls_md_info_t *
30mbedtls_md_info_from_ctx(const mbedtls_md_context_t *ctx)
31{
32 if (ctx == nullptr)
33 {
34 return nullptr;
35 }
36 return ctx->md_info;
37}
38
39static inline int
40mbedtls_x509_crt_has_ext_type(const mbedtls_x509_crt *crt, int ext_type)
41{
42 return crt->ext_types & ext_type;
43}
44
45static inline const unsigned char *
46mbedtls_pem_get_buffer(const mbedtls_pem_context *ctx, size_t *buf_size)
47{
48 *buf_size = ctx->buflen;
49 return ctx->buf;
50}
51#endif
static int mbedtls_x509_crt_has_ext_type(const mbedtls_x509_crt *crt, int ext_type)
static const mbedtls_md_info_t * mbedtls_md_info_from_ctx(const mbedtls_md_context_t *ctx)
static const unsigned char * mbedtls_pem_get_buffer(const mbedtls_pem_context *ctx, size_t *buf_size)