Skip to content
Snippets Groups Projects
Commit 954f7eec authored by Gospodin Bodurov's avatar Gospodin Bodurov
Browse files

Add support for hashing

parent ad870c64
Branches
Tags
1 merge request!44Implement a new signature/verification algorithm with severity level
......@@ -164,6 +164,7 @@ describe("SigningService tests", () => {
attachmentsToVerify.push(attachmentData);
attachmentsToVerify.push(attachmentData1);
attachmentsToVerify.push(attachmentData2);
attachmentsToVerify.push(attachmentHash);
var result = await signingService.verifyAttachments(publicKeyPEM, attachmentsToVerify, signatures);
console.log(result);
......
......@@ -350,30 +350,36 @@ class SigningService {
if(filenameHash in signatures) {
var attachmentSignatures = signatures[filenameHash];
var hashingAlgorithms = {};
for(var j = 0; j < attachmentSignatures.length; j++) {
var signature = attachmentSignatures[j];
hashingAlgorithms[signature.hashingAlgorithm] = true;
}
var attachmentVersionsHashed = [];
var attachmentVersions = [];
for (var hashingAlgorithm in hashingAlgorithms){
if (hashingAlgorithms.hasOwnProperty(hashingAlgorithm)) {
var attachmentVersion = {
filename: filename,
content: attachment.content,
type: "raw",
hashingAlgorithm: hashingAlgorithm
};
attachmentVersions.push(attachmentVersion);
}
}
if(attachment.type == "raw") {
var hashingAlgorithms = {};
var attachmentVersionsHashed = await this.hashAttachments(attachmentVersions, true);
for(var j = 0; j < attachmentSignatures.length; j++) {
var signature = attachmentSignatures[j];
hashingAlgorithms[signature.hashingAlgorithm] = true;
}
var attachmentVersions = [];
for (var hashingAlgorithm in hashingAlgorithms){
if (hashingAlgorithms.hasOwnProperty(hashingAlgorithm)) {
var attachmentVersion = {
filename: filename,
content: attachment.content,
type: "raw",
hashingAlgorithm: hashingAlgorithm
};
attachmentVersions.push(attachmentVersion);
}
}
attachmentVersionsHashed = await this.hashAttachments(attachmentVersions, true);
} else {
attachmentVersionsHashed.push(attachment);
}
var valid = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment