{"record":{"id":"9447680f0404e4d6","repo":"MuntashirAkon/AppManager","slug":"keystore-file-verification-failed-nfile-file-nfound-checksum","errorCode":null,"errorMessage":"KeyStore file verification failed.\\nFile: ${file}\\nFound: ${checksum}\\nRequired: ${mChecksum.get(file.getName())}","messagePattern":"KeyStore file verification failed\\.\\\\nFile: (.+?)\\\\nFound: (.+?)\\\\nRequired: (.+?)","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java","lineNumber":429,"sourceCode":"    private void restoreKeyStore() throws BackupException {\n        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {\n            // keystore v2 is not supported.\n            Log.w(TAG, \"Ignoring KeyStore backups for %s\", mPackageName);\n            return;\n        }\n        if (mPackageInfo == null) {\n            throw new BackupException(\"KeyStore restore is requested but the app isn't installed.\");\n        }\n        Path[] keyStoreFiles = mBackupItem.getKeyStoreFiles();\n        if (keyStoreFiles.length == 0) {\n            throw new BackupException(\"KeyStore files should've existed but they didn't\");\n        }\n        if (!mRequestedFlags.skipSignatureCheck()) {\n            String checksum;\n            for (Path file : keyStoreFiles) {\n                checksum = DigestUtils.getHexDigest(mBackupInfo.checksumAlgo, file);\n                if (!checksum.equals(mChecksum.get(file.getName()))) {\n                    throw new BackupException(\"KeyStore file verification failed.\" +\n                            \"\\nFile: \" + file +\n                            \"\\nFound: \" + checksum +\n                            \"\\nRequired: \" + mChecksum.get(file.getName()));\n                }\n            }\n        }\n        // Decrypt sources\n        try {\n            keyStoreFiles = mBackupItem.decrypt(keyStoreFiles);\n        } catch (IOException e) {\n            throw new BackupException(\"Failed to decrypt \" + Arrays.toString(keyStoreFiles), e);\n        }\n        // Restore KeyStore files to the /data/misc/keystore folder\n        Path keyStorePath = KeyStoreUtils.getKeyStorePath(mUserId);\n        // Note down UID/GID\n        UidGidPair uidGidPair;\n        int mode;\n        try {","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java#L411-L447","documentation":"Before restoring, each keystore file's checksum is recomputed with the backup's checksum algorithm and compared against the checksums recorded at backup time. This error means a keystore file failed checksum verification — its content differs from what was backed up (corruption or tampering). Restore is aborted to avoid installing wrong keystore material.","triggerScenarios":"DigestUtils.getHexDigest(mBackupInfo.checksumAlgo, file) does not equal mChecksum.get(file.getName()) for some keystore file; occurs when checksum verification is enabled (skipSignatureCheck is false).","commonSituations":"Files corrupted during transfer (USB copy, cloud sync truncation); checksum file from a different backup version; wrong checksumAlgo metadata; editing/renaming backup files manually.","solutions":["Re-transfer the backup and retry — corruption during copy is the usual cause.","Verify the checksums file and checksumAlgo match the backup; re-create the backup if mismatched.","Skip signature check only if you accept the risk (mRequestedFlags.skipSignatureCheck()).","Compare found vs required checksums in the message to identify which file is bad and replace just that file."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"String found = DigestUtils.getHexDigest(algo, file);\nif (!found.equals(expectedChecksums.get(file.getName()))) rejectFile(file, found, expectedChecksums.get(file.getName()));","typeGuard":null,"tryCatchPattern":"for (Path file : keyStoreFiles) { if (!checksum.equals(mChecksum.get(file.getName()))) throw new BackupException(\"KeyStore file verification failed...\" ); } // catch per-file to report which file mismatched","preventionTips":["Verify checksums immediately after transferring a backup","Keep the checksum file and checksumAlgo metadata together with the data files","Never manually edit or rename files inside a backup","Use checksumming transfer tools (rsync -c, checksums after copy)"],"tags":["android","keystore","integrity","checksum"],"backgroundTag":"checksum-mismatch","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"}