← Index
NYTProf Performance Profile   « line view »
For /usr/local/libexec/sympa/task_manager-debug.pl
  Run on Tue Jun 1 22:32:51 2021
Reported on Tue Jun 1 22:35:14 2021

Filename/usr/local/lib/perl5/site_perl/Mail/DKIM/Key.pm
StatementsExecuted 0 statements in 0s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
0000s0sMail::DKIM::Key::::BEGIN@2Mail::DKIM::Key::BEGIN@2
0000s0sMail::DKIM::Key::::BEGIN@3Mail::DKIM::Key::BEGIN@3
0000s0sMail::DKIM::Key::::calculate_EMMail::DKIM::Key::calculate_EM
0000s0sMail::DKIM::Key::::corkMail::DKIM::Key::cork
0000s0sMail::DKIM::Key::::dataMail::DKIM::Key::data
0000s0sMail::DKIM::Key::::errorstrMail::DKIM::Key::errorstr
0000s0sMail::DKIM::Key::::sizeMail::DKIM::Key::size
0000s0sMail::DKIM::Key::::typeMail::DKIM::Key::type
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Mail::DKIM::Key;
2use strict;
3use warnings;
4# ABSTRACT: Represents a DKIM Key
5our $VERSION = '1.20200907'; # VERSION
6
7# Copyright 2006 Jason Long. All rights reserved.
8#
9# Copyright (c) 2004 Anthony D. Urso. All rights reserved.
10# This program is free software; you can redistribute it and/or
11# modify it under the same terms as Perl itself.
12
13sub cork {
14 my $self = shift;
15
16 (@_)
17 and $self->{'CORK'} = shift;
18
19 $self->{'CORK'}
20 or $self->convert;
21
22 $self->{'CORK'};
23}
24
25sub data {
26 my $self = shift;
27
28 (@_)
29 and $self->{'DATA'} = shift;
30
31 $self->{'DATA'};
32}
33
34sub errorstr {
35 my $self = shift;
36
37 (@_)
38 and $self->{'ESTR'} = shift;
39
40 $self->{'ESTR'};
41}
42
43sub size {
44 my $self = shift;
45
46 return $self->cork->size * 8;
47}
48
49sub type {
50 my $self = shift;
51
52 (@_)
53 and $self->{'TYPE'} = shift;
54
55 $self->{'TYPE'};
56}
57
58sub calculate_EM {
59 my ( $digest_algorithm, $digest, $emLen ) = @_;
60
61 # this function performs DER encoding of the algorithm ID for the
62 # hash function and the hash value itself
63 # It has this syntax:
64 # DigestInfo ::= SEQUENCE {
65 # digestAlgorithm AlgorithmIdentifier,
66 # digest OCTET STRING
67 # }
68
69 # RFC 3447, page 42, provides the following octet values:
70 my %digest_encoding = (
71 'SHA-1' => pack( 'H*', '3021300906052B0E03021A05000414' ),
72 'SHA-256' => pack( 'H*', '3031300d060960864801650304020105000420' ),
73 );
74
75 defined $digest_encoding{$digest_algorithm}
76 or die "Unsupported digest algorithm '$digest_algorithm'";
77
78 my $T = $digest_encoding{$digest_algorithm} . $digest;
79 my $tLen = length($T);
80
81 if ( $emLen < $tLen + 11 ) {
82 die 'Intended encoded message length too short.';
83 }
84
85 my $PS = chr(0xff) x ( $emLen - $tLen - 3 );
86 my $EM = chr(0) . chr(1) . $PS . chr(0) . $T;
87 return $EM;
88}
89
901;
91
92__END__