| 1 | package Crypt::Perl::Ed25519::PublicKey; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 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 | ▶ | use parent qw( Crypt::Perl::Ed25519::KeyBase ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 34 | |||
| 35 | sub new { | ||
| 36 | 2 | ▶ | my ($class, $pub) = @_; |
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 37 | |||
| 38 | 2 | return bless { | |
| 39 | _public => $pub, | ||
| 40 | _public_ar => [ unpack 'C*', $pub ], | ||
| 41 | }, $class; | ||
| 42 | } | ||
| 43 | |||
| 44 | use constant { | ||
| 45 | 1 | _PEM_HEADER => 'PUBLIC KEY', | |
| 46 | _ASN1 => q< | ||
| 47 | FG_Key ::= SEQUENCE { | ||
| 48 | algorithmIdentifier AlgorithmIdentifier, | ||
| 49 | subjectPublicKey BIT STRING | ||
| 50 | } | ||
| 51 | >, | ||
| 52 | 1 | ▶ | }; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 53 | |||
| 54 | sub _to_der_args { | ||
| 55 | 1 | ▶ | my ($self) = @_; |
|
Subroutine
_to_der_args: called CC=1 SCAR=0.0
| |||
| 56 | |||
| 57 | return ( | ||
| 58 | |||
| 59 | # The leading bytes are the encoding of the inner CurvePrivateKey | ||
| 60 | # (i.e., OCTET STRING). | ||
| 61 | 1 | subjectPublicKey => $self->{'_public'}, | |
| 62 | ); | ||
| 63 | } | ||
| 64 | |||
| 65 | 1 | 1; | |