You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Case-sensitive algorithm argument in crypto.createVerify() #5031
Contrary to what can be seen & read in the documentation,
constverify=crypto.createVerify('rsa-sha256');
crypto.createVerify() throws if the algorithm argument is lowercase:
crypto.js:295
this._handle.init(algorithm);
^
Error: Unknown message digest
at Error (native)
at new Verify (crypto.js:295:16)
at Object.Verify (crypto.js:292:12)
It works perfectly fine if the algorithm is uppercased. Is this intended behavior (and the documentation just needs updating) or is this indeed a minor bug?
Strictly speaking it's the documentation that is wrong. The official openssl name is either RSA-SHA256 or sha256WithRSAEncryption and is case-sensitive.
We could add a crypto.getHashes().filter(s => RegExp(name, 'i').test(s)) step for convenience but I'd worry it introduce problems down the line.
Activity
bnoordhuis commentedon Feb 1, 2016
Strictly speaking it's the documentation that is wrong. The official openssl name is either
RSA-SHA256orsha256WithRSAEncryptionand is case-sensitive.We could add a
crypto.getHashes().filter(s => RegExp(name, 'i').test(s))step for convenience but I'd worry it introduce problems down the line.jhermsmeier commentedon Feb 1, 2016
Ah, interesting. But wouldn't just uppercasing the passed in
algorithmargument fix the issue without causing problems anywhere else?bnoordhuis commentedon Feb 2, 2016
Unfortunately not. If you uppercase e.g.
sha256WithRSAEncryption, openssl won't recognize it.raineroviir commentedon Feb 2, 2016
I've created a pull request which corrects this issue in the documentation
#5044
jhermsmeier commentedon Feb 4, 2016
Cool, thanks!
doc: uppercase 'RSA-SHA256' in crypto.markdown
doc: uppercase 'RSA-SHA256' in crypto.markdown
doc: uppercase 'RSA-SHA256' in crypto.markdown
doc: uppercase 'RSA-SHA256' in crypto.markdown
doc: uppercase 'RSA-SHA256' in crypto.markdown
doc: uppercase 'RSA-SHA256' in crypto.markdown