1
$\begingroup$

I have to create and store a bunch of RSA key pairs with openssl. The private keys will be encrypted with the aes256 option and a very long, random password.

Would it be safe to use the same password for all keys? Or is it better to encrypt every key with a different password?

$\endgroup$
3
  • 3
    $\begingroup$ Are you going to use these keys for the same purpose or for different purposes? Maybe there is something that requires a different access level from one key to the other? $\endgroup$
    – Maarten Bodewes
    Commented May 16, 2019 at 20:22
  • 1
    $\begingroup$ Do you have a reason to suspect that even if one password is compromised, the other ones may not be? And is there a different impact if one RSA key is compromised but not the others? $\endgroup$ Commented May 16, 2019 at 22:07
  • $\begingroup$ Keys all serve a similar purpose and need the same level of protection. The passwords would all be stored in the same vault, so if one gets compromised, they are all compromised. So my question is only about the encryption mechanism of openssl. Would I weaken it by using the same password for multiple keys? $\endgroup$
    – Gert-Jan
    Commented May 20, 2019 at 13:03

1 Answer 1

1
$\begingroup$

The openssl docs say nothing about this issue, and no answer from the community. So I tried to figure it out with a small experiment. I created a private key (not encrypted) with:

openssl genrsa -out key.pem

Then I encrypted the key twice, using the same password:

openssl rsa -aes256 -in key.pem -out key-enc-1.pem
openssl rsa -aes256 -in key.pem -out key-enc-2.pem

and compared the content of key-enc-1.pem and key-enc-2.pem

Files were completely different so it looks like the AES-encryption is done with a random salt.

So, answering my own question: using openssl genrsa with aes-encryption, it is safe to use the same password for all my private keys.

$\endgroup$
1
  • $\begingroup$ I could have saved the time for the experiment. The encrypted file contains a line with "DEK-Info". In the openssl docs it is explained that this line contains the encryption algorithm and an initialization vector. See openssl.org/docs/man1.1.0/man3/PEM_read_bio_X509_REQ.html $\endgroup$
    – Gert-Jan
    Commented May 22, 2019 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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