asmcrypto / asmcrypto.js

JavaScript Cryptographic Library with performance in mind.
MIT License
659 stars 182 forks source link

Key instanceof Array is failing #109

Closed guerrillalg closed 6 years ago

guerrillalg commented 7 years ago

Eventually, we are trying to use your library in our GWT project and have the following problem: Line https://github.com/vibornoff/asmcrypto.js/blob/master/src/rsa/rsa.js#L17 if ( key instanceof Array ) { Is failing the check and thus, we get an exception constantly. However, we pass a key as an Array. After googling a while, I've found out the following:

This approach will fail if obj was created in a different frame. Array.isArray doesn't have that issue if you can target EcmaScript5.

And indeed, GWT does some work in a different frame. I've put the following code for an expirement: if ( Array.isArray(key) ) { And it did work fine for us. So, the question is if you can use Array.isArray for the checks?

vibornoff commented 7 years ago

Does it compatible with IE10?

guerrillalg commented 7 years ago

Array methods are compatible with all browsers listed in the compatibility table: http://kangax.github.io/compat-table/es5/

vibornoff commented 7 years ago

Thanks, looks legit. But the problem is not only with instanceof Array. Suitable replacement is need also for:

guerrillalg commented 7 years ago

For those methods, I can't say anything. Either they are not used in our case, or they work. We use RSA encryption, SHA512 hashing and HMAC_SHA signing.

What are the system requirements?

vibornoff commented 7 years ago

IE10+, FF22+, Opera12+, Safari5.1+