Skip to content

Commit d6e4e97

Browse files
committed
Always return a boolean from NodeRSA.isPrivate
Currently, the `NodeRSA.isPrivate` method returns the `d` component of the key when the key is indeed a private key. Obviously, this result is truthy and hence does the job. However, I would classify it as a security risk since the name `isPrivate` raises the expectation that the result is a boolean and hence can safely be sent over the wire. This might leak the most private part of the key though, which would most likely be a disaster.
1 parent 14dcb98 commit d6e4e97

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libs/rsa.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ module.exports.Key = (function () {
272272
* Check if key pair contains private key
273273
*/
274274
RSAKey.prototype.isPrivate = function () {
275-
return this.n && this.e && this.d || false;
275+
return this.n && this.e && this.d && true || false;
276276
};
277277

278278
/**

0 commit comments

Comments
 (0)