I'm currently working on a business Java application, and we store sensitive files related to our users. What is the appropriate approach to store them securely?

Is it viable to encrypt/decrypt all the files in the business logic, and then store them in the filesystem? Then what the key could be? If I derive a key from the file uploader's password, other, authorized people won't be able to decrypt the file.

Or it would be better if we would concentrate on the infrastructure's security, because it is not frequent to encrypt files for a business application?

  • 6
    I'm voting to close this question as off-topic because it's about choosing security controls, not about designing or using cryptography. This is the sort of topic that's perfectly suited to Information Security, so you should ask there. But please include more information, otherwise the question is not answerable. Who is authorized to access the information? How is the server accessible (administrators, local users, web users)? What threats do you want to defend against? – Gilles Oct 21 at 10:14

Or it would be better if we would concentrate on the infrastructure's security, because it is not frequent to encrypt files for a business application?

If an attacker gains access to your server he can just steal, modify or delete all kind of data. This is not a desired consequence to suffer if someone breaks your security. Specially if the sensitive data is in plaintext.

For example, in the case you store files, the attacker can modify them to alter their functionality to install malware in the user's computer.

If I derive a key from the file uploader's password, other, authorized people won't be able to decrypt the file.

In your scheme, every user will have two keys, one for encryption and the other for providing integrity and authentication via MAC. This is done applying a key derivation function to a Master Key. In the case your server get compromised and the user's data gets modified, the legitimate user will notice the modification since tags are not equal.

  • Thanks! What do you exactly mean by a master key? For each and every user? Where should I store it? Or should I derive it from the user’s input password every time? And do you have any solution to share az encrypted file? It’s evident that we can’t share the owner user’s key (password) with others. – mrkflp Oct 21 at 10:08
  • Don't store those key, generate them instead by deriving both from his password every time the user wants to upload data to your server. – kub0x Oct 21 at 10:37

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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