| 1 | package Mail::DKIM::Signer; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | our $VERSION = '1.20261116'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: generates a DKIM signature for a message | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # Copyright 2005-2007 Messiah College. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # Jason Long <jlong@messiah.edu> | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | 6 | ▶ | use Mail::DKIM::PrivateKey; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 6 | ▶ | use Mail::DKIM::Signature; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 6 | ▶ | use base 'Mail::DKIM::Common'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 6 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # PROPERTIES | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # public: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # $dkim->{Algorithm} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # identifies what algorithm to use when signing the message | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # default is "rsa-sha1" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # $dkim->{Domain} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # identifies what domain the message is signed for | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # $dkim->{KeyFile} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # name of the file containing the private key used to sign | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # $dkim->{Method} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # identifies what canonicalization method to use when signing | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # the message. default is "relaxed" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # $dkim->{Policy} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # a signing policy (of type Mail::DKIM::SigningPolicy) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # $dkim->{Selector} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # identifies name of the selector identifying the key | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # $dkim->{Key} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # the loaded private key | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # private: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # $dkim->{algorithms} = [] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # an array of algorithm objects... an algorithm object is created for | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # each signature being added to the message | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | # $dkim->{result} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # result of the signing policy: "signed" or "skipped" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # $dkim->{signature} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # the created signature (of type Mail::DKIM::Signature) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 25 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 25 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 25 | $self->SUPER::init; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 25 | ▶ | unless ( $self->{'Algorithm'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # use default algorithm | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 10 | $self->{'Algorithm'} = 'rsa-sha1'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 25 | my $type = 'rsa'; # default | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 25 | ▶ | $type = 'ed25519' if ( $self->{'Algorithm'} =~ /^ed25519/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 25 | ▶ | if ( defined $self->{KeyFile} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | $self->{Key} ||= | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | Mail::DKIM::PrivateKey->load( File => $self->{KeyFile}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 23 | ▶ | Type => $type ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"Key"} ||= "Mail::DKIM::PrivateKey"->load("File", $self->{"KeyFile"}, "Type", $type)
MC/DC0%0/2
$self->{"Key"} ||= "Mail::DKIM::PrivateKey"->load("File", $self->{"KeyFile"}, "Type", $type)
$self->{"Key"}
"Mail::DKIM::PrivateKey"->load("File", $self->{"KeyFile"}, "Type", $type)
Truth table33%1/3
A ||= B
A= $self->{"Key"}B= "Mail::DKIM::PrivateKey"->load("File", $self->{"KeyFile"}, "Type", $type)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 23 | ▶ | unless ( $self->{'Method'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # use default canonicalization method | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 10 | $self->{'Method'} = 'relaxed'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 23 | ▶ | unless ( $self->{'Domain'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # use default domain | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 10 | $self->{'Domain'} = 'example.org'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 23 | ▶ | unless ( $self->{'Selector'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # use default selector | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 10 | $self->{'Selector'} = 'unknown'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 23 | ▶ | sub finish_header { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finish_header: called CC=19 SCAR=31.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 23 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 23 | $self->{algorithms} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 23 | my $policy = $self->{Policy}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 23 | ▶ | if ( UNIVERSAL::isa( $policy, 'CODE' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # policy is a subroutine ref | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 8 | my $default_sig = $policy->($self); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 8 | ▶ | unless ( @{ $self->{algorithms} } || $default_sig ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@{$self->{"algorithms"};} or $default_sig
MC/DC100%2/2
@{$self->{"algorithms"};} or $default_sig
@{$self->{"algorithms"};}
$default_sig
Truth table100%3/3
A or B
A= @{$self->{"algorithms"};}B= $default_sig
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | $self->{'result'} = 'skipped'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | ▶ | elsif ( $policy && $policy->can('apply') ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$policy and $policy->can("apply")
MC/DC50%1/2
$policy and $policy->can("apply")
$policy
$policy->can("apply")
Truth table66%2/3
A and B
A= $policyB= $policy->can("apply")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # policy is a Perl object or class | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | my $default_sig = $policy->apply($self); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | ▶ | unless ( @{ $self->{algorithms} } || $default_sig ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@{$self->{"algorithms"};} or $default_sig
MC/DC0%0/2
@{$self->{"algorithms"};} or $default_sig
@{$self->{"algorithms"};}
$default_sig
Truth table33%1/3
A or B
A= @{$self->{"algorithms"};}B= $default_sig
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $self->{'result'} = 'skipped'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 22 | ▶ | unless ( @{ $self->{algorithms} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # no algorithms were created yet, so construct a signature | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # using the current signature properties | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # check properties | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 16 | ▶ | unless ( $self->{'Algorithm'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | die 'invalid algorithm property'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 16 | ▶ | unless ( $self->{'Method'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | die 'invalid method property'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 16 | ▶ | unless ( $self->{'Domain'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | die 'invalid domain property'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 16 | ▶ | unless ( $self->{'Selector'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | die 'invalid selector property'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | $self->add_signature( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | Mail::DKIM::Signature->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | Algorithm => $self->{'Algorithm'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | Method => $self->{'Method'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | Headers => $self->headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | Domain => $self->{'Domain'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | Selector => $self->{'Selector'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | Key => $self->{'Key'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | KeyFile => $self->{'KeyFile'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | $self->{'Identity'} ? ( Identity => $self->{'Identity'} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | : () | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | $self->{'Timestamp'} ? ( Timestamp => $self->{'Timestamp'} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | : () | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | $self->{'Expiration'} ? ( Expiration => $self->{'Expiration'} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | : () | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 16 | ▶ | $self->{'Tags'} ? ( Tags => $self->{'Tags'} ) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | : () | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # share the header indexes between the signatures | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 22 | my $index = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 22 | foreach my $algorithm ( @{ $self->{algorithms} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # output header as received so far into canonicalization | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 23 | foreach my $header ( @{ $self->{headers} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 70 | $algorithm->add_header($header); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | $algorithm->finish_header( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | Headers => $self->{headers}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 23 | HeaderIndex => $index | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 23 | ▶ | sub finish_body { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finish_body: called CC=9 SCAR=22.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 23 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 23 | foreach my $algorithm ( @{ $self->{algorithms} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # finished canonicalizing | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 23 | $algorithm->finish_body; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 23 | my $type = 'rsa'; # default | |||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 23 | ▶ | $type = 'ed25519' if ( $self->{'Algorithm'} =~ /^ed25519/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # load the private key file if necessary | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 23 | my $signature = $algorithm->signature; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | my $key = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | $signature->{Key} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | || $signature->{KeyFile} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | || $self->{Key} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 23 | ▶ | || $self->{KeyFile}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition77%7/9
$signature->{'Key'} || $signature->{'KeyFile'} || $self->{'Key'} || $self->{'KeyFile'}
$signature->{"Key"} or $signature->{"KeyFile"} or $self->{"Key"}
$signature->{"Key"} or $signature->{"KeyFile"}
MC/DC0%0/4
$signature->{'Key'} || $signature->{'KeyFile'} || $self->{'Key'} || $self->{'KeyFile'}
$signature->{"Key"}
$signature->{"KeyFile"}
$self->{"Key"}
$self->{'KeyFile'}
Truth table60%3/5
A or B or C || D
A= $signature->{"Key"}B= $signature->{"KeyFile"}C= $self->{"Key"}D= $self->{'KeyFile'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 23 | ▶ | if ( defined($key) && !ref($key) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $key and not ref $key
MC/DC50%1/2
defined $key and not ref $key
defined $key
not ref $key
Truth table66%2/3
A and not(B)
A= defined $keyB= not ref $key
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | $key = Mail::DKIM::PrivateKey->load( File => $key, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | Type => $type ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | $key | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 23 | ▶ | or die "no key available to sign with\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # compute signature value | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 23 | my $signb64 = $algorithm->sign($key); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 23 | $signature->data($signb64); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # insert linebreaks in signature data, if desired | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 23 | $signature->prettify_safe(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 23 | $self->{signature} = $signature; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 23 | $self->{result} = 'signed'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 23 | ▶ | sub add_signature { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_signature: called CC=3 SCAR=11.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 23 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 23 | my $signature = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # create a canonicalization filter and algorithm | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 23 | ▶ | my $algorithm_class = | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$signature->algorithm || ''
MC/DC0%0/1
$signature->algorithm || ''
$signature->algorithm
Truth table0%0/2
A
A= $signature->algorithm
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | $signature->get_algorithm_class( $signature->algorithm ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | or die 'unsupported algorithm ' . ( $signature->algorithm || '' ) . "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | my $algorithm = $algorithm_class->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | Signature => $signature, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | Debug_Canonicalization => $self->{Debug_Canonicalization}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 23 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 23 | push @{ $self->{algorithms} }, $algorithm; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 23 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 3 | ▶ | sub algorithm { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
algorithm: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 3 | ▶ | if ( @_ == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 3 | $self->{Algorithm} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 3 | return $self->{Algorithm}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 3 | ▶ | sub domain { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
domain: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 3 | ▶ | if ( @_ == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 3 | $self->{Domain} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 3 | return $self->{Domain}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # these are headers that "should" be included in the signature, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # according to the DKIM spec. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 6 | my @DEFAULT_HEADERS = qw(From Sender Reply-To Subject Date | |||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | Message-ID To Cc MIME-Version | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | Content-Type Content-Transfer-Encoding Content-ID Content-Description | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | Resent-Date Resent-From Resent-Sender Resent-To Resent-cc | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | Resent-Message-ID | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | In-Reply-To References | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | List-Id List-Help List-Unsubscribe List-Subscribe | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | List-Post List-Owner List-Archive); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 1 | ▶ | sub process_headers_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_headers_hash: called CC=18 SCAR=33.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | my @headers; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # these are the header fields we found in the message we're signing | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 1 | my @found_headers = @{ $self->{header_field_names} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # Convert all keys to lower case | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 1 | foreach my $header ( keys %{ $self->{'ExtendedHeaders'} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 4 | ▶ | next if $header eq lc $header; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 4 | ▶ | if ( exists $self->{'ExtendedHeaders'}->{ lc $header } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | # Merge | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my $first = $self->{'ExtendedHeaders'}->{ lc $header }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my $second = $self->{'ExtendedHeaders'}->{$header}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if ( $first eq '+' || $second eq '+' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$first eq "+" or $second eq "+"
MC/DC0%0/2
$first eq "+" or $second eq "+"
$first eq "+"
$second eq "+"
Truth table0%0/3
A or B
A= $first eq "+"B= $second eq "+"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | $self->{'ExtendedHeaders'}->{ lc $header } = '+'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | ▶ | elsif ( $first eq '*' || $second eq '*' ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$first eq "*" or $second eq "*"
MC/DC0%0/2
$first eq "*" or $second eq "*"
$first eq "*"
$second eq "*"
Truth table0%0/3
A or B
A= $first eq "*"B= $second eq "*"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $self->{'ExtendedHeaders'}->{ lc $header } = '*'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $self->{'ExtendedHeaders'}->{ lc $header } = $first + $second; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # Rename | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | $self->{'ExtendedHeaders'}->{ lc $header } = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 4 | $self->{'ExtendedHeaders'}->{$header}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 4 | delete $self->{'ExtendedHeaders'}->{$header}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # Add the default headers | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | foreach my $default (@DEFAULT_HEADERS) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 28 | ▶ | if ( !exists $self->{'ExtendedHeaders'}->{ lc $default } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 26 | $self->{'ExtendedHeaders'}->{ lc $default } = '*'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | # Build a count of found headers | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 1 | my $header_counts = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | foreach my $header (@found_headers) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 10 | ▶ | if ( !exists $header_counts->{ lc $header } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 7 | $header_counts->{ lc $header } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 3 | $header_counts->{ lc $header } = $header_counts->{ lc $header } + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 1 | foreach my $header ( sort keys %{ $self->{'ExtendedHeaders'} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 30 | my $want_count = $self->{'ExtendedHeaders'}->{$header}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 30 | ▶ | my $have_count = $header_counts->{ lc $header } || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$header_counts{lc $header} || 0
MC/DC100%1/1
$$header_counts{lc $header} || 0
$$header_counts{lc $header}
Truth table100%2/2
A
A= $$header_counts{lc $header}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 30 | my $add_count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 30 | ▶ | if ( $want_count eq '+' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 1 | $add_count = $have_count + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | elsif ( $want_count eq '*' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 27 | $add_count = $have_count; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 2 | ▶ | if ( $want_count > $have_count ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $add_count = $have_count; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 2 | $add_count = $want_count; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 30 | for ( 1 .. $add_count ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 6 | push @headers, $header; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 1 | return join( ':', @headers ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 1 | ▶ | sub extended_headers { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extended_headers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 1 | $self->{'ExtendedHeaders'} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 21 | ▶ | sub headers { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
headers: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 21 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 21 | ▶ | croak 'unexpected argument' if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 21 | ▶ | if ( exists $self->{'ExtendedHeaders'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 1 | return $self->process_headers_hash(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | # these are the header fields we found in the message we're signing | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 20 | my @found_headers = @{ $self->{header_field_names} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | # these are the headers we actually want to sign | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 20 | my @wanted_headers = @DEFAULT_HEADERS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 20 | ▶ | if ( $self->{Headers} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | push @wanted_headers, split /:/, $self->{Headers}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | my @headers = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 20 | my $a = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 53 | scalar grep { lc($a) eq lc($_) } @wanted_headers | |||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } @found_headers; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 20 | return join( ':', @headers ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | # return nonzero if this is header we should sign | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | sub want_header { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
want_header: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my ($header_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | #TODO- provide a way for user to specify which headers to sign | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | return scalar grep { lc($_) eq lc($header_name) } @DEFAULT_HEADERS; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | sub key { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
key: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $self->{Key} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | $self->{KeyFile} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | return $self->{Key}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 1 | ▶ | sub key_file { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
key_file: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 1 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 1 | $self->{Key} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 1 | $self->{KeyFile} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 1 | return $self->{KeyFile}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 3 | ▶ | sub method { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
method: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 3 | ▶ | if ( @_ == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 3 | $self->{Method} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 3 | return $self->{Method}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 3 | ▶ | sub selector { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
selector: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 3 | ▶ | if ( @_ == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 3 | $self->{Selector} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 3 | return $self->{Selector}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 1 | ▶ | sub signatures { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
signatures: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 1 | ▶ | croak 'no arguments allowed' if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 1 | return map { $_->signature } @{ $self->{algorithms} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||