keyserver/templates/pkslookup.html.ep

137 lines
4.5 KiB
Text
Raw Normal View History

2024-11-11 01:54:24 -08:00
% layout 'default';
% title 'Lookup';
<h1><%= $c->config->{serverh1header} %></h1>
2024-11-11 01:54:24 -08:00
<p><a href="/">index</a></p>
<h2>Search results:</h2>
% for my $item (@{ $c->stash('mydata') }) {
% my $pubkey_fpr = 0;
% my $string;
% my @row = split /\n/, $item;
<pre class="blob">
<%
my %sigcls = (
'0x10' => 'self sig',
'0x11' => 'self sig',
'0x12' => 'self sig',
'0x13' => 'self sig',
'0x18' => 'subkey bind',
'0x19' => 'primary key bind',
'0x20' => 'revocation sig',
'0x28' => 'subkey revocation sig',
'0x30' => 'cert revocation sig',
'0x1F' => 'direct key sig',
);
my $PubKeyAlgos = PubKeyAlgos->new();
my $algo_and_bits = '';
2024-11-11 01:54:24 -08:00
for my $row (@row) {
my @data = split /:/, $row;
my $record = $data[0];
my $flag = $data[1];
my $keylen = $data[2];
my $algo = $data[3];
my $keyid = $data[4];
my $create = $data[5];
my $expire = $data[6];
my $version = $data[7]; # jjakke edition
2024-11-11 01:54:24 -08:00
my $userid = $data[9];
my $signatureclass = $data[10];
my $key_issuer = $data[12]; # jjakke edition
if ($flag and ($flag eq 'e' or $flag eq 'r')) {
$flag = "<span class=\"highlight\">$flag</span>"
}
2024-11-11 01:54:24 -08:00
if ($record eq 'pub') {
no warnings qw(uninitialized numeric); # when debugging, comment this out.
$algo_and_bits = $PubKeyAlgos->valid($algo)->[0] . "/$keylen";
2024-11-11 01:54:24 -08:00
if ($expire) {
$string .= "public key: " . gmtime($create) . " -> " . gmtime($expire) . " | flags: $flag | v:$version\n";
2024-11-11 01:54:24 -08:00
}
else {
$string .= "public key: <span class=\"date\">" . gmtime($create) . " -> n/a" . "</span> | flags: $flag | v:$version\n";
2024-11-11 01:54:24 -08:00
}
}
elsif ($record eq 'fpr') {
$algo_and_bits =~ s/\s+(\(.*\))//;
$algo_and_bits =~ s/\s?public key algorithm\s*//;
2024-11-11 01:54:24 -08:00
if (not $pubkey_fpr) {
$string .= "fingerprint: <a href=\"/pks/lookup?op=get&search=$userid\">$userid</a> | $algo_and_bits\n";
2024-11-11 01:54:24 -08:00
$pubkey_fpr = 1;
}
else {
$string .= "<span class=\"fingerprint\">fingerprint: $userid</span> | $algo_and_bits\n";
2024-11-11 01:54:24 -08:00
}
$algo_and_bits = '';
2024-11-11 01:54:24 -08:00
}
elsif ($record eq 'uid') {
my $safe = Encode::decode_utf8($userid);
2024-11-11 01:54:24 -08:00
$safe =~ s/>/&gt;/g if $safe;
$safe =~ s/</&lt;/g if $safe;
$string .= "\n<strong>$safe</strong>\n" if $safe;
}
elsif ($record eq 'sig') {
no warnings qw(uninitialized numeric); # when debugging, comment this out.
$string .= "signature: ";
# V6 keys 'MUST NOT' create keyids. However, they do have key issuer, which I will create a keyid from (high bits, not low bits like with V4) .
if ($keyid) {
$string .= $keyid
} elsif ($key_issuer and $version == 6) {
$string .= substr($key_issuer,0,16) . "[trun]";
} elsif ($key_issuer and $version == 4) {
$string .= "[trun]" . substr($key_issuer,-16);
}
if ($expire and (int $expire)) {
$string .= " | " . gmtime($create) . " -> ". gmtime($expire) . " | ";
}
else {
$string .= " | <span class=\"date\">" . gmtime($create) . " -> n/a" . "</span> | ";
}
(exists $sigcls{$signatureclass})
? ($string .= $sigcls{$signatureclass})
: ($string .= $signatureclass);
$string .= "\n";
2024-11-11 01:54:24 -08:00
}
elsif ($record eq 'sub') {
no warnings qw(uninitialized numeric); # when debugging, comment this out.
$algo_and_bits = $PubKeyAlgos->valid($algo)->[0] . "/$keylen";
if ($expire) {
if (time > $expire) {
$string .= "\nsub key: " . gmtime($create) . " -> <span class=\"highlight\">" . ( $expire ? gmtime($expire) : 'n/a' ) . "</span> | flags: $flag\n"
}
else {
$string .= "\nsub key: " . gmtime($create) . " -> " . ( $expire ? gmtime($expire) : 'n/a' ) . " | flags: $flag\n"
}
}
else {
$string .= "\nsub key: <span class=\"date\">" . gmtime($create) . " -> " . ( $expire ? gmtime($expire) : 'n/a' ) . "</span> | flags: $flag\n"
}
2024-11-11 01:54:24 -08:00
}
elsif ($record eq 'rev') {
no warnings qw(uninitialized numeric); # when debugging, comment this out.
$string .= "<span class=\"highlight\">revocation: $keyid </span>| " . gmtime($create) . " | ";
(exists $sigcls{$signatureclass})
? ($string .= $sigcls{$signatureclass})
: ($string .= $signatureclass);
$string .= "\n";
2024-11-11 01:54:24 -08:00
}
}
%>
%== $string
</pre>
<%
}
#rev:::1:95660BB822BAC934:1388248001:::::[selfsig]::20x:
#pub:u:255:22:9904E01052985080:1730221618:1856365618::u:,4
#fpr:::::::::50B750CC829A462D016AD9679904E01052985080:
#uid:::::::::Jake Thoughts (jjakke) <jake@jjakke.com>:
#sig:::22:9904E01052985080:1730221618:::::[selfsig]::13x:
#sub:u:255:18:190FCA50206CE28A:1730221618:1856365618:::
#fpr:::::::::B99D79A47141D942494EBCF2190FCA50206CE28A:
#sig:::22:9904E01052985080:1730221618:::::[keybind]::18x:
%>