ASN1 sequence to use in Convert::PEM to read pkcs8 DER privateKey? PERL

743 views Asked by At

I'm trying to convert to PEM a private key which is encoded and encrypted in DER using pkcs8, with module Convert::PEM and it ask for an ASN Sequence (I believe the algorithm used to encrypt is EDE_EDE3)

I've found this documentation: Public-Key Cryptography Standards (PKCS) #8: which describes the syntax used, but I haven't been able to applied successfully in my PERL code, I've tried:

my $pem = Convert::PEM->new(
               Name => "RSA PRIVATE KEY",
               ASN => qq(
                 PrivateKeyInfo ::= SEQUENCE {
                    version                   Version,
                    privateKeyAlgorithm       PrivateKeyAlgorithmIdentifier,
                    privateKey                PrivateKey,
                    attributes           [0]  IMPLICIT Attributes OPTIONAL }

                  Version ::= INTEGER

                  PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier

                  PrivateKey ::= OCTET STRING

                  Attributes ::= SET OF Attribute
        }
              ))or die "New failed: ", Convert::PEM->errstr;

What am I doing wrong?

0

There are 0 answers