I am currently attempting to put together a functioning KeyStore implementation in my Android application. I am currently building against a minimum API of 18 so that I can fully take advantage of a private
keyStore.setKeyEntry(String alias, byte key, Certificate chain);
keyStore.setKeyEntry(String alias, Key key, char password, Certificate chain);
java.security.KeyStoreException: entries cannot be protected with passwords
java.security.KeyStoreException: Operation not supported because key encoding is unknown
So I have found the answer - hopefully this will help save some issues for future users, as it is not clearly laid out in the docs.
KeyPairGeneratorSpec.Builder has a method
setAlias. When a key is generated, it is automatically stored in the KeyStore under this alias. there is no extra saving that needs to happen to make it work. You can then easily retrieve these keys through instantiating the KeyStore with the same
String provider as you did the KeyPairGenerator.