| 1 | package Mail::DKIM::Signature; | ||||||||||||||||||||||||||||||||
| 2 | 20 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | 20 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 20 | our $VERSION = '1.20261116'; # VERSION | |||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: represents a DKIM-Signature header | ||||||||||||||||||||||||||||||||
| 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 | 20 | ▶ | use Mail::DKIM::PublicKey; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | 20 | ▶ | use Mail::DKIM::Algorithm::rsa_sha1; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 16 | 20 | ▶ | use Mail::DKIM::Algorithm::rsa_sha256; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 17 | 20 | ▶ | use Mail::DKIM::Algorithm::ed25519_sha256; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | 20 | ▶ | use base 'Mail::DKIM::KeyValueList'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 20 | 20 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | 212 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 24 | 212 | my $class = shift; | |||||||||||||||||||||||||||||||
| 25 | 212 | my %prms = @_; | |||||||||||||||||||||||||||||||
| 26 | 212 | my $self = {}; | |||||||||||||||||||||||||||||||
| 27 | 212 | bless $self, $class; | |||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 212 | $self->version('1'); | |||||||||||||||||||||||||||||||
| 30 | 212 | ▶ | $self->algorithm( $prms{'Algorithm'} || 'rsa-sha1' ); | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$prms{'Algorithm'} || 'rsa-sha1'
MC/DC100%1/1
$prms{'Algorithm'} || 'rsa-sha1'
$prms{'Algorithm'}
Truth table100%2/2
A
A= $prms{'Algorithm'}
| |||||||||||||||||||||||||||||||||
| 31 | 212 | $self->signature( $prms{'Signature'} ); | |||||||||||||||||||||||||||||||
| 32 | 212 | ▶ | $self->canonicalization( $prms{'Method'} ) if exists $prms{'Method'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 33 | 212 | $self->domain( $prms{'Domain'} ); | |||||||||||||||||||||||||||||||
| 34 | 212 | $self->headerlist( $prms{'Headers'} ); | |||||||||||||||||||||||||||||||
| 35 | 212 | ▶ | $self->protocol( $prms{'Query'} ) if exists $prms{'Query'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 36 | 212 | $self->selector( $prms{'Selector'} ); | |||||||||||||||||||||||||||||||
| 37 | 212 | ▶ | $self->identity( $prms{'Identity'} ) if exists $prms{'Identity'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 38 | 212 | ▶ | $self->timestamp( $prms{'Timestamp'} ) if defined $prms{'Timestamp'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 39 | 212 | ▶ | $self->expiration( $prms{'Expiration'} ) if defined $prms{'Expiration'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 40 | 212 | ▶ | $self->tags( $prms{'Tags'} ) if defined $prms{'Tags'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 41 | 212 | ▶ | $self->key( $prms{'Key'} ) if defined $prms{'Key'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 42 | 212 | return $self; | |||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 1315 | ▶ | sub parse { | ||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 47 | 1315 | my $class = shift; | |||||||||||||||||||||||||||||||
| 48 | 1315 | ▶ | croak 'wrong number of arguments' unless ( @_ == 1 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 49 | 1315 | my ($string) = @_; | |||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | # remove line terminator, if present | ||||||||||||||||||||||||||||||||
| 52 | 1315 | $string =~ s/\015\012\z//; | |||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | # remove field name, if present | ||||||||||||||||||||||||||||||||
| 55 | 1315 | my $prefix = $class->prefix(); | |||||||||||||||||||||||||||||||
| 56 | 1315 | ▶ | if ( $string =~ s/^($prefix)//i ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | # save the field name (capitalization), so that it can be | ||||||||||||||||||||||||||||||||
| 59 | # restored later | ||||||||||||||||||||||||||||||||
| 60 | 1315 | $prefix = $1; | |||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | 1315 | my $self = $class->SUPER::parse($string); | |||||||||||||||||||||||||||||||
| 64 | 1309 | $self->{prefix} = $prefix; | |||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||
| 66 | 1309 | return $self; | |||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | # deprecated | ||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub wantheader { | ||||||||||||||||||||||||||||||
|
Subroutine
wantheader: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 72 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 73 | 0 | my $attr = shift; | |||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | $self->headerlist | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 76 | or return 1; | ||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | 0 | foreach my $key ( $self->headerlist ) { | |||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | lc $attr eq lc $key | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 80 | and return 1; | ||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | 0 | return; | |||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||
| 87 | 3962 | ▶ | sub algorithm { | ||||||||||||||||||||||||||||||
|
Subroutine
algorithm: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 88 | 3962 | my $self = shift; | |||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | 3962 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 91 | 1376 | $self->set_tag( 'a', shift ); | |||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | 3962 | my $a = $self->get_tag('a'); | |||||||||||||||||||||||||||||||
| 95 | 3962 | ▶ | return defined $a ? lc $a : undef; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||
| 99 | 1189 | ▶ | sub as_string { | ||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 100 | 1189 | my $self = shift; | |||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||
| 102 | 1189 | return $self->prefix() . $self->SUPER::as_string; | |||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||
| 105 | # undocumented method | ||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub as_string_debug { | ||||||||||||||||||||||||||||||
|
Subroutine
as_string_debug: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 107 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | return $self->prefix() | ||||||||||||||||||||||||||||||||
| 110 | 0 | . join( ';', map { '>' . $_->{raw} . '<' } @{ $self->{tags} } ); | |||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||
| 114 | 544 | ▶ | sub as_string_without_data { | ||||||||||||||||||||||||||||||
|
Subroutine
as_string_without_data: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 115 | 544 | my $self = shift; | |||||||||||||||||||||||||||||||
| 116 | 544 | ▶ | croak 'wrong number of arguments' unless ( @_ == 0 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | 544 | my $alt = $self->clone; | |||||||||||||||||||||||||||||||
| 119 | 544 | $alt->signature(''); | |||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||
| 121 | 544 | return $alt->as_string; | |||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | 348 | ▶ | sub body_count { | ||||||||||||||||||||||||||||||
|
Subroutine
body_count: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 126 | 348 | my $self = shift; | |||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||
| 128 | # set new body count if provided | ||||||||||||||||||||||||||||||||
| 129 | 348 | ▶ | (@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 130 | and $self->set_tag( 'l', shift ); | ||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||
| 132 | 348 | return $self->get_tag('l'); | |||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | 274 | ▶ | sub body_hash { | ||||||||||||||||||||||||||||||
|
Subroutine
body_hash: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 137 | 274 | my $self = shift; | |||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||
| 139 | # set new body hash if provided | ||||||||||||||||||||||||||||||||
| 140 | 274 | ▶ | (@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 141 | and $self->set_tag( 'bh', shift ); | ||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||
| 143 | 274 | my $result = $self->get_tag('bh'); | |||||||||||||||||||||||||||||||
| 144 | 274 | ▶ | if ( defined $result ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 145 | 271 | $result =~ s/\s+//gs; | |||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||
| 147 | 274 | return $result; | |||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||
| 151 | 748 | ▶ | sub canonicalization { | ||||||||||||||||||||||||||||||
|
Subroutine
canonicalization: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 152 | 748 | my $self = shift; | |||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||
| 154 | 748 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 155 | 40 | $self->set_tag( 'c', join( '/', @_ ) ); | |||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||
| 158 | 748 | my $c = $self->get_tag('c'); | |||||||||||||||||||||||||||||||
| 159 | 748 | ▶ | $c = lc $c if defined $c; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 160 | 748 | ▶ | if ( not $c ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 161 | 4 | $c = 'simple/simple'; | |||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||
| 163 | 748 | my ( $c1, $c2 ) = split( /\//, $c, 2 ); | |||||||||||||||||||||||||||||||
| 164 | 748 | ▶ | if ( not defined $c2 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||
| 166 | # default body canonicalization is "simple" | ||||||||||||||||||||||||||||||||
| 167 | 148 | $c2 = 'simple'; | |||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||
| 170 | 748 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 171 | 700 | return ( $c1, $c2 ); | |||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||
| 173 | else { | ||||||||||||||||||||||||||||||||
| 174 | 48 | return "$c1/$c2"; | |||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||
| 178 | 20 | ▶ | use MIME::Base64; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||
| 180 | # checks whether this signature specifies a legal canonicalization method | ||||||||||||||||||||||||||||||||
| 181 | # returns true if the canonicalization is acceptable, false otherwise | ||||||||||||||||||||||||||||||||
| 182 | # | ||||||||||||||||||||||||||||||||
| 183 | 614 | ▶ | sub check_canonicalization { | ||||||||||||||||||||||||||||||
|
Subroutine
check_canonicalization: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 184 | 614 | my $self = shift; | |||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||
| 186 | 614 | my ( $c1, $c2 ) = $self->canonicalization; | |||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||
| 188 | 614 | my @known = ( 'nowsp', 'simple', 'relaxed', 'seal' ); | |||||||||||||||||||||||||||||||
| 189 | 614 | ▶ | return undef unless ( grep { $_ eq $c1 } @known ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 190 | 611 | ▶ | return undef unless ( grep { $_ eq $c2 } @known ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 191 | 611 | return 1; | |||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||
| 194 | 1 | ▶ | sub set_verify_time { | ||||||||||||||||||||||||||||||
|
Subroutine
set_verify_time: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 195 | 1 | my ( $self, $verify_time ) = @_; | |||||||||||||||||||||||||||||||
| 196 | 1 | $self->{_verify_time} = $verify_time; | |||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||
| 199 | # checks whether the expiration time on this signature is acceptable | ||||||||||||||||||||||||||||||||
| 200 | # returns a true value if acceptable, false otherwise | ||||||||||||||||||||||||||||||||
| 201 | # | ||||||||||||||||||||||||||||||||
| 202 | 624 | ▶ | sub check_expiration { | ||||||||||||||||||||||||||||||
|
Subroutine
check_expiration: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 203 | 624 | my $self = shift; | |||||||||||||||||||||||||||||||
| 204 | 624 | my $x = $self->expiration; | |||||||||||||||||||||||||||||||
| 205 | 624 | ▶ | return 1 if not defined $x; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 206 | 5 | ▶ | $self->{_verify_time} ||= time(); | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"_verify_time"} ||= time
MC/DC100%1/1
$self->{"_verify_time"} ||= time
$self->{"_verify_time"}
Truth table100%2/2
A
A= $self->{"_verify_time"}
| |||||||||||||||||||||||||||||||||
| 207 | 5 | return ( $self->{_verify_time} <= $x ); | |||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||
| 210 | # Returns a filtered list of protocols that can be used to fetch the | ||||||||||||||||||||||||||||||||
| 211 | # public key corresponding to this signature. An empty list means that | ||||||||||||||||||||||||||||||||
| 212 | # all designated protocols are unrecognized. | ||||||||||||||||||||||||||||||||
| 213 | # Note: at this time, the only recognized protocol is "dns/txt". | ||||||||||||||||||||||||||||||||
| 214 | # | ||||||||||||||||||||||||||||||||
| 215 | 1180 | ▶ | sub check_protocol { | ||||||||||||||||||||||||||||||
|
Subroutine
check_protocol: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 216 | 1180 | my $self = shift; | |||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||
| 218 | 1180 | my $v = $self->version; | |||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||
| 220 | 1180 | foreach my $prot ( split /:/, $self->protocol ) { | |||||||||||||||||||||||||||||||
| 221 | 1182 | my ( $type, $options ) = split( /\//, $prot, 2 ); | |||||||||||||||||||||||||||||||
| 222 | 1182 | ▶ | if ( $type eq 'dns' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 223 | 1179 | ▶ | return ('dns/txt') if $options && $options eq 'txt'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$options and $options eq "txt"
MC/DC100%2/2
$options and $options eq "txt"
$options
$options eq "txt"
Truth table100%3/3
A and B
A= $optionsB= $options eq "txt"
| |||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||
| 225 | # prior to DKIM version 1, the '/txt' part was optional | ||||||||||||||||||||||||||||||||
| 226 | 12 | ▶ | if ( !$v ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 227 | 11 | ▶ | return ('dns/txt') if !defined($options); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||
| 232 | # unrecognized | ||||||||||||||||||||||||||||||||
| 233 | 2 | return; | |||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||
| 236 | # checks whether the version tag has an acceptable value | ||||||||||||||||||||||||||||||||
| 237 | # returns true if so, otherwise false | ||||||||||||||||||||||||||||||||
| 238 | # | ||||||||||||||||||||||||||||||||
| 239 | 625 | ▶ | sub check_version { | ||||||||||||||||||||||||||||||
|
Subroutine
check_version: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 240 | 625 | my $self = shift; | |||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||
| 242 | # check version | ||||||||||||||||||||||||||||||||
| 243 | 625 | ▶ | if ( my $version = $self->version ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 244 | 77 | my @ALLOWED_VERSIONS = ( '0.5', '1' ); | |||||||||||||||||||||||||||||||
| 245 | 77 | return ( grep { $_ eq $version } @ALLOWED_VERSIONS ); | |||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||
| 248 | # we still consider a missing v= tag acceptable, | ||||||||||||||||||||||||||||||||
| 249 | # for backwards-compatibility | ||||||||||||||||||||||||||||||||
| 250 | 548 | return 1; | |||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||
| 254 | 3109 | ▶ | sub data { | ||||||||||||||||||||||||||||||
|
Subroutine
data: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 255 | 3109 | my $self = shift; | |||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||
| 257 | 3109 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 258 | 2008 | $self->set_tag( 'b', shift ); | |||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||
| 261 | 3109 | my $b = $self->get_tag('b'); | |||||||||||||||||||||||||||||||
| 262 | 3109 | ▶ | $b =~ tr/\015\012 \t//d if defined $b; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 263 | 3109 | return $b; | |||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||
| 266 | 20 | *signature = \*data; | |||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||
| 268 | #undocumented, private function | ||||||||||||||||||||||||||||||||
| 269 | #derived from MIME::Base64::Perl (allowed, thanks to the Perl license) | ||||||||||||||||||||||||||||||||
| 270 | # | ||||||||||||||||||||||||||||||||
| 271 | 250 | ▶ | sub decode_qp { | ||||||||||||||||||||||||||||||
|
Subroutine
decode_qp: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 272 | 250 | my $res = shift; | |||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||
| 274 | #TODO- should I worry about non-ASCII systems here? | ||||||||||||||||||||||||||||||||
| 275 | 250 | ▶ | $res =~ s/=([\da-fA-F]{2})/pack('C', hex($1))/ge | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 276 | if defined $res; | ||||||||||||||||||||||||||||||||
| 277 | 250 | return $res; | |||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||
| 280 | #undocumented, private function | ||||||||||||||||||||||||||||||||
| 281 | #derived from MIME::Base64::Perl (allowed, thanks to the Perl license) | ||||||||||||||||||||||||||||||||
| 282 | # | ||||||||||||||||||||||||||||||||
| 283 | 2 | ▶ | sub encode_qp { | ||||||||||||||||||||||||||||||
|
Subroutine
encode_qp: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 284 | 2 | my $res = shift; | |||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||
| 286 | # note- unlike MIME quoted-printable, we don't allow whitespace chars | ||||||||||||||||||||||||||||||||
| 287 | 2 | my $DISALLOWED = qr/[^!"#\$%&'()*+,\-.\/0-9:;<>?\@A-Z[\\\]^_`a-z{|}~]/; | |||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||
| 289 | #TODO- should I worry about non-ASCII systems here? | ||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | $res =~ s/($DISALLOWED)/sprintf('=%02X', ord($1))/eg | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 291 | if defined $res; | ||||||||||||||||||||||||||||||||
| 292 | 2 | return $res; | |||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||
| 295 | 279 | ▶ | sub DEFAULT_PREFIX { | ||||||||||||||||||||||||||||||
|
Subroutine
DEFAULT_PREFIX: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 296 | 279 | return 'DKIM-Signature:'; | |||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||
| 299 | 2641 | ▶ | sub prefix { | ||||||||||||||||||||||||||||||
|
Subroutine
prefix: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 300 | 2641 | my $class = shift; | |||||||||||||||||||||||||||||||
| 301 | 2641 | ▶ | if ( ref($class) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 302 | 1326 | ▶ | $class->{prefix} = shift if @_; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 303 | 1326 | ▶ | return $class->{prefix} if $class->{prefix}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||
| 305 | 1590 | return $class->DEFAULT_PREFIX(); | |||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||
| 309 | 3981 | ▶ | sub domain { | ||||||||||||||||||||||||||||||
|
Subroutine
domain: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 310 | 3981 | my $self = shift; | |||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||
| 312 | 3981 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 313 | 1375 | $self->set_tag( 'd', shift ); | |||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||
| 316 | 3981 | my $d = $self->get_tag('d'); | |||||||||||||||||||||||||||||||
| 317 | 3981 | ▶ | return defined $d ? lc $d : undef; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||
| 321 | 612 | ▶ | sub expiration { | ||||||||||||||||||||||||||||||
|
Subroutine
expiration: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 322 | 612 | my $self = shift; | |||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||
| 324 | 612 | ▶ | (@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 325 | and $self->set_tag( 'x', shift ); | ||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||
| 327 | 612 | return $self->get_tag('x'); | |||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | sub tags { | ||||||||||||||||||||||||||||||
|
Subroutine
tags: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 331 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 332 | 0 | my $tags = shift; | |||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||
| 334 | 0 | for my $tag (sort keys %$tags) { | |||||||||||||||||||||||||||||||
| 335 | 0 | $self->set_tag( $tag, $tags->{$tag} ); | |||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||
| 337 | 0 | (@_) | |||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||
| 341 | # allows the type of signature to determine what "algorithm" gets used | ||||||||||||||||||||||||||||||||
| 342 | 1246 | ▶ | sub get_algorithm_class { | ||||||||||||||||||||||||||||||
|
Subroutine
get_algorithm_class: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 343 | 1246 | my $self = shift; | |||||||||||||||||||||||||||||||
| 344 | 1246 | ▶ | croak 'wrong number of arguments' unless ( @_ == 1 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 345 | 1246 | my ($algorithm) = @_; | |||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||
| 347 | 1246 | ▶ | my $class = | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 348 | $algorithm eq 'rsa-sha1' ? 'Mail::DKIM::Algorithm::rsa_sha1' | ||||||||||||||||||||||||||||||||
| 349 | : $algorithm eq 'rsa-sha256' ? 'Mail::DKIM::Algorithm::rsa_sha256' | ||||||||||||||||||||||||||||||||
| 350 | : $algorithm eq 'ed25519-sha256' ? 'Mail::DKIM::Algorithm::ed25519_sha256' | ||||||||||||||||||||||||||||||||
| 351 | : undef; | ||||||||||||||||||||||||||||||||
| 352 | 1246 | return $class; | |||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||
| 355 | # [private method] | ||||||||||||||||||||||||||||||||
| 356 | # fetch_public_key() - initiate a DNS query for fetching the key | ||||||||||||||||||||||||||||||||
| 357 | # | ||||||||||||||||||||||||||||||||
| 358 | # This method does NOT return the public key. | ||||||||||||||||||||||||||||||||
| 359 | # Use get_public_key() for that. | ||||||||||||||||||||||||||||||||
| 360 | # | ||||||||||||||||||||||||||||||||
| 361 | 584 | ▶ | sub fetch_public_key { | ||||||||||||||||||||||||||||||
|
Subroutine
fetch_public_key: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 362 | 584 | my $self = shift; | |||||||||||||||||||||||||||||||
| 363 | 584 | ▶ | return if exists $self->{public_key_query}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||
| 365 | 478 | ▶ | my $on_success = sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 366 | 478 | ▶ | if ( $_[0] ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 367 | 348 | $self->{public} = $_[0]; | |||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||
| 369 | else { | ||||||||||||||||||||||||||||||||
| 370 | 130 | $self->{public_error} = "not available\n"; | |||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||
| 372 | 584 | }; | |||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||
| 374 | 584 | my @methods = $self->check_protocol; | |||||||||||||||||||||||||||||||
| 375 | $self->{public_key_query} = Mail::DKIM::PublicKey->fetch_async( | ||||||||||||||||||||||||||||||||
| 376 | Protocol => $methods[0], | ||||||||||||||||||||||||||||||||
| 377 | Selector => $self->selector, | ||||||||||||||||||||||||||||||||
| 378 | Domain => $self->domain, | ||||||||||||||||||||||||||||||||
| 379 | Callbacks => { | ||||||||||||||||||||||||||||||||
| 380 | Success => $on_success, | ||||||||||||||||||||||||||||||||
| 381 | 3 | ▶ | Error => sub { $self->{public_error} = shift }, | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 382 | }, | ||||||||||||||||||||||||||||||||
| 383 | 584 | ); | |||||||||||||||||||||||||||||||
| 384 | 582 | return; | |||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||
| 387 | #EXPERIMENTAL | ||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | sub _refetch_public_key { | ||||||||||||||||||||||||||||||
|
Subroutine
_refetch_public_key: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 389 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | if ( $self->{public_key_query} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||
| 392 | # clear the existing query by waiting for it to complete | ||||||||||||||||||||||||||||||||
| 393 | 0 | $self->{public_key_query}->(); | |||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||
| 395 | 0 | delete $self->{public_key_query}; | |||||||||||||||||||||||||||||||
| 396 | 0 | delete $self->{public}; | |||||||||||||||||||||||||||||||
| 397 | 0 | delete $self->{public_error}; | |||||||||||||||||||||||||||||||
| 398 | 0 | $self->fetch_public_key; | |||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||
| 402 | 827 | ▶ | sub get_public_key { | ||||||||||||||||||||||||||||||
|
Subroutine
get_public_key: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 403 | 827 | my $self = shift; | |||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||
| 405 | # this ensures we only try fetching once, even if an error occurs | ||||||||||||||||||||||||||||||||
| 406 | 827 | ▶ | if ( not exists $self->{public_key_query} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 407 | 0 | $self->fetch_public_key; | |||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||
| 410 | 827 | ▶ | if ( $self->{public_key_query} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||
| 412 | # wait for public key query to finish | ||||||||||||||||||||||||||||||||
| 413 | 489 | $self->{public_key_query}->(); | |||||||||||||||||||||||||||||||
| 414 | 481 | $self->{public_key_query} = 0; | |||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||
| 417 | 819 | ▶ | if ( exists $self->{public} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 418 | 686 | return $self->{public}; | |||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||
| 420 | else { | ||||||||||||||||||||||||||||||||
| 421 | 133 | die $self->{public_error}; | |||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||
| 426 | 335 | ▶ | sub hash_algorithm { | ||||||||||||||||||||||||||||||
|
Subroutine
hash_algorithm: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 427 | 335 | my $self = shift; | |||||||||||||||||||||||||||||||
| 428 | 335 | my $algorithm = $self->algorithm; | |||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||
| 430 | return | ||||||||||||||||||||||||||||||||
| 431 | 335 | ▶ | $algorithm eq 'rsa-sha1' ? 'sha1' | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 432 | : $algorithm eq 'rsa-sha256' ? 'sha256' | ||||||||||||||||||||||||||||||||
| 433 | : $algorithm eq 'ed25519-sha256' ? 'sha256' | ||||||||||||||||||||||||||||||||
| 434 | : undef; | ||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||
| 438 | 1236 | ▶ | sub headerlist { | ||||||||||||||||||||||||||||||
|
Subroutine
headerlist: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 439 | 1236 | my $self = shift; | |||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||
| 441 | 1236 | ▶ | (@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 442 | and $self->set_tag( 'h', shift ); | ||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||
| 444 | 1236 | ▶ | my $h = $self->get_tag('h') || ''; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->get_tag('h') || ''
MC/DC100%1/1
$self->get_tag('h') || ''
$self->get_tag('h')
Truth table100%2/2
A
A= $self->get_tag('h')
| |||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||
| 446 | # remove whitespace next to colons | ||||||||||||||||||||||||||||||||
| 447 | 1236 | $h =~ s/\s+:/:/g; | |||||||||||||||||||||||||||||||
| 448 | 1236 | $h =~ s/:\s+/:/g; | |||||||||||||||||||||||||||||||
| 449 | 1236 | $h = lc $h; | |||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||
| 451 | 1236 | ▶ | if ( wantarray and $h ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
wantarray and $h
MC/DC100%2/2
wantarray and $h
wantarray
$h
Truth table100%3/3
A and B
A= wantarrayB= $h
| |||||||||||||||||||||||||||||||||
| 452 | 412 | my @list = split /:/, $h; | |||||||||||||||||||||||||||||||
| 453 | 412 | @list = map { s/^\s+//; s/\s+$//; $_ } @list; # not s/^\s+|\s+$//g, quadratic | |||||||||||||||||||||||||||||||
| 454 | 412 | return @list; | |||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||
| 456 | elsif (wantarray) { | ||||||||||||||||||||||||||||||||
| 457 | 10 | return (); | |||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||
| 460 | 814 | return $h; | |||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||
| 464 | 352 | ▶ | sub identity { | ||||||||||||||||||||||||||||||
|
Subroutine
identity: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 465 | 352 | my $self = shift; | |||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||
| 467 | # set new identity if provided | ||||||||||||||||||||||||||||||||
| 468 | 352 | ▶ | (@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 469 | and $self->set_tag( 'i', encode_qp(shift) ); | ||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||
| 471 | 352 | my $i = $self->get_tag('i'); | |||||||||||||||||||||||||||||||
| 472 | 352 | ▶ | if ( defined $i ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 473 | 250 | return decode_qp($i); | |||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||
| 475 | else { | ||||||||||||||||||||||||||||||||
| 476 | 102 | ▶ | return '@' . ( $self->domain || '' ); | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->domain || ''
MC/DC0%0/1
$self->domain || ''
$self->domain
Truth table50%1/2
A
A= $self->domain
| |||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | sub identity_matches { | ||||||||||||||||||||||||||||||
|
Subroutine
identity_matches: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 481 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 482 | 0 | my ($addr) = @_; | |||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||
| 484 | 0 | my $id = $self->identity; | |||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | if ( $id =~ /^\@/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||
| 487 | # the identity is a domain-name only, so it only needs to match | ||||||||||||||||||||||||||||||||
| 488 | # the domain part of the sender address | ||||||||||||||||||||||||||||||||
| 489 | 0 | return ( lc( substr( $addr, -length($id) ) ) eq lc($id) ); | |||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||
| 491 | # TODO - compare the parent domains? | ||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||
| 493 | 0 | return lc($addr) eq lc($id); | |||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||
| 497 | 57 | ▶ | sub key { | ||||||||||||||||||||||||||||||
|
Subroutine
key: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 498 | 57 | my $self = shift; | |||||||||||||||||||||||||||||||
| 499 | 57 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 500 | 57 | $self->{Key} = shift; | |||||||||||||||||||||||||||||||
| 501 | 57 | $self->{KeyFile} = undef; | |||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||
| 503 | 57 | return $self->{Key}; | |||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | sub method { | ||||||||||||||||||||||||||||||
|
Subroutine
method: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 508 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 511 | 0 | $self->set_tag( 'c', shift ); | |||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | return ( lc $self->get_tag('c') ) || 'simple'; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
lc $self->get_tag('c') || 'simple'
MC/DC0%0/1
lc $self->get_tag('c') || 'simple'
lc $self->get_tag('c')
Truth table0%0/2
A
A= lc $self->get_tag('c')
| |||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||
| 518 | 1184 | ▶ | sub protocol { | ||||||||||||||||||||||||||||||
|
Subroutine
protocol: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 519 | 1184 | my $self = shift; | |||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||
| 521 | 1184 | ▶ | (@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 522 | and $self->set_tag( 'q', shift ); | ||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||
| 524 | 1184 | my $q = $self->get_tag('q'); | |||||||||||||||||||||||||||||||
| 525 | 1184 | ▶ | if ( defined $q ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 526 | 84 | return $q; | |||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||
| 528 | else { | ||||||||||||||||||||||||||||||||
| 529 | 1100 | return 'dns/txt'; | |||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||
| 534 | 1266 | ▶ | sub result { | ||||||||||||||||||||||||||||||
|
Subroutine
result: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 535 | 1266 | my $self = shift; | |||||||||||||||||||||||||||||||
| 536 | 1266 | ▶ | @_ and $self->{verify_result} = shift; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 537 | 1266 | ▶ | @_ and $self->{verify_details} = shift; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 538 | 1266 | return $self->{verify_result}; | |||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||
| 542 | 466 | ▶ | sub result_detail { | ||||||||||||||||||||||||||||||
|
Subroutine
result_detail: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 543 | 466 | my $self = shift; | |||||||||||||||||||||||||||||||
| 544 | 466 | ▶ | croak 'wrong number of arguments' unless ( @_ == 0 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||
| 546 | 466 | ▶ | if ( $self->{verify_result} && $self->{verify_details} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"verify_result"} and $self->{"verify_details"}
MC/DC100%2/2
$self->{"verify_result"} and $self->{"verify_details"}
$self->{"verify_result"}
$self->{"verify_details"}
Truth table100%3/3
A and B
A= $self->{"verify_result"}B= $self->{"verify_details"}
| |||||||||||||||||||||||||||||||||
| 547 | 130 | return $self->{verify_result} . ' (' . $self->{verify_details} . ')'; | |||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||
| 549 | 336 | return $self->{verify_result}; | |||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||
| 553 | 2599 | ▶ | sub selector { | ||||||||||||||||||||||||||||||
|
Subroutine
selector: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 554 | 2599 | my $self = shift; | |||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||
| 556 | 2599 | ▶ | (@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 557 | and $self->set_tag( 's', shift ); | ||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||
| 559 | 2599 | return $self->get_tag('s'); | |||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||
| 563 | 70 | ▶ | sub prettify { | ||||||||||||||||||||||||||||||
|
Subroutine
prettify: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 564 | 70 | my $self = shift; | |||||||||||||||||||||||||||||||
| 565 | 70 | $self->wrap( | |||||||||||||||||||||||||||||||
| 566 | Start => length( $self->prefix() ), | ||||||||||||||||||||||||||||||||
| 567 | Tags => { | ||||||||||||||||||||||||||||||||
| 568 | b => 'b64', | ||||||||||||||||||||||||||||||||
| 569 | bh => 'b64', | ||||||||||||||||||||||||||||||||
| 570 | h => 'list', | ||||||||||||||||||||||||||||||||
| 571 | }, | ||||||||||||||||||||||||||||||||
| 572 | ); | ||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||
| 576 | 67 | ▶ | sub prettify_safe { | ||||||||||||||||||||||||||||||
|
Subroutine
prettify_safe: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 577 | 67 | my $self = shift; | |||||||||||||||||||||||||||||||
| 578 | 67 | $self->wrap( | |||||||||||||||||||||||||||||||
| 579 | Start => length( $self->prefix() ), | ||||||||||||||||||||||||||||||||
| 580 | Tags => { | ||||||||||||||||||||||||||||||||
| 581 | b => 'b64', | ||||||||||||||||||||||||||||||||
| 582 | }, | ||||||||||||||||||||||||||||||||
| 583 | PreserveNames => 1, | ||||||||||||||||||||||||||||||||
| 584 | Default => 'preserve', #preserves unknown tags | ||||||||||||||||||||||||||||||||
| 585 | ); | ||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||
| 589 | 605 | ▶ | sub timestamp { | ||||||||||||||||||||||||||||||
|
Subroutine
timestamp: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 590 | 605 | my $self = shift; | |||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||
| 592 | 605 | ▶ | (@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 593 | and $self->set_tag( 't', shift ); | ||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||
| 595 | 605 | return $self->get_tag('t'); | |||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||
| 599 | 2019 | ▶ | sub version { | ||||||||||||||||||||||||||||||
|
Subroutine
version: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 600 | 2019 | my $self = shift; | |||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||
| 602 | 2019 | ▶ | (@_) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 603 | and $self->set_tag( 'v', shift ); | ||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||
| 605 | 2019 | return $self->get_tag('v'); | |||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||
| 609 | 20 | 1; | |||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||
| 611 | __END__ | ||||||||||||||||||||||||||||||||