MuntashirAkon/AppManager · error · CryptoException
No KeyPair with alias ${ECC_KEY_ALIAS}
Error message
No KeyPair with alias ${ECC_KEY_ALIAS} What it means
ECCCrypto.decryptAesKey looks up the ECC key pair (alias ECC_KEY_ALIAS) via KeyStoreManager to unwrap the AES key. If no such KeyPair exists in the keystore, it throws CryptoException with the alias name, so decryption cannot proceed.
Source
Thrown at app/src/main/java/io/github/muntashirakon/AppManager/crypto/ECCCrypto.java:59
return super.getEncryptedAesKey();
}
@NonNull
static SecretKey generateAesKey() {
SecureRandom random = new SecureRandom();
byte[] key = new byte[AES_KEY_SIZE_BITS/8];
random.nextBytes(key);
return new SecretKeySpec(key, "AES");
}
@NonNull
static SecretKey decryptAesKey(@NonNull byte[] encryptedAesKey) throws CryptoException {
KeyPair keyPair;
try {
KeyStoreManager keyStoreManager = KeyStoreManager.getInstance();
keyPair = keyStoreManager.getKeyPair(ECC_KEY_ALIAS);
if (keyPair == null) {
throw new CryptoException("No KeyPair with alias " + ECC_KEY_ALIAS);
}
} catch (Exception e) {
throw new CryptoException(e);
}
try {
Cipher cipher = Cipher.getInstance(ECC_CIPHER_TYPE, new BouncyCastleProvider());
cipher.init(Cipher.DECRYPT_MODE, keyPair.getPrivateKey());
return new SecretKeySpec(cipher.doFinal(encryptedAesKey), "AES");
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | BadPaddingException
| IllegalBlockSizeException e) {
throw new CryptoException(e);
}
}
@NonNull
static byte[] encryptAesKey(@NonNull SecretKey key) throws CryptoException {
KeyPair keyPair;
try {View on GitHub (pinned to 0152f468fc)
Solutions
- Generate the ECC key pair (generateKeyPair / KeyStoreManager for ECC_KEY_ALIAS) on this device before decrypting
- Use the same device/app install that originally encrypted the data — keystore keys are non-exportable
- If keys are unrecoverable, the data cannot be decrypted; restore from an alternative source
Example fix
// before
SecretKey key = ECCCrypto.decryptAesKey(encryptedKey); // no keypair yet
// after
if (KeyStoreManager.getInstance().getKeyPair(ECC_KEY_ALIAS) == null) {
KeyStoreManager.getInstance().generateKeyPair(ECC_KEY_ALIAS); // or refuse to decrypt
}
SecretKey key = ECCCrypto.decryptAesKey(encryptedKey); Defensive patterns
Strategy: try-catch
Validate before calling
KeyPair kp = KeyStoreManager.getInstance().getKeyPair(ECC_KEY_ALIAS);
if (kp == null) {
// generate or refuse to decrypt
throw new IllegalStateException("ECC key pair missing; data from this install cannot be decrypted");
} Try / catch
try {
SecretKey key = ECCCrypto.decryptAesKey(encryptedKey);
} catch (CryptoException e) {
if (e.getMessage() != null && e.getMessage().contains("No KeyPair")) {
// inform user the keystore key is unavailable on this device
}
} Prevention
- Generate ECC keys at app first-run, before any encryption
- Never expect keystore keys to survive app data clear or device migration
- Check key existence before offering decryption features
When it happens
Trigger: Calling decryptAesKey (or decrypt through AESCrypto in ECC mode) when no KeyPair is stored under ECC_KEY_ALIAS, or KeyStoreManager.getKeyPair throws and is wrapped into CryptoException.
Common situations: Decrypting files on a device/installation where the ECC keys were never generated; app data cleared or device migration losing keystore keys; hardware keystore keys unrecoverable after OS update or backup restore to a new device.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- No SecretKey with alias ${AES_KEY_ALIAS}
- No KeyPair with alias ${RSA_KEY_ALIAS}
- No KeyPair with alias RSA_KEY_ALIAS
- Alias app_manager does not exist in KeyStore.
- Failed to setup metadata.
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/55cf2b0fb2f57751.
Report an issue: GitHub.