-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace node-forge by native node crypto. #86
Conversation
f3daf8e
to
7f53cac
Compare
Hello maintainers! Any interest in having this merged? |
This PR would also fix #93 :) @gkwang @esarafianou are you still working on this project ? |
Hi @forty, seems like we missed your previous messages. I'll have the PR reviewed within the week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless you're going to be re-using the KeyObject instance it's better to pass the key material down to the encrypt/decrypt to avoid C/JS context switching.
lib/xmlenc.js
Outdated
var private_key = crypto.createPrivateKey(options.key); | ||
var decrypted = crypto.privateDecrypt({ key: private_key, padding: padding}, key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var private_key = crypto.createPrivateKey(options.key); | |
var decrypted = crypto.privateDecrypt({ key: private_key, padding: padding}, key); | |
var decrypted = crypto.privateDecrypt({ key: options.key, padding: padding}, key); |
lib/xmlenc.js
Outdated
var rsa_pub = crypto.createPublicKey(options.rsa_pub); | ||
var encrypted = crypto.publicEncrypt({ | ||
key: rsa_pub, | ||
padding: padding | ||
}, symmetricKeyBuffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var rsa_pub = crypto.createPublicKey(options.rsa_pub); | |
var encrypted = crypto.publicEncrypt({ | |
key: rsa_pub, | |
padding: padding | |
}, symmetricKeyBuffer); | |
var encrypted = crypto.publicEncrypt({ | |
key: options.rsa_pub, | |
padding: padding | |
}, symmetricKeyBuffer); |
This requires dropping support for node 8, which is probably fine since node 8 is EoL since December 31, 2019.
7f53cac
to
7aaa734
Compare
Thanks for the comments @panva ! @esarafianou I've just updated the PR. Thanks! |
This requires dropping support for node 8, which is probably fine since
node 8 is EoL since December 31, 2019.
By submitting a PR to this repository, you agree to the terms within the Auth0 Code of Conduct. Please see the contributing guidelines for how to create and submit a high-quality PR for this repo.
Description
Drop node-forge (which is a huge dep), use native nodejs crypto.
References
About node 8 support
https://blog.risingstack.com/update-nodejs-8-end-of-life-no-support/
Node Crypto
https://nodejs.org/api/crypto.html#crypto_crypto_publicencrypt_key_buffer
https://nodejs.org/api/crypto.html#crypto_crypto_privatedecrypt_privatekey_buffer
Testing
I updated first the encryption part, ran the tests (it was fine) then the decryption part (tests still fine).
This made sure the new encryption works well with the
Checklist
master