From: fluffymormegil Date: Sun, 10 Oct 2010 20:44:01 +0000 (+0100) Subject: Minor sanity check in dice_setstate X-Git-Tag: v1.0.0~22^2~25 X-Git-Url: http://git.blackswordsonics.com/?a=commitdiff_plain;h=a0c5530174f91de452d675d5aff30c8bba0c9392;p=libmormegil Minor sanity check in dice_setstate --- diff --git a/src/dice.cc b/src/dice.cc index b4b6c31..174d310 100644 --- a/src/dice.cc +++ b/src/dice.cc @@ -58,7 +58,12 @@ extern "C" void dice_setstate(const uint32_t *key, const uint32_t *nonce, const dice_generator.counter = *counter; memcpy(dice_generator.key, key, 8 * sizeof(uint32_t)); memcpy(dice_generator.nonce, nonce, 2 * sizeof(uint32_t)); - dice_generator.subcounter = *subcounter; + dice_generator.subcounter = (*subcounter) & 15; + if (dice_generator.subcounter != 0) + { + /* if the subcounter wasn't zero, the generator will DTwrongT. */ + dice_generator.runstate(); + } } extern "C" void dice_getstate(uint32_t *key, uint32_t *nonce, uint64_t *counter, int *subcounter)