kevlened / isomorphic-webcrypto

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

Non-functional RSA-OEAP Support #49

Open cryptoAlgorithm opened 3 years ago

cryptoAlgorithm commented 3 years ago

In my React Native project, I decrypt data sent from another React frontend. The 2 most heavily used algorithms are RSA-OEAP and AES-GCM. Unfortunately, I found that the RSA-OEAP support was pretty broken, and using this

crypto.subtle.encrypt(
    {
        name: "RSA-OAEP",
        //label: Uint8Array([...]) //optional
    },
    publicKey, //from generateKey or importKey above
    data //ArrayBuffer of data you want to encrypt
)
.then(function(encrypted){
    //returns an ArrayBuffer containing the encrypted data
    console.log(new Uint8Array(encrypted));
})
.catch(function(err){
    console.error(err);
});

snippet from the WebCrypto examples repo in the readme caused an error:

Possible Unhandled Promise Rejection (id: 0):
TypeError: undefined is not an object (evaluating 'algorithm.hash.name.toUpperCase')

After adding the hash name (SHA-512), it didn't return any error but returned an empty ArrayBuffer []

I hope that this issue can be fixed soon (maybe by merging the latest mscrypto library?) so that i can use this library in my project.