Store AES key in Android


Marius

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

I am trying to use the generated keyKeyGenerator

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

But I can't access the key from KeyStore, later I try to useKeyPairGenerator

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

Alex Klyubin

Android Keystore only supports AES since API level 23 (see https://developer.android.com/training/articles/keystore.html#SupportedAlgorithms ). On older platforms, you can use the Android Keystore RSA key to wrap the AES key. However, this means that the key material for the AES key will be available during your application, removing many of the security benefits that come with using the Android Keystore.

Related


Store AES key in Android

Marius I want to store AES key in AndroidKeyStore on pre-M device I am trying to use the generated keyKeyGenerator KeyGenerator keyGen = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES); keyGen.init(256); SecretKey secretKey = keyGen.generateKey(); B

Android AES encryption key

David R. I am developing an android application and I want to use AES-128 for encryption. I use hex for the key and text. I use this website: http://testprotect.com/appendix/AEScalc , calculate the AES encryption with the following key: "c4dcc3c6ce0acaec4327b6

How to protect AES key in android

Milad Bachmanabadi I'm creating a payment library and I need to save 2 AES keys , the AES keys are private and users can't access them right now, I save them in sharedPrefrences. , my question is is there another way to protect my password key? Any help would

Decrypt AES key using RSA in Android

Sijo Chosan I'm trying to encrypt a small file using AES (128 bit) and then encrypt the AES key using RSA (1024 bit). This is good. As a logical next step, I tried decrypting the AES key using RSA. Decrypting with RSA returns a 128 byte block, but my AES key i

Decrypt AES key using RSA in Android

Sijo Chosan I'm trying to encrypt a small file using AES (128 bit) and then encrypt the AES key using RSA (1024 bit). This is good. As a logical next step, I tried decrypting the AES key using RSA. Decrypting with RSA returns a 128 byte block, but my AES key i

Generate symmetric key and store in android keystore

Ryogo I am trying to do the following, Generate keys for sqlcipher. Store the key in the android keystore. Retrieve the secret from the keystore. I've found almost everything I need, but I'm having trouble getting the code snippets below to work together. Last

ECDH with keys from Android Key Store

Olivier Grenoble I am developing an Android app that generates EC asymmetric keys. When my app connects to the device, they exchange their public keys. Then, they use ECDH to establish a shared secret. Then, use this shared secret to derive the AES session key

ECDH with keys from Android Key Store

Olivier Grenoble I am developing an Android app that generates EC asymmetric keys. When my app connects to the device, they exchange their public keys. Then, they use ECDH to establish a shared secret. Then, use this shared secret to derive the AES session key

AES key size in Java

Tom Brito: By testing RSA to encrypt an AES key, I realized that RSA is limited by only 1 block (whose size can be set by the programmer), which does store the encryption key. The problem is, when I use: KeyGenerator.getInstance("AES").generateKey() Will the

AES object key size

Bardh Mehmeti I'm working on a project which involves creating an application that encrypts data using the AES algorithm. In the main function, I create an AES object like this: Aes objAes = Aes.Create(); byte[] key = objAes.Key; byte[] IV = objAes.IV; From w

Key Verification in AES

Nilesh If the user enters the wrong key for AES decryption, some garbage data will be generated. I want to validate a given decryption key and throw an error if the key is incorrect. How to validate the key entered by the user? Luke Joshua Park Use HMAC . The

Encrypt AES key?

Ralph Keller Consider this situation: Key1 = random key Key2 = random key CombinedKey = Key1.encrypt (Key2) Input = "test" Step1 = CombinedKey.encrypt (Input) Step2 = key2.decrypt (step1) Result = key1.decrypt (step2) Does result == "test" if encryption type

AES round key generation

Anans Subramanian I am reading about the AES algorithm. For round 0 key generation, one of the steps is to add the round constant to the output of the s-box. For example: byte replacement (S-Box): (B7; 5A; 9D; 85)? Adding the circle constant (01; 00; 00; 00) g

AES key size in Java

Tom Brito: By testing RSA to encrypt an AES key, I realized that RSA is limited by only 1 block (whose size can be set by the programmer), which does store the encryption key. The problem is, when I use: KeyGenerator.getInstance("AES").generateKey() Will the

Is the AES key good enough?

old ghost System.Security.Cryptography.Aes.Create(algorithmName)When the method is called , a new key and IV are generated. Are these good enough? data These values are safe to use. The whole point of a framework like this is to make cryptographically random v

AES round key generation

Anans Subramanian I am reading about the AES algorithm. For round 0 key generation, one of the steps is to add the round constant to the output of the s-box. For example: byte replacement (S-Box): (B7; 5A; 9D; 85)? Adding the circle constant (01; 00; 00; 00) g

AES object key size

Bardh Mehmeti I'm working on a project that involves creating an application that encrypts data using the AES algorithm. In the main function, I create an AES object like this: Aes objAes = Aes.Create(); byte[] key = objAes.Key; byte[] IV = objAes.IV; From wh

AES object key size

Bardh Mehmeti I'm working on a project that involves creating an application that encrypts data using the AES algorithm. In the main function, I create an AES object like this: Aes objAes = Aes.Create(); byte[] key = objAes.Key; byte[] IV = objAes.IV; From wh

Key Verification in AES

Nilesh If the user enters the wrong key for AES decryption, some garbage data will be generated. I want to validate a given decryption key and throw an error if the key is incorrect. How to validate the key entered by the user? Luke Joshua Park Use HMAC . The

AES key schedule

Emil Grigore In the tutorial for the AES key plan, I see that the operations of the key plan (rotate, rcon, s-box) are applied to a 4-byte word. Can you explain where this word comes from? The key length is 128 bits. The keys are saved as a 4x4 matrix. So how

AES key schedule

Emil Grigore In the tutorial for the AES key plan, I see that the operations of the key plan (rotate, rcon, s-box) are applied to a 4-byte word. Can you explain where this word comes from? The key length is 128 bits. The keys are saved as a 4x4 matrix. So how

Unlock AES key on iOS

Ikaganovic We have a client-server architecture where the server uses the AES key wrapping algorithm ( rfc 3394 ) to return the AES key wrapped with other AES keys to the client. We need to implement a client on iOS that can decrypt these keys. I don't know an

Generate AES key on node

Eugenio Cuevas I'm working on a legacy application that uses a custom protocol to encrypt communications. The random AES key is generated in a legacy Java app like this: keygen = KeyGenerator.getInstance("AES"); keygen.init(128); keygen.generateKey().getEncode

Encrypt AES key?

Ralph Keller Consider this situation: Key1 = random key Key2 = random key CombinedKey = Key1.encrypt (Key2) Input = "test" Step1 = CombinedKey.encrypt (Input) Step2 = key2.decrypt (step1) Result = key1.decrypt (step2) Does result == "test" if encryption type