line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::DKIM::Algorithm::ed25519_sha256; |
2
|
14
|
|
|
14
|
|
96
|
use strict; |
|
14
|
|
|
|
|
30
|
|
|
14
|
|
|
|
|
413
|
|
3
|
14
|
|
|
14
|
|
68
|
use warnings; |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
572
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.20230911'; # VERSION |
5
|
|
|
|
|
|
|
# ABSTRACT: ed25519 sha256 algorithm class |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Copyright 2005-2006 Messiah College. All rights reserved. |
8
|
|
|
|
|
|
|
# Jason Long |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Copyright (c) 2004 Anthony D. Urso. All rights reserved. |
11
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
12
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
13
|
|
|
|
|
|
|
|
14
|
14
|
|
|
14
|
|
75
|
use base 'Mail::DKIM::Algorithm::Base'; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
1301
|
|
15
|
14
|
|
|
14
|
|
89
|
use Carp; |
|
14
|
|
|
|
|
25
|
|
|
14
|
|
|
|
|
779
|
|
16
|
14
|
|
|
14
|
|
83
|
use MIME::Base64; |
|
14
|
|
|
|
|
39
|
|
|
14
|
|
|
|
|
782
|
|
17
|
14
|
|
|
14
|
|
86
|
use Digest::SHA; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
4301
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init_digests { |
20
|
8
|
|
|
8
|
0
|
17
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# initialize a SHA-256 Digest |
23
|
8
|
|
|
|
|
48
|
$self->{header_digest} = new Digest::SHA(256); |
24
|
8
|
|
|
|
|
127
|
$self->{body_digest} = new Digest::SHA(256); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub sign { |
28
|
2
|
|
|
2
|
1
|
5
|
my $self = shift; |
29
|
2
|
50
|
|
|
|
8
|
croak 'wrong number of arguments' unless ( @_ == 1 ); |
30
|
2
|
|
|
|
|
7
|
my ($private_key) = @_; |
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
|
|
13
|
my $digest = $self->{header_digest}->digest; |
33
|
2
|
|
|
|
|
10
|
my $signature = $private_key->sign_digest( 'SHA-256', $digest ); |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
15
|
return encode_base64( $signature, '' ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub verify { |
39
|
3
|
|
|
3
|
1
|
8
|
my $self = shift; |
40
|
3
|
50
|
|
|
|
9
|
croak 'wrong number of arguments' unless ( @_ == 0 ); |
41
|
|
|
|
|
|
|
|
42
|
3
|
|
|
|
|
12
|
my $base64 = $self->signature->data; |
43
|
3
|
|
|
|
|
9
|
my $public_key = $self->signature->get_public_key; |
44
|
|
|
|
|
|
|
|
45
|
3
|
|
|
|
|
23
|
my $digest = $self->{header_digest}->digest; |
46
|
3
|
|
|
|
|
13
|
my $sig = decode_base64($base64); |
47
|
|
|
|
|
|
|
|
48
|
3
|
100
|
|
|
|
9
|
return unless $public_key->verify_digest( 'SHA-256', $digest, $sig ); |
49
|
2
|
|
|
|
|
23
|
return $self->check_body_hash; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub wants_pre_signature_headers { |
53
|
6
|
|
|
6
|
0
|
16
|
return 1; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |