We have an interesting problem. We have customer that wants to use our web-based application (back-end / DB is with us). However they want to encrypt patient information, so no one in our company can see it. Would there be some kind of javascript solution for this? Or some way use their encryption before it is sent to us?
2 Answers
You can (although, in the security community, this is not seen as a viable solution1, 2) send a javascript crypto library to them, but it would not solve the issue.
Note: I'll assume in this answer that your connection uses SSL/TLS, because without it, you cannot securely communicate with the client.
The problem is that the client needs to trust you. They will download the javascript code from your server. So, the owner of the server will be always be able change how the javascript behaves. This is because, even if you send out a completely valid and well audited javascript crypto library to the client, the client cannot verify this. The only assurance they have is that they got something from a host, which theytheir browser choose to trust, based on the SSL/TLS certificate.
Usually, people start to bring up a malicious Man-in-the-Middle scenario at this point. This concern is mood though: either your connection is properly secured by SSL/TLS, or it is not. If the a Man-in-the-Middle scenario is possible, than the javascript crypto library that the client downloaded from the server is also suspect. In other words, if the SSL/TLS layers would somehow be compromised, the client side crypto should also be considered compromised.
If they trust the host enough, to trust that they do not tamper with the javascripts and indeed perform all the crypto on the client side, than they may as well trust you to not abuse their data on the server side. Which leaves out a lot of the (unneeded) complexity. Less complexity leads to a cleaner setup which is easier to audit.
Disclaimer: If you work with medical data, there is probably quite some laws you need to comply with (depending on your country/state). If you are not comfortable with questions at this level, you should probably either hire some specialists, or accept that this request is more complex than you could comfortably build and kindly inform your customer that they would be better served finding a company that has more experience in working sensitive data.
1 Comment
Well there is a problem. How do you want to implement the en/decryption without knowing how it happens? ;)
Some simplified basic encryption theory: (keep in mind that im also not an expert in this topic)
In todays cryptography we mostly use 2 different kinds of encryptions which are being either symmetric or asymmetric (Wikipedia: Public-key_cryptography), we are focusing on symmetric. You dont need to know how they actually encrypt the data but what you need to know is that its based on a given Key/Password. The difference between them is that symmetric encryption uses 1 key for both, en- and decrypting and asymmetric uses 2 kinds of key but currently thats nothing you need.
So there are many different algorithms for encrypting in one or another way, and knowing which algorithm is being used shouldnt be a problem as long as the used key is strong and random enough so that even a brutefoce of it will last many years.
Based on the used key, the output of the encrypted data will be different so that the string "foo" with the password "bar" is different than the same text (foo) with a different password. And so its not possible to get the value without knowing which key was being used.
I never used crypto-libs in JS so i cant recommend you any, but im sure there are plenty out there which can be used in a few lines. A very good algorithm based on symmetric encryption is AES which also has a lot of implementations out there which are ready to use ;)
So now you just have to add a button on the submit form which asks for the password to encrypt and then a button on the view/whatever page which wants the used password to decrypt the datas. When sending, you can send the encrypted data value next to its not encrypted data keys (not the encryption key!), so you know which value is what.
Here is a site where you can see it in action. Note how the encrypted value is completly different with a small change in the password. You can also find some code there. http://www.movable-type.co.uk/scripts/aes.html
I hope you understood it and that its not too messy. My english is not very good so please excuse my terrible grammer x)