Skip to content

Commit

Permalink
Report size of RSA modulus when it is shorter than 2048 bits.
Browse files Browse the repository at this point in the history
  • Loading branch information
iay committed Nov 15, 2012
1 parent adbfc47 commit 701f509
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions build/check_authorities.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
use Date::Parse;
use Digest::SHA1 qw(sha1 sha1_hex sha1_base64);

sub error {
my($s) = @_;
print ' *** ' . $s . ' ***';
}

sub warning {
my ($s) = @_;
print ' ' . $s;
}

sub comment {
my($s) = @_;
print ' (' . $s . ')';
}

#
# Load RSA key blacklists.
#
Expand All @@ -29,7 +44,7 @@
if (/BEGIN CERTIFICATE/) {

#
# Output header line.
# Output header line.
#
print "Authority certificate:\n";

Expand Down Expand Up @@ -61,7 +76,7 @@
#

#
# Use openssl to convert the certificate to text
# Use openssl to convert the certificate to text
#
my(@lines, $issuer, $subjectCN, $issuerCN, $pubSize);
$cmd = "openssl x509 -in $filename -noout -text -nameopt RFC2253 -modulus |";
Expand All @@ -83,16 +98,20 @@
#
if (/RSA Public Key: \((\d+) bit\)/) { # OpenSSL 0.9x
$pubSize = $1;
# print " Public key size: $pubSize\n";
# print " Public key size: $pubSize\n";
if ($pubSize < 1024) {
error('PUBLIC KEY TOO SHORT');
} elsif ($pubSize < 2048) {
warning("short public key of $pubSize bits");
}
next;
} elsif (/^\s*Public-Key: \((\d+) bit\)/) { # OpenSSL 1.0
$pubSize = $1;
# print " Public key size: $pubSize\n";
# print " Public key size: $pubSize\n";
if ($pubSize < 1024) {
error('PUBLIC KEY TOO SHORT');
} elsif ($pubSize < 2048) {
warning("short public key of $pubSize bits");
}
next;
}
Expand Down Expand Up @@ -138,7 +157,7 @@
#
if (/Exponent: (\d+)/) {
$exponent = $1;
# print " exponent: $exponent\n";
# print " exponent: $exponent\n";
if (($exponent & 1) == 0) {
error("RSA public exponent $exponent is even");
} elsif ($exponent <= 3) {
Expand Down

0 comments on commit 701f509

Please sign in to comment.