Class StandardHandlerUsingAes256
- java.lang.Object
-
- com.itextpdf.kernel.crypto.securityhandler.SecurityHandler
-
- com.itextpdf.kernel.crypto.securityhandler.StandardSecurityHandler
-
- com.itextpdf.kernel.crypto.securityhandler.StandardHandlerUsingAes256
-
public class StandardHandlerUsingAes256 extends StandardSecurityHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
encryptMetadata
private boolean
isPdf2
private static int
KEY_SALT_OFFSET
private static int
SALT_LENGTH
private static int
VALIDATION_SALT_OFFSET
-
Fields inherited from class com.itextpdf.kernel.crypto.securityhandler.StandardSecurityHandler
permissions, PERMS_MASK_1_FOR_REVISION_2, PERMS_MASK_1_FOR_REVISION_3_OR_GREATER, PERMS_MASK_2, usedOwnerPassword
-
Fields inherited from class com.itextpdf.kernel.crypto.securityhandler.SecurityHandler
extra, md5, mkey, nextObjectKey, nextObjectKeySize
-
-
Constructor Summary
Constructors Constructor Description StandardHandlerUsingAes256(PdfDictionary encryptionDictionary, byte[] password)
StandardHandlerUsingAes256(PdfDictionary encryptionDictionary, byte[] userPassword, byte[] ownerPassword, int permissions, boolean encryptMetadata, boolean embeddedFilesOnly, PdfVersion version)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static boolean
compareArray(byte[] a, byte[] b, int len)
private byte[]
computeHash(byte[] password, byte[] salt, int saltOffset, int saltLen)
private byte[]
computeHash(byte[] password, byte[] salt, int saltOffset, int saltLen, byte[] userKey)
IDecryptor
getDecryptor()
OutputStreamEncryption
getEncryptionStream(java.io.OutputStream os)
private void
initKeyAndFillDictionary(PdfDictionary encryptionDictionary, byte[] userPassword, byte[] ownerPassword, int permissions, boolean encryptMetadata, boolean embeddedFilesOnly)
private void
initKeyAndReadDictionary(PdfDictionary encryptionDictionary, byte[] password)
boolean
isEncryptMetadata()
private void
setAES256DicEntries(PdfDictionary encryptionDictionary, byte[] oeKey, byte[] ueKey, byte[] aes256Perms, boolean encryptMetadata, boolean embeddedFilesOnly)
void
setHashKeyForNextObject(int objNumber, int objGeneration)
Note: For most of the supported security handlers algorithm to calculate encryption key for particular object is the same.private byte[]
truncateArray(byte[] array)
-
Methods inherited from class com.itextpdf.kernel.crypto.securityhandler.StandardSecurityHandler
equalsArray, generateOwnerPasswordIfNullOrEmpty, getIsoBytes, getPermissions, isUsedOwnerPassword, setStandardHandlerDicEntries
-
-
-
-
Field Detail
-
VALIDATION_SALT_OFFSET
private static final int VALIDATION_SALT_OFFSET
- See Also:
- Constant Field Values
-
KEY_SALT_OFFSET
private static final int KEY_SALT_OFFSET
- See Also:
- Constant Field Values
-
SALT_LENGTH
private static final int SALT_LENGTH
- See Also:
- Constant Field Values
-
isPdf2
private boolean isPdf2
-
encryptMetadata
protected boolean encryptMetadata
-
-
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()
-
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 classSecurityHandler
- Parameters:
objNumber
- number of particular object for encryptionobjGeneration
- generation of particular object for encryption
-
getEncryptionStream
public OutputStreamEncryption getEncryptionStream(java.io.OutputStream os)
- Specified by:
getEncryptionStream
in classSecurityHandler
-
getDecryptor
public IDecryptor getDecryptor()
- Specified by:
getDecryptor
in classSecurityHandler
-
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 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
-
compareArray
private static boolean compareArray(byte[] a, byte[] b, int len)
-
truncateArray
private byte[] truncateArray(byte[] array)
-
-