Skip to content

Commit b737e9d

Browse files
committed
bug fix: XDRBG - set initially seeded flag after seed operation was successful
Only set the initially seeded flag after all seeding steps were successful. A caller could provide a too long personalization string which would trigger an error where yet the XDRBG thinks it is initially seeded. This is a bug fix. Yet, the caller receives an error during initially seeding in this case and should process it properly. If he tries to reseed with proper data, the resulting state of the XDRBG is cryptographically secure but it may not be the state defined after an initial seeding operation. Thus, it is considered a bug, but no security issue. Reported-by: Conner Webber Signed-off-by: Stephan Mueller <[email protected]>
1 parent 4e46730 commit b737e9d

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎CHANGES.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ Changes 1.9.0-prerelease
4747

4848
* bug fix: lc_memcmp_secure returns negative error on string mismatch to align its return code with the rest of leancrypto (reported by Conner Webber)
4949

50-
* bug fix: GCM contains a buffer overflow potentially writing zeros beyond a caller buffer upon GCM decrypt with an oversized tag length
50+
* bug fix: GCM contains a buffer overflow potentially writing zeros beyond a caller buffer upon GCM decrypt with an oversized tag length (reported by Conner Webber)
51+
52+
* bug fix: Treat XDRBG initially seeded only after all seeding steps are successful (reported by Conner Webber)
5153

5254
Changes 1.8.0
5355
* X.509: provide a common automated serial number generator which is the 20 leftmost bytes of the SHA3-256 hash of the certificate DER blob with the serial number being 20 bytes of 0xff and the signature part equally a range of 0xff bytes

‎drng/src/xdrbg.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ int lc_xdrbg_drng_seed_nocheck(void *_state, const uint8_t *seed,
259259
*/
260260
if (initially_seeded)
261261
lc_hash_update(xof_ctx, state->v, keysize);
262-
else
263-
state->status |= LC_XDRBG_DRNG_INITIALLY_SEEDED;
264262

265263
/* Insert the seed data into the XOF state. */
266264
lc_hash_update(xof_ctx, seed, seedlen);
@@ -273,6 +271,9 @@ int lc_xdrbg_drng_seed_nocheck(void *_state, const uint8_t *seed,
273271
/* Generate the V to store in the state and overwrite V'. */
274272
lc_xdrbg_xof_final(xof_ctx, state->v, keysize);
275273

274+
/* At this point, we are initially seeded (this is a noop on reseed) */
275+
state->status |= LC_XDRBG_DRNG_INITIALLY_SEEDED;
276+
276277
out:
277278
/* Clear the XOF state which is not needed any more. */
278279
lc_hash_zero(xof_ctx);

0 commit comments

Comments
 (0)