Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/rsasign-1.2.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,26 @@ function _rsasign_getAlgNameAndHashFromHexDisgestInfo(hDigestInfo) {
return [];
}

/**
* verifies a raw RSA sigature for a message string with RSA public key.<br/>
* @name verifyRawWithMessageHex
* @memberOf RSAKey#
* @function
* @param {String} sMsgHex hexadecimal string of message to be verified.
* @param {String} hSig hexadecimal string of raw siganture.<br/>
* non-hexadecimal charactors including new lines will be ignored.
* @return returns 1 if valid, otherwise 0
*/
RSAKey.prototype.verifyRawWithMessageHex = function(sMsgHex, hSig) {
hSig = hSig.replace(_RE_HEXDECONLY, '');
hSig = hSig.replace(/[ \n]+/g, "");
var biSig = parseBigInt(hSig, 16);
if (biSig.bitLength() > this.n.bitLength()) return 0;
var biDecryptedSig = this.doPublic(biSig);
var hMsgHex = biDecryptedSig.toString(16).replace(/^1f+00/, '');
return (hMsgHex == sMsgHex);
};

/**
* verifies a sigature for a message string with RSA public key.<br/>
* @name verify
Expand Down