diff --git a/lib/browser/PayPro.js b/lib/browser/PayPro.js index 10a7697..52e98fb 100644 --- a/lib/browser/PayPro.js +++ b/lib/browser/PayPro.js @@ -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') {