SEC: Isaac: change reseeding algorithm by xoring the new seed over the
authorrasky <rasky@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 5 Oct 2010 17:49:39 +0000 (17:49 +0000)
committerrasky <rasky@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 5 Oct 2010 17:49:39 +0000 (17:49 +0000)
current context. This allows an initial full seeding.

git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4415 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/sec/prng/isaac.c

index 4e031c0be5d9a36d234088b8a39cd460a8a721d1..f3320a5469fbe3ff426a2e566d1b7ab527bf34f0 100644 (file)
@@ -107,9 +107,9 @@ static void isaac_reseed(PRNG *ctx_, const uint8_t *seed)
        ub4 a,b,c,d,e,f,g,h;
        ub4 *m,*r;
 
-       // Copy seed over half of randrsl, to reuse half of last-generated
-       // data as seed.
-       memcpy(ctx->randrsl, seed, sizeof(ctx->randrsl)/2);
+       // XOR the new seed over the current state, so to depend on
+       // the previously-generated output.
+       xor_block(ctx->randrsl, ctx->randrsl, seed, sizeof(ctx->randrsl));
 
        ctx->randa = ctx->randb = ctx->randc = 0;
        m=ctx->randmem;
@@ -172,7 +172,7 @@ void isaac_init(IsaacContext *ctx)
 {
        ctx->prng.reseed = isaac_reseed;
        ctx->prng.generate = isaac_generate;
-       ctx->prng.seed_len = sizeof(ctx->randrsl) / 2;
+       ctx->prng.seed_len = sizeof(ctx->randrsl);
        ctx->prng.seeded = 0;
 
        ctx->randcnt = CONFIG_ISAAC_RANDSIZ*4;