Branch Coverage

blib/lib/XML/Sig.pm
Criterion Covered Total %
branch 181 310 58.3


line true false branch
47 262 1668 if (exists $params->{$prop})
55 117 269 exists $params->{'x509'} ? :
56 15 371 if (exists $params->{'key_name'})
59 190 196 if (exists $params->{'key'})
62 63 321 if (exists $params->{'cert'})
65 4 380 if (exists $params->{'cert_text'})
68 15 369 if (exists $params->{'hmac_key'})
72 92 292 if (exists $params->{'sig_hash'} and grep {$_ eq $params->{'sig_hash'};} 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160') { }
80 104 280 if (exists $params->{'digest_hash'} and grep {$_ eq $params->{'digest_hash'};} 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160') { }
88 41 147 if (defined $self->{'key_type'} and check_dsa_version() and $self->{'key_type'} eq "dsa")
92 21 20 if ($sig_size eq 48) { }
99 2 382 if (exists $params->{'no_xml_declaration'} and $params->{'no_xml_declaration'} == 1) { }
105 15 181 if (not defined $self->{'key_type'} and exists $params->{'hmac_key'})
118 1 5 unless $self->key or $self->{'hmac_key'}
128 1 186 if ($self->{'ns'})
134 0 187 if $XML::Sig::DEBUG
140 0 195 if $XML::Sig::DEBUG
155 0 195 if $XML::Sig::DEBUG
166 195 0 if (my $ref = 'Digest::SHA'->can($self->{'digest_hash'})) { }
0 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($self->{'digest_hash'})) { }
179 0 195 if $XML::Sig::DEBUG
183 0 195 if $XML::Sig::DEBUG
213 42 153 if ($self->{'key_type'} eq 'dsa') { }
86 67 elsif ($self->{'key_type'} eq 'ecdsa') { }
62 5 elsif ($self->{'key_type'} eq 'rsa') { }
220 5 0 if (defined $self->{'hmac_key'}) { }
242 0 195 if $XML::Sig::DEBUG
265 2 204 if ($self->{'id_attr'})
266 2 0 if ($self->{'ns'})
275 0 206 if $XML::Sig::DEBUG
277 1 205 if $numsigs <= 0
282 0 218 if $XML::Sig::DEBUG
289 0 218 if $XML::Sig::DEBUG
291 0 218 if ($key_to_verify and $key_to_verify ne $reference)
292 0 0 if $XML::Sig::DEBUG
300 2 216 unless ($self->{'parser'}->findvalue(q(//*[@ID=') . $reference . q('])))
301 0 2 if $XML::Sig::DEBUG
302 1 1 if ($numsigs <= 1) { }
314 0 216 if $XML::Sig::DEBUG
321 0 216 if $XML::Sig::DEBUG
325 0 216 if $XML::Sig::DEBUG
337 0 216 if $XML::Sig::DEBUG
343 0 216 if $XML::Sig::DEBUG
345 216 0 if (my $ref = 'Digest::SHA'->can($signature_method)) { }
0 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($signature_method)) { }
355 216 0 if (my $ref = 'Digest::SHA'->can($digest_method)) { }
0 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($digest_method)) { }
367 16 200 if (defined $self->{'cert_obj'}) { }
10 190 elsif (not defined $self->{'cert_obj'} and defined $self->{'hmac_key'}) { }
369 0 16 unless ($self->_verify_x509_cert($self->{'cert_obj'}, $signed_info_canon, $signature))
376 5 5 unless ($self->_verify_hmac($signed_info_canon, $signature))
377 0 5 if $XML::Sig::DEBUG
393 190 287 if ($key_info_sig_type eq 'X509Data') { }
402 190 287 if ($keyinfo_nodeset->size)
404 0 190 if $XML::Sig::DEBUG
405 0 190 if (not $self->$verify_method($keyinfo_nodeset->get_node(0), $signed_info_canon, $signature)) { }
407 0 0 if $XML::Sig::DEBUG
411 0 190 if $XML::Sig::DEBUG
416 0 190 unless $keyinfo_nodeset and $keyinfo_nodeset->size > 0
434 0 211 if $XML::Sig::DEBUG
439 0 211 if $XML::Sig::DEBUG
441 0 211 if $XML::Sig::DEBUG
444 0 211 unless $refdigest eq _trim(&encode_base64($digest, ""))
446 0 211 if $XML::Sig::DEBUG
473 4 185 if ($self->{'id_attr'})
475 0 4 if ($nodes->size == 0)
487 193 0 if defined $val and length $val
506 0 195 unless $id
530 0 211 if $XML::Sig::DEBUG
559 0 211 if $XML::Sig::DEBUG
563 0 422 if $XML::Sig::DEBUG
564 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') { }
570 0 0 if $XML::Sig::DEBUG
574 0 0 if $XML::Sig::DEBUG
579 0 211 if $XML::Sig::DEBUG
584 0 0 if $XML::Sig::DEBUG
611 4 0 if ($child)
638 0 28 if $@
653 28 0 if $rsa_pub->verify_message($bin_signature, $canonical, $self->{'sig_hash'}, "v1.5")
672 0 62 if ref $cert
710 0 62 if $@
742 27 51 if ($cert->key_alg_name eq 'id-ecPublicKey') { }
2 49 elsif ($cert->key_alg_name eq 'dsaEncryption') { }
743 0 27 unless eval { do { require Crypt::PK::ECC; "CryptX"->VERSION("0.036"); 1 } }
752 27 0 if ($ecdsa_pub->verify_message_rfc7518($bin_signature, $canonical, uc $self->{'sig_hash'}))
758 0 2 unless $self->check_dsa_version
772 2 0 if ($dsa_pub->do_verify($self->{'sig_method'}->($canonical), $sigobj))
781 0 49 if $@
788 49 0 if ($rsa_pub->verify_message($bin_signature, $canonical, $self->{'sig_hash'}, "v1.5"))
884 0 282 if (not defined $ver or "version"->parse($ver) lt "version"->parse("0.20"))
907 0 41 unless $self->check_dsa_version
939 41 0 if $dsa_pub->do_verify($self->{'sig_method'}->($canonical), $sigobj)
959 0 59 unless eval { do { require Crypt::PK::ECC; "CryptX"->VERSION("0.036"); 1 } }
1003 59 0 if $ecdsa_pub->verify_message_rfc7518($bin_signature, $canonical, uc $self->{'sig_hash'})
1026 10 0 if (defined $self->{'hmac_key'}) { }
1027 0 10 if $XML::Sig::DEBUG
1028 10 0 if (my $ref = 'Digest::SHA'->can('hmac_' . $self->{'sig_hash'})) { }
0 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($self->{'sig_hash'})) { }
1029 5 5 if ($bin_signature eq $self->_calc_hmac_signature($canonical)) { }
1037 0 0 if ($bin_signature eq $self->_calc_hmac_signature($canonical)) { }
1068 211 195 if ($context) { }
1112 0 84 unless eval { do { require Crypt::PK::ECC; "CryptX"->VERSION("0.036"); 1 } }
1118 84 0 if ($ecdsa_key) { }
1164 0 41 unless $self->check_dsa_version
1169 41 0 if ($dsa_key) { }
1213 0 63 if $@
1218 63 0 if ($rsaKey) { }
1222 33 30 if (not $self->{'x509'})
1255 0 15 unless (defined $self->{'key_name'})
1281 0 0 if $@
1286 0 0 if ($x509Key) { }
1315 0 63 if $@
1318 63 0 if (open my $CERT, '<', "$file") { }
1325 63 0 if ($cert) { }
1361 0 4 if $@
1365 4 0 if ($cert) { }
1391 189 1 if (open my $KEY, '<', "$file") { }
1397 103 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/) { }
1400 62 41 if ($key_used eq 'RSA') { }
1463 0 195 if (not defined $self->{'key_type'} and defined $self->{'hmac_key'})
1467 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') { }
1471 0 86 if ($self->{'sig_hash'} eq 'ripemd160' or $self->{'sig_hash'} eq 'whirlpool') { }
1510 0 195 if ($self->{'digest_hash'} eq 'sha1') { }
52 143 elsif ($self->{'digest_hash'} eq 'sha224' or $self->{'digest_hash'} eq 'sha384') { }
1547 0 411 if $XML::Sig::DEBUG
1555 0 411 if $XML::Sig::DEBUG
1556 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') { }
1557 0 1 if $XML::Sig::DEBUG
1561 0 5 if $XML::Sig::DEBUG
1565 0 0 if $XML::Sig::DEBUG
1569 0 0 if $XML::Sig::DEBUG
1573 0 405 if $XML::Sig::DEBUG
1577 0 0 if $XML::Sig::DEBUG
1601 0 42 if $XML::Sig::DEBUG
1602 42 0 if (my $ref = 'Digest::SHA'->can($self->{'sig_hash'})) { }
0 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($self->{'sig_hash'})) { }
1645 0 86 if $XML::Sig::DEBUG
1671 0 62 if $XML::Sig::DEBUG
1693 0 15 if $XML::Sig::DEBUG
1694 15 0 if (my $ref = 'Digest::SHA'->can('hmac_' . $self->{'sig_hash'})) { }
0 0 elsif ($ref = 'Crypt::Digest::RIPEMD160'->can($self->{'sig_hash'})) { }