Commit a79e63da authored by Jan Včelák's avatar Jan Včelák 🚀

fix build without PKCS11 support

parent a88620a9
......@@ -24,9 +24,7 @@
_public_
void dnssec_crypto_init(void)
{
#ifdef ENABLE_PKCS11
gnutls_pkcs11_init(GNUTLS_PKCS11_FLAG_MANUAL, NULL);
#endif
p11_init();
gnutls_global_init();
}
......@@ -34,16 +32,11 @@ _public_
void dnssec_crypto_cleanup(void)
{
gnutls_global_deinit();
#ifdef ENABLE_PKCS11
gnutls_pkcs11_deinit();
p11_cleanup();
#endif
}
_public_
void dnssec_crypto_reinit(void)
{
#ifdef ENABLE_PKCS11
gnutls_pkcs11_reinit();
#endif
p11_reinit();
}
......@@ -22,11 +22,30 @@
#include <stdlib.h>
#include <string.h>
#ifdef ENABLE_PKCS11
#define PKCS11_MODULES_MAX 16
static char *pkcs11_modules[PKCS11_MODULES_MAX] = { 0 };
static int pkcs11_modules_count = 0;
static int map_result(int gnutls_result)
{
return gnutls_result == GNUTLS_E_SUCCESS ? DNSSEC_EOK : DNSSEC_ERROR;
}
int p11_init(void)
{
int r = gnutls_pkcs11_init(GNUTLS_PKCS11_FLAG_MANUAL, NULL);
return map_result(r);
}
int p11_reinit(void)
{
int r = gnutls_pkcs11_reinit();
return map_result(r);
}
int p11_load_module(const char *module)
{
for (int i = 0; i < pkcs11_modules_count; i++) {
......@@ -65,4 +84,30 @@ void p11_cleanup(void)
}
pkcs11_modules_count = 0;
gnutls_pkcs11_deinit();
}
#else
int p11_init(void)
{
return DNSSEC_EOK;
}
int p11_reinit(void)
{
return DNSSEC_EOK;
}
int p11_load_module(const char *module)
{
return DNSSEC_NOT_IMPLEMENTED_ERROR;
}
void p11_cleanup(void)
{
// this function intentionally left blank
}
#endif
......@@ -16,6 +16,16 @@
#pragma once
/*!
* Initialize PKCS11 global context.
*/
int p11_init(void);
/*!
* Reinitialize PKCS11 global context after fork().
*/
int p11_reinit(void);
/*!
* Load PKCS11 module unless the module was already loaded.
*
......@@ -24,7 +34,7 @@
int p11_load_module(const char *name);
/*!
* Clenaup list of loaded modules.
* Clenaup PKCS11 global context.
*
* Should be called when the library is deinitialized to prevent memory leaks.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment