How to build this encryption system that allows multiple users/objects.
- by Patrick
Hello!
I am trying to figure out how to create an optimal solution for my project. I made this simple picture in Photoshop to try to illustrate the problem and how i want it (if possible).
Illustrative image
Ill also try to explain it based on the picture.
First off we have a couple of objects to the left, these objects all get encrypted with their own encryption key (EKey on the picture) and then stored in the database. On the other side we have different users placed into roles (one user can be in a lot of roles) and the roles are associated with different objects. So one person only has access the to the objects that the role provides. So for instance Role A might have access to Object A and B. Role B have access only to Object C and Role C have access to all objects.
Nothing strange in that, right? Different roles have different objects that they can access.
Now to the problem part.
Each user has to login with his/her username/password and then he/she gets access to the objects that his/her roles provide. All the objects are encrypted so she needs to get a decryption key somehow. I don't want to store the encryption key as a text string on the server. It should be, if possible, decrypted using the users password (along with the role) or similar. That way you have to be a user on the server in order to decrypt an object an to work with it.
I was thinking about making a public/private key encryption system, but i am kinda stuck on how to give the different users the decryption key to the objects. Since i need to be able to move users to and from roles, add new users, add new roles and create/delete objects.
There will be one administrator that then adds some data to allow the users in that role to get the decryption key to decrypt the object.
Nothing is static and i am trying to get a picture of how this can be built or if there is a far better solution.
The only criteria are:
-Encrypted objects.
-Decryption key should not be stored as text.
-Different users have access to different objects.
-Does NOT have to have roles.