I'm working on a project which requires encryption of sensitive data, with communication of said data between a mobile app and a website (via an API).

I'm new to encryption and security, but my current thoughts are this:

  • Data will always be input into the app and viewed via the website, so only users of the website will need a public and private key as only they need to view the information (could use hybrid, but messages will be short)
  • Encrypt the data server-side using the public key of the correct user authorised to view the information
  • The encrypted data will be stored in the database
  • Keys will be stored on the server (not sure how this works in terms of access controls)

It is important that other users of the website are only able to see the data they are authorised to view, hence the public and private key cryptography. Obviously, querying the database here could prove difficult, but I think the use of IDs and other non-identifiable information would make it easier.

Is this a realistic idea or completely wrong in terms of how encryption works?


closed as too broad by Squeamish Ossifrage, Maeher, Maarten Bodewes Mar 16 at 1:03

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Well, public-key cryptosystems can be used in a solution for this, but the whole system will be quite a bit more complex - and security has to be considered for the entire system and not a single part of it. $\endgroup$ – tylo Nov 4 '16 at 16:08
  • $\begingroup$ @tylo of course, access controls, authentication and authorisation, password hashing etc will all be considered too, I was mainly singling out the encryption section as that's what I'm not sure about $\endgroup$ – Vanita Nov 4 '16 at 16:10
  • $\begingroup$ Access control (the other keywords belong to that pretty much) is of course an important topic as well, and that should be considered separately, you're right about that. But there are other questions, which are quite relevant what the best solution is. For example, do you have a PKI? Do you have proper key management in the mobile devices? Quite a lot of it also depends on what kind of library / tool you're using. And then there more questions, e.g. should the server be able to read the messages or not? Do you need non-repudiation? $\endgroup$ – tylo Nov 4 '16 at 16:53
  • $\begingroup$ As I said, I'm a beginner to encryption so I'm not sure about PKI or key management. If only users of the website need a public and private key generated for them, users of the mobile app just need access to the public key of the user they need to send the message to? Sorry, I'm completely new to this and I'm not sure how key management works in practice. $\endgroup$ – Vanita Nov 4 '16 at 16:57
  • 1
    $\begingroup$ Websites and keys for users don't go along very well - and in TLS usually only the server has them. Reasons are, that key management is tricky and there is no global trustworthy PKI. But in order to avoid this becoming a discussion, I am inclined to say that your question would actually be better suited over at security-SE, because it's about the usage of cryptography. $\endgroup$ – tylo Nov 4 '16 at 17:18