6 use Digest::SHA qw(sha256_hex);
 
  12     "ecdsa-sha2-nistp256" => "3",
 
  18 if (-f "/etc/ssh/ssh_known_hosts")
 
  20     open(HOSTS, "<", "/etc/ssh/ssh_known_hosts") || die $!;
 
  22     while (my $line = <HOSTS>)
 
  24         if ($line =~ /^([^, ]+)\S* (\S+) (\S+)$/)
 
  27             my $algorithm = $algorithms{$2};
 
  28             my $value = uc(sha256_hex(decode_base64($3)));
 
  30             $host =~ s/\.openstreetmap\.org$//;
 
  32             if ($algorithm ne "2")
 
  36                 if (exists($hosts{$host}))
 
  38                     if ($algorithm eq "3")
 
  42                     elsif ($algorithm eq "4" && $hosts{$host}->{algorithm} ne "3")
 
  55                         algorithm => $algorithm,
 
  67 open(SSHFP_JS, ">", "include/sshfp.js") || die $!;
 
  69 print SSHFP_JS qq|var SSHFP_RECORDS = [\n|;
 
  71 foreach my $host (sort keys %hosts)
 
  73     my $algorithm = $hosts{$host}->{algorithm};
 
  74     my $type = $hosts{$host}->{type};
 
  75     my $value = $hosts{$host}->{value};
 
  77     print SSHFP_JS qq|  SSHFP("${host}", ${algorithm}, ${type}, "${value}"),\n|;
 
  80 print SSHFP_JS qq|];\n|;