line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mail::DKIM::Algorithm::rsa_sha1; |
2
|
14
|
|
|
14
|
|
110
|
use strict; |
|
14
|
|
|
|
|
77
|
|
|
14
|
|
|
|
|
465
|
|
3
|
14
|
|
|
14
|
|
85
|
use warnings; |
|
14
|
|
|
|
|
4893
|
|
|
14
|
|
|
|
|
705
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.20230630'; # 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
|
|
95
|
use base 'Mail::DKIM::Algorithm::Base'; |
|
14
|
|
|
|
|
49
|
|
|
14
|
|
|
|
|
6722
|
|
15
|
14
|
|
|
14
|
|
93
|
use Carp; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
680
|
|
16
|
14
|
|
|
14
|
|
81
|
use MIME::Base64; |
|
14
|
|
|
|
|
25
|
|
|
14
|
|
|
|
|
571
|
|
17
|
14
|
|
|
14
|
|
7730
|
use Digest::SHA; |
|
14
|
|
|
|
|
39122
|
|
|
14
|
|
|
|
|
4286
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub init_digests { |
20
|
44
|
|
|
44
|
0
|
72
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# initialize a SHA-1 Digest |
23
|
44
|
|
|
|
|
218
|
$self->{header_digest} = Digest::SHA->new(1); |
24
|
44
|
|
|
|
|
666
|
$self->{body_digest} = Digest::SHA->new(1); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub sign { |
28
|
7
|
|
|
7
|
1
|
15
|
my $self = shift; |
29
|
7
|
50
|
|
|
|
18
|
croak 'wrong number of arguments' unless ( @_ == 1 ); |
30
|
7
|
|
|
|
|
14
|
my ($private_key) = @_; |
31
|
|
|
|
|
|
|
|
32
|
7
|
|
|
|
|
39
|
my $digest = $self->{header_digest}->digest; |
33
|
7
|
|
|
|
|
27
|
my $signature = $private_key->sign_digest( 'SHA-1', $digest ); |
34
|
|
|
|
|
|
|
|
35
|
7
|
|
|
|
|
53
|
return encode_base64( $signature, '' ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub verify { |
39
|
22
|
|
|
22
|
1
|
42
|
my $self = shift; |
40
|
22
|
50
|
|
|
|
50
|
croak 'wrong number of arguments' unless ( @_ == 0 ); |
41
|
|
|
|
|
|
|
|
42
|
22
|
|
|
|
|
63
|
my $base64 = $self->signature->data; |
43
|
22
|
|
|
|
|
57
|
my $public_key = $self->signature->get_public_key; |
44
|
|
|
|
|
|
|
|
45
|
22
|
|
|
|
|
85
|
my $sig = decode_base64($base64); |
46
|
22
|
|
|
|
|
136
|
my $digest = $self->{header_digest}->digest; |
47
|
22
|
100
|
|
|
|
82
|
return unless $public_key->verify_digest( 'SHA-1', $digest, $sig ); |
48
|
19
|
|
|
|
|
61
|
return $self->check_body_hash; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub wants_pre_signature_headers { |
52
|
37
|
|
|
37
|
0
|
94
|
return 1; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |