line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::DKIM::Algorithm::rsa_sha1; |
2
|
14
|
|
|
14
|
|
122
|
use strict; |
|
14
|
|
|
|
|
42
|
|
|
14
|
|
|
|
|
459
|
|
3
|
14
|
|
|
14
|
|
106
|
use warnings; |
|
14
|
|
|
|
|
4896
|
|
|
14
|
|
|
|
|
695
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.20230911'; # VERSION |
5
|
|
|
|
|
|
|
# ABSTRACT: rsa sha1 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
|
|
103
|
use base 'Mail::DKIM::Algorithm::Base'; |
|
14
|
|
|
|
|
48
|
|
|
14
|
|
|
|
|
6928
|
|
15
|
14
|
|
|
14
|
|
97
|
use Carp; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
721
|
|
16
|
14
|
|
|
14
|
|
81
|
use MIME::Base64; |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
535
|
|
17
|
14
|
|
|
14
|
|
8039
|
use Digest::SHA; |
|
14
|
|
|
|
|
40205
|
|
|
14
|
|
|
|
|
4447
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init_digests { |
20
|
44
|
|
|
44
|
0
|
77
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# initialize a SHA-1 Digest |
23
|
44
|
|
|
|
|
210
|
$self->{header_digest} = Digest::SHA->new(1); |
24
|
44
|
|
|
|
|
656
|
$self->{body_digest} = Digest::SHA->new(1); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub sign { |
28
|
7
|
|
|
7
|
1
|
16
|
my $self = shift; |
29
|
7
|
50
|
|
|
|
22
|
croak 'wrong number of arguments' unless ( @_ == 1 ); |
30
|
7
|
|
|
|
|
17
|
my ($private_key) = @_; |
31
|
|
|
|
|
|
|
|
32
|
7
|
|
|
|
|
47
|
my $digest = $self->{header_digest}->digest; |
33
|
7
|
|
|
|
|
32
|
my $signature = $private_key->sign_digest( 'SHA-1', $digest ); |
34
|
|
|
|
|
|
|
|
35
|
7
|
|
|
|
|
55
|
return encode_base64( $signature, '' ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub verify { |
39
|
22
|
|
|
22
|
1
|
36
|
my $self = shift; |
40
|
22
|
50
|
|
|
|
58
|
croak 'wrong number of arguments' unless ( @_ == 0 ); |
41
|
|
|
|
|
|
|
|
42
|
22
|
|
|
|
|
60
|
my $base64 = $self->signature->data; |
43
|
22
|
|
|
|
|
64
|
my $public_key = $self->signature->get_public_key; |
44
|
|
|
|
|
|
|
|
45
|
22
|
|
|
|
|
93
|
my $sig = decode_base64($base64); |
46
|
22
|
|
|
|
|
130
|
my $digest = $self->{header_digest}->digest; |
47
|
22
|
100
|
|
|
|
67
|
return unless $public_key->verify_digest( 'SHA-1', $digest, $sig ); |
48
|
19
|
|
|
|
|
69
|
return $self->check_body_hash; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub wants_pre_signature_headers { |
52
|
37
|
|
|
37
|
0
|
102
|
return 1; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |