Skip to content

Commit

Permalink
fix AE-2 format
Browse files Browse the repository at this point in the history
  • Loading branch information
xqdoo00o committed Aug 29, 2020
1 parent 6a45148 commit 0eea9a8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/aes.js
Expand Up @@ -91,7 +91,7 @@ AesWorker.prototype.cleanUp = function () {
AesWorker.prototype._createAes = function () {
if (this._dir) {
var salt = sjcl.random.randomWords(this._saltLen);
var derivedKey = sjcl.misc.pbkdf2(this._password, salt, 1000, (this._macLen + this._keyLen + passwordVerifierLen) * 8, sjcl.misc.hmac);
var derivedKey = sjcl.misc.pbkdf2(this._password, salt, 1000, (this._macLen + this._keyLen + passwordVerifierLen) * 8);
this._aesKey = sjcl.bitArray.bitSlice(derivedKey, 0, this._keyLen * 8);
var macKey = sjcl.bitArray.bitSlice(derivedKey, this._keyLen * 8, (this._keyLen + this._macLen) * 8);
var derivedPassVerifier = sjcl.bitArray.bitSlice(derivedKey, (this._keyLen + this._macLen) * 8);
Expand Down Expand Up @@ -127,7 +127,7 @@ exports.verifyPassword = function (data, options) {
var saltLen = keyLen / 2;

var salt = sjcl.codec.bytes.toBits(data.subarray(0, saltLen));
var derivedKey = sjcl.misc.pbkdf2(password, salt, 1000, (macLen + keyLen + passwordVerifierLen) * 8, sjcl.misc.hmac);
var derivedKey = sjcl.misc.pbkdf2(password, salt, 1000, (macLen + keyLen + passwordVerifierLen) * 8);
var derivedPassVerifier = sjcl.bitArray.bitSlice(derivedKey, (keyLen + macLen) * 8);
var passVerifyValue = sjcl.codec.bytes.toBits(data.subarray(saltLen, saltLen + passwordVerifierLen));
if (!sjcl.bitArray.equal(passVerifyValue, derivedPassVerifier)) {
Expand Down
1 change: 0 additions & 1 deletion lib/compressedObject.js
Expand Up @@ -81,7 +81,6 @@ CompressedObject.prototype = {
CompressedObject.createWorkerFrom = function (uncompressedWorker, compression, compressionOptions, encryptOptions) {
if (encryptOptions.password !== null) {
return uncompressedWorker
.pipe(new Crc32Probe())
.pipe(new DataLengthProbe("uncompressedSize"))
.pipe(compression.compressWorker(compressionOptions))
.pipe(aes.EncryptWorker(encryptOptions))
Expand Down
4 changes: 4 additions & 0 deletions lib/load.js
Expand Up @@ -14,6 +14,10 @@ var nodejsUtils = require("./nodejsUtils");
*/
function checkEntryCRC32(zipEntry) {
return new external.Promise(function (resolve, reject) {
if (zipEntry.options.aes.version === 2) {
reject(new Error("Encrypted zip : no CRC32 stored"));
return;
}
var worker = zipEntry.decompressed.getContentWorker().pipe(new Crc32Probe());
worker.on("error", function (e) {
reject(e);
Expand Down

0 comments on commit 0eea9a8

Please sign in to comment.