From e4c4101b5f17366391e08c027b56ecfc3b7de93d Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 16 Jul 2014 08:29:14 -0700 Subject: [PATCH] paypro: fix rsa+sha256 vs rsa+sha1. --- lib/PayPro.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/PayPro.js b/lib/PayPro.js index d775d22..c991921 100644 --- a/lib/PayPro.js +++ b/lib/PayPro.js @@ -213,7 +213,8 @@ PayPro.prototype.sign = function(key) { var crypto = require('crypto'); var pki_data = this.get('pki_data'); // contains one or more x509 certs //var details = this.get('serialized_payment_details'); - var signature = crypto.createSign('RSA-SHA256'); + var type = pki_type.split('+').toUpperCase(); + var verifier = crypto.createSign('RSA-' + type); var buf = this.serializeForSig(); signature.update(buf); //var pki_data = require('fs').readFileSync(__dirname + '/../test/data/x509.pem'); @@ -244,7 +245,8 @@ PayPro.prototype.verify = function() { var pki_data = this.get('pki_data'); // var details = this.get('serialized_payment_details'); var buf = this.serializeForSig(); - var verifier = crypto.createVerify('RSA-SHA256'); + var type = pki_type.split('+').toUpperCase(); + var verifier = crypto.createVerify('RSA-' + type); verifier.update(buf); return verifier.verify(pki_data, sig); } else if (pki_type === 'none') {