25 #ifndef XKEY_COMMON_H_
26 #define XKEY_COMMON_H_
30 #if defined(ENABLE_CRYPTO_OPENSSL)
31 #include <openssl/opensslv.h>
32 #if OPENSSL_VERSION_NUMBER >= 0x30000010L && !defined(DISABLE_XKEY_PROVIDER)
33 #define HAVE_XKEY_PROVIDER 1
34 #include <openssl/provider.h>
35 #include <openssl/core_dispatch.h>
36 #include <openssl/ecdsa.h>
42 OSSL_provider_init_fn xkey_provider_init;
44 #define XKEY_PROV_PROPS "provider=ovpn.xkey"
82 typedef int (XKEY_EXTERNAL_SIGN_fn)(
void *handle,
unsigned char *sig,
size_t *siglen,
83 const unsigned char *tbs,
size_t tbslen,
90 typedef void (XKEY_PRIVKEY_FREE_fn)(
void *handle);
101 EVP_PKEY *xkey_load_management_key(
OSSL_LIB_CTX *libctx, EVP_PKEY *pubkey);
120 encode_pkcs1(
unsigned char *enc,
size_t *enc_len,
const char *mdname,
121 const unsigned char *tbs,
size_t tbslen);
138 xkey_digest(
const unsigned char *src,
size_t srclen,
unsigned char *buf,
139 size_t *buflen,
const char *mdname);
155 xkey_load_generic_key(
OSSL_LIB_CTX *libctx,
void *handle, EVP_PKEY *pubkey,
156 XKEY_EXTERNAL_SIGN_fn *sign_op, XKEY_PRIVKEY_FREE_fn *free_op);
168 xkey_max_saltlen(
int modBits,
int hLen)
170 int emLen = (modBits - 1 + 7)/8;
172 return emLen - hLen - 2;
186 ecdsa_bin2der(
unsigned char *buf,
int len,
size_t capacity);