Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async response for built in algo sign/verify #209

Merged
merged 2 commits into from
Apr 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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