line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::DKIM::Algorithm::rsa_sha1; |
2
|
14
|
|
|
14
|
|
109
|
use strict; |
|
14
|
|
|
|
|
36
|
|
|
14
|
|
|
|
|
442
|
|
3
|
14
|
|
|
14
|
|
96
|
use warnings; |
|
14
|
|
|
|
|
31
|
|
|
14
|
|
|
|
|
666
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.20230212'; # 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
|
|
97
|
use base 'Mail::DKIM::Algorithm::Base'; |
|
14
|
|
|
|
|
43
|
|
|
14
|
|
|
|
|
6830
|
|
15
|
14
|
|
|
14
|
|
111
|
use Carp; |
|
14
|
|
|
|
|
67
|
|
|
14
|
|
|
|
|
753
|
|
16
|
14
|
|
|
14
|
|
118
|
use MIME::Base64; |
|
14
|
|
|
|
|
32
|
|
|
14
|
|
|
|
|
637
|
|
17
|
14
|
|
|
14
|
|
7602
|
use Digest::SHA; |
|
14
|
|
|
|
|
38203
|
|
|
14
|
|
|
|
|
4416
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init_digests { |
20
|
44
|
|
|
44
|
0
|
86
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# initialize a SHA-1 Digest |
23
|
44
|
|
|
|
|
207
|
$self->{header_digest} = Digest::SHA->new(1); |
24
|
44
|
|
|
|
|
688
|
$self->{body_digest} = Digest::SHA->new(1); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub sign { |
28
|
7
|
|
|
7
|
1
|
21
|
my $self = shift; |
29
|
7
|
50
|
|
|
|
18
|
croak 'wrong number of arguments' unless ( @_ == 1 ); |
30
|
7
|
|
|
|
|
16
|
my ($private_key) = @_; |
31
|
|
|
|
|
|
|
|
32
|
7
|
|
|
|
|
34
|
my $digest = $self->{header_digest}->digest; |
33
|
7
|
|
|
|
|
29
|
my $signature = $private_key->sign_digest( 'SHA-1', $digest ); |
34
|
|
|
|
|
|
|
|
35
|
7
|
|
|
|
|
57
|
return encode_base64( $signature, '' ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub verify { |
39
|
22
|
|
|
22
|
1
|
40
|
my $self = shift; |
40
|
22
|
50
|
|
|
|
53
|
croak 'wrong number of arguments' unless ( @_ == 0 ); |
41
|
|
|
|
|
|
|
|
42
|
22
|
|
|
|
|
67
|
my $base64 = $self->signature->data; |
43
|
22
|
|
|
|
|
63
|
my $public_key = $self->signature->get_public_key; |
44
|
|
|
|
|
|
|
|
45
|
22
|
|
|
|
|
94
|
my $sig = decode_base64($base64); |
46
|
22
|
|
|
|
|
138
|
my $digest = $self->{header_digest}->digest; |
47
|
22
|
100
|
|
|
|
69
|
return unless $public_key->verify_digest( 'SHA-1', $digest, $sig ); |
48
|
19
|
|
|
|
|
71
|
return $self->check_body_hash; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub wants_pre_signature_headers { |
52
|
37
|
|
|
37
|
0
|
90
|
return 1; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |