Skip to content
Snippets Groups Projects
Commit 3215e86c authored by Zdravko Iliev's avatar Zdravko Iliev
Browse files

add build

parent ac7ddba0
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.verify = void 0;
const forge = __importStar(require("@vereign/node-forge"));
const certUtils_1 = require("./certUtils");
const errors_1 = require("./errors");
const signatureUtils_1 = require("./signatureUtils");
const verify = (signature, signatureMeta) => {
const message = (0, signatureUtils_1.getMessageFromSignature)(signature);
......@@ -40,11 +39,21 @@ const verify = (signature, signatureMeta) => {
.update(forge.asn1.toDer(set).data)
.digest()
.getBytes();
const validAuthenticatedAttributes = clientCertificate["publicKey"].verify(digest, sig);
if (!validAuthenticatedAttributes) {
throw new errors_1.AppError("Wrong authenticated attributes");
}
// WIP: fix integrity check
//FIXME: verification for some of the pdf documents is failing
// Encryption block is invalid.
// Check if the code is wrong or the PDF is not valid
// try {
// const validAuthenticatedAttributes = clientCertificate["publicKey"].verify(
// digest,
// sig
// );
// } catch (error) {
// console.log(error);
// }
// if (!validAuthenticatedAttributes) {
// throw new AppError("Wrong authenticated attributes");
// }
// FIXME: fix integrity check
// const messageDigestAttr = forge.pki.oids.messageDigest;
// const fullAttrDigest = attrs.find(
// (attr) => forge.asn1.derToOid(attr.value[0].value) === messageDigestAttr
......@@ -58,7 +67,7 @@ const verify = (signature, signatureMeta) => {
// const integrity = dataDigest === attrDigest;
const sortedCerts = (0, certUtils_1.sortCertificateChain)(certificates);
const parsedCerts = (0, certUtils_1.extractCertificatesDetails)(sortedCerts);
//WIP: fix authenticity check after you have the root cert
//FIXME: fix authenticity check after you have the root cert
// const authenticity = authenticateSignature(sortedCerts);
const isExpired = (0, certUtils_1.isCertsExpired)(sortedCerts);
return {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment