I want to create a key for use in AES encryption. I found a way to do this using Java’s keytool. The trick was to specify that the type of the keystore was JCEKS, not the default JCE.
So this command will create the key:
keytool -genseckey -alias aestest -keyalg AES -keysize 192 -storetype JCEKS
My questions are:
-
how in the heck do I get that generated key out of the keystore, and into a file so I can use it!?
-
are there any special properties that an AES key must have, or can I choose any arbitrary 192 bits as my AES key, thus avoiding needing to use keytool at all?
Thanks
Peter
You can choose an arbitrary key – any random data will do. Generally the only scenario in which you’re likely to need an actual key generator is when you’re generating a pair of keys (public and private), in which case those two keys have to be mathematically linked, but AES is a symmetric cipher and only has the one key, which can be anything.