bug 1255: Mixed up variable names for pub/Y, don't calculate the bit size
authorMichael Tänzer <neo@nhng.de>
Sun, 9 Mar 2014 02:47:32 +0000 (03:47 +0100)
committerMichael Tänzer <neo@nhng.de>
Sun, 9 Mar 2014 02:47:32 +0000 (03:47 +0100)
of all variables

Signed-off-by: Michael Tänzer <neo@nhng.de>
includes/lib/check_weak_key.php

index 6628bed..090d66b 100644 (file)
@@ -222,11 +222,7 @@ function checkWeakKeyText($text)
                $num_Q = @gmp_init($key_Q, 16);
                $num_G = @gmp_init($key_G, 16);
 
-               $bit_pub = ltrim(gmp_strval($num_pub, 2), "0");
                $bit_P = ltrim(gmp_strval($num_P, 2), "0");
-               $bit_Q = ltrim(gmp_strval($num_Q, 2), "0");
-               $bit_G = ltrim(gmp_strval($num_G, 2), "0");
-
                $keysize = strlen($bit_P);
 
                if ($keysize < 2048) {
@@ -261,9 +257,9 @@ function checkWeakKeyText($text)
                }
 
                //Check the numbers are all less than the public modulus P
-               if(0 <= gmp_cmp($num_Q, $num_P) || 0 <= gmp_cmp($num_G, $num_P) || 0 <= gmp_cmp($num_Y, $num_P)) {
+               if(0 <= gmp_cmp($num_Q, $num_P) || 0 <= gmp_cmp($num_G, $num_P) || 0 <= gmp_cmp($num_pub, $num_P)) {
                        return failWithId("checkWeakKeyText(): The supplied DSA ".
-                                       "key does seem to be normalized to have Q < P, G < P and Y < P.\nData:\n$text");
+                                       "key does seem to be normalized to have Q < P, G < P and pub < P.\nData:\n$text");
                }
 
                break;