bug 964: Add check for key size to the Xenroll code
authorMichael Tänzer <neo@nhng.de>
Tue, 24 Jul 2012 22:36:21 +0000 (00:36 +0200)
committerMichael Tänzer <neo@nhng.de>
Tue, 24 Jul 2012 22:36:21 +0000 (00:36 +0200)
Signed-off-by: Michael Tänzer <neo@nhng.de>
www/keygenIE.js

index 51da0ef..7b5aed2 100644 (file)
                /// Get the selected key size
                var getKeySize = function () {
                        var bits = parseInt(keySize.value, 10);
-                       //TODO: check if the bits are sane
+                       if ( bits < getMinSigKeyLength() || bits > getMaxSigKeyLength() ||
+                                       (getStepSigKeyLength() &&
+                                               (bits - getMinSigKeyLength()) %
+                                                       getStepSigKeyLength() !== 0)
+                               )
+                       {
+                               return false;
+                       }
+                       
                        return bits;
                }