paypro: rename type to sigHashAlg.

This commit is contained in:
Christopher Jeffrey 2014-09-02 19:31:44 -07:00
parent a50b9ed3a3
commit b53e285a7c
2 changed files with 13 additions and 7 deletions

View File

@ -135,7 +135,10 @@ PayPro.prototype.x509Verify = function(returnTrust) {
return verified && chainVerified;
};
PayPro.verifyCertChain = function(chain, type) {
PayPro.verifyCertChain = function(chain, sigHashAlg) {
if (sigHashAlg === 'none') {
return true;
}
return chain.every(function(cert, i) {
var der = cert.toString('hex');
var pem = PayPro.DERtoPEM(der, 'CERTIFICATE');
@ -189,7 +192,7 @@ PayPro.verifyCertChain = function(chain, type) {
// from the DER Certificate:
var tbs = PayPro.getTBSCertificate(data);
var verifier = crypto.createVerify(type ? 'RSA-' + type : 'RSA');
var verifier = crypto.createVerify('RSA-' + sigHashAlg);
verifier.update(tbs);
var sigVerified = verifier.verify(npubKey, sig);

View File

@ -149,7 +149,10 @@ PayPro.prototype.x509Verify = function(returnTrust) {
return verified && chainVerified;
};
PayPro.verifyCertChain = function(chain, type) {
PayPro.verifyCertChain = function(chain, sigHashAlg) {
if (sigHashAlg === 'none') {
return true;
}
return chain.every(function(cert, i) {
var der = cert.toString('hex');
// var pem = self._DERtoPEM(der, 'CERTIFICATE');
@ -180,9 +183,9 @@ PayPro.verifyCertChain = function(chain, type) {
//
// Get Public Key from next certificate (via KJUR because it's a mess):
//
if (type !== 'none') {
if (sigHashAlg !== 'none') {
var js = new KJUR.crypto.Signature({
alg: type + 'withRSA',
alg: sigHashAlg + 'withRSA',
prov: 'cryptojs/jsrsa'
});
js.initVerifyByCertificatePEM(npem);
@ -212,9 +215,9 @@ PayPro.verifyCertChain = function(chain, type) {
// Verify current Certificate signature
//
if (type !== 'none') {
if (sigHashAlg !== 'none') {
var jsrsaSig = new KJUR.crypto.Signature({
alg: type + 'withRSA',
alg: sigHashAlg + 'withRSA',
prov: 'cryptojs/jsrsa'
});
jsrsaSig.initVerifyByPublicKey(npubKey);