The tpm plugin offers random number generation

The tpm plugin can be used to derive true random numbers from a
TPM 2.0 device. The get_random method must be explicitly enabled
in strongswan.conf with the plugin.tpm.use_rng = yes option.
This commit is contained in:
Andreas Steffen
2017-03-20 21:16:10 +01:00
parent 46d4d2a71e
commit 2b233c8a64
9 changed files with 211 additions and 3 deletions
+22 -2
View File
@@ -15,6 +15,7 @@
#include "tpm_plugin.h"
#include "tpm_private_key.h"
#include "tpm_rng.h"
#include <library.h>
@@ -40,13 +41,32 @@ METHOD(plugin_t, get_name, char*,
METHOD(plugin_t, get_features, int,
private_tpm_plugin_t *this, plugin_feature_t *features[])
{
static plugin_feature_t f[] = {
static plugin_feature_t f_rng[] = {
PLUGIN_REGISTER(RNG, tpm_rng_create),
PLUGIN_PROVIDE(RNG, RNG_STRONG),
PLUGIN_PROVIDE(RNG, RNG_TRUE),
};
static plugin_feature_t f_privkey[] = {
PLUGIN_REGISTER(PRIVKEY, tpm_private_key_connect, FALSE),
PLUGIN_PROVIDE(PRIVKEY, KEY_ANY),
};
static plugin_feature_t f[countof(f_rng) + countof(f_privkey)] = {};
static int count = 0;
if (!count)
{
plugin_features_add(f, f_privkey, countof(f_privkey), &count);
if (lib->settings->get_bool(lib->settings,
"%s.plugins.tpm.use_rng", FALSE, lib->ns))
{
plugin_features_add(f, f_rng, countof(f_rng), &count);
}
}
*features = f;
return countof(f);
return count;
}
METHOD(plugin_t, destroy, void,