Skip to content

Commit

Permalink
Merge branch 'develop' into devsecops
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-ivanov committed Mar 5, 2025
2 parents 70c6345 + 0b86836 commit 6fbbda2
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,15 @@ public virtual void OpenEncryptedWithPasswordDocWithDefaultKeyLength() {
}
}

[NUnit.Framework.Test]
public virtual void CheckPermissionsLongValue() {
// The test checks
// that no IoLogMessageConstant.ENCRYPTION_ENTRIES_P_AND_ENCRYPT_METADATA_NOT_CORRESPOND_PERMS_ENTRY is logged
PdfDocument doc = new PdfDocument(new PdfReader(sourceFolder + "encryptedWithPasswordAes256_modifiedPermissions.pdf"
, new ReaderProperties().SetPassword(PdfEncryptionTestUtils.OWNER)));
doc.Close();
}

public virtual void EncryptWithPassword2(String filename, int encryptionType, int compression) {
EncryptWithPassword2(filename, encryptionType, compression, false);
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private void InitKeyAndReadDictionary(PdfDictionary encryptionDictionary, byte[]
byte[] ueValue = GetIsoBytes(encryptionDictionary.GetAsString(PdfName.UE));
byte[] perms = GetIsoBytes(encryptionDictionary.GetAsString(PdfName.Perms));
PdfNumber pValue = (PdfNumber)encryptionDictionary.Get(PdfName.P);
this.permissions = pValue.IntValue();
this.permissions = (int)pValue.LongValue();
byte[] hash;
hash = ComputeHash(password, oValue, VALIDATION_SALT_OFFSET, SALT_LENGTH, uValue);
usedOwnerPassword = EqualsArray(hash, oValue, 32);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private void InitKeyAndReadDictionary(PdfDictionary encryptionDictionary, byte[]
byte[] uValue = GetIsoBytes(encryptionDictionary.GetAsString(PdfName.U));
byte[] oValue = GetIsoBytes(encryptionDictionary.GetAsString(PdfName.O));
PdfNumber pValue = (PdfNumber)encryptionDictionary.Get(PdfName.P);
this.permissions = pValue.IntValue();
this.permissions = (int)pValue.LongValue();
this.documentId = documentId;
keyLength = GetKeyLength(encryptionDictionary);
byte[] paddedPassword = PadPassword(password);
Expand Down
2 changes: 1 addition & 1 deletion itext/itext.pdfua/itext/pdfua/checkers/PdfUA1Checker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ private void CheckCrypto(PdfDictionary encryptionDictionary) {
throw new PdfUAConformanceException(PdfUAExceptionMessageConstants.P_VALUE_IS_ABSENT_IN_ENCRYPTION_DICTIONARY
);
}
int permissions = ((PdfNumber)encryptionDictionary.Get(PdfName.P)).IntValue();
int permissions = (int)((PdfNumber)encryptionDictionary.Get(PdfName.P)).LongValue();
if ((EncryptionConstants.ALLOW_SCREENREADERS & permissions) == 0) {
throw new PdfUAConformanceException(PdfUAExceptionMessageConstants.TENTH_BIT_OF_P_VALUE_IN_ENCRYPTION_SHOULD_BE_NON_ZERO
);
Expand Down
2 changes: 1 addition & 1 deletion port-hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
31982ffa741c53dba41efb38a4f8139dd53b1897
750a1ef4c0feeadfce1b8f46caf639dcb5a56eec

0 comments on commit 6fbbda2

Please sign in to comment.