line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::DKIM::Algorithm::rsa_sha256; |
2
|
14
|
|
|
14
|
|
99
|
use strict; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
452
|
|
3
|
14
|
|
|
14
|
|
73
|
use warnings; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
669
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.20230630'; # VERSION |
5
|
|
|
|
|
|
|
# ABSTRACT: rsa 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
|
|
80
|
use base 'Mail::DKIM::Algorithm::Base'; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
1441
|
|
15
|
14
|
|
|
14
|
|
98
|
use Carp; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
907
|
|
16
|
14
|
|
|
14
|
|
141
|
use MIME::Base64; |
|
14
|
|
|
|
|
44
|
|
|
14
|
|
|
|
|
748
|
|
17
|
14
|
|
|
14
|
|
86
|
use Digest::SHA; |
|
14
|
|
|
|
|
25
|
|
|
14
|
|
|
|
|
4367
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init_digests { |
20
|
408
|
|
|
408
|
0
|
630
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# initialize a SHA-256 Digest |
23
|
408
|
|
|
|
|
1270
|
$self->{header_digest} = new Digest::SHA(256); |
24
|
408
|
|
|
|
|
5949
|
$self->{body_digest} = new Digest::SHA(256); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub sign { |
28
|
45
|
|
|
45
|
1
|
82
|
my $self = shift; |
29
|
45
|
50
|
|
|
|
128
|
croak 'wrong number of arguments' unless ( @_ == 1 ); |
30
|
45
|
|
|
|
|
167
|
my ($private_key) = @_; |
31
|
|
|
|
|
|
|
|
32
|
45
|
|
|
|
|
306
|
my $digest = $self->{header_digest}->digest; |
33
|
45
|
|
|
|
|
159
|
my $signature = $private_key->sign_digest( 'SHA-256', $digest ); |
34
|
|
|
|
|
|
|
|
35
|
45
|
|
|
|
|
286
|
return encode_base64( $signature, '' ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub verify { |
39
|
306
|
|
|
306
|
1
|
496
|
my $self = shift; |
40
|
306
|
50
|
|
|
|
685
|
croak 'wrong number of arguments' unless ( @_ == 0 ); |
41
|
|
|
|
|
|
|
|
42
|
306
|
|
|
|
|
924
|
my $base64 = $self->signature->data; |
43
|
306
|
|
|
|
|
804
|
my $public_key = $self->signature->get_public_key; |
44
|
|
|
|
|
|
|
|
45
|
306
|
|
|
|
|
2098
|
my $digest = $self->{header_digest}->digest; |
46
|
306
|
|
|
|
|
1301
|
my $sig = decode_base64($base64); |
47
|
306
|
100
|
|
|
|
815
|
return unless $public_key->verify_digest( 'SHA-256', $digest, $sig ); |
48
|
238
|
|
|
|
|
717
|
return $self->check_body_hash; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub wants_pre_signature_headers { |
52
|
363
|
|
|
363
|
0
|
903
|
return 1; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |