diff --git a/lib/signed-xml.js b/lib/signed-xml.js index b02ff078..8db07f21 100644 --- a/lib/signed-xml.js +++ b/lib/signed-xml.js @@ -85,10 +85,11 @@ function RSASHA1() { * Sign the given string using the given key * */ - this.getSignature = function(signedInfo, signingKey) { + this.getSignature = function(signedInfo, signingKey, callback) { var signer = crypto.createSign("RSA-SHA1") signer.update(signedInfo) var res = signer.sign(signingKey, 'base64') + if (callback) callback(null, res) return res } @@ -96,10 +97,11 @@ function RSASHA1() { * Verify the given signature of the given string using key * */ - this.verifySignature = function(str, key, signatureValue) { + this.verifySignature = function(str, key, signatureValue, callback) { var verifier = crypto.createVerify("RSA-SHA1") verifier.update(str) var res = verifier.verify(key, signatureValue, 'base64') + if (callback) callback(null, res) return res } @@ -120,10 +122,11 @@ function RSASHA256() { * Sign the given string using the given key * */ - this.getSignature = function(signedInfo, signingKey) { + this.getSignature = function(signedInfo, signingKey, callback) { var signer = crypto.createSign("RSA-SHA256") signer.update(signedInfo) var res = signer.sign(signingKey, 'base64') + if (callback) callback(null, res) return res } @@ -131,10 +134,11 @@ function RSASHA256() { * Verify the given signature of the given string using key * */ - this.verifySignature = function(str, key, signatureValue) { + this.verifySignature = function(str, key, signatureValue, callback) { var verifier = crypto.createVerify("RSA-SHA256") verifier.update(str) var res = verifier.verify(key, signatureValue, 'base64') + if (callback) callback(null, res) return res } @@ -154,10 +158,11 @@ function RSASHA512() { * Sign the given string using the given key * */ - this.getSignature = function(signedInfo, signingKey) { + this.getSignature = function(signedInfo, signingKey, callback) { var signer = crypto.createSign("RSA-SHA512") signer.update(signedInfo) var res = signer.sign(signingKey, 'base64') + if (callback) callback(null, res) return res } @@ -165,10 +170,11 @@ function RSASHA512() { * Verify the given signature of the given string using key * */ - this.verifySignature = function(str, key, signatureValue) { + this.verifySignature = function(str, key, signatureValue, callback) { var verifier = crypto.createVerify("RSA-SHA512") verifier.update(str) var res = verifier.verify(key, signatureValue, 'base64') + if (callback) callback(null, res) return res }