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)

1
  • 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
    Commented Dec 19, 2015 at 8:14

1 Answer 1

3

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.

2
  • 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
    Commented Dec 19, 2015 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
    Commented Dec 20, 2015 at 14:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .