commit c8acae6e93bdace887d87df01f1b57dde17e7758
parent 0fd569497eba9368fad2339c76a274869b9d3962
Author: Amit Dutta <amitdutta4255@gmail.com>
Date: Wed, 15 Apr 2026 13:17:02 +0530
Enhance integrity check with timingSafeEqual
Diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/CipherEngine.js b/lib/CipherEngine.js
@@ -390,7 +390,10 @@ export class CipherEngine {
return;
}
- if (footerHex !== calcDigest) {
+ const footerBuffer = Buffer.from(footerHex, 'hex');
+ const calcBuffer = Buffer.from(calcDigest, 'hex');
+
+ if (footerBuffer.length !== calcBuffer.length || !crypto.timingSafeEqual(footerBuffer, calcBuffer)) {
this.emit('error', new Error("FILE_TAMPERED"));
return;
}
@@ -451,4 +454,4 @@ export class CipherEngine {
}
return buf;
}
-}
-\ No newline at end of file
+}