Branch Coverage

blib/lib/XML/Sig.pm
Criterion Covered Total %
branch 191 308 62.0


line true false branch
46 451 2959 if (exists $params->{$prop})
54 199 483 exists $params->{'x509'} ? :
55 18 664 if (exists $params->{'key_name'})
58 337 345 if (exists $params->{'key'})
61 108 572 if (exists $params->{'cert'})
64 2 678 if (exists $params->{'cert_text'})
67 18 662 if (exists $params->{'hmac_key'})
71 151 529 if (exists $params->{'sig_hash'} and grep {$_ eq $params->{'sig_hash'};} 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160') { }
79 204 476 if (exists $params->{'digest_hash'} and grep {$_ eq $params->{'digest_hash'};} 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160') { }
87 56 624 if (defined $self->{'key_type'} and $self->{'key_type'} eq "dsa")
91 28 28 if ($sig_size eq 48) { }
98 2 678 if (exists $params->{'no_xml_declaration'} and $params->{'no_xml_declaration'} == 1) { }
104 18 327 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
165 311 34 if (my $ref = 'Digest::SHA'->can($self->{'digest_hash'})) { }
34 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($self->{'digest_hash'})) { }
178 0 345 if $XML::Sig::DEBUG
182 0 345 if $XML::Sig::DEBUG
208 58 287 if ($self->{'key_type'} eq 'dsa') { }
172 115 elsif ($self->{'key_type'} eq 'ecdsa') { }
109 6 elsif ($self->{'key_type'} eq 'rsa') { }
215 6 0 if (defined $self->{'hmac_key'}) { }
228 0 345 if $XML::Sig::DEBUG
251 2 355 if ($self->{'id_attr'})
252 2 0 if ($self->{'ns'})
261 0 357 if $XML::Sig::DEBUG
267 0 370 if $XML::Sig::DEBUG
274 0 370 if $XML::Sig::DEBUG
276 0 370 if ($key_to_verify and $key_to_verify ne $reference)
277 0 0 if $XML::Sig::DEBUG
285 2 368 unless ($self->{'parser'}->findvalue("//*[\@ID='" . $reference . "']"))
286 0 2 if $XML::Sig::DEBUG
287 1 1 if ($numsigs <= 1) { }
299 0 368 if $XML::Sig::DEBUG
306 0 368 if $XML::Sig::DEBUG
310 0 368 if $XML::Sig::DEBUG
322 0 368 if $XML::Sig::DEBUG
328 0 368 if $XML::Sig::DEBUG
330 342 26 if (my $ref = 'Digest::SHA'->can($signature_method)) { }
26 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($signature_method)) { }
340 334 34 if (my $ref = 'Digest::SHA'->can($digest_method)) { }
34 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($digest_method)) { }
352 17 351 if (defined $self->{'cert_obj'}) { }
12 339 elsif (not defined $self->{'cert_obj'} and defined $self->{'hmac_key'}) { }
354 0 17 unless ($self->_verify_x509_cert($self->{'cert_obj'}, $signed_info_canon, $signature))
361 6 6 unless ($self->_verify_hmac($signed_info_canon, $signature))
362 0 6 if $XML::Sig::DEBUG
378 339 533 if ($key_info_sig_type eq 'X509Data') { }
387 339 533 if ($keyinfo_nodeset->size)
389 0 339 if $XML::Sig::DEBUG
390 0 339 if (not $self->$verify_method($keyinfo_nodeset->get_node(0), $signed_info_canon, $signature)) { }
392 0 0 if $XML::Sig::DEBUG
396 0 339 if $XML::Sig::DEBUG
401 0 339 unless $keyinfo_nodeset and $keyinfo_nodeset->size > 0
419 0 362 if $XML::Sig::DEBUG
424 0 362 if $XML::Sig::DEBUG
426 0 362 if $XML::Sig::DEBUG
429 0 362 unless $refdigest eq _trim(&encode_base64($digest, ""))
431 0 362 if $XML::Sig::DEBUG
458 3 336 if ($self->{'id_attr'})
460 0 3 if ($nodes->size == 0)
472 344 0 if defined $val and length $val
491 0 345 unless $id
515 0 362 if $XML::Sig::DEBUG
544 0 362 if $XML::Sig::DEBUG
548 0 724 if $XML::Sig::DEBUG
549 362 362 if ($alg eq 'http://www.w3.org/2000/09/xmldsig#enveloped-signature') { }
0 362 elsif ($alg eq 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315') { }
0 362 elsif ($alg eq 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments') { }
362 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') { }
555 0 0 if $XML::Sig::DEBUG
559 0 0 if $XML::Sig::DEBUG
564 0 362 if $XML::Sig::DEBUG
569 0 0 if $XML::Sig::DEBUG
596 4 0 if ($child)
633 53 0 if $rsa_pub->verify($canonical, $bin_signature)
652 0 107 if ref $cert
690 0 107 if $@
722 50 74 if ($cert->key_alg_name eq 'id-ecPublicKey') { }
2 72 elsif ($cert->key_alg_name eq 'dsaEncryption') { }
723 0 50 unless eval { do { require Crypt::PK::ECC; "CryptX"->VERSION("0.036"); 1 } }
732 50 0 if ($ecdsa_pub->verify_message_rfc7518($bin_signature, $canonical, uc $self->{'sig_hash'}))
741 0 2 if $@
755 2 0 if ($dsa_pub->do_verify($self->{'sig_method'}->($canonical), $sigobj))
764 0 72 if $@
772 72 0 if ($rsa_pub->verify($canonical, $bin_signature))
850 0 57 if $@
882 57 0 if $dsa_pub->do_verify($self->{'sig_method'}->($canonical), $sigobj)
902 0 122 unless eval { do { require Crypt::PK::ECC; "CryptX"->VERSION("0.036"); 1 } }
946 122 0 if $ecdsa_pub->verify_message_rfc7518($bin_signature, $canonical, uc $self->{'sig_hash'})
969 12 0 if (defined $self->{'hmac_key'}) { }
970 0 12 if $XML::Sig::DEBUG
971 10 2 if (my $ref = 'Digest::SHA'->can('hmac_' . $self->{'sig_hash'})) { }
2 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($self->{'sig_hash'})) { }
972 5 5 if ($bin_signature eq $self->_calc_hmac_signature($canonical)) { }
980 1 1 if ($bin_signature eq $self->_calc_hmac_signature($canonical)) { }
1011 362 345 if ($context) { }
1026 0 0 if ($node) { }
1038 0 0 if (defined $self->{'dsig_prefix'} and length $self->{'dsig_prefix'})
1084 0 170 unless eval { do { require Crypt::PK::ECC; "CryptX"->VERSION("0.036"); 1 } }
1090 170 0 if ($ecdsa_key) { }
1140 0 56 if $@
1144 56 0 if ($dsa_key) { }
1188 0 109 if $@
1192 109 0 if ($rsaKey) { }
1197 55 54 if (not $self->{'x509'})
1234 0 18 unless (defined $self->{'key_name'})
1260 0 0 if $@
1265 0 0 if ($x509Key) { }
1294 0 108 if $@
1297 108 0 if (open my $CERT, '<', $file) { }
1304 108 0 if ($cert) { }
1340 0 2 if $@
1344 2 0 if ($cert) { }
1370 336 1 if (open my $KEY, '<', $file) { }
1376 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/) { }
1379 107 56 if ($key_used eq 'RSA') { }
1442 0 345 if (not defined $self->{'key_type'} and defined $self->{'hmac_key'})
1446 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') { }
1450 12 160 if ($self->{'sig_hash'} eq 'ripemd160' or $self->{'sig_hash'} eq 'whirlpool') { }
1489 34 311 if ($self->{'digest_hash'} eq 'sha1') { }
68 243 elsif ($self->{'digest_hash'} eq 'sha224' or $self->{'digest_hash'} eq 'sha384') { }
1526 0 713 if $XML::Sig::DEBUG
1534 0 713 if $XML::Sig::DEBUG
1535 1 712 if ($alg eq 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315') { }
5 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') { }
1536 0 1 if $XML::Sig::DEBUG
1540 0 5 if $XML::Sig::DEBUG
1544 0 0 if $XML::Sig::DEBUG
1548 0 0 if $XML::Sig::DEBUG
1552 0 707 if $XML::Sig::DEBUG
1556 0 0 if $XML::Sig::DEBUG
1580 0 58 if $XML::Sig::DEBUG
1581 58 0 if (my $ref = 'Digest::SHA'->can($self->{'sig_hash'})) { }
0 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($self->{'sig_hash'})) { }
1624 0 172 if $XML::Sig::DEBUG
1650 0 109 if $XML::Sig::DEBUG
1674 0 18 if $XML::Sig::DEBUG
1675 15 3 if (my $ref = 'Digest::SHA'->can('hmac_' . $self->{'sig_hash'})) { }
3 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($self->{'sig_hash'})) { }