Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added extra encryption algorithm #621

Merged
merged 10 commits into from
Jun 14, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ public class PdfModule extends ModuleBase {
private static final String PROP_NAME_REVISION = "Revision";
private static final String PROP_NAME_OWNER_STRING = "OwnerString";
private static final String PROP_NAME_USER_STRING = "UserString";
private static final String PROP_NAME_OWNERKEY_STRING = "OwnerEncryptionKey";
private static final String PROP_NAME_USERKEY_STRING = "UserEncryptionKey";
private static final String PROP_NAME_USER_UNIT = DICT_KEY_USER_UNIT;
private static final String PROP_NAME_STANDARD_SECURITY_HANDLER = "StandardSecurityHandler";
private static final String PROP_NAME_TITLE = DICT_KEY_TITLE;
Expand Down Expand Up @@ -1863,6 +1865,34 @@ protected boolean readEncryptDict(RepInfo info) throws IOException {
toHex(((PdfSimpleObject) uObj).getRawBytes())));
}
}
// Required if ExtensionLevel 3 and Encryption Algorithm (V) is 5
// Defined in Adobe® Supplement to the ISO 32000
if (algValue == 5) {
PdfObject oeObj = dict.get("OE");
if (oeObj != null) {
if (oeObj instanceof PdfSimpleObject) {
stdList.add(new Property(PROP_NAME_OWNERKEY_STRING,
PropertyType.STRING,
toHex(((PdfSimpleObject) oeObj).getRawBytes())));
}
} else {
// if algValue is 5; OE is mandatory
throw new PdfInvalidException
(MessageConstants.PDF_HUL_152, _parser.getOffset());
}
PdfObject ueObj = dict.get("UE");
if (ueObj != null) {
if (ueObj instanceof PdfSimpleObject) {
stdList.add(new Property(PROP_NAME_USERKEY_STRING,
PropertyType.STRING,
toHex(((PdfSimpleObject) ueObj).getRawBytes())));
}
} else {
// if algValue is 5; UE is mandatory
throw new PdfInvalidException
(MessageConstants.PDF_HUL_153, _parser.getOffset());
}
}
_encryptList.add(new Property(
PROP_NAME_STANDARD_SECURITY_HANDLER,
PropertyType.PROPERTY, PropertyArity.LIST, stdList));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ public enum MessageConstants {
public static final JhoveMessage PDF_HUL_148 = messageFactory.getMessage("PDF-HUL-148");
public static final JhoveMessage PDF_HUL_149 = messageFactory.getMessage("PDF-HUL-149");
public static final JhoveMessage PDF_HUL_150 = messageFactory.getMessage("PDF-HUL-150");
public static final JhoveMessage PDF_HUL_151 = messageFactory.getMessage("PDF-HUL-151");
public static final JhoveMessage PDF_HUL_152 = messageFactory.getMessage("PDF-HUL-152");
public static final JhoveMessage PDF_HUL_153 = messageFactory.getMessage("PDF-HUL-153");

/**
* Logger Messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public class PdfStrings
"40-bit RC4 or AES",
"40-bit or greater RC4 or AES",
"Unpublished",
"Document-defined"
"Document-defined",
"256-bit AES"
};

/** Flags for FontDescriptor. In PDF notation, bit 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,6 @@ PDF-HUL-147 = Page tree node not found.
PDF-HUL-148 = PDF minor version number is greater than 7.
PDF-HUL-149 = Invalid indirect destination - referenced object ''{0}'' cannot be found
PDF-HUL-150 = Cross-reference stream must be a stream
PDF-HUL-151 = Unexpected error occurred while attempting to read the cross-reference table
PDF-HUL-152 = Encrypt dictionary has no OE key or it has a null value
PDF-HUL-153 = Encrypt dictionary has no UE key or it has a null value