From: rasky Date: Tue, 5 Oct 2010 17:49:39 +0000 (+0000) Subject: SEC: Isaac: change reseeding algorithm by xoring the new seed over the X-Git-Tag: 2.6.0~5^2~105 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=ebd1541f1666aad733559ecd07ce6c04d7e86dcf;p=bertos.git SEC: Isaac: change reseeding algorithm by xoring the new seed over the current context. This allows an initial full seeding. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4415 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/sec/prng/isaac.c b/bertos/sec/prng/isaac.c index 4e031c0b..f3320a54 100644 --- a/bertos/sec/prng/isaac.c +++ b/bertos/sec/prng/isaac.c @@ -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;