Package list libcryptx-perl / 365226a
enable pkcs#8 encrypted RSA keys (supported by the latest libtomcrypt) Karel Miko 2 years ago
2 changed file(s) with 10 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
127127 elsif ($data =~ /-----BEGIN PRIVATE KEY-----(.*?)-----END/sg) {
128128 # PKCS#8 PrivateKeyInfo (PEM header: BEGIN PRIVATE KEY)
129129 $data = pem_to_der($data, $password);
130 return $self->_import_pkcs8($data, $password) if $data;
130 return $self->_import_pkcs8($data, $password);
131131 }
132132 elsif ($data =~ /-----BEGIN ENCRYPTED PRIVATE KEY-----(.*?)-----END/sg) {
133 # XXX-TODO: PKCS#8 EncryptedPrivateKeyInfo (PEM header: BEGIN ENCRYPTED PRIVATE KEY)
134 croak "FATAL: encrypted pkcs8 RSA private keys are not supported";
133 # PKCS#8 PrivateKeyInfo (PEM header: BEGIN ENCRYPTED PRIVATE KEY)
134 $data = pem_to_der($data, $password);
135 return $self->_import_pkcs8($data, $password);
135136 }
136137 elsif ($data =~ /^\s*(\{.*?\})\s*$/s) {
137138 # JSON Web Key (JWK) - http://tools.ietf.org/html/draft-ietf-jose-json-web-key
417418 fyoy4t3yHT+/nw==
418419 -----END PRIVATE KEY-----
419420
420 =item * PKCS#8 encrypted private keys ARE NOT SUPPORTED YET!
421 =item * PKCS#8 encrypted private keys - password protected keys (supported since: CryptX-0.062)
421422
422423 -----BEGIN ENCRYPTED PRIVATE KEY-----
423424 MIICojAcBgoqhkiG9w0BDAEDMA4ECCQk+Rr1yzzcAgIIAASCAoD/mgpUFjxxM/Ty
00 use strict;
11 use warnings;
2 use Test::More tests => 12;
2 use Test::More tests => 14;
33
44 use Crypt::PK::RSA;
55 use Crypt::PK::ECC;
3535 ok($rsa->is_private, "RSA is_private $f");
3636 }
3737
38 ### XXX-FIXME password protected pkcs8 private keys are not supported
39 ### for my $f (qw/pkcs8.rsa-priv-pass.der pkcs8.rsa-priv-pass.pem/) {
40 ### $rsa->import_key("t/data/$f", "secret");
41 ### ok($rsa->is_private, "RSA is_private $f");
42 ### }
38 for my $f (qw/pkcs8.rsa-priv-pass.der pkcs8.rsa-priv-pass.pem/) {
39 $rsa->import_key("t/data/$f", "secret");
40 ok($rsa->is_private, "RSA is_private $f");
41 }
4342
4443 for my $f (qw/pkcs8.ec-short-priv-nopass.der pkcs8.ec-short-priv-nopass.pem pkcs8.ec-priv-nopass.der pkcs8.ec-priv-nopass.pem/) {
4544 $ec->import_key("t/data/$f");