line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::DKIM::Algorithm::rsa_sha256; |
2
|
14
|
|
|
14
|
|
99
|
use strict; |
|
14
|
|
|
|
|
41
|
|
|
14
|
|
|
|
|
441
|
|
3
|
14
|
|
|
14
|
|
73
|
use warnings; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
581
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.20230212'; # 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
|
|
105
|
use base 'Mail::DKIM::Algorithm::Base'; |
|
14
|
|
|
|
|
56
|
|
|
14
|
|
|
|
|
1596
|
|
15
|
14
|
|
|
14
|
|
98
|
use Carp; |
|
14
|
|
|
|
|
40
|
|
|
14
|
|
|
|
|
763
|
|
16
|
14
|
|
|
14
|
|
98
|
use MIME::Base64; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
691
|
|
17
|
14
|
|
|
14
|
|
90
|
use Digest::SHA; |
|
14
|
|
|
|
|
36
|
|
|
14
|
|
|
|
|
4243
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init_digests { |
20
|
408
|
|
|
408
|
0
|
764
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# initialize a SHA-256 Digest |
23
|
408
|
|
|
|
|
1323
|
$self->{header_digest} = new Digest::SHA(256); |
24
|
408
|
|
|
|
|
5676
|
$self->{body_digest} = new Digest::SHA(256); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub sign { |
28
|
45
|
|
|
45
|
1
|
110
|
my $self = shift; |
29
|
45
|
50
|
|
|
|
144
|
croak 'wrong number of arguments' unless ( @_ == 1 ); |
30
|
45
|
|
|
|
|
107
|
my ($private_key) = @_; |
31
|
|
|
|
|
|
|
|
32
|
45
|
|
|
|
|
286
|
my $digest = $self->{header_digest}->digest; |
33
|
45
|
|
|
|
|
187
|
my $signature = $private_key->sign_digest( 'SHA-256', $digest ); |
34
|
|
|
|
|
|
|
|
35
|
45
|
|
|
|
|
303
|
return encode_base64( $signature, '' ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub verify { |
39
|
306
|
|
|
306
|
1
|
569
|
my $self = shift; |
40
|
306
|
50
|
|
|
|
675
|
croak 'wrong number of arguments' unless ( @_ == 0 ); |
41
|
|
|
|
|
|
|
|
42
|
306
|
|
|
|
|
926
|
my $base64 = $self->signature->data; |
43
|
306
|
|
|
|
|
784
|
my $public_key = $self->signature->get_public_key; |
44
|
|
|
|
|
|
|
|
45
|
306
|
|
|
|
|
2116
|
my $digest = $self->{header_digest}->digest; |
46
|
306
|
|
|
|
|
1260
|
my $sig = decode_base64($base64); |
47
|
306
|
100
|
|
|
|
959
|
return unless $public_key->verify_digest( 'SHA-256', $digest, $sig ); |
48
|
238
|
|
|
|
|
745
|
return $self->check_body_hash; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub wants_pre_signature_headers { |
52
|
363
|
|
|
363
|
0
|
924
|
return 1; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |