# Secure private key storage

I'm developing application in Java that has to store RSA keys in software for foreseeable future (that is, at least 10 years).

The two most common standards of storing private keys are PKCS12 and JKS (Java Key Store). While PKCS12 supports many different algorithms, even the most secure ones are based on 3DES with SHA1. JKS is even worse as the default is based on MD5 and 3DES.

The Bouncy Castle Java library version of JKS is a bit better as it uses PBEWithSHAAndTwofish-CBC for "UBER" version of its key store format.

Are there any standard formats of private key storage that support encrypting the key pair using AES and SHA-2?

• – David Cary Aug 8 '12 at 15:44
• OpenSSL seems to support AES and SHA-2 for PKCS #12. openssl.org/docs/apps/pkcs12.html – mikeazo Aug 8 '12 at 16:32
• @mikeazo: Yes, but not in a straightforward way, the -aes256 options refer to PEM output used when extracting private keys. To actually create PKCS12 file with AES encryption one needs to use something like this: openssl pkcs12 -export -inkey server.key -keypbe AES-128-CBC -macalg SHA256 -in server.crt -out server.p12. But I have no way to verify if it actually does this... Still, I don't think it's possible to create such a file with JCE (Java Cryptographic Extensions), maybe with Bouncy Castle low level API... – Hubert Kario Aug 8 '12 at 22:07

I went with PKCS#8 and Bouncy Castle specific PBEWithSHA256And256BitAES-CBC-BC encryption. Unfortunately BC nor Java doesn't support regular PBE with SHA1 and AES.