anvilresearch / webcrypto

W3C Web Cryptography API for Node.js
MIT License
82 stars 14 forks source link

Error: Algorithm requires a valid hash object. #82

Open matt-richard opened 5 years ago

matt-richard commented 5 years ago

I'm having trouble when trying to use the importKey method. The output I'm getting, along with the error is:

Error: Algorithm requires a valid hash object. at new RSA_OAEP (/project/node_modules/@trust/webcrypto/src/algorithms/RSA-OAEP.js:47:17) at RSA_OAEP.importKey (/project/node_modules/@trust/webcrypto/src/algorithms/RSA-OAEP.js:374:15) at Promise (/project/node_modules/@trust/webcrypto/src/SubtleCrypto.js:304:12) at new Promise (<anonymous>) at SubtleCrypto.importKey (/project/node_modules/@trust/webcrypto/src/SubtleCrypto.js:285:12) at /project/app.js:73:19 at Layer.handle [as handle_request] (/project/node_modules/express/lib/router/layer.js:95:5) at next (/project/node_modules/express/lib/router/route.js:137:13) at Route.dispatch (/project/node_modules/express/lib/router/route.js:112:3) at Layer.handle [as handle_request] (/project/node_modules/express/lib/router/layer.js:95:5)

The algorithm object I'm using is: {"name": "RSA-OAEP","hash": {"name": "SHA-256"}} and should be valid. Any assistance you could offer is greatly appreciated. I poked around a little bit logging stuff to the console, and found after 'modulusLength' and 'publicExponent' gets added to the object, 'hash' becomes undefined. I didn't dig anymore than that before I wanted to report the issue and get some insight first.