5 ms·
Don’t use it, just use WebCrypto API.
by dchest 6y ago
Don’t use it, just use WebCrypto API.
- BiteCode_dev 6y agoIt's way lower level, and easier to missuse.
- henriquez 6y agoThe only low-level thing I noticed about the native Web Crypto APIs is its reliance on typed arrays. The speed difference is night and day as the native stuff can be hardware-accelerated by dedicated CPU instructions. Browser support is very good: https://caniuse.com/#feat=cryptography https://caniuse.com/#feat=cryptography Documentation is also very good: https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypt... In terms of "ease of misuse" it's debatable. One of the biggest default security improvements with Web Crypto is that *cryption keys are _not readable by JS_ once instantiated - they can only be used by the cryptographic functions (unless you explicitly make them exportable). This is a subtle but very important defense against certain drive-by attacks that could dump loaded keys from whatever non-native JS crypto library you might be using. In general I don't think it's safe to be using crypto at all outside of basic stuff like password hashing if you don't have a basic understanding of concepts like salt lengths, block cipher modes, hasher output sizes, etc. so I don't really agree with the "easier to misuse" statement. Some library that holds your hand more isn't going to significantly make things safer.
- codysc 6y agoI agree that Web Crypto has a lot to offer. I use it in my latest project. In terms of it being easy to misuse, I think that applies to cryptography in general, but there are some gotchas lingering in javascript. Self blog promoting. I just put this out a few days ago on this very subject. https://pritact.com/blog/posts/crypto-mistakes-part-1.html https://pritact.com/blog/posts/crypto-mistakes-part-1.html
- memexy 6y ago> One of the biggest default security improvements with Web Crypto is that *cryption keys are _not readable by JS_ once instantiated - they can only be used by the cryptographic functions (unless you explicitly make them exportable). This is a subtle but very important defense against certain drive-by attacks that could dump loaded keys from whatever non-native JS crypto library you might be using. That's a really nice feature. This should be better advertised. I wasn't aware that Web Crypto was even a thing.
- codysc 6y agoYes, that kinda HSMish model of non-extractable keys is a very nice touch. I really wish they would add Argon2 though. PBKDF2 is still a valid choice but there are a lot of HW optimized solvers out there for it.
- d0m 6y agonot available in all js runtime