Android KeyStore operation failed: Unsupported Digest












0















I'm having an error while decrypting data using the keystore on about 1% of my users (in different API versions and device models). The crash log is:



Caused by java.lang.RuntimeException: java.security.InvalidKeyException: Keystore operation failed
at es.xxxx.yyyy.utils.KeyStoreHelperManager.decrypt(KeyStoreHelperManager.java:256)
at es.xxxx.yyyy.activities.MainActivity.checkKeyStoreCorrecto(MainActivity.java:308)
at es.xxxx.yyyy.activities.MainActivity.configurarLayout(MainActivity.java:294)
at es.xxxx.yyyy.activities.MainActivity.onCreate(MainActivity.java:84)
at android.app.Activity.performCreate(Activity.java:7144)
at android.app.Activity.performCreate(Activity.java:7135)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6680)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Caused by java.security.InvalidKeyException: Keystore operation failed
at android.security.KeyStore.getInvalidKeyException(KeyStore.java:901)
at android.security.KeyStore.getInvalidKeyException(KeyStore.java:926)
at android.security.keystore.KeyStoreCryptoOperationUtils.getInvalidKeyExceptionForInit(KeyStoreCryptoOperationUtils.java:54)
at android.security.keystore.KeyStoreCryptoOperationUtils.getExceptionForCipherInit(KeyStoreCryptoOperationUtils.java:89)
at android.security.keystore.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:265)
at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineInit(AndroidKeyStoreCipherSpiBase.java:109)
at javax.crypto.Cipher.tryTransformWithProvider(Cipher.java:2984)
at javax.crypto.Cipher.tryCombinations(Cipher.java:2891)
at javax.crypto.Cipher$SpiAndProviderUpdater.updateAndGetSpiAndProvider(Cipher.java:2796)
at javax.crypto.Cipher.chooseProvider(Cipher.java:773)
at javax.crypto.Cipher.init(Cipher.java:1143)
at javax.crypto.Cipher.init(Cipher.java:1084)
at es.xxxx.yyyy.utils.KeyStoreHelperManager.decrypt(KeyStoreHelperManager.java:251)
at es.xxxx.yyyy.activities.MainActivity.checkKeyStoreCorrecto(MainActivity.java:308)
at es.xxxx.yyyy.activities.MainActivity.configurarLayout(MainActivity.java:294)
at es.xxxx.yyyy.activities.MainActivity.onCreate(MainActivity.java:84)
at android.app.Activity.performCreate(Activity.java:7144)
at android.app.Activity.performCreate(Activity.java:7135)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6680)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Caused by android.security.KeyStoreException: Unsupported digest
at android.security.KeyStore.getKeyStoreException(KeyStore.java:839)
at android.security.KeyStore.getInvalidKeyException(KeyStore.java:926)
at android.security.keystore.KeyStoreCryptoOperationUtils.getInvalidKeyExceptionForInit(KeyStoreCryptoOperationUtils.java:54)
at android.security.keystore.KeyStoreCryptoOperationUtils.getExceptionForCipherInit(KeyStoreCryptoOperationUtils.java:89)
at android.security.keystore.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:265)
at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineInit(AndroidKeyStoreCipherSpiBase.java:109)
at javax.crypto.Cipher.tryTransformWithProvider(Cipher.java:2984)
at javax.crypto.Cipher.tryCombinations(Cipher.java:2891)
at javax.crypto.Cipher$SpiAndProviderUpdater.updateAndGetSpiAndProvider(Cipher.java:2796)
at javax.crypto.Cipher.chooseProvider(Cipher.java:773)
at javax.crypto.Cipher.init(Cipher.java:1143)
at javax.crypto.Cipher.init(Cipher.java:1084)
at es.xxxx.yyyy.utils.KeyStoreHelperManager.decrypt(KeyStoreHelperManager.java:251)
at es.xxxx.yyyy.activities.MainActivity.checkKeyStoreCorrecto(MainActivity.java:308)
at es.xxxx.yyyy.activities.MainActivity.configurarLayout(MainActivity.java:294)
at es.xxxx.yyyy.activities.MainActivity.onCreate(MainActivity.java:84)
at android.app.Activity.performCreate(Activity.java:7144)
at android.app.Activity.performCreate(Activity.java:7135)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6680)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

