Branch Coverage

blib/lib/HTTP/PublicKeyPins.pm
Criterion Covered Total %
branch 36 54 66.6


line true false branch
29 1 28 unless my $handle = 'FileHandle'->new($path)
32 0 28 unless read $handle, my $file_header, _CERTIFICATE_HEADER_SIZE()
35 5 23 if ($file_header =~ /^[-]{5}BEGIN[ ](?:X[.]?509[ ]|TRUSTED[ ])?CERTIFICATE[-]{5}/msx) { }
8 15 elsif ($file_header =~ /^[-]{5}BEGIN[ ](?:RSA[ ])?(PUBLIC|PRIVATE)[ ]KEY[-]{5}/msx) { }
4 11 elsif ($file_header =~ /^[-]{5}BEGIN[ ](?:NEW[ ])?CERTIFICATE[ ]REQUEST[-]{5}/msx) { }
45 0 8 if ($type eq 'PRIVATE') { }
67 1 10 unless (defined $pem_encoded_public_key_string)
88 3 2 if ($file_header =~ /^[-]{5}BEGIN[ ]CERTIFICATE[-]{5}/msx) { }
94 0 2 unless seek $handle, 0, 0
96 0 2 unless defined read($handle, my $pem_encoded_certificate_string, _MAX_PUBLIC_KEY_SIZE())
126 6 5 unless (eval { do { my $x509 = 'Crypt::OpenSSL::X509'->new_from_file($path, 1); $pem_encoded_public_key_string = _get_pem_encoded_public_key_string($x509) } })
135 0 6 unless seek $handle, 0, 0
137 0 6 unless defined read($handle, my $der_encoded_public_key_string, _MAX_PUBLIC_KEY_SIZE())
141 0 6 unless $asn->prepare("SEQUENCE {\n algorithm SEQUENCE { algorithm OBJECT IDENTIFIER, parameters ANY OPTIONAL },\n subjectPublicKey BIT STRING\n}\n")
149 1 5 unless my $pub_key = $asn->decode($der_encoded_public_key_string)
156 1 5 unless (eval { do { Carp::croak('Failed to decode SubjectPublicKeyInfo in ASN1:' . $asn->error) unless my $pub_key = $asn->decode($der_encoded_public_key_string); $pem_encoded_public_key_string = "-----BEGIN PUBLIC KEY-----\n" . &MIME::Base64::encode_base64($der_encoded_public_key_string) . "-----END PUBLIC KEY-----\n" } })
165 0 6 unless seek $handle, 0, 0
167 0 6 unless defined read($handle, my $der_encoded_private_key_string, _MAX_PUBLIC_KEY_SIZE())
178 6 0 unless (eval { do { my $privkey = 'Crypt::OpenSSL::RSA'->new_private_key($pem_encoded_private_key_string); $pem_encoded_public_key_string = $privkey->get_public_key_x509_string } })
187 0 0 unless seek $handle, 0, 0
189 0 0 unless defined read($handle, my $rsa_private_key_string, _MAX_PUBLIC_KEY_SIZE())
199 1 7 if ($file_header =~ /^[-]{5}BEGIN[ ]RSA[ ]PUBLIC[ ]KEY[-]{5}/msx) { }
200 0 1 unless seek $handle, 0, 0
202 0 1 unless defined read($handle, my $pem_encoded_rsa_public_key_string, _MAX_PUBLIC_KEY_SIZE())
210 0 7 unless seek $handle, 0, 0
212 0 7 unless defined read($handle, $pem_encoded_public_key_string, _MAX_PUBLIC_KEY_SIZE())
222 4 6 if ($x509->key_alg_name eq 'rsaEncryption') { }