added API for random number generators, served through credential factory

ported randomizer_t to a rng_t on top of /dev/(u)random (plugin random)
This commit is contained in:
Martin Willi
2008-04-15 05:56:35 +00:00
parent 0644ebd3de
commit 6a365f0740
33 changed files with 700 additions and 451 deletions
+5 -7
View File
@@ -122,18 +122,16 @@ static status_t initiate_peer(private_eap_md5_t *this, eap_payload_t **out)
*/
static status_t initiate_server(private_eap_md5_t *this, eap_payload_t **out)
{
randomizer_t *randomizer;
status_t status;
rng_t *rng;
eap_md5_header_t *req;
randomizer = randomizer_create();
status = randomizer->allocate_pseudo_random_bytes(randomizer, CHALLENGE_LEN,
&this->challenge);
randomizer->destroy(randomizer);
if (status != SUCCESS)
rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
if (!rng)
{
return FAILED;
}
rng->allocate_bytes(rng, CHALLENGE_LEN, &this->challenge);
rng->destroy(rng);
req = alloca(PAYLOAD_LEN);
req->length = htons(PAYLOAD_LEN);