Lets say that on an Android app the user has to enter a 6-digit PIN on startup. Let's also say that we have some sensitive data in this application that we'd like to encrypt.
The way I would to this is:
- Using a key derivation function (e.g. PBKDF2) we generate a key from the PIN.
- Encrypt the sensitive data with AES using the key (and a decent config like CBC+padding).
- Store encrypted data wherever, e.g. in shared preferences.
The main issue I see here: the original PIN space for a 6-digit PIN is 10^6, which is laughably small to use as the basis of your encryption...
Can we actually fine tune this so the stored data is reasonably secure for a while?
Even if we tune our KDF such that a simple derivation takes 1 second (I don't think we can expect our users to wait much longer during app start), then going through 1'000'000 of them takes merely 11.5 days (assuming same processing power as the phone, which isn't likely...).
Obviously using a longer/stronger PIN would help - but regretfully even just a 6-digit PIN is seen as a hurdle by users, so this isn't likely an option. Also the KDF strength is limited by the amount of time we can expect the users to wait during app start, which I'd say is in the order of magnitude of 1 second.