#0. Crashed: main
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2914)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6680)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)


This is the way we create the KeyPair:



@TargetApi(Build.VERSION_CODES.M)
static void createKeysM(String alias, boolean requireAuth) {
try {
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(
KeyProperties.KEY_ALGORITHM_RSA, SecurityConstants.KEYSTORE_PROVIDER_ANDROID_KEYSTORE);
keyPairGenerator.initialize(
new KeyGenParameterSpec.Builder(
alias,
KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT)
.setAlgorithmParameterSpec(new RSAKeyGenParameterSpec(1024, F4))
.setBlockModes(KeyProperties.BLOCK_MODE_CBC)
.setRandomizedEncryptionRequired(false)
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
.setDigests(KeyProperties.DIGEST_SHA256,
KeyProperties.DIGEST_SHA384,
KeyProperties.DIGEST_SHA512)
// Only permit the private key to be used if the user authenticated
// within the last five minutes.
.setUserAuthenticationRequired(requireAuth)
.build());
KeyPair keyPair = keyPairGenerator.generateKeyPair();
Log.d(TAG, "Public Key is: " + keyPair.getPublic().toString());

} catch (NoSuchProviderException | NoSuchAlgorithmException | InvalidAlgorithmParameterException e) {
throw new RuntimeException(e);
}
}


This is the method we use to encrypt data:



 public static String encrypt(String alias, String plaintext) {
try {

KeyStore ks = KeyStore
.getInstance(SecurityConstants.KEYSTORE_PROVIDER_ANDROID_KEYSTORE);
ks.load(null);


//PrivateKey privateKey = (PrivateKey) keyStore.getKey("alias", null);
PublicKey publicKey = ks.getCertificate(alias).getPublicKey();


//PublicKey publicKey = getPrivateKeyEntry(alias).getCertificate().getPublicKey();
Cipher cipher = getCipher();
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
return Base64.encodeToString(cipher.doFinal(plaintext.getBytes()), Base64.NO_WRAP);
} catch (NullPointerException ex){
Logs.logException(ex);
throw ex;
}
catch (Exception e) {
Logs.logException(e);
throw new RuntimeException(e);
}
}


And this is the method to decrypt data:



public static String decrypt(String alias, String ciphertext) throws IllegalBlockSizeException {
try {

KeyStore ks = KeyStore
.getInstance(SecurityConstants.KEYSTORE_PROVIDER_ANDROID_KEYSTORE);
ks.load(null);


PrivateKey privateKey = (PrivateKey) ks.getKey(alias, null);


//PrivateKey privateKey = getPrivateKeyEntry(alias).getPrivateKey();
Cipher cipher = getCipher();
cipher.init(Cipher.DECRYPT_MODE, privateKey);
return new String(cipher.doFinal(Base64.decode(ciphertext, Base64.NO_WRAP)));
}catch (IllegalBlockSizeException ex){
throw ex;
} catch (Exception e) {
throw new RuntimeException(e);
}
}


The error is being launched while decrypting, just while doing cipher.init.



Our cypher is created like this:



private static Cipher getCipher() throws NoSuchPaddingException, NoSuchAlgorithmException {
return Cipher.getInstance(
String.format("%s/%s/%s",
"RSA",
"NoPadding",
"BLOCKING_MODE"));
}









