Skip to content

Commit

Permalink
Merge pull request #209 from troyfactor4/master
Browse files Browse the repository at this point in the history
Async response for built in algo sign/verify
  • Loading branch information
LoneRifle authored Apr 14, 2020
2 parents 713f3d8 + f982b0c commit 79fc2ac
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/signed-xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,23 @@ 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
}

/**
* 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
}

Expand All @@ -120,21 +122,23 @@ 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
}

/**
* 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
}

Expand All @@ -154,21 +158,23 @@ 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
}

/**
* 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
}

Expand Down

0 comments on commit 79fc2ac

Please sign in to comment.