Branch Coverage

blib/lib/XML/Sig.pm
Criterion Covered Total %
branch 180 308 58.4


line true false branch
46 260 1665 if (exists $params->{$prop})
54 117 268 exists $params->{'x509'} ? :
55 15 370 if (exists $params->{'key_name'})
58 189 196 if (exists $params->{'key'})
61 63 320 if (exists $params->{'cert'})
64 3 380 if (exists $params->{'cert_text'})
67 15 368 if (exists $params->{'hmac_key'})
71 92 291 if (exists $params->{'sig_hash'} and grep {$_ eq $params->{'sig_hash'};} 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160') { }
79 104 279 if (exists $params->{'digest_hash'} and grep {$_ eq $params->{'digest_hash'};} 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160') { }
87 41 342 if (defined $self->{'key_type'} and $self->{'key_type'} eq "dsa")
91 21 20 if ($sig_size eq 48) { }
98 2 381 if (exists $params->{'no_xml_declaration'} and $params->{'no_xml_declaration'} == 1) { }
104 15 181 if (not defined $self->{'key_type'} and exists $params->{'hmac_key'})
117 1 5 unless $self->key or $self->{'hmac_key'}
127 1 186 if ($self->{'ns'})
133 0 187 if $XML::Sig::DEBUG
139 0 195 if $XML::Sig::DEBUG
154 0 195 if $XML::Sig::DEBUG
165 195 0 if (my $ref = 'Digest::SHA'->can($self->{'digest_hash'})) { }
0 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($self->{'digest_hash'})) { }
178 0 195 if $XML::Sig::DEBUG
182 0 195 if $XML::Sig::DEBUG
212 42 153 if ($self->{'key_type'} eq 'dsa') { }
86 67 elsif ($self->{'key_type'} eq 'ecdsa') { }
62 5 elsif ($self->{'key_type'} eq 'rsa') { }
219 5 0 if (defined $self->{'hmac_key'}) { }
241 0 195 if $XML::Sig::DEBUG
264 2 204 if ($self->{'id_attr'})
265 2 0 if ($self->{'ns'})
274 0 206 if $XML::Sig::DEBUG
276 1 205 if $numsigs <= 0
281 0 218 if $XML::Sig::DEBUG
288 0 218 if $XML::Sig::DEBUG
290 0 218 if ($key_to_verify and $key_to_verify ne $reference)
291 0 0 if $XML::Sig::DEBUG
299 2 216 unless ($self->{'parser'}->findvalue(q(//*[@ID=') . $reference . q('])))
300 0 2 if $XML::Sig::DEBUG
301 1 1 if ($numsigs <= 1) { }
313 0 216 if $XML::Sig::DEBUG
320 0 216 if $XML::Sig::DEBUG
324 0 216 if $XML::Sig::DEBUG
336 0 216 if $XML::Sig::DEBUG
342 0 216 if $XML::Sig::DEBUG
344 216 0 if (my $ref = 'Digest::SHA'->can($signature_method)) { }
0 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($signature_method)) { }
354 216 0 if (my $ref = 'Digest::SHA'->can($digest_method)) { }
0 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($digest_method)) { }
366 16 200 if (defined $self->{'cert_obj'}) { }
10 190 elsif (not defined $self->{'cert_obj'} and defined $self->{'hmac_key'}) { }
368 0 16 unless ($self->_verify_x509_cert($self->{'cert_obj'}, $signed_info_canon, $signature))
375 5 5 unless ($self->_verify_hmac($signed_info_canon, $signature))
376 0 5 if $XML::Sig::DEBUG
392 190 287 if ($key_info_sig_type eq 'X509Data') { }
401 190 287 if ($keyinfo_nodeset->size)
403 0 190 if $XML::Sig::DEBUG
404 0 190 if (not $self->$verify_method($keyinfo_nodeset->get_node(0), $signed_info_canon, $signature)) { }
406 0 0 if $XML::Sig::DEBUG
410 0 190 if $XML::Sig::DEBUG
415 0 190 unless $keyinfo_nodeset and $keyinfo_nodeset->size > 0
433 0 211 if $XML::Sig::DEBUG
438 0 211 if $XML::Sig::DEBUG
440 0 211 if $XML::Sig::DEBUG
443 0 211 unless $refdigest eq _trim(&encode_base64($digest, ""))
445 0 211 if $XML::Sig::DEBUG
472 4 185 if ($self->{'id_attr'})
474 0 4 if ($nodes->size == 0)
486 193 0 if defined $val and length $val
505 0 195 unless $id
529 0 211 if $XML::Sig::DEBUG
558 0 211 if $XML::Sig::DEBUG
562 0 422 if $XML::Sig::DEBUG
563 211 211 if ($alg eq 'http://www.w3.org/2000/09/xmldsig#enveloped-signature') { }
0 211 elsif ($alg eq 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315') { }
0 211 elsif ($alg eq 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments') { }
211 0 elsif ($alg eq 'http://www.w3.org/2001/10/xml-exc-c14n#') { }
0 0 elsif ($alg eq 'http://www.w3.org/2001/10/xml-exc-c14n#WithComments') { }
569 0 0 if $XML::Sig::DEBUG
573 0 0 if $XML::Sig::DEBUG
578 0 211 if $XML::Sig::DEBUG
583 0 0 if $XML::Sig::DEBUG
610 4 0 if ($child)
637 0 28 if $@
652 28 0 if $rsa_pub->verify_message($bin_signature, $canonical, $self->{'sig_hash'}, "v1.5")
671 0 62 if ref $cert
709 0 62 if $@
741 27 51 if ($cert->key_alg_name eq 'id-ecPublicKey') { }
2 49 elsif ($cert->key_alg_name eq 'dsaEncryption') { }
742 0 27 unless eval { do { require Crypt::PK::ECC; "CryptX"->VERSION("0.036"); 1 } }
751 27 0 if ($ecdsa_pub->verify_message_rfc7518($bin_signature, $canonical, uc $self->{'sig_hash'}))
760 0 2 if $@
774 2 0 if ($dsa_pub->do_verify($self->{'sig_method'}->($canonical), $sigobj))
783 0 49 if $@
790 49 0 if ($rsa_pub->verify_message($bin_signature, $canonical, $self->{'sig_hash'}, "v1.5"))
868 0 41 if $@
900 41 0 if $dsa_pub->do_verify($self->{'sig_method'}->($canonical), $sigobj)
920 0 59 unless eval { do { require Crypt::PK::ECC; "CryptX"->VERSION("0.036"); 1 } }
964 59 0 if $ecdsa_pub->verify_message_rfc7518($bin_signature, $canonical, uc $self->{'sig_hash'})
987 10 0 if (defined $self->{'hmac_key'}) { }
988 0 10 if $XML::Sig::DEBUG
989 10 0 if (my $ref = 'Digest::SHA'->can('hmac_' . $self->{'sig_hash'})) { }
0 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($self->{'sig_hash'})) { }
990 5 5 if ($bin_signature eq $self->_calc_hmac_signature($canonical)) { }
998 0 0 if ($bin_signature eq $self->_calc_hmac_signature($canonical)) { }
1029 211 195 if ($context) { }
1073 0 84 unless eval { do { require Crypt::PK::ECC; "CryptX"->VERSION("0.036"); 1 } }
1079 84 0 if ($ecdsa_key) { }
1129 0 41 if $@
1133 41 0 if ($dsa_key) { }
1177 0 62 if $@
1182 62 0 if ($rsaKey) { }
1186 32 30 if (not $self->{'x509'})
1219 0 15 unless (defined $self->{'key_name'})
1245 0 0 if $@
1250 0 0 if ($x509Key) { }
1279 0 63 if $@
1282 63 0 if (open my $CERT, '<', "$file") { }
1289 63 0 if ($cert) { }
1325 0 3 if $@
1329 3 0 if ($cert) { }
1355 188 1 if (open my $KEY, '<', "$file") { }
1361 102 86 if ($text =~ /BEGIN ([DR]SA) PRIVATE KEY/) { }
84 2 elsif ($text =~ /BEGIN EC PRIVATE KEY/) { }
1 1 elsif ($text =~ /BEGIN PRIVATE KEY/) { }
0 1 elsif ($text =~ /BEGIN CERTIFICATE/) { }
1364 61 41 if ($key_used eq 'RSA') { }
1427 0 195 if (not defined $self->{'key_type'} and defined $self->{'hmac_key'})
1431 22 173 if ($self->{'sig_hash'} eq 'sha1' and $self->{'key_type'} ne 'ecdsa') { }
86 87 elsif ($self->{'key_type'} eq 'ecdsa') { }
20 67 elsif ($self->{'key_type'} eq 'dsa' and $self->{'sig_hash'} eq 'sha256') { }
1435 0 86 if ($self->{'sig_hash'} eq 'ripemd160' or $self->{'sig_hash'} eq 'whirlpool') { }
1474 0 195 if ($self->{'digest_hash'} eq 'sha1') { }
52 143 elsif ($self->{'digest_hash'} eq 'sha224' or $self->{'digest_hash'} eq 'sha384') { }
1511 0 411 if $XML::Sig::DEBUG
1519 0 411 if $XML::Sig::DEBUG
1520 1 410 if ($alg eq 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315') { }
5 405 elsif ($alg eq 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments') { }
0 405 elsif ($alg eq 'http://www.w3.org/TR/2008/REC-xml-c14n11-20080502') { }
0 405 elsif ($alg eq 'http://www.w3.org/TR/2008/REC-xml-c14n11-20080502#WithComments') { }
405 0 elsif ($alg eq 'http://www.w3.org/2001/10/xml-exc-c14n#') { }
0 0 elsif ($alg eq 'http://www.w3.org/2001/10/xml-exc-c14n#WithComments') { }
1521 0 1 if $XML::Sig::DEBUG
1525 0 5 if $XML::Sig::DEBUG
1529 0 0 if $XML::Sig::DEBUG
1533 0 0 if $XML::Sig::DEBUG
1537 0 405 if $XML::Sig::DEBUG
1541 0 0 if $XML::Sig::DEBUG
1565 0 42 if $XML::Sig::DEBUG
1566 42 0 if (my $ref = 'Digest::SHA'->can($self->{'sig_hash'})) { }
0 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($self->{'sig_hash'})) { }
1609 0 86 if $XML::Sig::DEBUG
1635 0 62 if $XML::Sig::DEBUG
1657 0 15 if $XML::Sig::DEBUG
1658 15 0 if (my $ref = 'Digest::SHA'->can('hmac_' . $self->{'sig_hash'})) { }
0 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($self->{'sig_hash'})) { }