#define yarrow256_random nettle_yarrow256_random
#define yarrow256_is_seeded nettle_yarrow256_is_seeded
#define yarrow256_needed_sources nettle_yarrow256_needed_sources
-#define yarrow256_force_reseed nettle_yarrow256_force_reseed
+#define yarrow256_fast_reseed nettle_yarrow256_fast_reseed
+#define yarrow256_slow_reseed nettle_yarrow256_slow_reseed
#define yarrow_key_event_init nettle_yarrow_key_event_init
#define yarrow_key_event_estimate nettle_yarrow_key_event_estimate
+/* Obsolete alias for backwards compatibility. Will be deleted in some
+ later version. */
+#define yarrow256_force_reseed yarrow256_slow_reseed
+
enum yarrow_pool_id { YARROW_FAST = 0, YARROW_SLOW = 1 };
struct yarrow_source
/* Indexed by yarrow_pool_id */
struct sha256_ctx pools[2];
- uint8_t seed_file[YARROW256_SEED_FILE_SIZE];
-
int seeded;
/* The current key and counter block */
yarrow256_needed_sources(struct yarrow256_ctx *ctx);
void
-yarrow256_force_reseed(struct yarrow256_ctx *ctx);
+yarrow256_fast_reseed(struct yarrow256_ctx *ctx);
+
+void
+yarrow256_slow_reseed(struct yarrow256_ctx *ctx);
/* Key event estimator */
#define YARROW_MAX_ENTROPY 0x100000
/* Forward declarations */
-
-static void
-yarrow_fast_reseed(struct yarrow256_ctx *ctx);
-
static void
yarrow_gate(struct yarrow256_ctx *ctx);
ctx->seeded = 0;
- /* Not strictly, necessary, but it makes it easier to see if the
+ /* Not strictly necessary, but it makes it easier to see if the
* values are sane. */
- memset(ctx->seed_file, 0, YARROW256_SEED_FILE_SIZE);
memset(ctx->counter, 0, sizeof(ctx->counter));
ctx->nsources = n;
assert(length > 0);
sha256_update(&ctx->pools[YARROW_FAST], length, seed_file);
- yarrow_fast_reseed(ctx);
+ yarrow256_fast_reseed(ctx);
ctx->seeded = 1;
}
/* NOTE: The SHA-256 digest size equals the AES key size, so we need
* no "size adaptor". */
-static void
-yarrow_fast_reseed(struct yarrow256_ctx *ctx)
+void
+yarrow256_fast_reseed(struct yarrow256_ctx *ctx)
{
uint8_t digest[SHA256_DIGEST_SIZE];
unsigned i;
#if YARROW_DEBUG
- fprintf(stderr, "yarrow_fast_reseed\n");
+ fprintf(stderr, "yarrow256_fast_reseed\n");
#endif
/* We feed two block of output using the current key into the pool
/* Reset estimates. */
for (i = 0; i<ctx->nsources; i++)
ctx->sources[i].estimate[YARROW_FAST] = 0;
-
- /* New seed file. */
- /* FIXME: Extract this into a function of its own. */
- for (i = 0; i < sizeof(ctx->seed_file); i+= AES_BLOCK_SIZE)
- yarrow_generate_block(ctx, ctx->seed_file + i);
-
- yarrow_gate(ctx);
}
-static void
-yarrow_slow_reseed(struct yarrow256_ctx *ctx)
+void
+yarrow256_slow_reseed(struct yarrow256_ctx *ctx)
{
uint8_t digest[SHA256_DIGEST_SIZE];
unsigned i;
#if YARROW_DEBUG
- fprintf(stderr, "yarrow_slow_reseed\n");
+ fprintf(stderr, "yarrow256_slow_reseed\n");
#endif
/* Get digest of the slow pool*/
/* Feed it into the fast pool */
sha256_update(&ctx->pools[YARROW_FAST], sizeof(digest), digest);
- yarrow_fast_reseed(ctx);
+ yarrow256_fast_reseed(ctx);
/* Reset estimates. */
for (i = 0; i<ctx->nsources; i++)
#endif
if (source->estimate[YARROW_FAST] >= YARROW_FAST_THRESHOLD)
{
- yarrow_fast_reseed(ctx);
+ yarrow256_fast_reseed(ctx);
return 1;
}
else
{
if (!yarrow256_needed_sources(ctx))
{
- yarrow_slow_reseed(ctx);
+ yarrow256_slow_reseed(ctx);
ctx->seeded = 1;
return 1;
return (k < YARROW_SLOW_K) ? (YARROW_SLOW_K - k) : 0;
}
-
-void
-yarrow256_force_reseed(struct yarrow256_ctx *ctx)
-{
- yarrow_slow_reseed(ctx);
-}