paypro: fix encodings with jsrsasign.

This commit is contained in:
Christopher Jeffrey 2014-07-16 15:08:02 -07:00
parent 059b23f899
commit 722a10f965
1 changed files with 5 additions and 6 deletions

View File

@ -20,12 +20,12 @@ PayPro.sign = function(key) {
var pki_data = this.get('pki_data'); // contains one or more x509 certs
var type = pki_type.split('+').toUpperCase();
var buf = this.serializeForSig();
var jsrsaSig = KJUR.crypto.Signature({
var jsrsaSig = new KJUR.crypto.Signature({
alg: type + 'withRSA',
prov: 'cryptojs/jsrsa'
});
jsrsaSig.initSign(pki_data);
jsrsaSig.updateString(buf.toString());
jsrsaSig.updateHex(buf.toString('hex'));
var sig = new Buffer(jsrsasig.sign(), 'hex');
} else if (pki_type === 'none') {
return this;
@ -33,7 +33,6 @@ PayPro.sign = function(key) {
throw new Error('Unsupported pki_type');
}
this.set('signature', sig);
return this;
};
@ -52,16 +51,16 @@ PayPro.verify = function() {
var buf = this.serializeForSig();
var type = pki_type.split('+').toUpperCase();
var jsrsaSig = KJUR.crypto.Signature({
var jsrsaSig = new KJUR.crypto.Signature({
alg: type + 'withRSA',
prov: 'cryptojs/jsrsa'
});
jsrsaSig.initVerifyByCertificatePEM(pki_data);
jsrsaSig.updateString(buf.toString());
jsrsaSig.updateHex(buf.toString('hex'));
var result = jsrsaSig.verify(sig.toString(16)); // should be hex
var result = jsrsaSig.verify(sig.toString('hex'));
return result;
} else if (pki_type === 'none') {