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