Class StandardHandlerUsingAes256


public class StandardHandlerUsingAes256 extends StandardSecurityHandler
  • Field Details

    • VALIDATION_SALT_OFFSET

      private static final int VALIDATION_SALT_OFFSET
      See Also:
    • KEY_SALT_OFFSET

      private static final int KEY_SALT_OFFSET
      See Also:
    • SALT_LENGTH

      private static final int SALT_LENGTH
      See Also:
    • isPdf2

      private boolean isPdf2
    • encryptMetadata

      protected boolean encryptMetadata
  • Constructor Details

    • 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 Details

    • isEncryptMetadata

      public boolean isEncryptMetadata()
    • 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
    • getEncryptionStream

      public OutputStreamEncryption getEncryptionStream(OutputStream os)
      Specified by:
      getEncryptionStream in class SecurityHandler
    • getDecryptor

      public IDecryptor getDecryptor()
      Specified by:
      getDecryptor in class SecurityHandler
    • initKeyAndFillDictionary

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

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

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

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

      private byte[] computeHash(byte[] password, byte[] salt, int saltOffset, int saltLen, byte[] userKey) throws NoSuchAlgorithmException
      Throws:
      NoSuchAlgorithmException
    • compareArray

      private static boolean compareArray(byte[] a, byte[] b, int len)
    • truncateArray

      private byte[] truncateArray(byte[] array)