line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::Perl::Ed25519::PublicKey; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=encoding utf-8 |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Crypt::Perl::Ed25519::PublicKey |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# This expects an octet string. |
15
|
|
|
|
|
|
|
my $import_key = Crypt::Perl::Ed25519::PublicKey->new( $pub_str ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$key->verify( $message, $signature ) or die "Invalid sig for msg!"; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Returns an octet string. |
22
|
|
|
|
|
|
|
my $pub_str = $key->get_public(); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Returns an object |
25
|
|
|
|
|
|
|
my $pub_obj = $key->get_public_key(); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This class implements Ed25519 verification. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
1
|
|
4
|
use parent qw( Crypt::Perl::Ed25519::KeyBase ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
36
|
2
|
|
|
2
|
0
|
3
|
my ($class, $pub) = @_; |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
13
|
return bless { |
39
|
|
|
|
|
|
|
_public => $pub, |
40
|
|
|
|
|
|
|
_public_ar => [ unpack 'C*', $pub ], |
41
|
|
|
|
|
|
|
}, $class; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
use constant { |
45
|
1
|
|
|
|
|
102
|
_PEM_HEADER => 'PUBLIC KEY', |
46
|
|
|
|
|
|
|
_ASN1 => q< |
47
|
|
|
|
|
|
|
FG_Key ::= SEQUENCE { |
48
|
|
|
|
|
|
|
algorithmIdentifier AlgorithmIdentifier, |
49
|
|
|
|
|
|
|
subjectPublicKey BIT STRING |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
>, |
52
|
1
|
|
|
1
|
|
114
|
}; |
|
1
|
|
|
|
|
7
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _to_der_args { |
55
|
1
|
|
|
1
|
|
2
|
my ($self) = @_; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
return ( |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# The leading bytes are the encoding of the inner CurvePrivateKey |
60
|
|
|
|
|
|
|
# (i.e., OCTET STRING). |
61
|
1
|
|
|
|
|
6
|
subjectPublicKey => $self->{'_public'}, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |