Class StandardHandlerUsingAes256

    • Field Detail

      • VALIDATION_SALT_OFFSET

        private static final int VALIDATION_SALT_OFFSET
        See Also:
        Constant Field Values
      • encryptMetadata

        protected boolean encryptMetadata
      • isPdf2

        private boolean isPdf2
    • Constructor Detail

      • StandardHandlerUsingAes256

        public StandardHandlerUsingAes256​(PdfDictionary encryptionDictionary,
                                          byte[] userPassword,
                                          byte[] ownerPassword,
                                          int permissions,
                                          boolean encryptMetadata,
                                          boolean embeddedFilesOnly,
                                          PdfVersion version)
      • StandardHandlerUsingAes256

        public StandardHandlerUsingAes256​(PdfDictionary encryptionDictionary,
                                          byte[] password)
    • Method Detail

      • isEncryptMetadata

        public boolean isEncryptMetadata()
        Checks whether the document-level metadata stream will be encrypted.
        Returns:
        true if the document-level metadata stream shall be encrypted, false otherwise
      • setHashKeyForNextObject

        public void setHashKeyForNextObject​(int objNumber,
                                            int objGeneration)
        Description copied from class: SecurityHandler
        Note: For most of the supported security handlers algorithm to calculate encryption key for particular object is the same.
        Overrides:
        setHashKeyForNextObject in class SecurityHandler
        Parameters:
        objNumber - number of particular object for encryption
        objGeneration - generation of particular object for encryption
      • setPermissions

        public void setPermissions​(int permissions,
                                   PdfDictionary encryptionDictionary)
        Updates encryption dictionary with the security permissions provided.
        Overrides:
        setPermissions in class StandardSecurityHandler
        Parameters:
        permissions - new permissions to set
        encryptionDictionary - encryption dictionary to update
      • setAES256DicEntries

        void setAES256DicEntries​(PdfDictionary encryptionDictionary,
                                 byte[] oeKey,
                                 byte[] ueKey,
                                 byte[] aes256Perms,
                                 boolean encryptMetadata,
                                 boolean embeddedFilesOnly)
      • setEncryptionDictionaryEntries

        void setEncryptionDictionaryEntries​(PdfDictionary encryptionDictionary,
                                            byte[] oeKey,
                                            byte[] ueKey,
                                            byte[] aes256Perms,
                                            boolean encryptMetadata,
                                            boolean embeddedFilesOnly,
                                            int version,
                                            int revision,
                                            PdfName cryptoFilter)
      • initKeyAndFillDictionary

        private void initKeyAndFillDictionary​(PdfDictionary encryptionDictionary,
                                              byte[] userPassword,
                                              byte[] ownerPassword,
                                              int permissions,
                                              boolean encryptMetadata,
                                              boolean embeddedFilesOnly)
      • getAes256Perms

        private byte[] getAes256Perms​(int permissions,
                                      boolean encryptMetadata)
      • initKeyAndReadDictionary

        private void initKeyAndReadDictionary​(PdfDictionary encryptionDictionary,
                                              byte[] password)
      • computeHash

        private byte[] computeHash​(byte[] password,
                                   byte[] salt,
                                   int saltOffset,
                                   int saltLen)
                            throws java.security.NoSuchAlgorithmException
        Throws:
        java.security.NoSuchAlgorithmException
      • computeHash

        private byte[] computeHash​(byte[] password,
                                   byte[] salt,
                                   int saltOffset,
                                   int saltLen,
                                   byte[] userKey)
                            throws java.security.NoSuchAlgorithmException
        Throws:
        java.security.NoSuchAlgorithmException
      • truncateArray

        private byte[] truncateArray​(byte[] array)