shadowsocks / shadowsocks-chromeapp

Chrome client for shadowsocks
696 stars 541 forks source link

Use WebCrypto API for HMAC-SHA1 #15

Open librehat opened 8 years ago

librehat commented 8 years ago

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

nekolab commented 8 years ago

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.

librehat commented 8 years ago

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

nekolab commented 8 years ago

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

librehat commented 8 years ago

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

nekolab commented 8 years ago

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

librehat commented 8 years ago

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

I'm very new to JavaScript...