Implemented libstrongswan.plugins.random.strong_equals_true option

This commit is contained in:
Andreas Steffen
2013-11-16 00:11:40 +01:00
parent 85adb98daf
commit b63246c5db
4 changed files with 26 additions and 0 deletions
+4
View File
@@ -905,6 +905,10 @@ File to read random bytes from, instead of @random_device@
.BR libstrongswan.plugins.random.urandom " [@urandom_device@]"
File to read pseudo random bytes from, instead of @urandom_device@
.TP
.BR libstrongswan.plugins.random.strong_equals_true " [no]"
If set to yes the RNG_STRONG class reads random bytes from the same source as
the RNG_TRUE class.
.TP
.BR libstrongswan.plugins.unbound.resolv_conf " [/etc/resolv.conf]"
File to read DNS resolver configuration from
.TP
@@ -51,6 +51,9 @@ static int dev_random = -1;
/** /dev/urandom file descriptor */
static int dev_urandom = -1;
/** Is strong randomness equivalent to true randomness? */
static bool strong_equals_true = FALSE;
/**
* See header.
*/
@@ -67,6 +70,14 @@ int random_plugin_get_dev_urandom()
return dev_urandom;
}
/**
* See header.
*/
bool random_plugin_get_strong_equals_true()
{
return strong_equals_true;
}
/**
* Open a random device file
*/
@@ -131,6 +142,8 @@ plugin_t *random_plugin_create()
},
);
strong_equals_true = lib->settings->get_bool(lib->settings,
"libstrongswan.plugins.random.strong_equals_true", FALSE);
urandom_file = lib->settings->get_str(lib->settings,
"libstrongswan.plugins.random.urandom", DEV_URANDOM);
random_file = lib->settings->get_str(lib->settings,
@@ -49,4 +49,9 @@ int random_plugin_get_dev_random();
*/
int random_plugin_get_dev_urandom();
/**
* Must strong randomness be equivalent to true randomness?
*/
bool random_plugin_get_strong_equals_true();
#endif /** RANDOM_PLUGIN_H_ @}*/
@@ -99,6 +99,10 @@ random_rng_t *random_rng_create(rng_quality_t quality)
this->fd = random_plugin_get_dev_random();
break;
case RNG_STRONG:
this->fd = random_plugin_get_strong_equals_true() ?
random_plugin_get_dev_random() :
random_plugin_get_dev_urandom();
break;
case RNG_WEAK:
default:
this->fd = random_plugin_get_dev_urandom();