Choosing safe encryption for mobile applications
Encryption needs an appropriate algorithm, mode and key lifecycle to protect the intended data. Understanding safe encryption for mobile applications helps establish which security property the feature needs and where that property is actually enforced.
What does this involve?
Cryptographic protection depends on the whole operation: the algorithm, its parameters, key handling and the way results are verified. Different mechanisms provide confidentiality, integrity or evidence of origin. Substituting one property for another can leave the important business requirement unprotected.
To test for the use of broken encryption algorithms in Android apps, we need to focus on methods from cryptographic frameworks and libraries that are used to perform encryption and decryption operations.
To test for the use of broken encryption modes in Android apps, we should focus on methods in cryptographic frameworks and libraries used to configure and apply encryption modes.
Why it matters
Consider a realistic failure: repeated message patterns remain visible despite an application's claim that its records are encrypted.
A weakness can undermine trust in stored records or messages even when their appearance does not change. Assessment should connect the defect to the data or action it protects and the capabilities available to an attacker.
Mobile behaviour can change between a fresh installation, an authenticated session, background activity and a device migration. The assessment needs the actual release and representative supported device states.
How penetration testers check for it
Inspect algorithm choices, authenticated encryption and how nonces are generated.
- Cipher.getInstance: Initializes a Cipher object for encryption or decryption. The algorithm parameter can be one of the supported algorithms.
- SecretKeyFactory.getInstance: Returns a SecretKeyFactory object that converts keys into key specifications and vice versa. The algorithm parameter can be one of the supported algorithms.
- KeyGenerator.getInstance: Returns a KeyGenerator object that generates secret keys for symmetric algorithms. The algorithm parameter can be one of the supported algorithms.
- Cipher.init(int opmode, Key key, AlgorithmParameters params) where opmode is one of.
- Trace key generation, access, replacement and verification.
- Test invalid inputs and failure handling with controlled data.
How to fix it
Use maintained cryptographic libraries and authenticated modes with correctly managed keys and nonces.
- Use maintained standard implementations and appropriate parameters.
- Protect keys throughout generation, use and retirement.
- Authenticate the content and identity that the operation actually relies on.
- Reject failed verification before trusting or processing the result.
An unusual cryptographic implementation is not enough to establish practical compromise. The report should explain the failed property and a defensible consequence.
Recheck the changed behaviour against the original failure conditions and the legitimate user journey. Keep enough evidence to show which release and configuration were verified, and include related entry points that depend on the same security decision.
Related issues
- Generating strong mobile encryption keys
- Deriving mobile encryption keys safely
- When application-layer payload encryption benefits mobile apps
Read about our methodology or contact pentested.com to discuss your mobile applications.