| 1 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # Crypt::PKCS10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: parse PKCS #10 certificate requests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # This software is copyright (c) 2014 by Gideon Knocke. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # Copyright (c) 2016 Gideon Knocke, Timothe Litt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # See LICENSE for details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | package Crypt::PKCS10; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use overload( q("") => 'as_string' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 3 | ▶ | use Convert::ASN1( qw/:tag :const/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use Encode (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | ▶ | use MIME::Base64; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | our $VERSION = '2.005'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | my $apiVersion = undef; # 0 for compatibility. 1 for prefered | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | my $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # N.B. Names are exposed in the API. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # %shortnames follows & depends on (some) values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # When adding OIDs, re-generate the documentation (see "for MAINTAINER" below) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # New OIDs don't need the [ ] syntax, which is [ prefered name, deprecated name ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # Some of the deprecated names are used in the ASN.1 definition. and in the $self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # structure, which unfortunately is exposed with the attributes() method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # Dealing with the deprecated names causes some messy code. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 3 | my %oids = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | '2.5.4.6' => 'countryName', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | '2.5.4.8' => 'stateOrProvinceName', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | '2.5.4.10' => 'organizationName', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | '2.5.4.11' => 'organizationalUnitName', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | '2.5.4.3' => 'commonName', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | '1.2.840.113549.1.9.1' => 'emailAddress', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | '1.2.840.113549.1.9.2' => 'unstructuredName', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | '1.2.840.113549.1.9.7' => 'challengePassword', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | '1.2.840.113549.1.9.8' => 'unstructuredAddress', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | '1.2.840.113549.1.1.1' => [ 'rsaEncryption', 'RSA encryption' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | '1.2.840.113549.1.1.5' => [ 'sha1WithRSAEncryption', 'SHA1 with RSA encryption' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | '1.2.840.113549.1.1.4' => [ 'md5WithRSAEncryption', 'MD5 with RSA encryption' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | '1.2.840.113549.1.1.10' => 'rsassaPss', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | '1.2.840.113549.1.9.14' => 'extensionRequest', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | '1.3.6.1.4.1.311.13.2.3' => 'OS_Version', # Microsoft | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | '1.3.6.1.4.1.311.13.2.2' => 'EnrollmentCSP', # Microsoft | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | '1.3.6.1.4.1.311.21.20' => 'ClientInformation', # Microsoft REQUEST_CLIENT_INFO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | '1.3.6.1.4.1.311.21.7' => 'certificateTemplate', # Microsoft | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | '2.5.29.37' => [ 'extKeyUsage', 'EnhancedKeyUsage' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | '2.5.29.15' => [ 'keyUsage', 'KeyUsage' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | '1.3.6.1.4.1.311.21.10' => 'ApplicationCertPolicies', # Microsoft APPLICATION_CERT_POLICIES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | '2.5.29.14' => [ 'subjectKeyIdentifier', 'SubjectKeyIdentifier' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | '2.5.29.17' => 'subjectAltName', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | '1.3.6.1.4.1.311.20.2' => 'certificateTemplateName', # Microsoft | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | '2.16.840.1.113730.1.1' => 'netscapeCertType', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | '2.16.840.1.113730.1.2' => 'netscapeBaseUrl', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | '2.16.840.1.113730.1.4' => 'netscapeCaRevocationUrl', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | '2.16.840.1.113730.1.7' => 'netscapeCertRenewalUrl', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | '2.16.840.1.113730.1.8' => 'netscapeCaPolicyUrl', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | '2.16.840.1.113730.1.12' => 'netscapeSSLServerName', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | '2.16.840.1.113730.1.13' => 'netscapeComment', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | #untested | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | '2.5.29.19' => [ 'basicConstraints', 'Basic Constraints' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | '1.2.840.10040.4.1' => [ 'dsa', 'DSA' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | '1.2.840.10040.4.3' => [ 'dsaWithSha1', 'DSA with SHA1' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | '1.2.840.10045.2.1' => 'ecPublicKey', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | '1.2.840.10045.4.3.1' => 'ecdsa-with-SHA224', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | '1.2.840.10045.4.3.2' => 'ecdsa-with-SHA256', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | '1.2.840.10045.4.3.3' => 'ecdsa-with-SHA384', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | '1.2.840.10045.4.3.4' => 'ecdsa-with-SHA512', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | '1.3.36.3.3.2.8.1.1.1' => 'brainpoolP160r1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | '1.3.36.3.3.2.8.1.1.2' => 'brainpoolP160t1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | '1.3.36.3.3.2.8.1.1.3' => 'brainpoolP192r1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | '1.3.36.3.3.2.8.1.1.4' => 'brainpoolP192t1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | '1.3.36.3.3.2.8.1.1.5' => 'brainpoolP224r1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | '1.3.36.3.3.2.8.1.1.6' => 'brainpoolP224t1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | '1.3.36.3.3.2.8.1.1.7' => 'brainpoolP256r1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | '1.3.36.3.3.2.8.1.1.8' => 'brainpoolP256t1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | '1.3.36.3.3.2.8.1.1.9' => 'brainpoolP320r1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | '1.3.36.3.3.2.8.1.1.10' => 'brainpoolP320t1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | '1.3.36.3.3.2.8.1.1.11' => 'brainpoolP384r1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | '1.3.36.3.3.2.8.1.1.12' => 'brainpoolP384t1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | '1.3.36.3.3.2.8.1.1.13' => 'brainpoolP512r1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | '1.3.36.3.3.2.8.1.1.14' => 'brainpoolP512t1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | '1.2.840.10045.3.1.1' => 'secp192r1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | '1.3.132.0.1' => 'sect163k1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | '1.3.132.0.15' => 'sect163r2', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | '1.3.132.0.33' => 'secp224r1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | '1.3.132.0.26' => 'sect233k1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | '1.3.132.0.27' => 'sect233r1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | '1.3.132.0.16' => 'sect283k1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | '1.3.132.0.17' => 'sect283r1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | '1.2.840.10045.3.1.7' => 'secp256r1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | '1.3.132.0.34' => 'secp384r1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | '1.3.132.0.36' => 'sect409k1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | '1.3.132.0.37' => 'sect409r1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | '1.3.132.0.35' => 'secp521r1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | '1.3.132.0.38' => 'sect571k1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | '1.3.132.0.39' => 'sect571r1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | #not std yet '1.3.6.1.4.1.3029.1.5.1' => 'curve25519', # GNU TLS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # '1.3.6.1.4.1.11591.7' => 'curve25519', #ID josefsson-pkix-newcurves-00 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # '1.3.6.1.4.1.11591.8' => 'curve448', #ID josefsson-pkix-newcurves-00 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | '0.9.2342.19200300.100.1.25' => 'domainComponent', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | '0.9.2342.19200300.100.1.1' => 'userID', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | '2.5.4.7' => 'localityName', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | '1.2.840.113549.1.1.11' => [ 'sha256WithRSAEncryption', 'SHA-256 with RSA encryption' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | '1.2.840.113549.1.1.12' => 'sha384WithRSAEncryption', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | '1.2.840.113549.1.1.13' => [ 'sha512WithRSAEncryption', 'SHA-512 with RSA encryption' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | '1.2.840.113549.1.1.14' => 'sha224WithRSAEncryption', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | '1.2.840.113549.1.1.2' => [ 'md2WithRSAEncryption', 'MD2 with RSA encryption' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | '1.2.840.113549.1.1.3' => 'md4WithRSAEncryption', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | '1.2.840.113549.1.1.6' => 'rsaOAEPEncryptionSET', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | '1.2.840.113549.1.1.7' => 'RSAES-OAEP', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | '1.2.840.113549.1.9.15' => [ 'smimeCapabilities', 'SMIMECapabilities' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | '1.3.14.3.2.26' => 'sha1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | '1.3.14.3.2.29' => [ 'sha1WithRSAEncryption', 'SHA1 with RSA signature' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | '1.3.6.1.4.1.311.13.1' => 'RENEWAL_CERTIFICATE', # Microsoft | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | '1.3.6.1.4.1.311.13.2.1' => 'ENROLLMENT_NAME_VALUE_PAIR', # Microsoft | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | '1.3.6.1.4.1.311.13.2.2' => 'ENROLLMENT_CSP_PROVIDER', # Microsoft | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | '1.3.6.1.4.1.311.2.1.14' => 'CERT_EXTENSIONS', # Microsoft | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | '1.3.6.1.5.2.3.5' => [ 'keyPurposeKdc', 'KDC Authentication' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | '1.3.6.1.5.5.7.9.5' => 'countryOfResidence', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | '2.16.840.1.101.3.4.2.1' => [ 'sha256', 'SHA-256' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | '2.16.840.1.101.3.4.2.2' => [ 'sha384', 'SHA-384' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | '2.16.840.1.101.3.4.2.3' => [ 'sha512', 'SHA-512' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | '2.16.840.1.101.3.4.2.4' => [ 'sha224', 'SHA-224' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | '2.16.840.1.101.3.4.3.1' => 'dsaWithSha224', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | '2.16.840.1.101.3.4.3.2' => 'dsaWithSha256', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | '2.16.840.1.101.3.4.3.3' => 'dsaWithSha384', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | '2.16.840.1.101.3.4.3.4' => 'dsaWithSha512', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | '2.5.4.12' => [ 'title', 'Title' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | '2.5.4.13' => [ 'description', 'Description' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | '2.5.4.14' => 'searchGuide', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | '2.5.4.15' => 'businessCategory', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | '2.5.4.16' => 'postalAddress', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | '2.5.4.17' => 'postalCode', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | '2.5.4.18' => 'postOfficeBox', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | '2.5.4.19', => 'physicalDeliveryOfficeName', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | '2.5.4.20', => 'telephoneNumber', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | '2.5.4.23', => 'facsimileTelephoneNumber', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | '2.5.4.4' => [ 'surname', 'Surname' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | '2.5.4.41' => [ 'name', 'Name' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | '2.5.4.42' => 'givenName', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | '2.5.4.43' => 'initials', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | '2.5.4.44' => 'generationQualifier', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | '2.5.4.45' => 'uniqueIdentifier', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | '2.5.4.46' => 'dnQualifier', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | '2.5.4.51' => 'houseIdentifier', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | '2.5.4.65' => 'pseudonym', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | '2.5.4.5' => 'serialNumber', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | '2.5.4.9' => 'streetAddress', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | '2.5.29.32' => 'certificatePolicies', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | '2.5.29.32.0' => 'anyPolicy', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | '1.3.6.1.5.5.7.2.1' => 'CPS', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | '1.3.6.1.5.5.7.2.2' => 'userNotice', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 3 | my %variantNames; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 3 | foreach (keys %oids) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 360 | my $val = $oids{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 360 | ▶ | if( ref $val ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 69 | $variantNames{$_} = $val; # OID to [ new, trad ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 69 | $variantNames{$val->[0]} = $val->[1]; # New name to traditional for lookups | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 69 | $variantNames{'$' . $val->[1]} = $val->[0]; # \$Traditional to new | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 69 | ▶ | $oids{$_} = $val->[!$apiVersion || 0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
!$apiVersion || 0
MC/DC0%0/1
!$apiVersion || 0
!$apiVersion
Truth table50%1/2
not(A)
A= !$apiVersion
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 3 | my %oid2extkeyusage = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | '1.3.6.1.5.5.7.3.1' => 'serverAuth', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | '1.3.6.1.5.5.7.3.2' => 'clientAuth', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | '1.3.6.1.5.5.7.3.3' => 'codeSigning', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | '1.3.6.1.5.5.7.3.4' => 'emailProtection', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | '1.3.6.1.5.5.7.3.8' => 'timeStamping', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | '1.3.6.1.5.5.7.3.9' => 'OCSPSigning', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | '1.3.6.1.5.5.7.3.21' => 'sshClient', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | '1.3.6.1.5.5.7.3.22' => 'sshServer', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | # Microsoft usages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | '1.3.6.1.4.1.311.10.3.1' => 'msCTLSign', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | '1.3.6.1.4.1.311.10.3.2' => 'msTimeStamping', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | '1.3.6.1.4.1.311.10.3.3' => 'msSGC', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | '1.3.6.1.4.1.311.10.3.4' => 'msEFS', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | '1.3.6.1.4.1.311.10.3.4.1' => 'msEFSRecovery', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | '1.3.6.1.4.1.311.10.3.5' => 'msWHQLCrypto', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | '1.3.6.1.4.1.311.10.3.6' => 'msNT5Crypto', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | '1.3.6.1.4.1.311.10.3.7' => 'msOEMWHQLCrypto', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | '1.3.6.1.4.1.311.10.3.8' => 'msEmbeddedNTCrypto', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | '1.3.6.1.4.1.311.10.3.9' => 'msRootListSigner', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | '1.3.6.1.4.1.311.10.3.10' => 'msQualifiedSubordination', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | '1.3.6.1.4.1.311.10.3.11' => 'msKeyRecovery', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | '1.3.6.1.4.1.311.10.3.12' => 'msDocumentSigning', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | '1.3.6.1.4.1.311.10.3.13' => 'msLifetimeSigning', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | '1.3.6.1.4.1.311.10.3.14' => 'msMobileDeviceSoftware', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | '1.3.6.1.4.1.311.2.1.21' => 'msCodeInd', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | '1.3.6.1.4.1.311.2.1.22' => 'msCodeCom', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | '1.3.6.1.4.1.311.20.2.2' => 'msSmartCardLogon', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # Netscape | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | '2.16.840.1.113730.4.1' => 'nsSGC', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 3 | my %shortnames = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | countryName => 'C', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | stateOrProvinceName => 'ST', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | organizationName => 'O', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | organizationalUnitName => 'OU', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | commonName => 'CN', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | # emailAddress => 'E', # Deprecated & not recognized by some software | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | domainComponent => 'DC', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | localityName => 'L', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | userID => 'UID', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | surname => 'SN', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | givenName => 'GN', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 3 | our $schema = <<ASN1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | DirectoryString ::= CHOICE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | teletexString TeletexString, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | printableString PrintableString, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | bmpString BMPString, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | universalString UniversalString, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | utf8String UTF8String, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | ia5String IA5String, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | integer INTEGER} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | Algorithms ::= ANY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | Name ::= SEQUENCE OF RelativeDistinguishedName | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | RelativeDistinguishedName ::= SET OF AttributeTypeAndValue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | AttributeTypeAndValue ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | type OBJECT IDENTIFIER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | value DirectoryString} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | Attributes ::= SET OF Attribute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | Attribute ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | type OBJECT IDENTIFIER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | values SET OF ANY} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | AlgorithmIdentifier ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | algorithm OBJECT IDENTIFIER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | parameters Algorithms OPTIONAL} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | SubjectPublicKeyInfo ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | algorithm AlgorithmIdentifier, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | subjectPublicKey BIT STRING} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | --- Certificate Request --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | CertificationRequest ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | certificationRequestInfo CertificationRequestInfo, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | signatureAlgorithm AlgorithmIdentifier, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | signature BIT STRING}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | CertificationRequestInfo ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | version INTEGER , | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | subject Name OPTIONAL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | subjectPKInfo SubjectPublicKeyInfo, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | attributes [0] Attributes OPTIONAL} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | --- Extensions --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | BasicConstraints ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | cA BOOLEAN OPTIONAL, -- DEFAULT FALSE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | pathLenConstraint INTEGER OPTIONAL} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | OS_Version ::= IA5String | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | emailAddress ::= IA5String | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | EnrollmentCSP ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | KeySpec INTEGER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | Name BMPString, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | Signature BIT STRING} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | ENROLLMENT_CSP_PROVIDER ::= SEQUENCE { -- MSDN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | keySpec INTEGER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | cspName BMPString, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | signature BIT STRING} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | ENROLLMENT_NAME_VALUE_PAIR ::= EnrollmentNameValuePair -- MSDN: SEQUENCE OF | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | EnrollmentNameValuePair ::= SEQUENCE { -- MSDN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | name BMPString, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | value BMPString} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | ClientInformation ::= SEQUENCE { -- MSDN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | clientId INTEGER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | MachineName UTF8String, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | UserName UTF8String, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | ProcessName UTF8String} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | extensionRequest ::= SEQUENCE OF Extension | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | Extension ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | extnID OBJECT IDENTIFIER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | critical BOOLEAN OPTIONAL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | extnValue OCTET STRING} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | SubjectKeyIdentifier ::= OCTET STRING | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | certificateTemplate ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | templateID OBJECT IDENTIFIER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | templateMajorVersion INTEGER OPTIONAL, -- (0..4294967295) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | templateMinorVersion INTEGER OPTIONAL} -- (0..4294967295) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | EnhancedKeyUsage ::= SEQUENCE OF OBJECT IDENTIFIER | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | KeyUsage ::= BIT STRING | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | netscapeCertType ::= BIT STRING | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | ApplicationCertPolicies ::= SEQUENCE OF PolicyInformation -- Microsoft | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | PolicyInformation ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | policyIdentifier OBJECT IDENTIFIER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | policyQualifiers SEQUENCE OF PolicyQualifierInfo OPTIONAL} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | PolicyQualifierInfo ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | policyQualifierId OBJECT IDENTIFIER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | qualifier ANY} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | certificatePolicies ::= SEQUENCE OF certPolicyInformation -- RFC 3280 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | certPolicyInformation ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | policyIdentifier CertPolicyId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | policyQualifier SEQUENCE OF certPolicyQualifierInfo OPTIONAL} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | CertPolicyId ::= OBJECT IDENTIFIER | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | certPolicyQualifierInfo ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | policyQualifierId CertPolicyQualifierId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | qualifier ANY DEFINED BY policyQualifierId} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | CertPolicyQualifierId ::= OBJECT IDENTIFIER | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | CertPolicyQualifier ::= CHOICE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | cPSuri CPSuri, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | userNotice UserNotice } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | CPSuri ::= IA5String | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | UserNotice ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | noticeRef NoticeReference OPTIONAL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | explicitText DisplayText OPTIONAL} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | NoticeReference ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | organization DisplayText, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | noticeNumbers SEQUENCE OF INTEGER } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | DisplayText ::= CHOICE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | ia5String IA5String, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | visibleString VisibleString, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | bmpString BMPString, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | utf8String UTF8String } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | unstructuredName ::= CHOICE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | Ia5String IA5String, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | directoryString DirectoryString} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | unstructuredAddress ::= CHOICE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | Ia5String IA5String, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | directoryString DirectoryString} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | challengePassword ::= DirectoryString | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | subjectAltName ::= SEQUENCE OF GeneralName | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | GeneralName ::= CHOICE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | otherName [0] AnotherName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | rfc822Name [1] IA5String, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | dNSName [2] IA5String, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | x400Address [3] ANY, --ORAddress, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | directoryName [4] Name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | ediPartyName [5] EDIPartyName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | uniformResourceIdentifier [6] IA5String, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | iPAddress [7] OCTET STRING, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | registeredID [8] OBJECT IDENTIFIER} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | AnotherName ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | type OBJECT IDENTIFIER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | value [0] EXPLICIT ANY } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | EDIPartyName ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | nameAssigner [0] DirectoryString OPTIONAL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | partyName [1] DirectoryString } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | certificateTemplateName ::= CHOICE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | octets OCTET STRING, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | directoryString DirectoryString} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | rsaKey ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | modulus INTEGER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | publicExponent INTEGER} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | dsaKey ::= INTEGER | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | dsaPars ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | P INTEGER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | Q INTEGER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | G INTEGER} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | eccName ::= OBJECT IDENTIFIER | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | ecdsaSigValue ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | r INTEGER, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | s INTEGER} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | rsassaPssParam ::= SEQUENCE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | digestAlgorithm [0] EXPLICIT AlgorithmIdentifier OPTIONAL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | maskGenAlgorithm [1] EXPLICIT AlgorithmIdentifier OPTIONAL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | saltLength [2] EXPLICIT INTEGER OPTIONAL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | trailerField [3] EXPLICIT INTEGER OPTIONAL} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | ASN1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 3 | my %name2oid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | # For generating documentation, not part of API | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | sub _cmpOID { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cmpOID: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my @a = split( /\./, $a ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my @b = split( /\./, $b ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | while( @a && @b ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@a and @b
MC/DC0%0/2
@a and @b
@a
@b
Truth table0%0/3
A and B
A= @aB= @b
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my $c = shift @a <=> shift @b; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | return $c if( $c ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | return @a <=> @b; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | sub __listOIDs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__listOIDs: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | my ( $hash ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | my @max = (0) x 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | foreach my $oid ( keys %$hash ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | my $len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | $len = length $oid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | $max[0] = $len if( $len > $max[0] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | if( exists $variantNames{$oid} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | $len = length $variantNames{$oid}[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | $max[1] = $len if( $len > $max[1] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | $len = length $variantNames{$oid}[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | $max[2] = $len if( $len > $max[2] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | $len = length $hash->{$oid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | $max[1] = $len if( $len > $max[1] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | printf( " %-*s %-*s %s\n %s %s %s\n", $max[0], 'OID', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | $max[1], 'Name (API v1)', 'Old Name (API v0)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | '-' x $max[0], '-' x $max[1], '-' x $max[2] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | foreach my $oid ( sort _cmpOID keys %$hash ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | printf( " %-*s %-*s", $max[0], $oid, $max[1], (exists $variantNames{$oid})? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | $variantNames{$oid}[0]: $hash->{$oid} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | printf( " (%-s)", $variantNames{$oid}[1] ) if( exists $variantNames{$oid} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | print( "\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | sub _listOIDs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_listOIDs: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | $class->setAPIversion(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | $class-> __listOIDs( { %oids, %oid2extkeyusage } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 3 | ▶ | sub setAPIversion { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setAPIversion: called CC=10 SCAR=25.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 3 | my( $class, $version ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 3 | ▶ | croak( substr(($error = "Wrong number of arguments\n"), 0, -1) ) unless( @_ == 2 && defined $class && !ref $class ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
@_ == 2 and defined $class and not ref $class
@_ == 2 and defined $class
MC/DC0%0/3
@_ == 2 and defined $class and not ref $class
@_ == 2
defined $class
not ref $class
Truth table25%1/4
A and B and not(C)
A= @_ == 2B= defined $classC= not ref $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 3 | ▶ | $version = 0 unless( defined $version ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 3 | ▶ | croak( substr(($error = "Unsupported API version $version\n"), 0, -1) ) unless( $version >= 0 && $version <= 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$version >= 0 and $version <= 1
MC/DC0%0/2
$version >= 0 and $version <= 1
$version >= 0
$version <= 1
Truth table33%1/3
A and B
A= $version >= 0B= $version <= 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 3 | $apiVersion = $version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 3 | ▶ | $version = !$version || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
!$version || 0
MC/DC100%1/1
!$version || 0
!$version
Truth table100%2/2
not(A)
A= !$version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 3 | foreach (keys %variantNames) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 204 | ▶ | $oids{$_} = $variantNames{$_}[$version] if( /^\d/ ); # Map OID to selected name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 3 | %name2oid = reverse (%oids, %oid2extkeyusage); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 2 | ▶ | sub getAPIversion { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getAPIversion: called CC=4 SCAR=15.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 2 | my( $class ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 2 | ▶ | croak( "Class not specified for getAPIversion()" ) unless( defined $class ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 2 | ▶ | return $class->{_apiVersion} if( ref $class && $class->isa( __PACKAGE__ ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $class and $class->isa(__PACKAGE__)
MC/DC0%0/2
ref $class and $class->isa(__PACKAGE__)
ref $class
$class->isa(__PACKAGE__)
Truth table33%1/3
A and B
A= ref $classB= $class->isa(__PACKAGE__)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 2 | return $apiVersion; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 4 | ▶ | sub name2oid { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name2oid: called CC=5 SCAR=18.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 4 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 4 | my( $oid ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 4 | ▶ | croak( "Class not specifed for name2oid()" ) unless( defined $class ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 4 | ▶ | return unless( defined $oid && defined $apiVersion && $apiVersion > 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $oid and defined $apiVersion and $apiVersion > 0
defined $oid and defined $apiVersion
MC/DC0%0/3
defined $oid and defined $apiVersion and $apiVersion > 0
defined $oid
defined $apiVersion
$apiVersion > 0
Truth table25%1/4
A and B and C
A= defined $oidB= defined $apiVersionC= $apiVersion > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 4 | return $name2oid{$oid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 4 | ▶ | sub oid2name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
oid2name: called CC=4 SCAR=15.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 4 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 4 | my( $oid ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 4 | ▶ | croak( "Class not specifed for oid2name()" ) unless( defined $class ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 4 | ▶ | return $oid unless( defined $apiVersion && $apiVersion > 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $apiVersion and $apiVersion > 0
MC/DC0%0/2
defined $apiVersion and $apiVersion > 0
defined $apiVersion
$apiVersion > 0
Truth table33%1/3
A and B
A= defined $apiVersionB= $apiVersion > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 4 | return $class->_oid2name( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | # Should not be exported, as overloading may break ASN lookups | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 75 | ▶ | sub _oid2name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_oid2name: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 75 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 75 | my( $oid ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 75 | ▶ | return unless($oid); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 74 | ▶ | if( exists $oids{$oid} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 24 | $oid = $oids{$oid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | }elsif( exists $oid2extkeyusage{$oid} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 1 | $oid = $oid2extkeyusage{$oid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 74 | return $oid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | # registerOID( $oid ) => true if $oid is registered, false if not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | # registerOID( $oid, $longname ) => Register an OID with its name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | # registerOID( $oid, $longname, $shortname ) => Register an OID with an abbreviation for RDNs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | # registerOID( $oid, undef, $shortname ) => Register an abbreviation for RDNs for an existing OID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 11 | ▶ | sub registerOID { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
registerOID: called CC=22 SCAR=31.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 11 | my( $class, $oid, $longname, $shortname ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 11 | ▶ | croak( "Class not specifed for registerOID()" ) unless( defined $class ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 11 | ▶ | unless( defined $apiVersion ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | carp( "${class}::setAPIversion MUST be called before registerOID(). Defaulting to legacy mode" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | $class->setAPIversion(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 11 | ▶ | return exists $oids{$oid} || exists $oid2extkeyusage{$oid} if( @_ == 2 && defined $oid ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@_ == 2 and defined $oid
exists $oids{$oid} || exists $oid2extkeyusage{$oid}
MC/DC100%2/2
@_ == 2 and defined $oid
@_ == 2
defined $oid
MC/DC100%2/2
exists $oids{$oid} || exists $oid2extkeyusage{$oid}
exists $oids{$oid}
exists $oid2extkeyusage{$oid}
Truth table100%3/3
A and B
A= @_ == 2B= defined $oid
Truth table100%3/3
A || B
A= exists $oids{$oid}B= exists $oid2extkeyusage{$oid}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 8 | ▶ | croak( "Not enough arguments" ) unless( @_ >= 3 && defined $oid && ( defined $longname || defined $shortname ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
@_ >= 3 and defined $oid and defined $longname || defined $shortname
@_ >= 3 and defined $oid
defined $longname or defined $shortname
MC/DC25%1/4
@_ >= 3 and defined $oid and defined $longname || defined $shortname
@_ >= 3
defined $oid
defined $longname
defined $shortname
Truth table60%3/5
A and B and C or D
A= @_ >= 3B= defined $oidC= defined $longnameD= defined $shortname
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 7 | ▶ | croak( "Invalid OID $oid" ) unless( defined $oid && $oid =~ /^\d+(?:\.\d+)*$/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $oid and $oid =~ /^\d+(?:\.\d+)*$/
MC/DC50%1/2
defined $oid and $oid =~ /^\d+(?:\.\d+)*$/
defined $oid
$oid =~ /^\d+(?:\.\d+)*$/
Truth table66%2/3
A and B
A= defined $oidB= $oid =~ /^\d+(?:\.\d+)*$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 6 | ▶ | if( defined $longname ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 3 | ▶ | croak( "$oid already registered" ) if( exists $oids{$oid} || exists $oid2extkeyusage{$oid} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $oids{$oid} or exists $oid2extkeyusage{$oid}
MC/DC50%1/2
exists $oids{$oid} or exists $oid2extkeyusage{$oid}
exists $oids{$oid}
exists $oid2extkeyusage{$oid}
Truth table66%2/3
A or B
A= exists $oids{$oid}B= exists $oid2extkeyusage{$oid}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 2 | ▶ | croak( "$longname already registered" ) if( grep /^$longname$/, values %oids ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 3 | ▶ | croak( "$oid not registered" ) unless( exists $oids{$oid} || exists $oid2extkeyusage{$oid} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $oids{$oid} or exists $oid2extkeyusage{$oid}
MC/DC50%1/2
exists $oids{$oid} or exists $oid2extkeyusage{$oid}
exists $oids{$oid}
exists $oid2extkeyusage{$oid}
Truth table66%2/3
A or B
A= exists $oids{$oid}B= exists $oid2extkeyusage{$oid}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 3 | ▶ | croak( "$shortname already registered" ) if( defined $shortname && grep /^\U$shortname\E$/, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $shortname and grep /^\U$shortname\E$/, values %shortnames
MC/DC100%2/2
defined $shortname and grep /^\U$shortname\E$/, values %shortnames
defined $shortname
grep /^\U$shortname\E$/, values %shortnames
Truth table100%3/3
A and B
A= defined $shortnameB= grep /^\U$shortname\E$/, values %shortnames
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | values %shortnames ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 2 | ▶ | if( defined $longname ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 1 | $oids{$oid} = $longname; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 1 | $name2oid{$longname} = $oid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 1 | $longname = $class->_oid2name( $oid ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 2 | ▶ | $shortnames{$longname} = uc $shortname if( defined $shortname ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 17 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=13 SCAR=27.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 17 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 17 | undef $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 17 | ▶ | $class = ref $class if( defined $class && ref $class && $class->isa( __PACKAGE__ ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $class and ref $class and $class->isa(__PACKAGE__)
defined $class and ref $class
MC/DC0%0/3
defined $class and ref $class and $class->isa(__PACKAGE__)
defined $class
ref $class
$class->isa(__PACKAGE__)
Truth table25%1/4
A and B and C
A= defined $classB= ref $classC= $class->isa(__PACKAGE__)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 17 | ▶ | unless( defined $apiVersion ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | carp( "${class}::setAPIversion MUST be called before new(). Defaulting to legacy mode" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | $class->setAPIversion(0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 17 | my( $void, $die ) = ( !defined wantarray, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 17 | my $self = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 17 | ▶ | die( "Insufficient arguments for new\n" ) unless( defined $class && @_ >= 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $class and @_ >= 1
MC/DC0%0/2
defined $class and @_ >= 1
defined $class
@_ >= 1
Truth table33%1/3
A and B
A= defined $classB= @_ >= 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 17 | ▶ | die( "Value of Crypt::PKCS10->new ignored\n" ) if( $void ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 16 | return $class->_new( \$die, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 17 | ▶ | }; if( $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 5 | $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 5 | ▶ | if( !$apiVersion || $die || !defined wantarray ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
not $apiVersion or $die or not defined wantarray
not $apiVersion or $die
MC/DC100%3/3
not $apiVersion or $die or not defined wantarray
not $apiVersion
$die
not defined wantarray
Truth table100%4/4
not(A) or B or not(C)
A= not $apiVersionB= $dieC= not defined wantarray
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 3 | ▶ | 1 while( chomp $@ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 3 | croak( $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 12 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 1 | ▶ | sub error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: called CC=4 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 1 | ▶ | croak( "Class not specifed for error()" ) unless( defined $class ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 1 | ▶ | if( ref $class && $class->isa( __PACKAGE__ ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $class and $class->isa(__PACKAGE__)
MC/DC0%0/2
ref $class and $class->isa(__PACKAGE__)
ref $class
$class->isa(__PACKAGE__)
Truth table33%1/3
A and B
A= ref $classB= $class->isa(__PACKAGE__)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | return $class->{_error}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 1 | return $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 3 | my $pemre = qr/(?ms:^\r?-----BEGIN\s(?:NEW\s)?CERTIFICATE\sREQUEST-----\s*\r?\n\s*(.*?)\s*^\r?-----END\s(?:NEW\s)?CERTIFICATE\sREQUEST-----\r?$)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 16 | ▶ | sub _new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new: called CC=42 SCAR=38.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 16 | my( $class, $die, $der ) = splice( @_, 0, 3 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 16 | my %options = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | acceptPEM => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | PEMonly => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | escapeStrings => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | readFile => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | ignoreNonBase64 => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | verifySignature => ($apiVersion >= 1), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | dieOnError => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 16 | ▶ | %options = ( %options, %{ shift @_ } ) if( @_ >= 1 && ref( $_[0] ) eq 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ >= 1 and ref $_[0] eq "HASH"
MC/DC100%2/2
@_ >= 1 and ref $_[0] eq "HASH"
@_ >= 1
ref $_[0] eq "HASH"
Truth table100%3/3
A and B
A= @_ >= 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 16 | ▶ | die( "Every option to new() must have a value\n" ) unless( @_ % 2 == 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 16 | ▶ | %options = ( %options, @_ ) if( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 16 | my $self = { _apiVersion => $apiVersion }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 16 | my $keys = join( '|', qw/escapeStrings acceptPEM PEMonly binaryMode readFile verifySignature ignoreNonBase64 warnings dieOnError/ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 16 | $self->{"_$_"} = delete $options{$_} foreach (grep { /^(?:$keys)$/ } keys %options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 16 | ▶ | $$die = $self->{_dieOnError} &&= $apiVersion >= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"_dieOnError"} &&= $apiVersion >= 1
MC/DC50%1/2
$self->{"_dieOnError"} &&= $apiVersion >= 1
$self->{"_dieOnError"}
$apiVersion >= 1
Truth table66%2/3
A &&= B
A= $self->{"_dieOnError"}B= $apiVersion >= 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 16 | ▶ | die( "\$csr argument to new() is not defined\n" ) unless( defined $der ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 15 | ▶ | if( keys %options ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | die( "Invalid option(s) specified: " . join( ', ', sort keys %options ) . "\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 15 | ▶ | $self->{_binaryMode} = !$self->{_acceptPEM} unless( exists $self->{_binaryMode} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 15 | my $parser; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | # malformed requests can produce various warnings; don't proceed in that case. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 15 | ▶ | local $SIG{__WARN__} = sub { my $msg = $_[0]; $msg =~ s/\A(.*?) at .*\Z/$1/s; 1 while( chomp $msg ); die "$msg\n" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 15 | ▶ | if( $self->{_readFile} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 9 | ▶ | open( my $fh, '<', $der ) or die( "Failed to open $der: $!\n" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 9 | $der = $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 15 | ▶ | if( Scalar::Util::openhandle( $der ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 11 | local $/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 11 | ▶ | binmode $der if( $self->{_binaryMode} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 11 | $der = <$der>; # Note: this closes files opened by readFile | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 11 | ▶ | die( "Failed to read request: $!\n" ) unless( defined $der ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 15 | my $isPEM; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 15 | ▶ | if( $self->{_PEMonly} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 2 | ▶ | if( $der =~ $pemre ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 1 | $der = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 1 | $isPEM = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 1 | die( "No certificate request found\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | ▶ | } elsif( $self->{_acceptPEM} && $der =~ $pemre ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"_acceptPEM"} and $der =~ /$pemre/
MC/DC50%1/2
$self->{"_acceptPEM"} and $der =~ /$pemre/
$self->{"_acceptPEM"}
$der =~ /$pemre/
Truth table66%2/3
A and B
A= $self->{"_acceptPEM"}B= $der =~ /$pemre/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 10 | $der = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 10 | $isPEM = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 14 | ▶ | if( $isPEM ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | # Some versions of MIME::Base64 check the input. Some don't. Those that do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | # seem to obey -w, but not 'use warnings'. So we'll check here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 11 | $der =~ s/\s+//g; # Delete whitespace, which is legal but meaningless | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 11 | ▶ | $der =~ tr~A-Za-z0-9+=/~~cd if( $self->{_ignoreNonBase64} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 11 | ▶ | unless( $der =~ m{\A[A-Za-z0-9+/]+={0,2}\z} && ( length( $der ) % 4 == 0 ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$der =~ m[\A[A-Za-z0-9+/]+={0,2}\z] and length($der) % 4 == 0
MC/DC50%1/2
$der =~ m[\A[A-Za-z0-9+/]+={0,2}\z] and length($der) % 4 == 0
$der =~ m[\A[A-Za-z0-9+/]+={0,2}\z]
length($der) % 4 == 0
Truth table66%2/3
A and B
A= $der =~ m[\A[A-Za-z0-9+/]+={0,2}\z]B= length($der) % 4 == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 1 | warn( "Invalid base64 encoding\n" ); # Invalid character or length | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 10 | $der = decode_base64( $der ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | # some requests may contain information outside of the regular ASN.1 structure. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | # This padding must be removed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 13 | $der = eval { # Catch out of range errors caused by bad DER & report as format errors. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | # SEQUENCE <len> -- CertificationRequest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 13 | my( $tlen, undef, $tag ) = asn_decode_tag2( $der ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 13 | ▶ | die( "SEQUENCE not present\n" ) unless( $tlen && $tag == ASN_SEQUENCE ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$tlen and $tag == 16
MC/DC0%0/2
$tlen and $tag == 16
$tlen
$tag == 16
Truth table33%1/3
A and B
A= $tlenB= $tag == 16
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 13 | my( $llen, $len ) = asn_decode_length( substr( $der, $tlen ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 13 | ▶ | die( "Invalid SEQUENCE length\n" ) unless( $llen && $len ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$llen and $len
MC/DC0%0/2
$llen and $len
$llen
$len
Truth table33%1/3
A and B
A= $llenB= $len
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 13 | $len += $tlen + $llen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 13 | $tlen = length $der; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 13 | ▶ | die( "DER too short to contain request\n" ) if( $tlen < $len ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 13 | ▶ | if( $tlen != $len && $self->{_warnings} ) { # Debugging | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$tlen != $len and $self->{"_warnings"}
MC/DC0%0/2
$tlen != $len and $self->{"_warnings"}
$tlen != $len
$self->{"_warnings"}
Truth table66%2/3
A and B
A= $tlen != $lenB= $self->{"_warnings"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | local $SIG{__WARN__}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | carp( sprintf( "DER length of %u contains %u bytes of padding", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | $tlen, $tlen - $len ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 13 | return substr( $der, 0, $len ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 13 | ▶ | }; if( $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | 1 while( chomp $@ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | die( "Invalid format for request: $@\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 13 | $self->{_der} = $der; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 13 | bless( $self, $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 13 | $self->{_bmpenc} = Encode::find_encoding('UCS2-BE'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 13 | my $asn = Convert::ASN1->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 13 | $self->{_asn} = $asn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 13 | ▶ | $asn->prepare($schema) or die( "Internal error in " . __PACKAGE__ . ": " . $asn->error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 13 | $asn->registertype( 'qualifier', '1.3.6.1.5.5.7.2.1', $self->_init('CPSuri') ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 13 | $asn->registertype( 'qualifier', '1.3.6.1.5.5.7.2.2', $self->_init('UserNotice') ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 13 | $parser = $self->_init( 'CertificationRequest' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 13 | ▶ | my $top = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | $parser->decode( $der ) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | confess( "decode: " . $parser->error . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | "Cannot handle input or missing ASN.1 definitions" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | $self->{certificationRequestInfo}{subject_raw} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 13 | = $top->{certificationRequestInfo}{subject}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | $self->{certificationRequestInfo}{subject} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 13 | = $self->_convert_rdn( $top->{certificationRequestInfo}{subject} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | $self->{certificationRequestInfo}{version} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 13 | = $top->{certificationRequestInfo}{version}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | $self->{certificationRequestInfo}{attributes} = $self->_convert_attributes( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 13 | $top->{certificationRequestInfo}{attributes} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | $self->{_pubkey} = "-----BEGIN PUBLIC KEY-----\n" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | _encode_PEM( $self->_init('SubjectPublicKeyInfo')-> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 13 | encode( $top->{certificationRequestInfo}{subjectPKInfo} ) ) . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | "-----END PUBLIC KEY-----\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | $self->{certificationRequestInfo}{subjectPKInfo} = $self->_convert_pkinfo( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 13 | $top->{certificationRequestInfo}{subjectPKInfo} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 13 | $self->{signature} = $top->{signature}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | $self->{signatureAlgorithm} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 13 | = $self->_convert_signatureAlgorithm( $top->{signatureAlgorithm} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | # parse parameters for RSA PSS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 13 | ▶ | if ($self->{signatureAlgorithm}{algorithm} eq 'rsassaPss') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | my $params = $self->_init('rsassaPssParam') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 4 | ->decode($self->{signatureAlgorithm}{parameters}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | my $sigInfo = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 4 | ▶ | 'saltLength' => ($params->{saltLength} || 20), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$params->{'saltLength'} || 20
MC/DC100%1/1
$params->{'saltLength'} || 20
$params->{'saltLength'}
Truth table100%2/2
A
A= $params->{'saltLength'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 'digestAlgorithm' => 'sha1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | $sigInfo->{digestAlgorithm} = $self->_oid2name($params->{digestAlgorithm}{algorithm}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 4 | ▶ | if($params->{digestAlgorithm}{algorithm}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | $sigInfo->{maskGenAlgorithm} = $self->_oid2name($params->{maskGenAlgorithm}{algorithm}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 4 | ▶ | if($params->{maskGenAlgorithm}{algorithm}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 4 | $self->{signatureAlgorithm}{parameters} = $sigInfo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | # Extract bundle of bits that is signed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | # The DER is SEQUENCE -- CertificationRequest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | # SEQUENCE -- CertificationRequestInfo [SIGNED] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 13 | my( $CRtaglen, $CRtag, $CRllen, $CRlen ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 13 | ($CRtaglen, undef, $CRtag) = asn_decode_tag2( $der ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 13 | ▶ | die( "Invalid CSR format: missing SEQUENCE 1\n" ) unless( $CRtag == ASN_SEQUENCE ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 13 | ($CRllen, $CRlen) = asn_decode_length( substr( $der, $CRtaglen ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 13 | my( $CItaglen, $CItag, $CIllen, $CIlen ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 13 | ($CItaglen, undef, $CItag) = asn_decode_tag2( substr( $der, $CRtaglen + $CRllen ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 13 | ▶ | die( "Invalid CSR format: missing SEQUENCE 2\n" ) unless( $CItag == ASN_SEQUENCE ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 13 | ($CIllen, $CIlen) = asn_decode_length( substr( $der, $CRtaglen + $CRllen + $CItaglen ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 13 | $self->{_signed} = substr( $der, $CRtaglen + $CRllen, $CItaglen + $CIllen + $CIlen ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 13 | ▶ | die( $error ) if( $self->{_verifySignature} && !$self->checkSignature ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"_verifySignature"} and not $self->checkSignature
MC/DC50%1/2
$self->{"_verifySignature"} and not $self->checkSignature
$self->{"_verifySignature"}
not $self->checkSignature
Truth table66%2/3
A and not(B)
A= $self->{"_verifySignature"}B= not $self->checkSignature
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 12 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | # Convert::ASN1 returns BMPStrings as 16-bit fixed-width characters, e.g. UCS2-BE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 9 | ▶ | sub _bmpstring { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bmpstring: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 9 | my $enc = $self->{_bmpenc}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 9 | $_ = $enc->decode( $_ ) foreach (@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 9 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | # Find the obvious BMPStrings in a value and convert them | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | # This doesn't catch direct values, but does find them in hashes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | # (generally as a result of a CHOICE) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | # Convert iPAddresses as well | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 213 | ▶ | sub _scanvalue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_scanvalue: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 213 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 213 | my( $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 213 | ▶ | return unless( ref $value ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 102 | ▶ | if( ref $value eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 24 | foreach (@$value) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 90 | $self->_scanvalue( $_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 24 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 78 | ▶ | if( ref $value eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 78 | foreach my $k (keys %$value) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 105 | ▶ | if( $k eq 'bmpString' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 3 | $self->_bmpstring( $value->{bmpString} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 3 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 102 | ▶ | if( $k eq 'iPAddress' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 3 | ▶ | use bytes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 6 | my $addr = $value->{iPAddress}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 6 | ▶ | if( length $addr == 4 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 3 | $value->{iPAddress} = sprintf( '%vd', $addr ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 3 | $addr = sprintf( '%*v02X', ':', $addr ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 3 | $addr =~ s/([[:xdigit:]]{2}):([[:xdigit:]]{2})/$1$2/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 3 | $value->{iPAddress} = $addr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 6 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 96 | $self->_scanvalue( $value->{$k} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 78 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 13 | ▶ | sub _convert_signatureAlgorithm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_signatureAlgorithm: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 13 | my $signatureAlgorithm = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | $signatureAlgorithm->{algorithm} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | = $oids{$signatureAlgorithm->{algorithm}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | if( defined $signatureAlgorithm->{algorithm} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 13 | ▶ | && exists $oids{$signatureAlgorithm->{algorithm}} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $signatureAlgorithm->{"algorithm"} and exists $oids{$signatureAlgorithm->{"algorithm"}}
MC/DC0%0/2
defined $signatureAlgorithm->{"algorithm"} and exists $oids{$signatureAlgorithm->{"algorithm"}}
defined $signatureAlgorithm->{"algorithm"}
exists $oids{$signatureAlgorithm->{"algorithm"}}
Truth table33%1/3
A and B
A= defined $signatureAlgorithm->{"algorithm"}B= exists $oids{$signatureAlgorithm->{"algorithm"}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 13 | return $signatureAlgorithm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 13 | ▶ | sub _convert_pkinfo { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_pkinfo: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 13 | my $pkinfo = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | $pkinfo->{algorithm}{algorithm} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | = $oids{$pkinfo->{algorithm}{algorithm}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | if( defined $pkinfo->{algorithm}{algorithm} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 13 | ▶ | && exists $oids{$pkinfo->{algorithm}{algorithm}} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $pkinfo->{"algorithm"}{"algorithm"} and exists $oids{$pkinfo->{"algorithm"}{"algorithm"}}
MC/DC0%0/2
defined $pkinfo->{"algorithm"}{"algorithm"} and exists $oids{$pkinfo->{"algorithm"}{"algorithm"}}
defined $pkinfo->{"algorithm"}{"algorithm"}
exists $oids{$pkinfo->{"algorithm"}{"algorithm"}}
Truth table33%1/3
A and B
A= defined $pkinfo->{"algorithm"}{"algorithm"}B= exists $oids{$pkinfo->{"algorithm"}{"algorithm"}}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 13 | return $pkinfo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | # OIDs requiring some sort of special handling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | # Called with decoded value, returns updated value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | # Key is ASN macro name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 3 | my %special; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | %special = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 3 | ▶ | EnhancedKeyUsage => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 3 | my( $value, $id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 3 | foreach (@{$value}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 21 | ▶ | $_ = $oid2extkeyusage{$_} if(defined $oid2extkeyusage{$_}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 3 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 6 | ▶ | KeyUsage => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 6 | my( $value, $id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 6 | my $bit = unpack('C*', @{$value}[0]); #get the decimal representation | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 6 | my $length = int(log($bit) / log(2) + 1); #get its bit length | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 6 | ▶ | my @usages = reverse( $id eq 'KeyUsage'? # Following are in order from bit 0 upwards | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | qw(digitalSignature nonRepudiation keyEncipherment dataEncipherment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | keyAgreement keyCertSign cRLSign encipherOnly decipherOnly) : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | qw(client server email objsign reserved sslCA emailCA objCA) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 6 | my $shift = ($#usages + 1) - $length; # computes the unused area in @usages | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 6 | @usages = @usages[ grep { $bit & (1 << $_ - $shift) } 0 .. $#usages ]; #transfer bitmap to barewords | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 6 | ▶ | return [ @usages ] if( $self->{_apiVersion} >= 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 1 | return join( ', ', @usages ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | ▶ | netscapeCertType => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | goto &{$special{KeyUsage}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 6 | ▶ | SubjectKeyIdentifier => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 6 | my( $value, $id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 6 | return unpack( "H*", $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | ▶ | ApplicationCertPolicies => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | ▶ | goto &{$special{certificatePolicies}} if( $_[0]->{_apiVersion} > 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | my( $value, $id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | foreach my $entry (@{$value}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | $entry->{policyIdentifier} = $self->_oid2name( $entry->{policyIdentifier} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | ▶ | certificateTemplate => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | my( $value, $id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | ▶ | $value->{templateID} = $self->_oid2name( $value->{templateID} ) if( $self->{_apiVersion} > 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | ▶ | EnrollmentCSP => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | my( $value, $id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | $self->_bmpstring( $value->{Name} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 3 | ▶ | ENROLLMENT_CSP_PROVIDER => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 3 | my( $value, $id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 3 | $self->_bmpstring( $value->{cspName} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 3 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 3 | ▶ | certificatePolicies => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 3 | my( $value, $id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 3 | foreach my $policy (@$value) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 6 | $policy->{policyIdentifier} = $self->_oid2name( $policy->{policyIdentifier} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 6 | ▶ | if( exists $policy->{policyQualifier} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 3 | foreach my $qualifier (@{$policy->{policyQualifier}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 12 | $qualifier->{policyQualifierId} = $self->_oid2name( $qualifier->{policyQualifierId} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 12 | my $qv = $qualifier->{qualifier}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 12 | ▶ | if( ref $qv eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 6 | foreach my $qt (keys %$qv) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 12 | ▶ | if( $qt eq 'explicitText' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 6 | $qv->{$qt} = (values %{$qv->{$qt}})[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | } elsif( $qt eq 'noticeRef' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 6 | my $userNotice = $qv->{$qt}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 6 | $userNotice->{organization} = (values %{$userNotice->{organization}})[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | $qv->{userNotice} = delete $qv->{noticeRef} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 6 | ▶ | if( exists $qv->{noticeRef} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 3 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | ▶ | CERT_EXTENSIONS => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | my( $value, $id, $entry ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | ▶ | return $self->_convert_extensionRequest( [ $value ] ) if( $self->{_apiVersion} > 0 ); # Untested | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 3 | ▶ | BasicConstraints => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 3 | my( $value, $id, $entry ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | my $r = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 3 | ▶ | CA => $value->{cA}? 'TRUE' : 'FALSE', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 3 | my $string = "CA:$r->{CA}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 3 | ▶ | if( exists $value->{pathLenConstraint} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | $r->{pathlen} = $value->{pathLenConstraint}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 0 | $string .= sprintf( ',pathlen:%u', $value->{pathLenConstraint} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 3 | $entry->{_FMT} = [ $r, $string ]; # [ Raw, formatted ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 3 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 3 | ▶ | unstructuredName => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 3 | my( $value, $id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 3 | return $self->_hash2string( $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | ▶ | unstructuredAddress => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | my( $value, $id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | return $self->_hash2string( $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 3 | ▶ | challengePassword => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 3 | my( $value, $id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 3 | return $self->_hash2string( $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 3 | ); # %special | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 13 | ▶ | sub _convert_attributes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_attributes: called CC=13 SCAR=26.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 13 | my( $typeandvalues ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 13 | foreach my $entry ( @{$typeandvalues} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 24 | my $oid = $entry->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 24 | my $name = $oids{$oid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 24 | ▶ | $name = $variantNames{$name} if( defined $name && exists $variantNames{$name} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and exists $variantNames{$name}
MC/DC0%0/2
defined $name and exists $variantNames{$name}
defined $name
exists $variantNames{$name}
Truth table33%1/3
A and B
A= defined $nameB= exists $variantNames{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 24 | ▶ | next unless( defined $name ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 24 | $entry->{type} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 24 | ▶ | if ($name eq 'extensionRequest') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 6 | $entry->{values} = $self->_convert_extensionRequest($entry->{values}[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | } elsif ($name eq 'ENROLLMENT_NAME_VALUE_PAIR') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 3 | my $parser = $self->_init( $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 3 | my @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 3 | foreach my $der (@{$entry->{values}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 3 | ▶ | my $pair = $parser->decode( $der ) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | confess( "Looks like damaged input parsing attribute $name" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 3 | $self->_bmpstring( $pair->{name}, $pair->{value} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 3 | push @values, $pair; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 3 | $entry->{values} = \@values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 15 | ▶ | my $parser = $self->_init( $name, 1 ) or next; # Skip unknown attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 15 | ▶ | if($entry->{values}[1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 0 | confess( "Incomplete parsing of attribute type: $name" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 15 | ▶ | my $value = $entry->{values} = $parser->decode( $entry->{values}[0] ) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | confess( "Looks like damaged input parsing attribute $name" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 15 | ▶ | if( exists $special{$name} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 9 | my $action = $special{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 9 | $entry->{values} = $action->( $self, $value, $name, $entry ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 13 | return $typeandvalues; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 6 | ▶ | sub _convert_extensionRequest { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_extensionRequest: called CC=9 SCAR=22.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 6 | my( $extensionRequest ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 6 | my $parser = $self->_init('extensionRequest'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 6 | ▶ | my $decoded = $parser->decode($extensionRequest) or return []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 6 | foreach my $entry (@{$decoded}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 27 | my $name = $oids{ $entry->{extnID} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 27 | ▶ | $name = $variantNames{$name} if( defined $name && exists $variantNames{$name} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $name and exists $variantNames{$name}
MC/DC50%1/2
defined $name and exists $variantNames{$name}
defined $name
exists $variantNames{$name}
Truth table66%2/3
A and B
A= defined $nameB= exists $variantNames{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 27 | ▶ | if (defined $name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 27 | my $asnName = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 27 | $asnName =~ tr/ //d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 27 | my $parser = $self->_init($asnName, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 27 | ▶ | if(!$parser) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 0 | $entry = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 27 | $entry->{extnID} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 27 | ▶ | my $dec = $parser->decode($entry->{extnValue}) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | confess( $parser->error . ".. looks like damaged input parsing extension $asnName" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 27 | $self->_scanvalue( $dec ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 27 | ▶ | if( exists $special{$asnName} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 21 | my $action = $special{$asnName}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 21 | $dec = $action->( $self, $dec, $asnName, $entry ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 27 | $entry->{extnValue} = $dec; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 6 | @{$decoded} = grep { defined } @{$decoded}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 6 | return $decoded; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 13 | ▶ | sub _convert_rdn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_rdn: called CC=8 SCAR=21.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 13 | my $typeandvalue = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 13 | my %hash = ( _subject => [], ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 13 | foreach my $entry ( @$typeandvalue ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 52 | foreach my $item (@$entry) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 54 | my $oid = $item->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 54 | ▶ | my $name = (exists $variantNames{$oid})? $variantNames{$oid}[1]: $oids{ $oid }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 54 | ▶ | if( defined $name ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 54 | push @{$hash{$name}}, sort values %{$item->{value}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 54 | push @{$hash{_subject}}, $name, [ sort values %{$item->{value}} ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | ▶ | my @names = (exists $variantNames{$oid})? @{$variantNames{$oid}} : ( $name ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 54 | foreach my $name ( @names ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 54 | ▶ | unless( $self->can( $name ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 3 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 2 | ▶ | *$name = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 2 | ▶ | return @{ $self->{certificationRequestInfo}{subject}{$name} } if( wantarray ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 1 | ▶ | return $self->{certificationRequestInfo}{subject}{$name}[0] || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'certificationRequestInfo'}{'subject'}{$name}[0] || ''
MC/DC0%0/1
$self->{'certificationRequestInfo'}{'subject'}{$name}[0] || ''
$self->{'certificationRequestInfo'}{'subject'}{$name}[0]
Truth table50%1/2
A
A= $self->{'certificationRequestInfo'}{'subject'}{$name}[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 3 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 13 | return \%hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 112 | ▶ | sub _init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init: called CC=3 SCAR=12.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 112 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 112 | my( $node, $optional ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 112 | my $parsed = $self->{_asn}->find($node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 112 | ▶ | unless( defined $parsed || $optional ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $parsed or $optional
MC/DC0%0/2
defined $parsed or $optional
defined $parsed
$optional
Truth table33%1/3
A or B
A= defined $parsedB= $optional
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 0 | croak( "Missing node $node in ASN.1" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | 112 | return $parsed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | ########################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | # interface methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 6 | ▶ | sub csrRequest { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
csrRequest: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | 6 | my $format = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | return( "-----BEGIN CERTIFICATE REQUEST-----\n" . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 6 | ▶ | _encode_PEM( $self->{_der} ) . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | "-----END CERTIFICATE REQUEST-----\n" ) if( $format ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 3 | return $self->{_der}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | # Common subject components documented to be always present: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 3 | foreach my $component (qw/commonName organizationalUnitName organizationName | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | emailAddress stateOrProvinceName countryName domainComponent/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 3 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 21 | ▶ | unless( defined &$component ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 9 | ▶ | *$component = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 9 | ▶ | return @{ $self->{certificationRequestInfo}{subject}{$component} || [] } if( wantarray ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->{'certificationRequestInfo'}{'subject'}{$component} || []
MC/DC0%0/1
$self->{'certificationRequestInfo'}{'subject'}{$component} || []
$self->{'certificationRequestInfo'}{'subject'}{$component}
Truth table50%1/2
A
A= $self->{'certificationRequestInfo'}{'subject'}{$component}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 2 | ▶ | return $self->{certificationRequestInfo}{subject}{$component}[0] || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'certificationRequestInfo'}{'subject'}{$component}[0] || ''
MC/DC0%0/1
$self->{'certificationRequestInfo'}{'subject'}{$component}[0] || ''
$self->{'certificationRequestInfo'}{'subject'}{$component}[0]
Truth table50%1/2
A
A= $self->{'certificationRequestInfo'}{'subject'}{$component}[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | 21 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | # Complete subject | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 5 | ▶ | sub subject { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subject: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 5 | my $long = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 5 | ▶ | return @{ $self->{certificationRequestInfo}{subject}{_subject} } if( wantarray ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 4 | my @subject = @{ $self->{certificationRequestInfo}{subject}{_subject} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 4 | my $subj = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 4 | ▶ | while( @subject ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 19 | my( $name, $value ) = splice( @subject, 0, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 19 | ▶ | $name = $shortnames{$name} if( !$long && exists $shortnames{$name} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $long and exists $shortnames{$name}
MC/DC50%1/2
not $long and exists $shortnames{$name}
not $long
exists $shortnames{$name}
Truth table66%2/3
not(A) and B
A= not $longB= exists $shortnames{$name}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 19 | $subj .= "/$name=" . join( ',', @$value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 4 | return $subj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 1 | ▶ | sub subjectRaw { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subjectRaw: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 1 | my @subject; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 1 | foreach my $rdn (@{$self->{certificationRequestInfo}{subject_raw}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | my @sequence = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 6 | $_->{format} = (keys %{$_->{value}})[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 6 | $_->{value} = (values %{$_->{value}})[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | 6 | $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 5 | } @{$rdn}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 5 | ▶ | if (scalar @sequence > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 1 | push @subject, \@sequence; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 4 | push @subject, $sequence[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 1 | return \@subject; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 0 | ▶ | sub subjectSequence { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subjectSequence: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | 0 | return $self->{certificationRequestInfo}{subject_raw}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | 4 | ▶ | sub subjectAltName { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subjectAltName: called CC=8 SCAR=21.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 4 | my( $type ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 4 | my $san = $self->extensionValue( 'subjectAltName' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 4 | ▶ | unless( defined $san ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 0 | ▶ | return () if( wantarray ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | return undef; ## no critic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | 4 | ▶ | if( !defined $type ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 2 | ▶ | if( wantarray ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 1 | my %comps; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | 1 | $comps{$_} = 1 foreach (map { keys %$_ } @$san); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 1 | return sort keys %comps; ## no critic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | 1 | my @string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 1 | foreach my $comp (@$san) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 9 | push @string, join( '+', map { "$_:$comp->{$_}" } sort keys %$comp ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 1 | return join( ',', @string ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 2 | my $result = [ map { $_->{$type} } grep { exists $_->{$type} } @$san ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 2 | ▶ | return @$result if( wantarray ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 1 | return $result->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 2 | ▶ | sub version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 2 | my $v = $self->{certificationRequestInfo}{version}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 2 | return sprintf( "v%u", $v+1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 13 | ▶ | sub pkAlgorithm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pkAlgorithm: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | 13 | return $self->{certificationRequestInfo}{subjectPKInfo}{algorithm}{algorithm}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 5 | ▶ | sub subjectPublicKey { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subjectPublicKey: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 5 | my $format = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 5 | ▶ | return $self->{_pubkey} if( $format ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | 2 | return unpack('H*', $self->{certificationRequestInfo}{subjectPKInfo}{subjectPublicKey}[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 5 | ▶ | sub subjectPublicKeyParams { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subjectPublicKeyParams: called CC=14 SCAR=36.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | 5 | my $detail = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | 5 | ▶ | croak( "Requires API version 1" ) unless( $self->{_apiVersion} >= 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 4 | undef $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 4 | delete $self->{_error}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | 4 | my $rv = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | 4 | my $at = $self->pkAlgorithm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | 4 | ▶ | $at = 'undef' unless( defined $at ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | # this is wrong but unfortunately seen in the wild | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 4 | ▶ | if( $at eq 'rsassaPss') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | 0 | $at = 'rsaEncryption'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | 0 | warn 'Got rsassaPss as pkAlgorithm - converting to RSA'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | 4 | ▶ | if( $at eq 'rsaEncryption' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | 3 | $rv->{keytype} = 'RSA'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | 3 | my $par = $self->_init( 'rsaKey' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 3 | my $rsa = $par->decode( $self->{certificationRequestInfo}{subjectPKInfo}{subjectPublicKey}[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | 3 | $rv->{keylen} = 4 * ( length( $rsa->{modulus}->as_hex ) -2 ); # 2 == length( '0x' ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 3 | $rv->{modulus} = substr( $rsa->{modulus}->as_hex, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | $rv->{publicExponent} = ( ref( $rsa->{publicExponent} )? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | $rsa->{publicExponent}->as_hex : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | 3 | ▶ | sprintf( '%x', $rsa->{publicExponent} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | } elsif( $at eq 'ecPublicKey' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | 0 | $rv->{keytype} = 'ECC'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | 0 | eval { require Crypt::PK::ECC; }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | 0 | ▶ | if( $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | 0 | $rv->{keytype} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | $self->{_error} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | 0 | $error = "ECC public key requires Crypt::PK::ECC\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | 0 | ▶ | croak( $error ) if( $self->{_dieOnError} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 0 | return $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | 0 | my $key = $self->subjectPublicKey(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 0 | $key = Crypt::PK::ECC->new( \$key )->key2hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | 0 | $rv->{keylen} = $key->{curve_bits}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | 0 | $rv->{pub_x} = $key->{pub_x}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | 0 | $rv->{pub_y} = $key->{pub_y}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | 0 | ▶ | $rv->{detail} = { %$key } if( $detail ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 0 | my $par = $self->_init( 'eccName' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | 0 | $rv->{curve} = $par->decode( $self->{certificationRequestInfo}{subjectPKInfo}{algorithm}{parameters} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | 0 | ▶ | $rv->{curve} = $self->_oid2name( $rv->{curve} ) if ($rv->{curve}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | } elsif( $at eq 'dsa' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | 1 | $rv->{keytype} = 'DSA'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | 1 | my $par = $self->_init( 'dsaKey' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | 1 | my $dsa = $par->decode( $self->{certificationRequestInfo}{subjectPKInfo}{subjectPublicKey}[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | 1 | $rv->{keylen} = 4 * ( length( $dsa->as_hex ) -2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | 1 | ▶ | if( exists $self->{certificationRequestInfo}{subjectPKInfo}{algorithm}{parameters} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 1 | $par = $self->_init('dsaPars'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 1 | $dsa = $par->decode($self->{certificationRequestInfo}{subjectPKInfo}{algorithm}{parameters}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 1 | $rv->{G} = substr( $dsa->{G}->as_hex, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | 1 | $rv->{P} = substr( $dsa->{P}->as_hex, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 1 | $rv->{Q} = substr( $dsa->{Q}->as_hex, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | 0 | $rv->{keytype} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | $self->{_error} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | 0 | $error = "Unrecognized public key type $at\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 0 | ▶ | croak( $error ) if( $self->{_dieOnError} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | 4 | return $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | 8 | ▶ | sub signatureAlgorithm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
signatureAlgorithm: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | 8 | return $self->{signatureAlgorithm}{algorithm}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | 1 | ▶ | sub signatureParams { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
signatureParams: called CC=5 SCAR=19.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | 1 | ▶ | return unless ( exists $self->{signatureAlgorithm}{parameters} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | # For RSA PSS the parameters have been parsed to a hash already | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | 1 | ▶ | if (ref $self->{signatureAlgorithm}{parameters} eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | return $self->{signatureAlgorithm}{parameters}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 1 | my( $tlen, undef, $tag ) = asn_decode_tag2( $self->{signatureAlgorithm}{parameters} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | 1 | ▶ | if( $tlen != 0 && $tag != ASN_NULL ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$tlen != 0 and $tag != 5
MC/DC0%0/2
$tlen != 0 and $tag != 5
$tlen != 0
$tag != 5
Truth table33%1/3
A and B
A= $tlen != 0B= $tag != 5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | return $self->{signatureAlgorithm}{parameters} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | # Known algorithm's parameters MAY return a hash of decoded fields. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | # For now, leaving that to the caller... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | 10 | ▶ | sub signature { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
signature: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | 10 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 10 | my $format = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | 10 | ▶ | if( defined $format && $format == 2 ) { # Per keytype decoding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $format and $format == 2
MC/DC100%2/2
defined $format and $format == 2
defined $format
$format == 2
Truth table100%3/3
A and B
A= defined $formatB= $format == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 7 | ▶ | if( $self->pkAlgorithm eq 'ecPublicKey' ) { # ECDSA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | 0 | my $par = $self->_init( 'ecdsaSigValue' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | 0 | return $par->decode( $self->{signature}[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | 7 | return; # Unknown | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | 3 | ▶ | return $self->{signature}[0] if( $format ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 2 | return unpack('H*', $self->{signature}[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 2 | ▶ | sub certificationRequest { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
certificationRequest: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | 2 | return $self->{_signed}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | 55 | ▶ | sub _attributes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_attributes: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | 55 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | 55 | my $attributes = $self->{certificationRequestInfo}{attributes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | 55 | ▶ | return unless( defined $attributes ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | 55 | return { map { $_->{type} => $_->{values} } @$attributes }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | 22 | ▶ | sub attributes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attributes: called CC=16 SCAR=32.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | 22 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | 22 | my( $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | 22 | ▶ | if( $self->{_apiVersion} < 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | 0 | my $attributes = $self->{certificationRequestInfo}{attributes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 0 | ▶ | return () unless( defined $attributes ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | 0 | my %hash = map { $_->{type} => $_->{values} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | 0 | @{$attributes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | 0 | return %hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | 22 | my $attributes = $self->_attributes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | 22 | ▶ | unless( defined $attributes ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | 0 | ▶ | return () if( wantarray ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | 0 | return undef; ## no critic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | 22 | ▶ | unless( defined $name ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | 5 | return grep { $_ ne 'extensionRequest' } sort keys %$attributes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | 17 | $name = $self->_oid2name( $name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | 17 | ▶ | if( $name eq 'extensionRequest' ) { # Meaningless, and extensions/extensionValue handle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | 0 | ▶ | return () if( wantarray ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | 0 | return undef; ## no critic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | # There can only be one matching the name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | # If the match becomes wider, sort the keys. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | 17 | my @attrs = grep { $_ eq $name } keys %$attributes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | 17 | ▶ | unless( @attrs ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | 1 | ▶ | return () if( wantarray ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | 1 | return undef; ## no critic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | 16 | my @values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | 16 | foreach my $attr (@attrs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | 16 | my $values = $attributes->{$attr}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | 16 | ▶ | $values = [ $values ] unless( ref $values eq 'ARRAY' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | 16 | foreach my $value (@$values) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | 16 | my $value = $self->_hash2string( $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | 16 | ▶ | push @values, (wantarray? $value : $self->_value2strings( $value )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | 16 | ▶ | return @values if( wantarray ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | 11 | ▶ | if( @values == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | 11 | $values[0] =~ s/^\((.*)\)$/$1/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | 11 | return $values[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | 0 | return join( ',', @values ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | 1 | ▶ | sub certificateTemplate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
certificateTemplate: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | 1 | return $self->extensionValue( 'certificateTemplate', @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | # If a hash contains one string (e.g. a CHOICE containing type=>value), return the string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | # If the hash is nested, try recursing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | # If the string can't be identified (clutter in the hash), return the hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | # Some clutter can be filtered by specifying $exclude (a regexp) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | 43 | ▶ | sub _hash2string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hash2string: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | 43 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | 43 | my( $hash, $exclude ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | 43 | ▶ | return $hash unless( ref $hash eq 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | 20 | my @keys = keys %$hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | 20 | ▶ | @keys = grep { $_ !~ /$exclude/ } @keys if( defined $exclude ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | 20 | ▶ | return $hash if( @keys != 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | 11 | ▶ | return $self->_hash2string( $hash->{$keys[0]} ) if( ref $hash->{$keys[0]} eq 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | 7 | return $hash->{$keys[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | # Convert a value to a printable string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | 99 | ▶ | sub _value2strings { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value2strings: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | 99 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | 99 | my( $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | 99 | my @strings; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | 99 | ▶ | if( ref $value eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | 10 | foreach my $value (@$value) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | 34 | push @strings, $self->_value2strings( $value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | 10 | ▶ | return '(' . join( ',', @strings ) . ')' if( @strings > 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | 1 | return join( ',', @strings ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | 89 | ▶ | if( ref $value eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | 25 | foreach my $k (sort keys %$value) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | 46 | push @strings, "$k=" . $self->_value2strings( $value->{$k} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | 25 | ▶ | return '(' . join( ',', @strings ) . ')' if( @strings > 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | 10 | return join( ',', @strings ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | 64 | ▶ | return $value if( $value =~ /^\d+$/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | # OpenSSL and Perl-compatible string syntax | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | 54 | ▶ | $value =~ s/(["\\\$])/\\$1/g if( $self->{_escapeStrings} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | 54 | ▶ | return $value if( $value =~ m{\A[\w!\@$%^&*_=+\[\]\{\}:;|<>./?"'-]+\z} ); # Barewords | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | 10 | return '"' . $value . '"'; # Must quote: whitespace, non-printable, comma, (), \, null string | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | 4 | ▶ | sub extensions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extensions: called CC=6 SCAR=18.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | 4 | my $attributes = $self->_attributes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | 4 | ▶ | return () unless( defined $attributes && exists $attributes->{extensionRequest} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $attributes and exists $attributes->{"extensionRequest"}
MC/DC0%0/2
defined $attributes and exists $attributes->{"extensionRequest"}
defined $attributes
exists $attributes->{"extensionRequest"}
Truth table33%1/3
A and B
A= defined $attributesB= exists $attributes->{"extensionRequest"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | 4 | my @present = map { $_->{extnID} } @{$attributes->{extensionRequest}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | 4 | ▶ | if( $self->{_apiVersion} >= 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | 4 | foreach my $ext (@present) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | 15 | ▶ | $ext = $variantNames{'$' . $ext} if( exists $variantNames{'$' . $ext} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | 4 | return @present; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | 23 | ▶ | sub extensionValue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extensionValue: called CC=12 SCAR=25.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | 23 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | 23 | my( $extensionName, $format ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | 23 | my $attributes = $self->_attributes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | 23 | my $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | 23 | ▶ | return unless( defined $attributes && exists $attributes->{extensionRequest} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $attributes and exists $attributes->{"extensionRequest"}
MC/DC0%0/2
defined $attributes and exists $attributes->{"extensionRequest"}
defined $attributes
exists $attributes->{"extensionRequest"}
Truth table33%1/3
A and B
A= defined $attributesB= exists $attributes->{"extensionRequest"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | 23 | $extensionName = $self->_oid2name( $extensionName ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | 23 | ▶ | $extensionName = $variantNames{$extensionName} if( exists $variantNames{$extensionName} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | 23 | foreach my $entry (@{$attributes->{extensionRequest}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | 76 | ▶ | if ($entry->{extnID} eq $extensionName) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | 21 | $value = $entry->{extnValue}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | 21 | ▶ | if( $self->{_apiVersion} == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | 1 | ▶ | while (ref $value eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | 0 | my @keys = sort keys %{$value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 0 | $value = $value->{ shift @keys } ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | 20 | ▶ | if( $entry->{_FMT} ) { # Special formatting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | 3 | ▶ | $value = $entry->{_FMT}[$format? 1:0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | 17 | $value = $self->_hash2string( $value, '(?i:^(?:critical|.*id)$)' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | 17 | ▶ | $value = $self->_value2strings( $value ) if( $format ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | 21 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | 23 | ▶ | $value =~ s/^\((.*)\)$/$1/ if( $format ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | 23 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | 6 | ▶ | sub extensionPresent { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extensionPresent: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | 6 | my( $extensionName ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | 6 | my $attributes = $self->_attributes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | 6 | ▶ | return unless( defined $attributes && exists $attributes->{extensionRequest} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $attributes and exists $attributes->{"extensionRequest"}
MC/DC0%0/2
defined $attributes and exists $attributes->{"extensionRequest"}
defined $attributes
exists $attributes->{"extensionRequest"}
Truth table33%1/3
A and B
A= defined $attributesB= exists $attributes->{"extensionRequest"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | 6 | $extensionName = $self->_oid2name( $extensionName ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | 6 | ▶ | $extensionName = $variantNames{$extensionName} if( exists $variantNames{$extensionName} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | 6 | foreach my $entry (@{$attributes->{extensionRequest}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | 18 | ▶ | if ($entry->{extnID} eq $extensionName) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | 5 | ▶ | return 2 if ($entry->{critical}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | 1 | ▶ | sub checkSignature { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checkSignature: called CC=17 SCAR=45.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | 1 | undef $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | 1 | delete $self->{_error}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | 1 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | 1 | ▶ | die( "checkSignature requires API version 1\n" ) unless( $self->{_apiVersion} >= 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | 1 | my $key = $self->subjectPublicKey(1); # Key as PEM | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | 1 | my $sig = $self->signature(1); # Signature as DER | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | 1 | my $alg = $self->signatureAlgorithm; # Algorithm name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | # Determine the signature hash type from the algorithm name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | 1 | my @params = ( $sig, $self->certificationRequest ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | 1 | ▶ | if( $alg =~ /sha-?(\d+)/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | 1 | push @params, "SHA$1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | } elsif( $alg =~ /md-?(\d)/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | 0 | push @params, "MD$1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | } elsif ( $alg eq 'rsassaPss' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | 0 | my $sigParam = $self->signatureParams; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | 0 | push @params, uc($sigParam->{digestAlgorithm}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | 0 | push @params, 'pss'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | 0 | push @params, $sigParam->{saltLength}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | 0 | die( "Unknown hash in signature algorithm $alg\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | 1 | my $keyp = $self->subjectPublicKeyParams; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | 1 | ▶ | die( "Unknown public key type\n" ) unless( defined $keyp->{keytype} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | # Verify signature using the correct module and hash type. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | 1 | ▶ | if( $keyp->{keytype} eq 'RSA' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | 1 | eval { require Crypt::PK::RSA; }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | 1 | ▶ | die( "Unable to load Crypt::PK::RSA\n" ) if( $@ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | # We have seen requests in the wild that accidentially | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | # have the rsaPSS OID set for the key type which is wrong | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | # and therefore not supported by Crypt::PK::RSA. We therefore | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | # build the key directly from the components extracted earlier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | $key = Crypt::PK::RSA->new( { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | e => $keyp->{publicExponent}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | N => $keyp->{modulus}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | 0 | } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | # if we have NOT pss padding we need to add v1.5 padding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | 0 | ▶ | push @params, 'v1.5' if ( $alg ne 'rsassaPss' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | 0 | return $key->verify_message( @params ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | 0 | ▶ | if( $keyp->{keytype} eq 'DSA' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | 0 | eval { require Crypt::PK::DSA; }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | 0 | ▶ | die( "Unable to load Crypt::PK::DSA\n" ) if( $@ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | 0 | $key = Crypt::PK::DSA->new( \$key ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | 0 | return $key->verify_message( @params ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | 0 | ▶ | if( $keyp->{keytype} eq 'ECC' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | 0 | eval { require Crypt::PK::ECC; }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | 0 | ▶ | die( "Unable to load Crypt::PK::ECC\n" ) if( $@ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | 0 | $key = Crypt::PK::ECC->new( \$key ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | 0 | return $key->verify_message( @params ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | 0 | die( "Unknown key type $keyp->{keytype}\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | 1 | ▶ | if( $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | $self->{_error} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | 1 | $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | 1 | ▶ | croak( $error ) if( $self->{_dieOnError} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | 0 | ▶ | return 1 if( $ok ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | $self->{_error} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | 0 | $error = "Incorrect signature\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | 0 | ▶ | croak( $error ) if( $self->{_dieOnError} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | 14 | ▶ | sub _wrap { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_wrap: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | 14 | my( $to, $text ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | 14 | my $wid = 76 - $to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | 14 | my $out = substr( $text, 0, $wid, '' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | 14 | ▶ | while( length $text ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | 17 | $out .= "\n" . (' ' x $to) . substr( $text, 0, $wid, '' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | 14 | return $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | 16 | ▶ | sub _encode_PEM { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_encode_PEM: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | 16 | my $text = encode_base64( $_[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | 16 | ▶ | return $text if( length $text <= 65 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | 16 | $text =~ tr/\n//d; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | 16 | my $out = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | 16 | ▶ | $out .= substr( $text, 0, 64, '' ) . "\n" while( length $text ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | 16 | return $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | 1 | ▶ | sub as_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=8 SCAR=22.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | 1 | local $self->{_escapeStrings} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | 1 | local( $@, $_, $! ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | 1 | my $v = $apiVersion; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | 1 | ▶ | ref( $self )->setAPIversion( 1 ) unless( defined $v && $v == 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $v and $v == 1
MC/DC0%0/2
defined $v and $v == 1
defined $v
$v == 1
Truth table33%1/3
A and B
A= defined $vB= $v == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | 1 | my $string = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | 1 | $self = ref( $self )->new( $self->{_der}, acceptPEM => 0, verifySignature => 0, escapeStrings => 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | 1 | ▶ | return $error if( !defined $self ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | 1 | $self->__stringify; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | 1 | my $at = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | 1 | ▶ | ref( $self )->setAPIversion( $v ) unless( defined $v && $v == 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $v and $v == 1
MC/DC0%0/2
defined $v and $v == 1
defined $v
$v == 1
Truth table33%1/3
A and B
A= defined $vB= $v == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | 1 | ▶ | $string = '' unless( defined $string ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | 1 | ▶ | $string .= $at if( $at ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | 1 | return $string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | 1 | ▶ | sub __stringify { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__stringify: called CC=20 SCAR=38.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | 1 | my $max = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | 1 | foreach ($self->attributes, $self->extensions, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | qw/Version Subject Key_algorithm Public_key Signature_algorithm Signature/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | 13 | ▶ | $max = length if( length > $max ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | 1 | my $string = sprintf( "%-*s: %s\n", $max, 'Version', $self->version ) ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | 1 | $string .= sprintf( "%-*s: %s\n", $max, 'Subject', _wrap( $max+2, scalar $self->subject ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | 1 | $string .= "\n --Attributes--\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | 1 | ▶ | $string .= " --None--" unless( $self->attributes ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | 1 | foreach ($self->attributes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | 4 | $string .= sprintf( "%-*s: %s\n", $max, $_, _wrap( $max+2, scalar $self->attributes($_) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | 1 | $string .= "\n --Extensions--\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | 1 | ▶ | $string .= " --None--" unless( $self->extensions ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | 1 | foreach ($self->extensions) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | 3 | ▶ | my $critical = $self->extensionPresent($_) == 2? 'critical,': ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | 3 | ▶ | $string .= sprintf( "%-*s: %s\n", $max, $_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | _wrap( $max+2, $critical . ($_ eq 'subjectAltName'? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | scalar $self->subjectAltName: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | $self->extensionValue($_, 1) ) ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | 1 | $string .= "\n --Key and signature--\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | 1 | $string .= sprintf( "%-*s: %s\n", $max, 'Key algorithm', $self->pkAlgorithm ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | 1 | $string .= sprintf( "%-*s: %s\n", $max, 'Public key', _wrap( $max+2, $self->subjectPublicKey ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | 1 | $string .= $self->subjectPublicKey(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | 1 | my $kp = $self->subjectPublicKeyParams(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | 1 | foreach (sort keys %$kp) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | 4 | my $v = $kp->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | 4 | ▶ | if( !defined $v && !defined( $v = $self->error ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
defined $v || defined($v = $self->error)
MC/DC0%0/2
defined $v || defined($v = $self->error)
defined $v
defined($v = $self->error)
Truth table33%1/3
A || B
A= defined $vB= defined($v = $self->error)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | 0 | $v = 'undef'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | } elsif( ref $v ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | 4 | $string .= sprintf( "%-*s: %s\n", $max, $_, _wrap( $max+2, $v ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | 1 | ▶ | if( exists $kp->{detail} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | 0 | $kp = $kp->{detail}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | 0 | $string .= "Key details\n-----------\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | 0 | foreach (sort keys %$kp) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | 0 | ▶ | next if( ref $kp->{$_} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | 0 | $string .= sprintf( "%-*s: %s\n", $max, $_, _wrap( $max+2, $kp->{$_} ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | 1 | $string .= sprintf( "\n%-*s: %s\n", $max, 'Signature algorithm', $self->signatureAlgorithm ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | 1 | $string .= sprintf( "%-*s: %s\n", $max, 'Signature', _wrap( $max+2, $self->signature ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | 1 | my $sp = $self->signature(2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | 1 | ▶ | if( $sp ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | 0 | foreach (sort keys %$sp) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | 0 | my $v = $sp->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | 0 | ▶ | if( ref $v ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | 0 | ▶ | if( $v->can('as_hex') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | 0 | $v = substr( $v->as_hex, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | 0 | $string .= sprintf( "%-*s: %s\n", $max, $_, _wrap( $max+2, $v ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | 1 | $string .= "\n --Request--\n" . $self->csrRequest(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | 1 | return $string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||