1

What is best practice for the encryption of offline application data?

I have an application where multiple users can log in. The user gets data from an internet API, where the user authenticates. I want to store some of the data, for example, a list of events (name, location, etc.) offline in a database for access with no internet connection.

My plan is to use a key generated from a PBKDF2-algorithm with the users password and store the database in the app directory identifiable by the username. I'm not storing the password, just the username as the database name for checking during login, if the login data is available at all. I will delete the data and store the new updated data when there is internet access and the user logs in again.

Is this approach dangerous, because attackers can brute force the user password on these databases? Are there any security vulnerabilities or weaknesses that I'm missing out on?

Implementation notes: The programming language is Dart (in combination with the flutter framework) and the platforms are iOS and Android. The database will be a hive, which uses AES-256 encryption.

1

1 Answer 1

0

Use secure enclave for iOS or similar hardware-backed keystore for Android to store the encryption key.

Even if an attacker gets access to the device RAM or disk storage, it is impossible to extract such keys/secrets.

If the attacker obtains the encrypted data, the only way to decrypt them is brute-forcing, which, with proper encryption algorithm and password, is impossible.

10
  • A nitpick: bruteforcing the data is near-impossible in the current time, don't get too caught up by the Zeitgeist ;-) In the not so far future the encrypted data might get easily decrypted using Quantum Computers or something similar. Jun 1 at 19:29
  • 1
    @SirMuffington: A nitpick for nitpick: Quantum computers can potentially break RSA and ECC only, not symmetric algorithms. That's why AES is post-quantum resistant 😉 To be precise, for the same strength in the quantum case, you need keys twice longer than in the pre-quant case. To get 128 bit security, you need 256 bits key. The reason for this see here: "The best quantum attack against generic symmetric-key systems ... requires work proportional to the square root of the size of the key space".
    – mentallurg
    Jun 1 at 21:01
  • Isn't it only in case of Shor's algorithm? Or is it valid in general? I mean what if a more efficient algorithm comes out Jun 2 at 16:36
  • 1
    Grover's search on unstructured data set is proven to be optimal asymptotically. As a result block ciphers and hash functions with enough keys and output sizes are safe against Grover's quantum search. Shor's algorithm, on the other hand, is a period finding algorithm that exploited the periodic structures of RSA and discrete logs. This is why there is no post-quantum symmetric cipher and hash function competition on the NIST post-quantum, however, there are public key system encryption and digital signature algorithm..
    – kelalaka
    Jun 3 at 7:29
  • 1
    @kelalaka: According to Apple: "Can’t import preexisting keys. You must create keys directly inside the Secure Enclave. Not having a mechanism to transfer key data into or out of the Secure Enclave is fundamental to its security."
    – mentallurg
    Jun 3 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.