@syncfusion/ej2-pdf 23.1.38 → 23.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37461,21 +37461,21 @@ class _PdfEncryptor {
37461
37461
  else {
37462
37462
  algorithm = new _BasicEncryption();
37463
37463
  }
37464
- let password;
37464
+ let p;
37465
37465
  if (passwordBytes) {
37466
- password = passwordBytes.subarray(0, Math.min(127, passwordBytes.length));
37466
+ p = passwordBytes.subarray(0, Math.min(127, passwordBytes.length));
37467
37467
  }
37468
37468
  else {
37469
- password = new Uint8Array([]);
37469
+ p = new Uint8Array([]);
37470
37470
  }
37471
- if (algorithm._checkUserPassword(password, userValidationSalt, userPassword)) {
37472
- encryptionKey = this._createEncryptionKey(true, password, ownerKeySalt, uBytes, userKeySalt, ownerEncryption, userEncryption, algorithm);
37471
+ if (algorithm._checkUserPassword(p, userValidationSalt, userPassword)) {
37472
+ encryptionKey = this._createEncryptionKey(true, p, ownerKeySalt, uBytes, userKeySalt, ownerEncryption, userEncryption, algorithm);
37473
37473
  this._isUserPassword = true;
37474
- if (password.length && algorithm._checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
37474
+ if (password.length && algorithm._checkOwnerPassword(p, ownerValidationSalt, uBytes, ownerPassword)) {
37475
37475
  this._hasUserPasswordOnly = true;
37476
37476
  }
37477
37477
  }
37478
- else if (password.length && algorithm._checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
37478
+ else if (password.length && algorithm._checkOwnerPassword(p, ownerValidationSalt, uBytes, ownerPassword)) {
37479
37479
  encryptionKey = this._createEncryptionKey(false, passwordBytes, ownerKeySalt, uBytes, userKeySalt, ownerEncryption, userEncryption, algorithm);
37480
37480
  this._isUserPassword = false;
37481
37481
  }
@@ -37490,7 +37490,6 @@ class _PdfEncryptor {
37490
37490
  throw new Error('Cannot open an encrypted document. The password is invalid.');
37491
37491
  }
37492
37492
  }
37493
- this._encryptionKey = encryptionKey;
37494
37493
  if (algorithm >= 4) {
37495
37494
  const cipherDictionary = dictionary.get('CF');
37496
37495
  if (cipherDictionary) {
@@ -37510,6 +37509,10 @@ class _PdfEncryptor {
37510
37509
  this._string = dictionary.get('StrF') || _PdfName.get('Identity');
37511
37510
  this._eff = dictionary.get('EFF') || this._stream;
37512
37511
  }
37512
+ if (!encryptionKey && !this._encryptOnlyAttachment) {
37513
+ throw new Error('Cannot open an encrypted document. The password is invalid.');
37514
+ }
37515
+ this._encryptionKey = encryptionKey;
37513
37516
  }
37514
37517
  get _md5() {
37515
37518
  if (typeof this._messageDigest === 'undefined') {
@@ -38850,7 +38853,7 @@ class _AdvancedEncryption256Cipher extends _AdvancedEncryptionBaseCipher {
38850
38853
  }
38851
38854
  }
38852
38855
  for (let n = 0; n < 4; ++n) {
38853
- result[Number.parseInt(i.toString(), 10)] = t1 ^= result[j - 32];
38856
+ result[Number.parseInt(j.toString(), 10)] = t1 ^= result[j - 32];
38854
38857
  result[j + 1] = t2 ^= result[j - 31];
38855
38858
  result[j + 2] = t3 ^= result[j - 30];
38856
38859
  result[j + 3] = t4 ^= result[j - 29];