/usr/share/perl5/Protocol/ACME/Key.pm is in libprotocol-acme-perl 1.01-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | package Protocol::ACME::Key;
# A shim that imitates Crypt::OpenSSL::RSA.
use strict;
use warnings;
our $VERSION = '1.01';
use Crypt::RSA::Parse;
use Math::BigInt ();
use Protocol::ACME::Utils;
sub new
{
my ($class, %opts) = @_;
my $key = Crypt::RSA::Parse::private($opts{'keystring'});
my $self = {
_keystring => $opts{'keystring'},
_openssl_bin => $opts{'openssl'},
_private_key => $key,
e => Math::BigInt->new( $key->publicExponent() ),
n => $key->modulus(),
};
return bless $self, $class;
}
sub use_sha256_hash
{
# NOOP for compatibility with Crypt::OpenSSL::RSA
}
sub get_key_parameters
{
my $self = shift;
return ( $self->{n}, $self->{e} );
}
sub sign {
my ($self, $payload) = @_;
#TODO: Use an available SHA256-digest module, if any.
$self->{'_openssl'} ||= do {
require Protocol::ACME::OpenSSL;
Protocol::ACME::OpenSSL->new($self->{'_openssl_bin'});
};
require File::Temp;
my $fh = File::Temp->new();
my $kpath = $fh->filename();
print {$fh} $self->{'_keystring'} or die "write($kpath) failed: $!";
close $fh or die "close($kpath) failed: $!";
return $self->{'_openssl'}->run(
command => [
'dgst',
'-sha256',
'-binary',
'-sign' => $kpath,
],
stdin => $payload,
);
}
1;
|