shadowsocks-chromeapp icon indicating copy to clipboard operation
shadowsocks-chromeapp copied to clipboard

Use WebCrypto API for HMAC-SHA1

Open librehat opened this issue 9 years ago • 6 comments

Much faster than JS library and supported well by Chrome.

However, AES-CFB is removed from W3C draft and not supported by Chrome :(

https://www.chromium.org/blink/webcrypto

https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html

librehat avatar Dec 05 '15 18:12 librehat

This one is also in my plan :)

But first we need to unify the data representation, now we use string as forge's buffer and ArrayBuffer as Chrome API's buffer, they are different and the convert between them is expensive.

Maybe use ArrayBuffer at all time is a good choice, because it's native and WebCrypto API also use this. But we need something like StringView to interpret ArrayBuffer as String, this maybe a big change.

nekolab avatar Dec 05 '15 22:12 nekolab

ArrayBuffer should be more efficient. We can replace forge with asmcrypto which claims to be the fastest JS crypto and it accepts both Uint8Array and ArrayBuffer

librehat avatar Dec 05 '15 23:12 librehat

Sounds good~ We may run some tests to confirm this,and we must confirm asmcrypto supports partial block encryption,many js crypto implementation didnt support it

nekolab avatar Dec 06 '15 00:12 nekolab

Looks like we need to wait for awhile. https://github.com/vibornoff/asmcrypto.js/issues/68

librehat avatar Dec 06 '15 08:12 librehat

Or we can patch it by ourselves, like I did to forge, maybe it's not a hard work

nekolab avatar Dec 06 '15 08:12 nekolab

Neither you, nor I have the time for extra work.

I'm very new to JavaScript...

librehat avatar Dec 06 '15 11:12 librehat