{"record":{"id":"284eae9ca9d59303","repo":"MuntashirAkon/AppManager","slug":"could-not-get-crypto","errorCode":null,"errorMessage":"Could not get crypto ","messagePattern":"Could not get crypto ","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java","lineNumber":128,"sourceCode":"        mBackupItem = backupItem;\n        mUserId = userId;\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(\"Failed to get checksums.\", e);\n        }\n        // Verify metadata\n        if (!requestedFlags.skipSignatureCheck()) {\n            try {\n                verifyMetadata();","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java#L110-L146","documentation":"After availability checks pass, RestoreOp calls mBackupItem.setCrypto(mBackupInfo.getCrypto()); a CryptoException is wrapped as BackupException 'Could not get crypto <mode>'. Unlike error 100 this happens on the restore path and the backup item is cleaned up before aborting.","triggerScenarios":"setCrypto initialization fails despite isAvailable passing: wrong password/key derivation failure, corrupted key files, or the crypto backend throwing during setup for the encrypted backup.","commonSituations":"User restored a backup without its paired key/password; encrypted backup transferred without the hidden key directory; ROM update changed key storage semantics.","solutions":["Supply the correct password/key used when the backup was created","Ensure all crypto key files/directories belonging to the backup were copied together with the backup","Inspect the wrapped CryptoException cause to distinguish wrong-key from missing-backend problems","Re-create the backup with a working crypto mode if key material is unrecoverable"],"exampleFix":"// before\ntry {\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// after\ntry {\n    mBackupItem.setCrypto(mBackupInfo.getCrypto());\n} catch (CryptoException e) {\n    mBackupItem.cleanup();\n    throw new BackupException(\"Could not get crypto \" + mBackupInfo.crypto\n            + \": check password/key availability (cause: \" + e.getMessage() + \")\", e);\n}","handlingStrategy":"try-catch","validationCode":"// after isAvailable passes, verify key material exists for the mode before setCrypto\nif (!CryptoUtils.hasKeyMaterial(backupDir, mode)) throw new BackupException(\"Key/password for mode \" + mode + \" not available\");","typeGuard":null,"tryCatchPattern":"try { new RestoreOp(...); } catch (BackupException e) { if (e.getMessage().startsWith(\"Could not get crypto\")) { promptForPassword(); } throw e; }","preventionTips":["Store the backup password in a password manager at backup time","Copy crypto key files together with the rest of the backup","Note the crypto mode used so you can reinstall its provider on new devices"],"tags":["crypto","android","backup","restore"],"backgroundTag":"missing-credentials","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}