line |
true |
false |
branch |
29
|
1 |
32 |
unless my $handle = 'FileHandle'->new($path) |
32
|
0 |
32 |
unless read $handle, my $file_header, _CERTIFICATE_HEADER_SIZE() |
35
|
5 |
27 |
if ($file_header =~ /^[-]{5}BEGIN[ ](?:X[.]?509[ ]|TRUSTED[ ])?CERTIFICATE[-]{5}/msx) { } |
|
8 |
19 |
elsif ($file_header =~ /^[-]{5}BEGIN[ ](?:RSA[ ])?(PUBLIC|PRIVATE)[ ]KEY[-]{5}/msx) { } |
|
4 |
15 |
elsif ($file_header =~ /^[-]{5}BEGIN[ ](?:NEW[ ])?CERTIFICATE[ ]REQUEST[-]{5}/msx) { } |
45
|
0 |
8 |
if ($type eq 'PRIVATE') { } |
69
|
1 |
14 |
unless (defined $pem_encoded_public_key_string) |
90
|
3 |
2 |
if ($file_header =~ /^[-]{5}BEGIN[ ]CERTIFICATE[-]{5}/msx) { } |
96
|
0 |
2 |
unless seek $handle, 0, 0 |
98
|
0 |
2 |
unless defined read($handle, my $pem_encoded_certificate_string, _MAX_PUBLIC_KEY_SIZE()) |
115
|
0 |
4 |
unless seek $handle, 0, 0 |
117
|
0 |
4 |
unless defined read($handle, my $pkcs10_certificate_string, _MAX_PUBLIC_KEY_SIZE()) |
120
|
0 |
4 |
unless my $req = 'Crypt::PKCS10'->new($pkcs10_certificate_string) |
131
|
0 |
10 |
unless seek $handle, 0, 0 |
133
|
0 |
10 |
unless defined read($handle, my $pkcs10_certificate_string, _MAX_PUBLIC_KEY_SIZE()) |
139
|
8 |
2 |
unless (eval {
do {
Carp::croak("Failed to seek to start of ${path}:$HTTP::PublicKeyPins::EXTENDED_OS_ERROR") unless seek $handle, 0, 0;
Carp::croak("Failed to read from ${path}:$HTTP::PublicKeyPins::EXTENDED_OS_ERROR") unless defined read($handle, my $pkcs10_certificate_string, _MAX_PUBLIC_KEY_SIZE());
'Crypt::PKCS10'->setAPIversion(1);
my $req = 'Crypt::PKCS10'->new($pkcs10_certificate_string);
$pem_encoded_public_key_string = $req->subjectPublicKey(1)
}
}) |
153
|
10 |
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)
}
}) |
162
|
0 |
8 |
unless seek $handle, 0, 0 |
164
|
0 |
8 |
unless defined read($handle, my $der_encoded_public_key_string, _MAX_PUBLIC_KEY_SIZE()) |
168
|
0 |
8 |
unless $asn->prepare("SEQUENCE {\n algorithm SEQUENCE { algorithm OBJECT IDENTIFIER, parameters ANY OPTIONAL },\n subjectPublicKey BIT STRING\n}\n") |
176
|
1 |
7 |
unless my $pub_key = $asn->decode($der_encoded_public_key_string) |
183
|
1 |
7 |
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"
}
}) |
192
|
0 |
10 |
unless seek $handle, 0, 0 |
194
|
0 |
10 |
unless defined read($handle, my $der_encoded_private_key_string, _MAX_PUBLIC_KEY_SIZE()) |
205
|
10 |
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
}
}) |
214
|
0 |
0 |
unless seek $handle, 0, 0 |
216
|
0 |
0 |
unless defined read($handle, my $rsa_private_key_string, _MAX_PUBLIC_KEY_SIZE()) |
226
|
1 |
7 |
if ($file_header =~ /^[-]{5}BEGIN[ ]RSA[ ]PUBLIC[ ]KEY[-]{5}/msx) { } |
227
|
0 |
1 |
unless seek $handle, 0, 0 |
229
|
0 |
1 |
unless defined read($handle, my $pem_encoded_rsa_public_key_string, _MAX_PUBLIC_KEY_SIZE()) |
237
|
0 |
7 |
unless seek $handle, 0, 0 |
239
|
0 |
7 |
unless defined read($handle, $pem_encoded_public_key_string, _MAX_PUBLIC_KEY_SIZE()) |
249
|
4 |
6 |
if ($x509->key_alg_name eq 'rsaEncryption') { } |