From ef3174f2246ebc49d63abc80ea6be5cc4f0869f4 Mon Sep 17 00:00:00 2001 From: Adam Wick Date: Tue, 28 May 2019 21:02:55 -0700 Subject: [PATCH] Fix an overflow in DSA key generation. --- src/dsa/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dsa/mod.rs b/src/dsa/mod.rs index d71f629..ed16f7f 100644 --- a/src/dsa/mod.rs +++ b/src/dsa/mod.rs @@ -96,7 +96,7 @@ macro_rules! generate_dsa_pair { // strength of requested_security_strength or more. If an ERROR // indication is returned, then return an ERROR indication, // Invalid_x, and Invalid_y. - let returned_bits: Vec = rng.sample_iter(&Standard).take(n + 8).collect(); + let returned_bits: Vec = rng.sample_iter(&Standard).take( (n + 64) / 8 ).collect(); // 5. Convert returned_bits to the (non-negative) integer c. let c = $nbig::from_bytes(&returned_bits); // 6. x = (c mod (q-1)) + 1.