mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
libpv is a collection of definitions and functions related to Protected Virtualization (PV). The functions cover mainly encryption (e.g. AES-GCM) and certificates (X509). There are also helping functions for glib2. Most of the code is extracted+refactored from `genprotimg`, which will use this library in future. Requires openssl v1.1.1+, glib2.56+, and libcurl. libpv is not designed or intended to be dynamically linked or used outside of this project. Its purpose is to avoid code duplication as PV tools do very similar things regarding cryptography. Signed-off-by: Steffen Eiden <seiden@linux.ibm.com> Acked-by: Marc Hartmayer <mhartmay@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
46 lines
876 B
C
46 lines
876 B
C
/*
|
|
* Libpv common functions.
|
|
*
|
|
* Copyright IBM Corp. 2022
|
|
*
|
|
* s390-tools is free software; you can redistribute it and/or modify
|
|
* it under the terms of the MIT license. See LICENSE for details.
|
|
*
|
|
*/
|
|
/* Must be included before any other header */
|
|
#include "config.h"
|
|
|
|
#include "libpv/common.h"
|
|
#include "libpv/cert.h"
|
|
#include "libpv/curl.h"
|
|
|
|
/* setup and tear down */
|
|
int pv_init(void)
|
|
{
|
|
static size_t openssl_initalized;
|
|
|
|
if (g_once_init_enter(&openssl_initalized)) {
|
|
if (OPENSSL_VERSION_NUMBER < 0x1000100fL)
|
|
g_assert_not_reached();
|
|
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
|
SSL_library_init();
|
|
SSL_load_error_strings();
|
|
#else
|
|
OPENSSL_init_crypto(0, NULL);
|
|
#endif
|
|
|
|
if (pv_curl_init() != 0)
|
|
return -1;
|
|
|
|
pv_cert_init();
|
|
g_once_init_leave(&openssl_initalized, 1);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void pv_cleanup(void)
|
|
{
|
|
pv_cert_cleanup();
|
|
pv_curl_cleanup();
|
|
}
|