0

I want to make a web service where we can Login in this system with username and password. After the user select a file from his computer and send this file on server. I want encrypt this file to a group of users (I want use ABE cryptography). Now what are the steps to make them ?

My idea is: Login to the system with basic username and password. I store the username and password to my database in a table.

After with ABE cryptography where can I save the Master Private Key and the Master Public Key ? In my database ?

After login, the system make a secret key of the user. I save my secret key in my database. After I use the Master Public Key to encrypt the file (I recovery it from a SQL query) and upload it on my server and when I recover the file, I decrypt it with my secret key (I recover it with SQL query).

Is this approch correct ? Is there an approch more correctly ?

  • Any compromise of the database in this case will result in a full compromise of keys and thus undermine the security of the system as a whole. – Arran Schlosberg Sep 14 '16 at 11:29
  • @Arran Schlosberg, yes you have right. Can you give me hint ? – JLo Sep 14 '16 at 12:03
  • You don't necessarily need to use AWS, but their service will give you details for what else to read about: aws.amazon.com/kms – Arran Schlosberg Sep 14 '16 at 12:05
3

First, your approach for usernames/passwords - it shows that you are a novice to security, which is fine, but means you likely ought not be designing a secure file store. However, here goes with some more constructive feedback :

1) You NEVER store user passwords. Full stop. What you do is store a salted and hashed version of their password. When they attempt to login, salt and hash, compare with the stored hash. From OWASP : https://www.owasp.org/index.php/Password_Storage_Cheat_Sheet

2) There's no reason to use asymmetric encryption here - you can simply encrypt and decrypt from your data store. Store your key (and IV) in a secure location - traditionally, this is a file only accessible to your application on the server, where you ensure your application is running as an isolated user. However, more modern systems for key storage include HSMs (hardware modules, very expensive) or systems like Keywhiz or Hashicorp's Vault - complicated, but cheap. This is better if you want key rotation (good!) and redundancy in application servers.

Seriously, if this is a real application, these are things that need experts beyond random ones on the internet - there are a lot of subtle errors you can make that will devalue all the other security measures you take. You need to do everything right - get some professional help.

0

Is this approch correct ?

Too broad - like asking if its "secure". That should earn a vote to close. But you also asked the question:

where can I save the Master Private Key

(Where you save the public key is not a security concern beyond assuring its availability).

One solution is an HSM, but that only protects the capture of the key - you need additional measures in place to stop the abuse of the key.

Alternatively.... You can't really change the key frequently. But you can put a passphrase on it / encrypt it using an asymmetric algorithm and change that passphrase regularly. And the question of how to store security credentials inside a web application has been raised a lot of times before here:

  • store it at the client, not on server
  • only store it in memory on the server
  • ensure there is privilege seperation between the parts of the application which need to use the key and everything else on the server
  • sorry but I'm not a security expert. If I understand: 1) Store username and password of users in a simple database. 2) Store Master Private Key in a directory server (i.e /root/MprvK.txt) 3) Store Master Public Key in a directory server (i.e /authoritypubkey/MpubK.txt) 4) Store users private key on directory server (i.e /userskey/keyuser1.txt, keyuser2.txt, ..., keyusern.txt) – JLo Sep 14 '16 at 13:49
  • no, you've not understood what I've said. That may partly be my fault, but I think you need to spend some time doing research and, if not become a security expert, at least acquire a greater level of proficiency. – symcbean Sep 14 '16 at 14:07
  • I tried to search. I'm reading a lot of documents, but there is only theory. I want learn now how can I implement these services using technologies (framework, programming languages). Is there a tutorial i.e. to manage key for encrypt/decrypt data(or messages) (clients-->server) in python ? I don't found anything. – JLo Sep 14 '16 at 14:14
0

Based on your questions, you're much better with using some of existing schemes instead of inventing your own. More specifically, you should avoid using things like attribute-based cryptography - it was proposed quite recently, and, although it looks very simple, there are not many textbook-level examples you can follow, and being fooled by method's simplicity, might implement something completely irrelevant.

Apart from this boring grumbling, the functional goal and security guarantees of the system are not described well enough to propose you a solution.

It would be very helpful if you explain which security guarantees and functional expectations. What does the system do with the data, who should see it and regulated based on which requirements should they see it?

What kind of access users have to the system, etc.

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.