Branch Coverage

blib/lib/XML/Sig.pm
Criterion Covered Total %
branch 187 300 62.3


line true false branch
46 448 2957 if (exists $params->{$prop})
54 198 483 exists $params->{'x509'} ? :
55 18 663 if (exists $params->{'key_name'})
58 337 344 if (exists $params->{'key'})
61 108 571 if (exists $params->{'cert'})
64 1 678 if (exists $params->{'cert_text'})
67 18 661 if (exists $params->{'hmac_key'})
71 151 528 if (exists $params->{'sig_hash'} and grep {$_ eq $params->{'sig_hash'};} 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160') { }
79 204 475 if (exists $params->{'digest_hash'} and grep {$_ eq $params->{'digest_hash'};} 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160') { }
87 56 623 if (defined $self->{'key_type'} and $self->{'key_type'} eq "dsa")
91 28 28 if ($sig_size eq 48) { }
98 1 678 if (exists $params->{'no_xml_declaration'} and $params->{'no_xml_declaration'} == 1) { }
104 18 326 if (not defined $self->{'key_type'} and exists $params->{'hmac_key'})
117 1 6 unless $self->key or $self->{'hmac_key'}
127 1 336 if ($self->{'ns'})
133 0 337 if $XML::Sig::DEBUG
139 0 345 if $XML::Sig::DEBUG
154 0 345 if $XML::Sig::DEBUG
168 311 34 if (my $ref = 'Digest::SHA'->can($self->{'digest_hash'})) { }
34 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($self->{'digest_hash'})) { }
181 0 345 if $XML::Sig::DEBUG
185 0 345 if $XML::Sig::DEBUG
210 58 287 if ($self->{'key_type'} eq 'dsa') { }
172 115 elsif ($self->{'key_type'} eq 'ecdsa') { }
109 6 elsif ($self->{'key_type'} eq 'rsa') { }
217 6 0 if (defined $self->{'hmac_key'}) { }
230 0 345 if $XML::Sig::DEBUG
253 0 356 if $XML::Sig::DEBUG
259 0 369 if $XML::Sig::DEBUG
266 0 369 if $XML::Sig::DEBUG
272 2 367 unless ($self->{'parser'}->findvalue("//*[\@ID='" . $reference . "']"))
273 0 2 if $XML::Sig::DEBUG
274 1 1 if ($numsigs <= 1) { }
286 0 367 if $XML::Sig::DEBUG
293 0 367 if $XML::Sig::DEBUG
297 0 367 if $XML::Sig::DEBUG
309 0 367 if $XML::Sig::DEBUG
315 0 367 if $XML::Sig::DEBUG
317 341 26 if (my $ref = 'Digest::SHA'->can($signature_method)) { }
26 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($signature_method)) { }
327 333 34 if (my $ref = 'Digest::SHA'->can($digest_method)) { }
34 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($digest_method)) { }
339 16 351 if (defined $self->{'cert_obj'}) { }
12 339 elsif (not defined $self->{'cert_obj'} and defined $self->{'hmac_key'}) { }
341 0 16 unless ($self->_verify_x509_cert($self->{'cert_obj'}, $signed_info_canon, $signature))
348 6 6 unless ($self->_verify_hmac($signed_info_canon, $signature))
349 0 6 if $XML::Sig::DEBUG
365 339 533 if ($key_info_sig_type eq 'X509Data') { }
374 339 533 if ($keyinfo_nodeset->size)
376 0 339 if $XML::Sig::DEBUG
377 0 339 if (not $self->$verify_method($keyinfo_nodeset->get_node(0), $signed_info_canon, $signature)) { }
379 0 0 if $XML::Sig::DEBUG
383 0 339 if $XML::Sig::DEBUG
388 0 339 unless $keyinfo_nodeset and $keyinfo_nodeset->size > 0
406 0 361 if $XML::Sig::DEBUG
411 0 361 if $XML::Sig::DEBUG
413 0 361 if $XML::Sig::DEBUG
416 0 361 unless $refdigest eq _trim(&encode_base64($digest, ""))
418 0 361 if $XML::Sig::DEBUG
445 1 336 if ($self->{'id_attr'})
447 0 1 if ($nodes->size == 0)
462 0 344 unless $i
484 0 345 unless $id
508 0 361 if $XML::Sig::DEBUG
537 0 361 if $XML::Sig::DEBUG
541 0 722 if $XML::Sig::DEBUG
542 361 361 if ($alg eq 'http://www.w3.org/2000/09/xmldsig#enveloped-signature') { }
0 361 elsif ($alg eq 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315') { }
0 361 elsif ($alg eq 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments') { }
361 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') { }
548 0 0 if $XML::Sig::DEBUG
552 0 0 if $XML::Sig::DEBUG
557 0 361 if $XML::Sig::DEBUG
562 0 0 if $XML::Sig::DEBUG
589 4 0 if ($child)
626 53 0 if $rsa_pub->verify($canonical, $bin_signature)
645 0 107 if ref $cert
683 0 107 if $@
715 50 73 if ($cert->key_alg_name eq 'id-ecPublicKey') { }
2 71 elsif ($cert->key_alg_name eq 'dsaEncryption') { }
716 0 50 unless eval { do { require Crypt::PK::ECC; "CryptX"->VERSION("0.036"); 1 } }
725 50 0 if ($ecdsa_pub->verify_message_rfc7518($bin_signature, $canonical, uc $self->{'sig_hash'}))
734 0 2 if $@
748 2 0 if ($dsa_pub->do_verify($self->{'sig_method'}->($canonical), $sigobj))
757 0 71 if $@
765 71 0 if ($rsa_pub->verify($canonical, $bin_signature))
843 0 57 if $@
875 57 0 if $dsa_pub->do_verify($self->{'sig_method'}->($canonical), $sigobj)
895 0 122 unless eval { do { require Crypt::PK::ECC; "CryptX"->VERSION("0.036"); 1 } }
939 122 0 if $ecdsa_pub->verify_message_rfc7518($bin_signature, $canonical, uc $self->{'sig_hash'})
962 12 0 if (defined $self->{'hmac_key'}) { }
963 0 12 if $XML::Sig::DEBUG
964 10 2 if (my $ref = 'Digest::SHA'->can('hmac_' . $self->{'sig_hash'})) { }
2 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($self->{'sig_hash'})) { }
965 5 5 if ($bin_signature eq $self->_calc_hmac_signature($canonical)) { }
973 1 1 if ($bin_signature eq $self->_calc_hmac_signature($canonical)) { }
1004 361 345 if ($context) { }
1019 0 0 if ($node) { }
1031 0 0 if (defined $self->{'dsig_prefix'} and length $self->{'dsig_prefix'})
1077 0 170 unless eval { do { require Crypt::PK::ECC; "CryptX"->VERSION("0.036"); 1 } }
1083 170 0 if ($ecdsa_key) { }
1133 0 56 if $@
1137 56 0 if ($dsa_key) { }
1181 0 109 if $@
1185 109 0 if ($rsaKey) { }
1190 55 54 if (not $self->{'x509'})
1227 0 18 unless (defined $self->{'key_name'})
1253 0 0 if $@
1258 0 0 if ($x509Key) { }
1287 0 108 if $@
1290 108 0 if (open my $CERT, '<', $file) { }
1297 108 0 if ($cert) { }
1333 0 1 if $@
1337 1 0 if ($cert) { }
1363 336 1 if (open my $KEY, '<', $file) { }
1369 163 173 if ($text =~ /BEGIN ([DR]SA) PRIVATE KEY/) { }
170 3 elsif ($text =~ /BEGIN EC PRIVATE KEY/) { }
2 1 elsif ($text =~ /BEGIN PRIVATE KEY/) { }
0 1 elsif ($text =~ /BEGIN CERTIFICATE/) { }
1372 107 56 if ($key_used eq 'RSA') { }
1435 0 345 if (not defined $self->{'key_type'} and defined $self->{'hmac_key'})
1439 30 315 if ($self->{'sig_hash'} eq 'sha1' and $self->{'key_type'} ne 'ecdsa') { }
172 143 elsif ($self->{'key_type'} eq 'ecdsa') { }
28 115 elsif ($self->{'key_type'} eq 'dsa' and $self->{'sig_hash'} eq 'sha256') { }
1443 12 160 if ($self->{'sig_hash'} eq 'ripemd160' or $self->{'sig_hash'} eq 'whirlpool') { }
1482 34 311 if ($self->{'digest_hash'} eq 'sha1') { }
68 243 elsif ($self->{'digest_hash'} eq 'sha224' or $self->{'digest_hash'} eq 'sha384') { }
1519 0 712 if $XML::Sig::DEBUG
1527 0 712 if $XML::Sig::DEBUG
1528 1 711 if ($alg eq 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315') { }
4 707 elsif ($alg eq 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments') { }
0 707 elsif ($alg eq 'http://www.w3.org/TR/2008/REC-xml-c14n11-20080502') { }
0 707 elsif ($alg eq 'http://www.w3.org/TR/2008/REC-xml-c14n11-20080502#WithComments') { }
707 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') { }
1529 0 1 if $XML::Sig::DEBUG
1533 0 4 if $XML::Sig::DEBUG
1537 0 0 if $XML::Sig::DEBUG
1541 0 0 if $XML::Sig::DEBUG
1545 0 707 if $XML::Sig::DEBUG
1549 0 0 if $XML::Sig::DEBUG
1573 0 58 if $XML::Sig::DEBUG
1574 58 0 if (my $ref = 'Digest::SHA'->can($self->{'sig_hash'})) { }
0 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($self->{'sig_hash'})) { }
1617 0 172 if $XML::Sig::DEBUG
1643 0 109 if $XML::Sig::DEBUG
1667 0 18 if $XML::Sig::DEBUG
1668 15 3 if (my $ref = 'Digest::SHA'->can('hmac_' . $self->{'sig_hash'})) { }
3 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($self->{'sig_hash'})) { }