kevlened / isomorphic-webcrypto

:game_die: webcrypto library for Node, React Native and IE11+
https://www.w3.org/TR/WebCryptoAPI/
MIT License
116 stars 42 forks source link

Unsupported algorithm error #26

Closed oluomoniyi closed 4 years ago

oluomoniyi commented 4 years ago

Thanks a lot for this package.

I am having issues generating a keyPair in React Native, it worked perfectly in plane JS.

But once I try the following

` const KeyExchangeKeySpec = { name: 'RSA-OAEP', modulusLength: 2048, publicExponent: new Uint8Array([0x01, 0x00, 0x01]), hash: { name: 'SHA-256' } };

generateKeyPair = async = > { const keyPair = await subtle.generateKey(KeyExchangeKeySpec, false, ["encrypt", "decrypt"])

} `

I get an unsupported algorithm error (I have tried other algorithms too, none seem to be supported).

Can you help please?

kevlened commented 4 years ago

Glad you got it working outside of React Native!

Not all algorithms are supported in all environments. The compatibility table shows the algorithms that have been tested. Most of the tested algorithms deal with signing, not encryption, but many algorithms should work.

One caveat is generating RSA keys in React Native. The implementation in React Native is entirely JS, so generating RSA keys would take an extremely long time, so it's not implemented.