2

i want to store AES key in AndroidKeyStore on pre-M device

i tried to use key generated with KeyGenerator

KeyGenerator keyGen = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES);
keyGen.init(256);
SecretKey secretKey = keyGen.generateKey();

but i cannot access to that key from KeyStore, later i tried to use KeyPairGenerator

KeyPairGenerator kpg = KeyPairGenerator.getInstance(
                KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore");
kpg.initialize(new KeyPairGeneratorSpec.Builder(this)
                .setAlias("alias")
                .build());
KeyPair kp = kpg.genKeyPair();

but

java.security.NoSuchAlgorithmException: KeyPairGenerator AES implementation not found

2

1 Answer 1

8

Android Keystore supports AES only since API Level 23 (see https://developer.android.com/training/articles/keystore.html#SupportedAlgorithms). On older platforms, you could wrap the AES key using an Android Keystore RSA key. However, this means the AES key's key material will be available inside your app's process, which removes many of the security benefits of using Android Keystore.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.