3

It's almost 2016 and javascript encryption libraries have been around for a while. My question is, have they improved? Or should we still abandon the idea of having encryption done in our browsers?

Would it be safe to use something like OpenPGP.js to generate keys, encrypt the private key with some AES javascript library and send them to the server's database.

When the user needs the access to the private key, he requests it from the server and decrypts it (done in browser).

Or should everything be done at the server? (generate keys, encryption & decryption)

  • I've done this in the past. Over a TLS line with pinned certificates I sent the JavaScript needed. I used the API @Xander mentioned. I then generated keys, derived passwords and digested hashes. I also used SRP, a protocol with included private key exchange resulting in using TLS as the main layer of security, a shared secret as a second layer and the finally symmetrically encrypted data as the third. Data that was encrypted with a key derived from the derived password. Bottom line is, you can do it. Don't rely on it. Audit and test it thoroughly. – Alex Dec 19 '15 at 8:14
4

The problem with JavaScript crypto is not that it hasn't been around long enough to be vetted, it's that it is too easy to tamper with. That doesn't mean that we should give up on crypto in the browser though. It just needs to be built into the browser, so that it can't be subverted as easily. This is problem theWeb Cryptography API is designed to solve. We're not there yet, but this is the direction that we're moving towards to solve the problem eventually.

  • I've used the API before. It's not as streamlined or fully-fledged as it could be, but it does what it needs to do. As I can't vouch for its security, it does work. As for today I don't think that anything should rely on client side encryption in the browser (the support is not wide enough nor is it mature enough). – Alex Dec 19 '15 at 8:06
  • So, for now it's better to leave crypto for the server to handle? Such as encryption, decryption, key generation ect.? – Grimmjow Dec 20 '15 at 14:53

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.