My app will require maintaining an RSA keypair locally on the user's machine. I was a bit disappointed to discover that PKCS#12 and JKS don't offer higher than 3DES (correct me if I have this wrong). Or feel free to suggest a standard that does.

Are there any immediate concerns to me using my own format? so a model including:

  • Alias
  • Encrypted (private) key bytes
  • Matching x509 certificate

The encryption of the private key uses an AES key + IV. The AES key is derived from a user entered password and a stored salt using PBKDF2WithHmacSHA512

NOTE: This is just for storing keys, so a certificate-esque format is not essential.

Kind Regards,

  • 2
    You can of course use your own format to protect data and this includes key pairs. But if you do this you should do it properly. And I don't have the feeling that you really understand what you are doing: The "salt" you propose to add to your format and its explanation suggest to me that you do not understand how and why salts are commonly used. Also, the title talks about certificate but you actually want to store a key pair - which is in many ways different from a certificate. – Steffen Ullrich Jul 12 '17 at 10:19
  • The method I'm using for generating the AESkey goes roughly like so (I'm not with my code at the moment): SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA512"); KeySpec spec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount, keyStrength); in which a salt is used in the keyspec constructor and needed to reconstitute it later. Encryption will use an IV instead in combo with the key. Does that make more sense or am I still missing something? True I do just want to store keys there is no particular reason it has to look like a certificate. – 0zero Jul 12 '17 at 12:31
  • With this description it makes more sense now. If you ask about the technical details I suggest to add the details from the comment to the question. If you are not interested in getting feedback to the technical details I suggest to remove the existing ones from the question because they add currently more confusion since they are too incomplete. – Steffen Ullrich Jul 12 '17 at 12:38
  • Good point, hopefully the description and the question are a bit clearer now. – 0zero Jul 12 '17 at 13:07

Your Answer

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

Browse other questions tagged or ask your own question.