3
$\begingroup$

Let's pretend we create a passphrase protected PEM file using openssl:

$ openssl genrsa -aes256 -passout pass:password -out sample.pem 2048

And then extract the private key in DER format:

$ openssl rsa -in sample.pem -out sample.prv.der -outform DER

Is sample.prv.der still encrypted using the passphrase?

$\endgroup$
  • 2
    $\begingroup$ OpenSSL's 'legacy' privatekey formats, including PKCS1 for RSA, cannot be encrypted in DER form. If you want DER and encryption (PBE), use PKCS8. Or possibly PKCS12, although commandline can create PKCS12 only with both privatekey and cert/chain; doing privatekey alone requires writing a few lines of code. $\endgroup$ – dave_thompson_085 Aug 21 '16 at 16:24
4
$\begingroup$

No, it will output the PKCS#1 compatible encoding of the private key, try this:

openssl asn1parse -inform DER -in sample.prv.der

it will output an ASN.1 sequence of:

  • a version number (00);
  • the modulus;
  • the public exponent;
  • the private exponent;
  • the CRT parameters.

It did ask you for the password, right?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.