Branch Coverage

blib/lib/Crypt/PKCS10.pm
Criterion Covered Total %
branch 240 392 61.2


line true false branch
239 0 0 if $c
253 0 0 if $len > $max[0]
254 0 0 if (exists $variantNames{$oid}) { }
256 0 0 if $len > $max[1]
258 0 0 if $len > $max[2]
261 0 0 if $len > $max[1]
271 0 0 exists $variantNames{$oid} ? :
272 0 0 if exists $variantNames{$oid}
290 0 2 unless @_ == 2 and defined $class and not ref $class
291 0 2 unless defined $version
292 0 2 unless $version >= 0 and $version <= 1
298 46 90 if /^\d/
308 0 2 unless defined $class
310 0 2 if ref $class and $class->isa('Crypt::PKCS10')
319 0 4 unless defined $class
321 0 4 unless defined $oid and defined $apiVersion and $apiVersion > 0
330 0 4 unless defined $class
332 0 4 unless defined $apiVersion and $apiVersion > 0
343 1 68 unless $oid
345 21 47 if (exists $oids{$oid}) { }
1 46 elsif (exists $oid2extkeyusage{$oid}) { }
361 0 11 unless defined $class
363 0 11 unless (defined $apiVersion)
368 3 8 if @_ == 2 and defined $oid
370 0 7 unless @_ >= 3 and defined $oid and defined $longname || defined $shortname
371 1 6 unless defined $oid and $oid =~ /^\d+(?:\.\d+)*$/
373 3 3 if (defined $longname) { }
374 1 2 if exists $oids{$oid} or exists $oid2extkeyusage{$oid}
375 1 1 if grep /^$longname$/, values %oids
377 1 0 unless exists $oids{$oid} or exists $oid2extkeyusage{$oid}
379 1 2 if defined $shortname and grep /^\U$shortname\E$/, values %shortnames
382 1 1 if (defined $longname) { }
388 1 1 if defined $shortname
397 0 12 if defined $class and ref $class and $class->isa('Crypt::PKCS10')
399 0 12 unless (defined $apiVersion)
406 0 12 unless defined $class and @_ >= 1
407 1 11 if $void
409 4 8 if ($@)
411 2 1 if (not $apiVersion or $die or not defined wantarray)
424 0 1 unless defined $class
426 0 1 if (ref $class and $class->isa('Crypt::PKCS10'))
447 1 10 if @_ >= 1 and ref $_[0] eq 'HASH'
449 0 11 unless @_ % 2 == 0
451 11 0 if @_
461 1 10 unless defined $der
463 0 10 if (keys %options)
467 9 1 unless exists $self->{'_binaryMode'}
475 5 5 if ($self->{'_readFile'})
476 0 5 unless open my $fh, '<', $der
480 7 3 if (&Scalar::Util::openhandle($der))
483 2 5 if $self->{'_binaryMode'}
486 0 7 unless defined $der
491 2 8 if ($self->{'_PEMonly'}) { }
5 6 elsif ($self->{'_acceptPEM'} and $der =~ /$pemre/) { }
492 1 1 if ($der =~ /$pemre/) { }
502 6 3 if ($isPEM)
507 1 5 if $self->{'_ignoreNonBase64'}
509 1 5 unless ($der =~ m[\A[A-Za-z0-9+/]+={0,2}\z] and length($der) % 4 == 0)
522 0 8 unless $tlen and $tag == 16
525 0 8 unless $llen and $len
529 0 8 if $tlen < $len
531 0 2 if ($tlen != $len and $self->{'_warnings'})
537 0 8 if ($@)
550 0 8 unless $asn->prepare("\n DirectoryString ::= CHOICE {\n teletexString TeletexString,\n printableString PrintableString,\n bmpString BMPString,\n universalString UniversalString,\n utf8String UTF8String,\n ia5String IA5String,\n integer INTEGER}\n\n Algorithms ::= ANY\n\n Name ::= SEQUENCE OF RelativeDistinguishedName\n RelativeDistinguishedName ::= SET OF AttributeTypeAndValue\n AttributeTypeAndValue ::= SEQUENCE {\n type OBJECT IDENTIFIER,\n value DirectoryString}\n\n Attributes ::= SET OF Attribute\n Attribute ::= SEQUENCE {\n type OBJECT IDENTIFIER,\n values SET OF ANY}\n\n\n AlgorithmIdentifier ::= SEQUENCE {\n algorithm OBJECT IDENTIFIER,\n parameters Algorithms OPTIONAL}\n\n SubjectPublicKeyInfo ::= SEQUENCE {\n algorithm AlgorithmIdentifier,\n subjectPublicKey BIT STRING}\n\n --- Certificate Request ---\n\n CertificationRequest ::= SEQUENCE {\n certificationRequestInfo CertificationRequestInfo,\n signatureAlgorithm AlgorithmIdentifier,\n signature BIT STRING},\n\n CertificationRequestInfo ::= SEQUENCE {\n version INTEGER ,\n subject Name OPTIONAL,\n subjectPKInfo SubjectPublicKeyInfo,\n attributes [0] Attributes OPTIONAL}\n\n --- Extensions ---\n\n BasicConstraints ::= SEQUENCE {\n cA BOOLEAN OPTIONAL, -- DEFAULT FALSE,\n pathLenConstraint INTEGER OPTIONAL}\n\n OS_Version ::= IA5String\n emailAddress ::= IA5String\n\n EnrollmentCSP ::= SEQUENCE {\n KeySpec INTEGER,\n Name BMPString,\n Signature BIT STRING}\n\n ENROLLMENT_CSP_PROVIDER ::= SEQUENCE { -- MSDN\n keySpec INTEGER,\n cspName BMPString,\n signature BIT STRING}\n\n ENROLLMENT_NAME_VALUE_PAIR ::= EnrollmentNameValuePair -- MSDN: SEQUENCE OF\n\n EnrollmentNameValuePair ::= SEQUENCE { -- MSDN\n name BMPString,\n value BMPString}\n\n ClientInformation ::= SEQUENCE { -- MSDN\n clientId INTEGER,\n MachineName UTF8String,\n UserName UTF8String,\n ProcessName UTF8String}\n\n extensionRequest ::= SEQUENCE OF Extension\n Extension ::= SEQUENCE {\n extnID OBJECT IDENTIFIER,\n critical BOOLEAN OPTIONAL,\n extnValue OCTET STRING}\n\n SubjectKeyIdentifier ::= OCTET STRING\n\n certificateTemplate ::= SEQUENCE {\n templateID OBJECT IDENTIFIER,\n templateMajorVersion INTEGER OPTIONAL, -- (0..4294967295)\n templateMinorVersion INTEGER OPTIONAL} -- (0..4294967295)\n\n EnhancedKeyUsage ::= SEQUENCE OF OBJECT IDENTIFIER\n KeyUsage ::= BIT STRING\n netscapeCertType ::= BIT STRING\n\n ApplicationCertPolicies ::= SEQUENCE OF PolicyInformation -- Microsoft\n\n PolicyInformation ::= SEQUENCE {\n policyIdentifier OBJECT IDENTIFIER,\n policyQualifiers SEQUENCE OF PolicyQualifierInfo OPTIONAL}\n\n PolicyQualifierInfo ::= SEQUENCE {\n policyQualifierId OBJECT IDENTIFIER,\n qualifier ANY}\n\n certificatePolicies ::= SEQUENCE OF certPolicyInformation -- RFC 3280\n\n certPolicyInformation ::= SEQUENCE {\n policyIdentifier CertPolicyId,\n policyQualifier SEQUENCE OF certPolicyQualifierInfo OPTIONAL}\n\n CertPolicyId ::= OBJECT IDENTIFIER\n\n certPolicyQualifierInfo ::= SEQUENCE {\n policyQualifierId CertPolicyQualifierId,\n qualifier ANY DEFINED BY policyQualifierId}\n\n CertPolicyQualifierId ::= OBJECT IDENTIFIER\n\n CertPolicyQualifier ::= CHOICE {\n cPSuri CPSuri,\n userNotice UserNotice }\n\n CPSuri ::= IA5String\n\n UserNotice ::= SEQUENCE {\n noticeRef NoticeReference OPTIONAL,\n explicitText DisplayText OPTIONAL}\n\n NoticeReference ::= SEQUENCE {\n organization DisplayText,\n noticeNumbers SEQUENCE OF INTEGER }\n\n DisplayText ::= CHOICE {\n ia5String IA5String,\n visibleString VisibleString,\n bmpString BMPString,\n utf8String UTF8String }\n\n unstructuredName ::= CHOICE {\n Ia5String IA5String,\n directoryString DirectoryString}\n\n challengePassword ::= DirectoryString\n\n subjectAltName ::= SEQUENCE OF GeneralName\n\n GeneralName ::= CHOICE {\n otherName [0] AnotherName,\n rfc822Name [1] IA5String,\n dNSName [2] IA5String,\n x400Address [3] ANY, --ORAddress,\n directoryName [4] Name,\n ediPartyName [5] EDIPartyName,\n uniformResourceIdentifier [6] IA5String,\n iPAddress [7] OCTET STRING,\n registeredID [8] OBJECT IDENTIFIER}\n\n AnotherName ::= SEQUENCE {\n type OBJECT IDENTIFIER,\n value [0] EXPLICIT ANY }\n\n EDIPartyName ::= SEQUENCE {\n nameAssigner [0] DirectoryString OPTIONAL,\n partyName [1] DirectoryString }\n\n certificateTemplateName ::= CHOICE {\n octets OCTET STRING,\n directoryString DirectoryString}\n\n rsaKey ::= SEQUENCE {\n modulus INTEGER,\n publicExponent INTEGER}\n\n dsaKey ::= INTEGER\n\n dsaPars ::= SEQUENCE {\n P INTEGER,\n Q INTEGER,\n G INTEGER}\n\n eccName ::= OBJECT IDENTIFIER\n\n ecdsaSigValue ::= SEQUENCE {\n r INTEGER,\n s INTEGER}\n")
742 0 8 unless my $top = $parser->decode($der)
778 0 8 unless $CRtag == 16
783 0 8 unless $CItag == 16
788 0 8 if $self->{'_verifySignature'} and not $self->checkSignature
816 111 102 unless ref $value
817 24 78 if (ref $value eq 'ARRAY')
823 78 0 if (ref $value eq 'HASH')
825 3 102 if ($k eq 'bmpString')
829 6 96 if ($k eq 'iPAddress')
832 3 3 if (length $addr == 4) { }
855 8 0 if defined $signatureAlgorithm->{'algorithm'} and exists $oids{$signatureAlgorithm->{'algorithm'}}
868 8 0 if defined $pkinfo->{'algorithm'}{'algorithm'} and exists $oids{$pkinfo->{'algorithm'}{'algorithm'}}
1029 0 24 if defined $name and exists $variantNames{$name}
1031 0 24 unless defined $name
1035 6 18 if ($name eq 'extensionRequest') { }
1038 0 18 unless my $parser = $self->_init($name, 1)
1040 0 18 if ($entry->{'values'}[1])
1043 0 18 unless my $value = $entry->{'values'} = $parser->decode($entry->{'values'}[0])
1046 12 6 if (exists $special{$name})
1060 0 6 unless my $decoded = $parser->decode($extensionRequest)
1064 14 13 if defined $name and exists $variantNames{$name}
1065 27 0 if (defined $name)
1069 0 27 unless ($parser)
1074 0 27 unless my $dec = $parser->decode($entry->{'extnValue'})
1079 21 6 if (exists $special{$asnName})
1097 0 43 exists $variantNames{$oid} ? :
1098 43 0 if (defined $name)
1101 0 43 exists $variantNames{$oid} ? :
1103 2 41 unless ($self->can($name))
1107 1 1 if wantarray
1125 0 87 unless (defined $parsed or $optional)
1139 3 3 if $format
1154 0 7 unless $self->{'certificationRequestInfo'}{'subject'}{$component}
7 2 if wantarray
1166 1 4 if wantarray
1173 18 1 if not $long and exists $shortnames{$name}
1191 1 4 if (scalar @sequence > 1) { }
1207 0 4 unless (defined $san)
1208 0 0 if wantarray
1212 2 2 unless (defined $type)
1213 1 1 if (wantarray)
1227 1 1 if wantarray
1246 2 2 if $format
1254 1 3 unless $self->{'_apiVersion'} >= 1
1261 0 3 unless defined $at
1263 2 1 if ($at eq 'rsaEncryption') { }
0 1 elsif ($at eq 'ecPublicKey') { }
1 0 elsif ($at eq 'dsa') { }
1271 0 2 ref $rsa->{'publicExponent'} ? :
1276 0 0 if ($@)
1280 0 0 if $self->{'_dieOnError'}
1288 0 0 if $detail
1292 0 0 if $rv->{'curve'}
1298 1 0 if (exists $self->{'certificationRequestInfo'}{'subjectPKInfo'}{'algorithm'}{'parameters'})
1309 0 0 if $self->{'_dieOnError'}
1322 1 0 if (exists $self->{'signatureAlgorithm'}{'parameters'})
1324 0 1 if ($tlen != 0 and $tag != 5)
1338 3 2 if (defined $format and $format == 2)
1339 0 3 if ($self->pkAlgorithm eq 'ecPublicKey')
1345 0 2 if $format
1360 0 55 unless defined $attributes
1369 0 22 if ($self->{'_apiVersion'} < 1)
1371 0 0 unless defined $attributes
1379 0 22 unless (defined $attributes)
1380 0 0 if wantarray
1384 5 17 unless (defined $name)
1390 0 17 if ($name eq 'extensionRequest')
1391 0 0 if wantarray
1400 1 16 unless (@attrs)
1401 0 1 if wantarray
1408 16 0 unless ref $values eq 'ARRAY'
1411 5 11 wantarray ? :
1414 5 11 if wantarray
1416 11 0 if (@values == 1)
1438 23 20 unless ref $hash eq 'HASH'
1442 1 19 if defined $exclude
1444 9 11 if @keys != 1
1446 4 7 if ref $$hash{$keys[0]} eq 'HASH'
1458 10 89 if (ref $value eq 'ARRAY')
1462 9 1 if @strings > 1
1465 25 64 if (ref $value eq 'HASH')
1469 15 10 if @strings > 1
1473 10 54 if $value =~ /^\d+$/
1477 8 46 if $self->{'_escapeStrings'}
1479 44 10 if $value =~ m(\A[\w!\@$%^&*_=+\[\]\{\}:;|<>./?"'-]+\z)
1488 0 4 unless defined $attributes and exists $attributes->{'extensionRequest'}
1491 4 0 if ($self->{'_apiVersion'} >= 1)
1493 10 5 if exists $variantNames{'$' . $ext}
1505 0 23 unless defined $attributes and exists $attributes->{'extensionRequest'}
1509 10 13 if exists $variantNames{$extensionName}
1512 21 55 if ($entry->{'extnID'} eq $extensionName)
1514 1 20 if ($self->{'_apiVersion'} == 0) { }
1520 3 17 if ($entry->{'_FMT'}) { }
1521 2 1 $format ? :
1524 8 9 if $format
1530 10 13 if $format
1540 0 6 unless defined $attributes and exists $attributes->{'extensionRequest'}
1544 4 2 if exists $variantNames{$extensionName}
1547 5 13 if ($entry->{'extnID'} eq $extensionName)
1548 2 3 if $entry->{'critical'}
1562 0 0 unless $self->{'_apiVersion'} >= 1
1571 0 0 if ($alg =~ /sha-?(\d+)/i) { }
0 0 elsif ($alg =~ /md-?(\d)/i) { }
1585 0 0 unless defined $keyp->{'keytype'}
1589 0 0 if ($keyp->{'keytype'} eq 'RSA')
1592 0 0 if $@
1599 0 0 if ($keyp->{'keytype'} eq 'DSA')
1602 0 0 if $@
1608 0 0 if ($keyp->{'keytype'} eq 'ECC')
1610 0 0 if $@
1618 0 0 if ($@)
1621 0 0 if $self->{'_dieOnError'}
1624 0 0 if $ok
1628 0 0 if $self->{'_dieOnError'}
1648 0 11 if length $text <= 65
1662 0 1 unless defined $v and $v == 1
1666 0 1 unless defined $self
1671 0 1 unless defined $v and $v == 1
1673 0 1 unless defined $string
1674 0 1 if $at
1685 3 10 if length $_ > $max
1694 0 1 unless $self->attributes
1702 0 1 unless $self->extensions
1705 1 2 $self->extensionPresent($_) == 2 ? :
1707 0 3 $_ eq 'subjectAltName' ? :
1721 0 4 if (not defined $v || defined($v = $self->error)) { }
0 4 elsif (ref $v) { }
1728 0 1 if (exists $kp->{'detail'})
1732 0 0 if ref $kp->{$_}
1740 0 1 if ($sp)
1744 0 0 if (ref $v)
1745 0 0 if ($v->can('as_hex')) { }