Skip to content

Commit

Permalink
Async response for built in algo sign/verify
Browse files Browse the repository at this point in the history
  • Loading branch information
troyfactor4 committed Apr 13, 2020
1 parent 713f3d8 commit 4ffe0aa
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions lib/signed-xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,24 @@ 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')
return res
if (callback) callback(null, res)
else return res
}

/**
* 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')
return res
if (callback) callback(null, res)
else return res
}

this.getAlgorithmName = function() {
Expand All @@ -120,22 +122,24 @@ 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')
return res
if (callback) callback(null, res)
else return res
}

/**
* 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')
return res
if (callback) callback(null, res)
else return res
}

this.getAlgorithmName = function() {
Expand All @@ -154,22 +158,24 @@ 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')
return res
if (callback) callback(null, res)
else return res
}

/**
* 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')
return res
if (callback) callback(null, res)
else return res
}

this.getAlgorithmName = function() {
Expand Down

0 comments on commit 4ffe0aa

Please sign in to comment.