return ret;
}
+static void drbg_async_seed(struct work_struct *work)
+{
+ struct drbg_string data;
+ LIST_HEAD(seedlist);
+ struct drbg_state *drbg = container_of(work, struct drbg_state,
+ seed_work);
+
+ get_blocking_random_bytes(drbg->seed_buf, drbg->seed_buf_len);
+
+ drbg_string_fill(&data, drbg->seed_buf, drbg->seed_buf_len);
+ list_add_tail(&data.list, &seedlist);
+ mutex_lock(&drbg->drbg_mutex);
+ __drbg_seed(drbg, &seedlist, true);
+ memzero_explicit(drbg->seed_buf, drbg->seed_buf_len);
+ mutex_unlock(&drbg->drbg_mutex);
+}
+
/*
* Seeding or reseeding of the DRBG
*
if (!reseed)
drbg->seed_buf_len = drbg->seed_buf_len / 3 * 2;
+ /* Invoke asynchronous seeding unless DRBG is in test mode. */
+ if (!list_empty(&drbg->test_data.list) && !reseed)
+ schedule_work(&drbg->seed_work);
+
out:
return ret;
}
if (!drbg->seed_buf)
goto err;
+ INIT_WORK(&drbg->seed_work, drbg_async_seed);
+
return 0;
err:
*/
static int drbg_uninstantiate(struct drbg_state *drbg)
{
+ cancel_work_sync(&drbg->seed_work);
if (drbg->d_ops)
drbg->d_ops->crypto_fini(drbg);
drbg_dealloc_state(drbg);
#include <linux/fips.h>
#include <linux/mutex.h>
#include <linux/list.h>
+#include <linux/workqueue.h>
/*
* Concatenation Helper and string operation helper
bool fips_primed; /* Continuous test primed? */
unsigned char *prev; /* FIPS 140-2 continuous test value */
#endif
+ struct work_struct seed_work; /* asynchronous seeding support */
u8 *seed_buf; /* buffer holding the seed */
size_t seed_buf_len;
const struct drbg_state_ops *d_ops;