From 63ae349e98cf6cc548bd0ba8ba3229f5e6b2e8c3 Mon Sep 17 00:00:00 2001 From: Bill Thorsteinson Date: Thu, 30 Oct 2014 23:10:01 -0400 Subject: [PATCH] Add sha-384 and sha-512 --- CERT.pm | 2 ++ GUI.pm | 6 ++++-- GUI/WORDS.pm | 2 ++ OpenSSL.pm | 24 ++++++++++++++++++++++++ REQ.pm | 4 ++++ 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/CERT.pm b/CERT.pm index a51fa48..588b421 100644 --- a/CERT.pm +++ b/CERT.pm @@ -481,6 +481,8 @@ sub export_cert { $out .= "Fingerprint (MD5): $opts->{'parsed'}->{'FINGERPRINTMD5'}\n"; $out .= "Fingerprint (SHA1): $opts->{'parsed'}->{'FINGERPRINTSHA1'}\n\n"; $out .= "Fingerprint (SHA256): $opts->{'parsed'}->{'FINGERPRINTSHA256'}\n\n"; + $out .= "Fingerprint (SHA384): $opts->{'parsed'}->{'FINGERPRINTSHA384'}\n\n"; + $out .= "Fingerprint (SHA512): $opts->{'parsed'}->{'FINGERPRINTSHA512'}\n\n"; } else { $out = ''; } diff --git a/GUI.pm b/GUI.pm index 27847e2..0805b16 100644 --- a/GUI.pm +++ b/GUI.pm @@ -37,7 +37,9 @@ my %md_algorithms = ( 'ripemd160' => 'RIPEMD-160', # 'sha' => 'SHA', 'sha1' => 'SHA-1', - 'sha256' => 'SHA256', + 'sha256' => 'SHA-256', + 'sha384' => 'SHA-384', + 'sha512' => 'SHA-512', ); my %bit_lengths = ( @@ -1061,7 +1063,7 @@ sub create_detail_tree { $piter = $store->append($root); $store->set($piter, 0 => $t); - for my $l (qw(FINGERPRINTMD5 FINGERPRINTSHA1 FINGERPRINTSHA256)) { + for my $l (qw(FINGERPRINTMD5 FINGERPRINTSHA1 FINGERPRINTSHA256 FINGERPRINTSHA384 FINGERPRINTSHA512)) { if(defined($parsed->{$l})) { $citer = $store->append($piter); $store->set($citer, diff --git a/GUI/WORDS.pm b/GUI/WORDS.pm index cdd67d5..9cb1d35 100644 --- a/GUI/WORDS.pm +++ b/GUI/WORDS.pm @@ -71,6 +71,8 @@ sub new { 'FINGERPRINTMD5' => _("Fingerprint (MD5)"), 'FINGERPRINTSHA1' => _("Fingerprint (SHA1)"), 'FINGERPRINTSHA256' => _("Fingerprint (SHA256)"), + 'FINGERPRINTSHA384' => _("Fingerprint (SHA384)"), + 'FINGERPRINTSHA512' => _("Fingerprint (SHA512)"), _("Not set") => 'none', _("Ask User") => 'user', _("critical") => 'critical', diff --git a/OpenSSL.pm b/OpenSSL.pm index 1775dad..e9f0f21 100644 --- a/OpenSSL.pm +++ b/OpenSSL.pm @@ -686,6 +686,30 @@ sub parsecert { waitpid($pid, 0); $ret = $? >> 8; + $cmd = "$self->{'bin'} x509 -noout -fingerprint -sha384 -in $file"; + $ext = "$cmd\n\n"; + $pid = open3($wtfh, $rdfh, $rdfh, $cmd); + while(<$rdfh>){ + $ext .= $_; + ($k, $v) = split(/=/); + $tmp->{'FINGERPRINTSHA384'} = $v if($k =~ /SHA384 Fingerprint/i); + chomp($tmp->{'FINGERPRINTSHA384'}); + } + waitpid($pid, 0); + $ret = $? >> 8; + + $cmd = "$self->{'bin'} x509 -noout -fingerprint -sha512 -in $file"; + $ext = "$cmd\n\n"; + $pid = open3($wtfh, $rdfh, $rdfh, $cmd); + while(<$rdfh>){ + $ext .= $_; + ($k, $v) = split(/=/); + $tmp->{'FINGERPRINTSHA512'} = $v if($k =~ /SHA512 Fingerprint/i); + chomp($tmp->{'FINGERPRINTSHA512'}); + } + waitpid($pid, 0); + $ret = $? >> 8; + if($ret) { $t = _("Error reading fingerprint from Certificate"); GUI::HELPERS::print_warning($t, $ext); diff --git a/REQ.pm b/REQ.pm index 7dc60ae..86e693e 100644 --- a/REQ.pm +++ b/REQ.pm @@ -428,6 +428,10 @@ sub get_sign_req { $opts->{'digest'} = "sha1"; } elsif ($opts->{'digest'} =~ /^sha256/) { $opts->{'digest'} = "sha256"; + } elsif ($opts->{'digest'} =~ /^sha384/) { + $opts->{'digest'} = "sha384"; + } elsif ($opts->{'digest'} =~ /^sha512/) { + $opts->{'digest'} = "sha512"; } elsif ($opts->{'digest'} =~ /^ripemd160/) { $opts->{'digest'} = "ripemd160"; } else { -- 1.9.1