line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::DKIM::Algorithm::rsa_sha256; |
2
|
14
|
|
|
14
|
|
100
|
use strict; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
441
|
|
3
|
14
|
|
|
14
|
|
69
|
use warnings; |
|
14
|
|
|
|
|
30
|
|
|
14
|
|
|
|
|
617
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.20230911'; # 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
|
|
90
|
use base 'Mail::DKIM::Algorithm::Base'; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
1481
|
|
15
|
14
|
|
|
14
|
|
101
|
use Carp; |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
1019
|
|
16
|
14
|
|
|
14
|
|
105
|
use MIME::Base64; |
|
14
|
|
|
|
|
36
|
|
|
14
|
|
|
|
|
719
|
|
17
|
14
|
|
|
14
|
|
82
|
use Digest::SHA; |
|
14
|
|
|
|
|
49
|
|
|
14
|
|
|
|
|
4560
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init_digests { |
20
|
408
|
|
|
408
|
0
|
681
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# initialize a SHA-256 Digest |
23
|
408
|
|
|
|
|
1317
|
$self->{header_digest} = new Digest::SHA(256); |
24
|
408
|
|
|
|
|
6114
|
$self->{body_digest} = new Digest::SHA(256); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub sign { |
28
|
45
|
|
|
45
|
1
|
78
|
my $self = shift; |
29
|
45
|
50
|
|
|
|
114
|
croak 'wrong number of arguments' unless ( @_ == 1 ); |
30
|
45
|
|
|
|
|
177
|
my ($private_key) = @_; |
31
|
|
|
|
|
|
|
|
32
|
45
|
|
|
|
|
308
|
my $digest = $self->{header_digest}->digest; |
33
|
45
|
|
|
|
|
175
|
my $signature = $private_key->sign_digest( 'SHA-256', $digest ); |
34
|
|
|
|
|
|
|
|
35
|
45
|
|
|
|
|
276
|
return encode_base64( $signature, '' ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub verify { |
39
|
306
|
|
|
306
|
1
|
480
|
my $self = shift; |
40
|
306
|
50
|
|
|
|
736
|
croak 'wrong number of arguments' unless ( @_ == 0 ); |
41
|
|
|
|
|
|
|
|
42
|
306
|
|
|
|
|
869
|
my $base64 = $self->signature->data; |
43
|
306
|
|
|
|
|
848
|
my $public_key = $self->signature->get_public_key; |
44
|
|
|
|
|
|
|
|
45
|
306
|
|
|
|
|
2255
|
my $digest = $self->{header_digest}->digest; |
46
|
306
|
|
|
|
|
1313
|
my $sig = decode_base64($base64); |
47
|
306
|
100
|
|
|
|
837
|
return unless $public_key->verify_digest( 'SHA-256', $digest, $sig ); |
48
|
238
|
|
|
|
|
741
|
return $self->check_body_hash; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub wants_pre_signature_headers { |
52
|
363
|
|
|
363
|
0
|
953
|
return 1; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |