mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-14 20:30:04 +01:00
Add crypt_backend_destroy() function and cll it as library destructor.
This commit is contained in:
@@ -31,6 +31,7 @@ struct crypt_cipher;
|
||||
struct crypt_storage;
|
||||
|
||||
int crypt_backend_init(struct crypt_device *ctx);
|
||||
void crypt_backend_destroy(void);
|
||||
|
||||
#define CRYPT_BACKEND_KERNEL (1 << 0) /* Crypto uses kernel part, for benchmark */
|
||||
|
||||
|
||||
@@ -121,6 +121,14 @@ int crypt_backend_init(struct crypt_device *ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void crypt_backend_destroy(void)
|
||||
{
|
||||
if (crypto_backend_initialised)
|
||||
gcry_control(GCRYCTL_TERM_SECMEM);
|
||||
|
||||
crypto_backend_initialised = 0;
|
||||
}
|
||||
|
||||
const char *crypt_backend_version(void)
|
||||
{
|
||||
return crypto_backend_initialised ? version : "";
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#endif
|
||||
|
||||
static int crypto_backend_initialised = 0;
|
||||
static char version[64];
|
||||
static char version[256];
|
||||
|
||||
struct hash_alg {
|
||||
const char *name;
|
||||
@@ -126,6 +126,11 @@ int crypt_backend_init(struct crypt_device *ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void crypt_backend_destroy(void)
|
||||
{
|
||||
crypto_backend_initialised = 0;
|
||||
}
|
||||
|
||||
uint32_t crypt_backend_flags(void)
|
||||
{
|
||||
return CRYPT_BACKEND_KERNEL;
|
||||
|
||||
@@ -143,6 +143,11 @@ int crypt_backend_init(struct crypt_device *ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void crypt_backend_destroy(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const char *crypt_backend_version(void)
|
||||
{
|
||||
return version;
|
||||
|
||||
@@ -88,6 +88,11 @@ int crypt_backend_init(struct crypt_device *ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void crypt_backend_destroy(void)
|
||||
{
|
||||
crypto_backend_initialised = 0;
|
||||
}
|
||||
|
||||
uint32_t crypt_backend_flags(void)
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -116,6 +116,11 @@ int crypt_backend_init(struct crypt_device *ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void crypt_backend_destroy(void)
|
||||
{
|
||||
crypto_backend_initialised = 0;
|
||||
}
|
||||
|
||||
uint32_t crypt_backend_flags(void)
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -3062,3 +3062,8 @@ int crypt_get_integrity_info(struct crypt_device *cd,
|
||||
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static void __attribute__((destructor)) libcryptsetup_exit(void)
|
||||
{
|
||||
crypt_backend_destroy();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user