{"record":{"id":"f78da6a3b4717808","repo":"MuntashirAkon/AppManager","slug":"unsupported-mode-mparentmode","errorCode":null,"errorMessage":"Unsupported mode ${mParentMode}","messagePattern":"Unsupported mode (.+?)","errorType":"exception","errorClass":"CryptoException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/crypto/AESCrypto.java","lineNumber":95,"sourceCode":"                    // No encryption key provided, generate one\n                    mSecretKey = RSACrypto.generateAesKey();\n                } else {\n                    // Encryption key provided\n                    mSecretKey = RSACrypto.decryptAesKey(encryptedAesKey);\n                }\n                break;\n            case CryptoUtils.MODE_ECC:\n                // Hybrid encryption using ECC\n                if (encryptedAesKey == null) {\n                    // No encryption key provided, generate one\n                    mSecretKey = ECCCrypto.generateAesKey();\n                } else {\n                    // Encryption key provided\n                    mSecretKey = ECCCrypto.decryptAesKey(encryptedAesKey);\n                }\n                break;\n            default:\n                throw new CryptoException(\"Unsupported mode \" + mParentMode);\n        }\n    }\n\n    public void setMacSizeBits(int macSizeBits) {\n        if (macSizeBits == MAC_SIZE_BITS || macSizeBits == MAC_SIZE_BITS_OLD) {\n            mMacSizeBits = macSizeBits;\n        }\n    }\n\n    @NonNull\n    private AEADParameters getParams() {\n        // We need to generate it dynamically due to MAC size issues\n        return new AEADParameters(new KeyParameter(mSecretKey.getEncoded()), mMacSizeBits, mIv);\n    }\n\n    @CallSuper\n    @NonNull\n    protected byte[] getEncryptedAesKey() throws CryptoException {","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/crypto/AESCrypto.java#L77-L113","documentation":"AESCrypto's constructor throws this CryptoException when invoked with a mode other than the supported CryptoUtils.MODE_AES / MODE_RSA (and EC-related modes handled above) — the default branch of its switch. It is a programming/configuration error: an unrecognized crypto mode constant was passed.","triggerScenarios":"Passing an undefined mode int to the AESCrypto constructor, e.g. CryptoUtils.MODE_GCM, a custom mode constant, or garbage from an unvalidated persisted preference/Intent extra.","commonSituations":"Refactors that add new CryptoUtils modes without updating AESCrypto; stale mode values read from old encrypted session files or SharedPreferences; mixing up CryptoUtils constants across versions.","solutions":["Only pass modes defined and supported by CryptoUtils (MODE_AES, MODE_RSA)","Validate/whitelist the mode before constructing AESCrypto, falling back to MODE_AES","If a new mode was added to CryptoUtils, extend AESCrypto's switch to handle it","Migrate stale persisted mode values to current constants"],"exampleFix":"// before\nAESCrypto crypto = new AESCrypto(someIntMode); // unvalidated\n// after\nif (mode != CryptoUtils.MODE_AES && mode != CryptoUtils.MODE_RSA) {\n    mode = CryptoUtils.MODE_AES; // safe default\n}\nAESCrypto crypto = new AESCrypto(mode);","handlingStrategy":"validation","validationCode":"Set<Integer> supported = new HashSet<>(Arrays.asList(\n        CryptoUtils.MODE_AES, CryptoUtils.MODE_RSA));\nif (!supported.contains(mode)) {\n    throw new IllegalArgumentException(\"Unsupported crypto mode: \" + mode);\n}","typeGuard":"boolean isSupportedCryptoMode(int mode) {\n    return mode == CryptoUtils.MODE_AES || mode == CryptoUtils.MODE_RSA;\n}","tryCatchPattern":"try {\n    crypto = new AESCrypto(mode);\n} catch (CryptoException e) {\n    Log.e(TAG, \"Bad crypto mode \" + mode, e);\n    crypto = new AESCrypto(CryptoUtils.MODE_AES); // safe default\n}","preventionTips":["Whitelist mode constants before constructing","Migrate stale persisted mode values","Extend AESCrypto's switch when CryptoUtils gains modes","Avoid reading mode ints from untrusted inputs"],"tags":["android","crypto","unsupported-mode","configuration"],"backgroundTag":"invalid-enum-value","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"}