share|improve this question



























    0















    I'm having an error while decrypting data using the keystore on about 1% of my users (in different API versions and device models). The crash log is:



    Caused by java.lang.RuntimeException: java.security.InvalidKeyException: Keystore operation failed
    at es.xxxx.yyyy.utils.KeyStoreHelperManager.decrypt(KeyStoreHelperManager.java:256)
    at es.xxxx.yyyy.activities.MainActivity.checkKeyStoreCorrecto(MainActivity.java:308)
    at es.xxxx.yyyy.activities.MainActivity.configurarLayout(MainActivity.java:294)
    at es.xxxx.yyyy.activities.MainActivity.onCreate(MainActivity.java:84)
    at android.app.Activity.performCreate(Activity.java:7144)
    at android.app.Activity.performCreate(Activity.java:7135)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6680)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

    Caused by java.security.InvalidKeyException: Keystore operation failed
    at android.security.KeyStore.getInvalidKeyException(KeyStore.java:901)
    at android.security.KeyStore.getInvalidKeyException(KeyStore.java:926)
    at android.security.keystore.KeyStoreCryptoOperationUtils.getInvalidKeyExceptionForInit(KeyStoreCryptoOperationUtils.java:54)
    at android.security.keystore.KeyStoreCryptoOperationUtils.getExceptionForCipherInit(KeyStoreCryptoOperationUtils.java:89)
    at android.security.keystore.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:265)
    at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineInit(AndroidKeyStoreCipherSpiBase.java:109)
    at javax.crypto.Cipher.tryTransformWithProvider(Cipher.java:2984)
    at javax.crypto.Cipher.tryCombinations(Cipher.java:2891)
    at javax.crypto.Cipher$SpiAndProviderUpdater.updateAndGetSpiAndProvider(Cipher.java:2796)
    at javax.crypto.Cipher.chooseProvider(Cipher.java:773)
    at javax.crypto.Cipher.init(Cipher.java:1143)
    at javax.crypto.Cipher.init(Cipher.java:1084)
    at es.xxxx.yyyy.utils.KeyStoreHelperManager.decrypt(KeyStoreHelperManager.java:251)
    at es.xxxx.yyyy.activities.MainActivity.checkKeyStoreCorrecto(MainActivity.java:308)
    at es.xxxx.yyyy.activities.MainActivity.configurarLayout(MainActivity.java:294)
    at es.xxxx.yyyy.activities.MainActivity.onCreate(MainActivity.java:84)
    at android.app.Activity.performCreate(Activity.java:7144)
    at android.app.Activity.performCreate(Activity.java:7135)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6680)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

    Caused by android.security.KeyStoreException: Unsupported digest
    at android.security.KeyStore.getKeyStoreException(KeyStore.java:839)
    at android.security.KeyStore.getInvalidKeyException(KeyStore.java:926)
    at android.security.keystore.KeyStoreCryptoOperationUtils.getInvalidKeyExceptionForInit(KeyStoreCryptoOperationUtils.java:54)
    at android.security.keystore.KeyStoreCryptoOperationUtils.getExceptionForCipherInit(KeyStoreCryptoOperationUtils.java:89)
    at android.security.keystore.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:265)
    at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineInit(AndroidKeyStoreCipherSpiBase.java:109)
    at javax.crypto.Cipher.tryTransformWithProvider(Cipher.java:2984)
    at javax.crypto.Cipher.tryCombinations(Cipher.java:2891)
    at javax.crypto.Cipher$SpiAndProviderUpdater.updateAndGetSpiAndProvider(Cipher.java:2796)
    at javax.crypto.Cipher.chooseProvider(Cipher.java:773)
    at javax.crypto.Cipher.init(Cipher.java:1143)
    at javax.crypto.Cipher.init(Cipher.java:1084)
    at es.xxxx.yyyy.utils.KeyStoreHelperManager.decrypt(KeyStoreHelperManager.java:251)
    at es.xxxx.yyyy.activities.MainActivity.checkKeyStoreCorrecto(MainActivity.java:308)
    at es.xxxx.yyyy.activities.MainActivity.configurarLayout(MainActivity.java:294)
    at es.xxxx.yyyy.activities.MainActivity.onCreate(MainActivity.java:84)
    at android.app.Activity.performCreate(Activity.java:7144)
    at android.app.Activity.performCreate(Activity.java:7135)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6680)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

    #0. Crashed: main
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2914)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6680)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)


    This is the way we create the KeyPair:



    @TargetApi(Build.VERSION_CODES.M)
    static void createKeysM(String alias, boolean requireAuth) {
    try {
    KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(
    KeyProperties.KEY_ALGORITHM_RSA, SecurityConstants.KEYSTORE_PROVIDER_ANDROID_KEYSTORE);
    keyPairGenerator.initialize(
    new KeyGenParameterSpec.Builder(
    alias,
    KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT)
    .setAlgorithmParameterSpec(new RSAKeyGenParameterSpec(1024, F4))
    .setBlockModes(KeyProperties.BLOCK_MODE_CBC)
    .setRandomizedEncryptionRequired(false)
    .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
    .setDigests(KeyProperties.DIGEST_SHA256,
    KeyProperties.DIGEST_SHA384,
    KeyProperties.DIGEST_SHA512)
    // Only permit the private key to be used if the user authenticated
    // within the last five minutes.
    .setUserAuthenticationRequired(requireAuth)
    .build());
    KeyPair keyPair = keyPairGenerator.generateKeyPair();
    Log.d(TAG, "Public Key is: " + keyPair.getPublic().toString());

    } catch (NoSuchProviderException | NoSuchAlgorithmException | InvalidAlgorithmParameterException e) {
    throw new RuntimeException(e);
    }
    }


    This is the method we use to encrypt data:



     public static String encrypt(String alias, String plaintext) {
    try {

    KeyStore ks = KeyStore
    .getInstance(SecurityConstants.KEYSTORE_PROVIDER_ANDROID_KEYSTORE);
    ks.load(null);


    //PrivateKey privateKey = (PrivateKey) keyStore.getKey("alias", null);
    PublicKey publicKey = ks.getCertificate(alias).getPublicKey();


    //PublicKey publicKey = getPrivateKeyEntry(alias).getCertificate().getPublicKey();
    Cipher cipher = getCipher();
    cipher.init(Cipher.ENCRYPT_MODE, publicKey);
    return Base64.encodeToString(cipher.doFinal(plaintext.getBytes()), Base64.NO_WRAP);
    } catch (NullPointerException ex){
    Logs.logException(ex);
    throw ex;
    }
    catch (Exception e) {
    Logs.logException(e);
    throw new RuntimeException(e);
    }
    }


    And this is the method to decrypt data:



    public static String decrypt(String alias, String ciphertext) throws IllegalBlockSizeException {
    try {

    KeyStore ks = KeyStore
    .getInstance(SecurityConstants.KEYSTORE_PROVIDER_ANDROID_KEYSTORE);
    ks.load(null);


    PrivateKey privateKey = (PrivateKey) ks.getKey(alias, null);


    //PrivateKey privateKey = getPrivateKeyEntry(alias).getPrivateKey();
    Cipher cipher = getCipher();
    cipher.init(Cipher.DECRYPT_MODE, privateKey);
    return new String(cipher.doFinal(Base64.decode(ciphertext, Base64.NO_WRAP)));
    }catch (IllegalBlockSizeException ex){
    throw ex;
    } catch (Exception e) {
    throw new RuntimeException(e);
    }
    }


    The error is being launched while decrypting, just while doing cipher.init.



    Our cypher is created like this:



    private static Cipher getCipher() throws NoSuchPaddingException, NoSuchAlgorithmException {
    return Cipher.getInstance(
    String.format("%s/%s/%s",
    "RSA",
    "NoPadding",
    "BLOCKING_MODE"));
    }









    share|improve this question

























      0












      0








      0








      I'm having an error while decrypting data using the keystore on about 1% of my users (in different API versions and device models). The crash log is:



      Caused by java.lang.RuntimeException: java.security.InvalidKeyException: Keystore operation failed
      at es.xxxx.yyyy.utils.KeyStoreHelperManager.decrypt(KeyStoreHelperManager.java:256)
      at es.xxxx.yyyy.activities.MainActivity.checkKeyStoreCorrecto(MainActivity.java:308)
      at es.xxxx.yyyy.activities.MainActivity.configurarLayout(MainActivity.java:294)
      at es.xxxx.yyyy.activities.MainActivity.onCreate(MainActivity.java:84)
      at android.app.Activity.performCreate(Activity.java:7144)
      at android.app.Activity.performCreate(Activity.java:7135)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
      at android.os.Handler.dispatchMessage(Handler.java:106)
      at android.os.Looper.loop(Looper.java:193)
      at android.app.ActivityThread.main(ActivityThread.java:6680)
      at java.lang.reflect.Method.invoke(Method.java)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

      Caused by java.security.InvalidKeyException: Keystore operation failed
      at android.security.KeyStore.getInvalidKeyException(KeyStore.java:901)
      at android.security.KeyStore.getInvalidKeyException(KeyStore.java:926)
      at android.security.keystore.KeyStoreCryptoOperationUtils.getInvalidKeyExceptionForInit(KeyStoreCryptoOperationUtils.java:54)
      at android.security.keystore.KeyStoreCryptoOperationUtils.getExceptionForCipherInit(KeyStoreCryptoOperationUtils.java:89)
      at android.security.keystore.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:265)
      at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineInit(AndroidKeyStoreCipherSpiBase.java:109)
      at javax.crypto.Cipher.tryTransformWithProvider(Cipher.java:2984)
      at javax.crypto.Cipher.tryCombinations(Cipher.java:2891)
      at javax.crypto.Cipher$SpiAndProviderUpdater.updateAndGetSpiAndProvider(Cipher.java:2796)
      at javax.crypto.Cipher.chooseProvider(Cipher.java:773)
      at javax.crypto.Cipher.init(Cipher.java:1143)
      at javax.crypto.Cipher.init(Cipher.java:1084)
      at es.xxxx.yyyy.utils.KeyStoreHelperManager.decrypt(KeyStoreHelperManager.java:251)
      at es.xxxx.yyyy.activities.MainActivity.checkKeyStoreCorrecto(MainActivity.java:308)
      at es.xxxx.yyyy.activities.MainActivity.configurarLayout(MainActivity.java:294)
      at es.xxxx.yyyy.activities.MainActivity.onCreate(MainActivity.java:84)
      at android.app.Activity.performCreate(Activity.java:7144)
      at android.app.Activity.performCreate(Activity.java:7135)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
      at android.os.Handler.dispatchMessage(Handler.java:106)
      at android.os.Looper.loop(Looper.java:193)
      at android.app.ActivityThread.main(ActivityThread.java:6680)
      at java.lang.reflect.Method.invoke(Method.java)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

      Caused by android.security.KeyStoreException: Unsupported digest
      at android.security.KeyStore.getKeyStoreException(KeyStore.java:839)
      at android.security.KeyStore.getInvalidKeyException(KeyStore.java:926)
      at android.security.keystore.KeyStoreCryptoOperationUtils.getInvalidKeyExceptionForInit(KeyStoreCryptoOperationUtils.java:54)
      at android.security.keystore.KeyStoreCryptoOperationUtils.getExceptionForCipherInit(KeyStoreCryptoOperationUtils.java:89)
      at android.security.keystore.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:265)
      at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineInit(AndroidKeyStoreCipherSpiBase.java:109)
      at javax.crypto.Cipher.tryTransformWithProvider(Cipher.java:2984)
      at javax.crypto.Cipher.tryCombinations(Cipher.java:2891)
      at javax.crypto.Cipher$SpiAndProviderUpdater.updateAndGetSpiAndProvider(Cipher.java:2796)
      at javax.crypto.Cipher.chooseProvider(Cipher.java:773)
      at javax.crypto.Cipher.init(Cipher.java:1143)
      at javax.crypto.Cipher.init(Cipher.java:1084)
      at es.xxxx.yyyy.utils.KeyStoreHelperManager.decrypt(KeyStoreHelperManager.java:251)
      at es.xxxx.yyyy.activities.MainActivity.checkKeyStoreCorrecto(MainActivity.java:308)
      at es.xxxx.yyyy.activities.MainActivity.configurarLayout(MainActivity.java:294)
      at es.xxxx.yyyy.activities.MainActivity.onCreate(MainActivity.java:84)
      at android.app.Activity.performCreate(Activity.java:7144)
      at android.app.Activity.performCreate(Activity.java:7135)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
      at android.os.Handler.dispatchMessage(Handler.java:106)
      at android.os.Looper.loop(Looper.java:193)
      at android.app.ActivityThread.main(ActivityThread.java:6680)
      at java.lang.reflect.Method.invoke(Method.java)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

      #0. Crashed: main
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2914)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
      at android.os.Handler.dispatchMessage(Handler.java:106)
      at android.os.Looper.loop(Looper.java:193)
      at android.app.ActivityThread.main(ActivityThread.java:6680)
      at java.lang.reflect.Method.invoke(Method.java)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)


      This is the way we create the KeyPair:



      @TargetApi(Build.VERSION_CODES.M)
      static void createKeysM(String alias, boolean requireAuth) {
      try {
      KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(
      KeyProperties.KEY_ALGORITHM_RSA, SecurityConstants.KEYSTORE_PROVIDER_ANDROID_KEYSTORE);
      keyPairGenerator.initialize(
      new KeyGenParameterSpec.Builder(
      alias,
      KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT)
      .setAlgorithmParameterSpec(new RSAKeyGenParameterSpec(1024, F4))
      .setBlockModes(KeyProperties.BLOCK_MODE_CBC)
      .setRandomizedEncryptionRequired(false)
      .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
      .setDigests(KeyProperties.DIGEST_SHA256,
      KeyProperties.DIGEST_SHA384,
      KeyProperties.DIGEST_SHA512)
      // Only permit the private key to be used if the user authenticated
      // within the last five minutes.
      .setUserAuthenticationRequired(requireAuth)
      .build());
      KeyPair keyPair = keyPairGenerator.generateKeyPair();
      Log.d(TAG, "Public Key is: " + keyPair.getPublic().toString());

      } catch (NoSuchProviderException | NoSuchAlgorithmException | InvalidAlgorithmParameterException e) {
      throw new RuntimeException(e);
      }
      }


      This is the method we use to encrypt data:



       public static String encrypt(String alias, String plaintext) {
      try {

      KeyStore ks = KeyStore
      .getInstance(SecurityConstants.KEYSTORE_PROVIDER_ANDROID_KEYSTORE);
      ks.load(null);


      //PrivateKey privateKey = (PrivateKey) keyStore.getKey("alias", null);
      PublicKey publicKey = ks.getCertificate(alias).getPublicKey();


      //PublicKey publicKey = getPrivateKeyEntry(alias).getCertificate().getPublicKey();
      Cipher cipher = getCipher();
      cipher.init(Cipher.ENCRYPT_MODE, publicKey);
      return Base64.encodeToString(cipher.doFinal(plaintext.getBytes()), Base64.NO_WRAP);
      } catch (NullPointerException ex){
      Logs.logException(ex);
      throw ex;
      }
      catch (Exception e) {
      Logs.logException(e);
      throw new RuntimeException(e);
      }
      }


      And this is the method to decrypt data:



      public static String decrypt(String alias, String ciphertext) throws IllegalBlockSizeException {
      try {

      KeyStore ks = KeyStore
      .getInstance(SecurityConstants.KEYSTORE_PROVIDER_ANDROID_KEYSTORE);
      ks.load(null);


      PrivateKey privateKey = (PrivateKey) ks.getKey(alias, null);


      //PrivateKey privateKey = getPrivateKeyEntry(alias).getPrivateKey();
      Cipher cipher = getCipher();
      cipher.init(Cipher.DECRYPT_MODE, privateKey);
      return new String(cipher.doFinal(Base64.decode(ciphertext, Base64.NO_WRAP)));
      }catch (IllegalBlockSizeException ex){
      throw ex;
      } catch (Exception e) {
      throw new RuntimeException(e);
      }
      }


      The error is being launched while decrypting, just while doing cipher.init.



      Our cypher is created like this:



      private static Cipher getCipher() throws NoSuchPaddingException, NoSuchAlgorithmException {
      return Cipher.getInstance(
      String.format("%s/%s/%s",
      "RSA",
      "NoPadding",
      "BLOCKING_MODE"));
      }









      share|improve this question














      I'm having an error while decrypting data using the keystore on about 1% of my users (in different API versions and device models). The crash log is:



      Caused by java.lang.RuntimeException: java.security.InvalidKeyException: Keystore operation failed
      at es.xxxx.yyyy.utils.KeyStoreHelperManager.decrypt(KeyStoreHelperManager.java:256)
      at es.xxxx.yyyy.activities.MainActivity.checkKeyStoreCorrecto(MainActivity.java:308)
      at es.xxxx.yyyy.activities.MainActivity.configurarLayout(MainActivity.java:294)
      at es.xxxx.yyyy.activities.MainActivity.onCreate(MainActivity.java:84)
      at android.app.Activity.performCreate(Activity.java:7144)
      at android.app.Activity.performCreate(Activity.java:7135)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
      at android.os.Handler.dispatchMessage(Handler.java:106)
      at android.os.Looper.loop(Looper.java:193)
      at android.app.ActivityThread.main(ActivityThread.java:6680)
      at java.lang.reflect.Method.invoke(Method.java)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

      Caused by java.security.InvalidKeyException: Keystore operation failed
      at android.security.KeyStore.getInvalidKeyException(KeyStore.java:901)
      at android.security.KeyStore.getInvalidKeyException(KeyStore.java:926)
      at android.security.keystore.KeyStoreCryptoOperationUtils.getInvalidKeyExceptionForInit(KeyStoreCryptoOperationUtils.java:54)
      at android.security.keystore.KeyStoreCryptoOperationUtils.getExceptionForCipherInit(KeyStoreCryptoOperationUtils.java:89)
      at android.security.keystore.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:265)
      at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineInit(AndroidKeyStoreCipherSpiBase.java:109)
      at javax.crypto.Cipher.tryTransformWithProvider(Cipher.java:2984)
      at javax.crypto.Cipher.tryCombinations(Cipher.java:2891)
      at javax.crypto.Cipher$SpiAndProviderUpdater.updateAndGetSpiAndProvider(Cipher.java:2796)
      at javax.crypto.Cipher.chooseProvider(Cipher.java:773)
      at javax.crypto.Cipher.init(Cipher.java:1143)
      at javax.crypto.Cipher.init(Cipher.java:1084)
      at es.xxxx.yyyy.utils.KeyStoreHelperManager.decrypt(KeyStoreHelperManager.java:251)
      at es.xxxx.yyyy.activities.MainActivity.checkKeyStoreCorrecto(MainActivity.java:308)
      at es.xxxx.yyyy.activities.MainActivity.configurarLayout(MainActivity.java:294)
      at es.xxxx.yyyy.activities.MainActivity.onCreate(MainActivity.java:84)
      at android.app.Activity.performCreate(Activity.java:7144)
      at android.app.Activity.performCreate(Activity.java:7135)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
      at android.os.Handler.dispatchMessage(Handler.java:106)
      at android.os.Looper.loop(Looper.java:193)
      at android.app.ActivityThread.main(ActivityThread.java:6680)
      at java.lang.reflect.Method.invoke(Method.java)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

      Caused by android.security.KeyStoreException: Unsupported digest
      at android.security.KeyStore.getKeyStoreException(KeyStore.java:839)
      at android.security.KeyStore.getInvalidKeyException(KeyStore.java:926)
      at android.security.keystore.KeyStoreCryptoOperationUtils.getInvalidKeyExceptionForInit(KeyStoreCryptoOperationUtils.java:54)
      at android.security.keystore.KeyStoreCryptoOperationUtils.getExceptionForCipherInit(KeyStoreCryptoOperationUtils.java:89)
      at android.security.keystore.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:265)
      at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineInit(AndroidKeyStoreCipherSpiBase.java:109)
      at javax.crypto.Cipher.tryTransformWithProvider(Cipher.java:2984)
      at javax.crypto.Cipher.tryCombinations(Cipher.java:2891)
      at javax.crypto.Cipher$SpiAndProviderUpdater.updateAndGetSpiAndProvider(Cipher.java:2796)
      at javax.crypto.Cipher.chooseProvider(Cipher.java:773)
      at javax.crypto.Cipher.init(Cipher.java:1143)
      at javax.crypto.Cipher.init(Cipher.java:1084)
      at es.xxxx.yyyy.utils.KeyStoreHelperManager.decrypt(KeyStoreHelperManager.java:251)
      at es.xxxx.yyyy.activities.MainActivity.checkKeyStoreCorrecto(MainActivity.java:308)
      at es.xxxx.yyyy.activities.MainActivity.configurarLayout(MainActivity.java:294)
      at es.xxxx.yyyy.activities.MainActivity.onCreate(MainActivity.java:84)
      at android.app.Activity.performCreate(Activity.java:7144)
      at android.app.Activity.performCreate(Activity.java:7135)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2894)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
      at android.os.Handler.dispatchMessage(Handler.java:106)
      at android.os.Looper.loop(Looper.java:193)
      at android.app.ActivityThread.main(ActivityThread.java:6680)
      at java.lang.reflect.Method.invoke(Method.java)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

      #0. Crashed: main
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2914)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3049)
      at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1809)
      at android.os.Handler.dispatchMessage(Handler.java:106)
      at android.os.Looper.loop(Looper.java:193)
      at android.app.ActivityThread.main(ActivityThread.java:6680)
      at java.lang.reflect.Method.invoke(Method.java)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)


      This is the way we create the KeyPair:



      @TargetApi(Build.VERSION_CODES.M)
      static void createKeysM(String alias, boolean requireAuth) {
      try {
      KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(
      KeyProperties.KEY_ALGORITHM_RSA, SecurityConstants.KEYSTORE_PROVIDER_ANDROID_KEYSTORE);
      keyPairGenerator.initialize(
      new KeyGenParameterSpec.Builder(
      alias,
      KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT)
      .setAlgorithmParameterSpec(new RSAKeyGenParameterSpec(1024, F4))
      .setBlockModes(KeyProperties.BLOCK_MODE_CBC)
      .setRandomizedEncryptionRequired(false)
      .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
      .setDigests(KeyProperties.DIGEST_SHA256,
      KeyProperties.DIGEST_SHA384,
      KeyProperties.DIGEST_SHA512)
      // Only permit the private key to be used if the user authenticated
      // within the last five minutes.
      .setUserAuthenticationRequired(requireAuth)
      .build());
      KeyPair keyPair = keyPairGenerator.generateKeyPair();
      Log.d(TAG, "Public Key is: " + keyPair.getPublic().toString());

      } catch (NoSuchProviderException | NoSuchAlgorithmException | InvalidAlgorithmParameterException e) {
      throw new RuntimeException(e);
      }
      }


      This is the method we use to encrypt data:



       public static String encrypt(String alias, String plaintext) {
      try {

      KeyStore ks = KeyStore
      .getInstance(SecurityConstants.KEYSTORE_PROVIDER_ANDROID_KEYSTORE);
      ks.load(null);


      //PrivateKey privateKey = (PrivateKey) keyStore.getKey("alias", null);
      PublicKey publicKey = ks.getCertificate(alias).getPublicKey();


      //PublicKey publicKey = getPrivateKeyEntry(alias).getCertificate().getPublicKey();
      Cipher cipher = getCipher();
      cipher.init(Cipher.ENCRYPT_MODE, publicKey);
      return Base64.encodeToString(cipher.doFinal(plaintext.getBytes()), Base64.NO_WRAP);
      } catch (NullPointerException ex){
      Logs.logException(ex);
      throw ex;
      }
      catch (Exception e) {
      Logs.logException(e);
      throw new RuntimeException(e);
      }
      }


      And this is the method to decrypt data:



      public static String decrypt(String alias, String ciphertext) throws IllegalBlockSizeException {
      try {

      KeyStore ks = KeyStore
      .getInstance(SecurityConstants.KEYSTORE_PROVIDER_ANDROID_KEYSTORE);
      ks.load(null);


      PrivateKey privateKey = (PrivateKey) ks.getKey(alias, null);


      //PrivateKey privateKey = getPrivateKeyEntry(alias).getPrivateKey();
      Cipher cipher = getCipher();
      cipher.init(Cipher.DECRYPT_MODE, privateKey);
      return new String(cipher.doFinal(Base64.decode(ciphertext, Base64.NO_WRAP)));
      }catch (IllegalBlockSizeException ex){
      throw ex;
      } catch (Exception e) {
      throw new RuntimeException(e);
      }
      }


      The error is being launched while decrypting, just while doing cipher.init.



      Our cypher is created like this:



      private static Cipher getCipher() throws NoSuchPaddingException, NoSuchAlgorithmException {
      return Cipher.getInstance(
      String.format("%s/%s/%s",
      "RSA",
      "NoPadding",
      "BLOCKING_MODE"));
      }






      android encryption keystore






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 8:42









      pozuelogpozuelog

      1,074922




      1,074922
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408149%2fandroid-keystore-operation-failed-unsupported-digest%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408149%2fandroid-keystore-operation-failed-unsupported-digest%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          If I really need a card on my start hand, how many mulligans make sense? [duplicate]

          Alcedinidae

          Can an atomic nucleus contain both particles and antiparticles? [duplicate]