X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/79bc45d029fd0283e76c3774070ec05710351ce9..2b18034e2e663f9483327c02d2088ceb46c23471:/rand/rand.c diff --git a/rand/rand.c b/rand/rand.c index 5cca087e..304c68dc 100644 --- a/rand/rand.c +++ b/rand/rand.c @@ -304,6 +304,8 @@ void rand_gate(rand_pool *r) HASH_CTX hc; CIPHER_CTX cc; + STATIC_ASSERT(CIPHER_KEYSZ <= HASH_SZ, "rand cipher keysize too long"); + RAND_RESOLVE(r); QUICK(r); @@ -311,6 +313,7 @@ void rand_gate(rand_pool *r) HASH_INIT(&hc); STORE32(g, r->gen); HASH(&hc, g, sizeof(g)); + HASH(&hc, r->k.k, RAND_KEYSZ); HASH(&hc, r->pool, RAND_POOLSZ); HASH(&hc, r->buf, RAND_BUFSZ); HASH_DONE(&hc, h); @@ -318,7 +321,6 @@ void rand_gate(rand_pool *r) /* --- Now mangle all of the data based on the hash --- */ - assert(CIPHER_KEYSZ <= HASH_SZ); CIPHER_INIT(&cc, h, CIPHER_KEYSZ, 0); CIPHER_ENCRYPT(&cc, r->pool, r->pool, RAND_POOLSZ); CIPHER_ENCRYPT(&cc, r->buf, r->buf, RAND_BUFSZ); @@ -354,6 +356,8 @@ void rand_stretch(rand_pool *r) HASH_CTX hc; CIPHER_CTX cc; + STATIC_ASSERT(CIPHER_KEYSZ <= HASH_SZ, "rand cipher keysize too long"); + RAND_RESOLVE(r); QUICK(r); @@ -361,6 +365,7 @@ void rand_stretch(rand_pool *r) HASH_INIT(&hc); STORE32(g, r->gen); HASH(&hc, g, sizeof(g)); + HASH(&hc, r->k.k, RAND_KEYSZ); HASH(&hc, r->pool, RAND_POOLSZ); HASH(&hc, r->buf, RAND_BUFSZ); HASH_DONE(&hc, h); @@ -368,7 +373,6 @@ void rand_stretch(rand_pool *r) /* --- Now mangle the buffer based on the hash --- */ - assert(CIPHER_KEYSZ <= HASH_SZ); CIPHER_INIT(&cc, h, CIPHER_KEYSZ, 0); CIPHER_ENCRYPT(&cc, r->buf, r->buf, RAND_BUFSZ); BURN(cc);