diff --git a/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/PdfModule.java b/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/PdfModule.java index b8952e30d..df93a649e 100644 --- a/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/PdfModule.java +++ b/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/PdfModule.java @@ -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; @@ -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)); diff --git a/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/MessageConstants.java b/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/MessageConstants.java index be175df32..2d7071a21 100644 --- a/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/MessageConstants.java +++ b/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/MessageConstants.java @@ -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 diff --git a/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/PdfStrings.java b/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/PdfStrings.java index 10b573bc9..cabd5ed1c 100644 --- a/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/PdfStrings.java +++ b/jhove-modules/pdf-hul/src/main/java/edu/harvard/hul/ois/jhove/module/pdf/PdfStrings.java @@ -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 diff --git a/jhove-modules/pdf-hul/src/main/resources/edu/harvard/hul/ois/jhove/module/pdf/ErrorMessages.properties b/jhove-modules/pdf-hul/src/main/resources/edu/harvard/hul/ois/jhove/module/pdf/ErrorMessages.properties index da142460d..00c55a528 100644 --- a/jhove-modules/pdf-hul/src/main/resources/edu/harvard/hul/ois/jhove/module/pdf/ErrorMessages.properties +++ b/jhove-modules/pdf-hul/src/main/resources/edu/harvard/hul/ois/jhove/module/pdf/ErrorMessages.properties @@ -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