OpenVPN 3 Core Library
Loading...
Searching...
No Matches
xkey_common.h
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) 2022- OpenVPN Inc.
8// Copyright (C) 2021-2022 Selva Nair <selva.nair@gmail.com>
9//
10// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception OR GPL-2.0-only WITH openvpn-openssl-exception
11//
12
13
14#ifndef XKEY_COMMON_H_
15#define XKEY_COMMON_H_
16
17#if defined (__cplusplus)
18extern "C" {
19#endif
20
21/* Guard to only enable if OpenSSL is used and not trigger an error if mbed
22 * TLS is compiled without OpenSSL being installed */
23#if defined(USE_OPENSSL)
24#include <openssl/opensslv.h>
25#if OPENSSL_VERSION_NUMBER >= 0x30000010L && !defined(DISABLE_XKEY_PROVIDER)
26#define HAVE_XKEY_PROVIDER 1
27
28#include <stdbool.h>
29#include <openssl/provider.h>
30#include <openssl/core_dispatch.h>
31
36OSSL_provider_init_fn xkey_provider_init;
37
38
39
40#define XKEY_PROV_PROPS "provider=ovpn.xkey"
41
46typedef struct {
47 const char *padmode;
48 const char *mdname;
49 const char *saltlen;
50 const char *keytype;
51 const char *op;
52} XKEY_SIGALG;
53
78typedef int (XKEY_EXTERNAL_SIGN_fn)(void *handle, unsigned char *sig, size_t *siglen,
79 const unsigned char *tbs, size_t tbslen,
80 XKEY_SIGALG sigalg);
86typedef void (XKEY_PRIVKEY_FREE_fn)(void *handle);
87
88
94EVP_PKEY *
95xkey_load_generic_key(OSSL_LIB_CTX *libctx, void *handle, EVP_PKEY *pubkey,
96 XKEY_EXTERNAL_SIGN_fn *sign_op, XKEY_PRIVKEY_FREE_fn *free_op);
97
113bool
114xkey_encode_pkcs1(unsigned char *enc, size_t *enc_len, const char *mdname,
115 const unsigned char *tbs, size_t tbslen);
116
119typedef void (XKEY_LOGGING_CALLBACK_fn)(const char *msg, bool debug);
120
121
127void xkey_set_logging_cb_function(XKEY_LOGGING_CALLBACK_fn logfunc);
128
129
130#endif /* HAVE_XKEY_PROVIDER */
131
132#endif /* USE_OPENSSL */
133
134#if defined (__cplusplus)
135}
136#endif
137#endif /* XKEY_COMMON_H_ */
#define msg(flags,...)