encryb / simplecrypto

Simple wrapper around WebCrypto implementations
Apache License 2.0
21 stars 4 forks source link

Question: PBKDF2 in Earlier Safari? #1

Open kuza55 opened 9 years ago

kuza55 commented 9 years ago

I ran into this project while trying to figure out what the best way of doing pbkdf2 on safari was since the chrome code I had tried to use obviously failed.

I'm just wondering if the pbkdf2 parts will work in earlier versions of safari, and whether you know how far back it would work?

encryb commented 9 years ago

As far as I know, no version of Safari 7 supports any of the WebCrypto bits. A pure javascript library like SJCL would be your only option. Safari 8+ has support for HMAC, so you can implement a relatively fast PBKDF2 (about 5 or so times slower than native) relatively easily. (code for this is in simplecrypto)

WebKit bug for full PBKDF2 support is at https://bugs.webkit.org/show_bug.cgi?id=143458

kuza55 commented 9 years ago

Safari 7 has window.crypto.webkitSubtle, but its pretty hard to tell what it actually supports.

I managed to get it to do native sha1 digests and import AES-CBC keys, but it did not want to generate or load SHA-1 HMAC keys for me, but it's hard to tell if I'm just doing it wrong or if there's really no way.

encryb commented 9 years ago

I would try getting generate or importKey working in Safari 8 first. If both Safari 7 and 8 don't work, link me the piece of code you are using and I'll check it out.

If it works in Safari 8, but not in Safari 7, you should check the webkit unit test history @ https://github.com/WebKit/webkit/tree/master/LayoutTests/crypto/subtle . I don't know what version of webkit Apple is using in Safari 7 these days, but the tests for all version should be there.

Keep in mind that you might go crazy, since Apple is using older draft on WebCrypto, nothing really works as it should and there is no decent documentation.