{"record":{"id":"908aa975462050f3","repo":"MuntashirAkon/AppManager","slug":"could-not-get-crypto-mbackupinfo-crypto","errorCode":null,"errorMessage":"Could not get crypto \" + mBackupInfo.crypto","messagePattern":"Could not get crypto \" \\+ mBackupInfo\\.crypto","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/VerifyOp.java","lineNumber":50,"sourceCode":"    VerifyOp(@NonNull BackupItems.BackupItem backupItem) throws BackupException {\n        mBackupItem = backupItem;\n        try {\n            mBackupInfo = mBackupItem.getInfo();\n            mBackupFlags = mBackupInfo.flags;\n        } catch (IOException e) {\n            mBackupItem.cleanup();\n            throw new BackupException(\"Could not read backup info. Possibly due to a malformed json file.\", e);\n        }\n        // Setup crypto\n        if (!CryptoUtils.isAvailable(mBackupInfo.crypto)) {\n            mBackupItem.cleanup();\n            throw new BackupException(\"Mode \" + mBackupInfo.crypto + \" is currently unavailable.\");\n        }\n        try {\n            mBackupItem.setCrypto(mBackupInfo.getCrypto());\n        } catch (CryptoException e) {\n            mBackupItem.cleanup();\n            throw new BackupException(\"Could not get crypto \" + mBackupInfo.crypto, e);\n        }\n        try {\n            mBackupMetadata = mBackupItem.getMetadata(mBackupInfo).metadata;\n        } catch (IOException e) {\n            mBackupItem.cleanup();\n            throw new BackupException(\"Could not read backup metadata. Possibly due to a malformed json file.\", e);\n        }\n        // Get checksums\n        try {\n            mChecksum = mBackupItem.getChecksum();\n        } catch (Throwable e) {\n            mBackupItem.cleanup();\n            throw new BackupException(\"Could not get checksums.\", e);\n        }\n        // Verify metadata\n        try {\n            verifyMetadata();\n        } catch (BackupException e) {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/VerifyOp.java#L32-L68","documentation":"VerifyOp's constructor calls mBackupItem.setCrypto(mBackupInfo.getCrypto()) to instantiate the crypto handler recorded in backup.json. A CryptoException here means the mode is available in principle but the crypto object could not be constructed — bad key material, wrong password, or provider initialization failure. cleanup() runs and this BackupException wraps the cause.","triggerScenarios":"Verifying a backup whose keystore/PGP key is missing or password-protected without the password being supplied, so CryptoUtils can initialize the Crypto interface instance for mBackupInfo.crypto.","commonSituations":"New device without the original keystore entry, expired/removed PGP key, wrong stored password, or provider (e.g. OpenPGP) installed but not authorized for AppManager.","solutions":["Provide the correct password/key material that matches the backup's encryption.","Re-grant OpenPGP (or other provider) access to AppManager in the provider app.","Import the original keystore key to the device before verifying.","Fall back to a fresh unencrypted backup/verify cycle if the key is unrecoverable."],"exampleFix":"// before: keystore key deleted, getCrypto() throws\n// after: re-import the key or prompt the user for the password first\nString password = promptUserForPassword();\ncrypto = CryptoUtils.getCrypto(mBackupInfo.crypto, password);","handlingStrategy":"try-catch","validationCode":"// Ensure key material exists before verification\nboolean keyPresent = CryptoUtils.isAvailable(backupInfo.crypto)\n        && (keystoreContainsKey(alias) || password != null);","typeGuard":null,"tryCatchPattern":"try {\n    new VerifyOp(backupItem).verify();\n} catch (BackupException e) {\n    if (e.getMessage().startsWith(\"Could not get crypto\")) {\n        // prompt for password / re-import keystore key, then retry\n    }\n}","preventionTips":["Export and safely store the encryption key when creating the backup.","Re-grant provider (OpenPGP) access after app reinstalls.","Do not wipe keystore/credentials on the source device until backups are verified restorable."],"tags":["crypto","keystore","backup-verify","key-missing"],"backgroundTag":"missing-credentials","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}