| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Crypt::Perl::Ed25519::PublicKey; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
22
|
use strict; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
99
|
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
126
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=encoding utf-8 |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Crypt::Perl::Ed25519::PublicKey |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# This requires 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
|
|
|
|
|
|
|
# This returns a hash reference, NOT a JSON string. |
|
28
|
|
|
|
|
|
|
my $pub_hr = $key->get_struct_for_public_jwk(); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This class implements Ed25519 verification. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
|
35
|
|
|
|
|
|
|
|
|
36
|
3
|
|
|
3
|
|
17
|
use parent qw( Crypt::Perl::Ed25519::KeyBase ); |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
24
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub new { |
|
39
|
3
|
|
|
3
|
0
|
12
|
my ($class, $pub) = @_; |
|
40
|
|
|
|
|
|
|
|
|
41
|
3
|
|
|
|
|
22
|
$class->_verify_binary_key_part($pub); |
|
42
|
|
|
|
|
|
|
|
|
43
|
3
|
|
|
|
|
31
|
return bless { |
|
44
|
|
|
|
|
|
|
_public => $pub, |
|
45
|
|
|
|
|
|
|
_public_ar => [ unpack 'C*', $pub ], |
|
46
|
|
|
|
|
|
|
}, $class; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
use constant { |
|
50
|
3
|
|
|
|
|
350
|
_PEM_HEADER => 'PUBLIC KEY', |
|
51
|
|
|
|
|
|
|
_ASN1 => q< |
|
52
|
|
|
|
|
|
|
FG_Key ::= SEQUENCE { |
|
53
|
|
|
|
|
|
|
algorithmIdentifier AlgorithmIdentifier, |
|
54
|
|
|
|
|
|
|
subjectPublicKey BIT STRING |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
>, |
|
57
|
3
|
|
|
3
|
|
486
|
}; |
|
|
3
|
|
|
|
|
7
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _to_der_args { |
|
60
|
2
|
|
|
2
|
|
6
|
my ($self) = @_; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return ( |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# The leading bytes are the encoding of the inner CurvePrivateKey |
|
65
|
|
|
|
|
|
|
# (i.e., OCTET STRING). |
|
66
|
2
|
|
|
|
|
16
|
subjectPublicKey => $self->{'_public'}, |
|
67
|
|
|
|
|
|
|
); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |