Class StandardHandlerUsingAes256
java.lang.Object
com.itextpdf.kernel.crypto.securityhandler.SecurityHandler
com.itextpdf.kernel.crypto.securityhandler.StandardSecurityHandler
com.itextpdf.kernel.crypto.securityhandler.StandardHandlerUsingAes256
- Direct Known Subclasses:
StandardHandlerUsingAesGcm
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprivate booleanprivate static final intprivate static final intprivate static final intFields inherited from class StandardSecurityHandler
permissions, PERMS_MASK_1_FOR_REVISION_2, PERMS_MASK_1_FOR_REVISION_3_OR_GREATER, PERMS_MASK_2, usedOwnerPasswordFields inherited from class SecurityHandler
extra, md5, mkey, nextObjectKey, nextObjectKeySize -
Constructor Summary
ConstructorsConstructorDescriptionStandardHandlerUsingAes256(PdfDictionary encryptionDictionary, byte[] password) StandardHandlerUsingAes256(PdfDictionary encryptionDictionary, byte[] userPassword, byte[] ownerPassword, int permissions, boolean encryptMetadata, boolean embeddedFilesOnly, PdfVersion version) -
Method Summary
Modifier and TypeMethodDescriptionprivate byte[]computeHash(byte[] password, byte[] salt, int saltOffset, int saltLen) private byte[]computeHash(byte[] password, byte[] salt, int saltOffset, int saltLen, byte[] userKey) private byte[]getAes256Perms(int permissions, boolean encryptMetadata) Gets decryptor object.Gets a stream wrapper, responsible for encryption.private voidinitKeyAndFillDictionary(PdfDictionary encryptionDictionary, byte[] userPassword, byte[] ownerPassword, int permissions, boolean encryptMetadata, boolean embeddedFilesOnly) private voidinitKeyAndReadDictionary(PdfDictionary encryptionDictionary, byte[] password) protected voidInit md5 message digest.booleanChecks whether the document-level metadata stream will be encrypted.(package private) booleanisPdf2(PdfDictionary encryptionDictionary) (package private) voidsetAES256DicEntries(PdfDictionary encryptionDictionary, byte[] oeKey, byte[] ueKey, byte[] aes256Perms, boolean encryptMetadata, boolean embeddedFilesOnly) (package private) voidsetEncryptionDictionaryEntries(PdfDictionary encryptionDictionary, byte[] oeKey, byte[] ueKey, byte[] aes256Perms, boolean encryptMetadata, boolean embeddedFilesOnly, int version, int revision, PdfName cryptoFilter) voidsetHashKeyForNextObject(int objNumber, int objGeneration) Note: For most of the supported security handlers algorithm to calculate encryption key for particular object is the same.voidsetPermissions(int permissions, PdfDictionary encryptionDictionary) Updates encryption dictionary with the security permissions provided.private byte[]truncateArray(byte[] array) Methods inherited from class StandardSecurityHandler
equalsArray, generateOwnerPasswordIfNullOrEmpty, getIsoBytes, getPermissions, isUsedOwnerPassword, setStandardHandlerDicEntriesMethods inherited from class SecurityHandler
getMkey, getNextObjectKey
-
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:
-
encryptMetadata
protected boolean encryptMetadata -
isPdf2
private boolean isPdf2
-
-
Constructor Details
-
StandardHandlerUsingAes256
public StandardHandlerUsingAes256(PdfDictionary encryptionDictionary, byte[] userPassword, byte[] ownerPassword, int permissions, boolean encryptMetadata, boolean embeddedFilesOnly, PdfVersion version) -
StandardHandlerUsingAes256
-
-
Method Details
-
isEncryptMetadata
public boolean isEncryptMetadata()Checks whether the document-level metadata stream will be encrypted.- Returns:
trueif the document-level metadata stream shall be encrypted,falseotherwise
-
setHashKeyForNextObject
public void setHashKeyForNextObject(int objNumber, int objGeneration) Description copied from class:SecurityHandlerNote: For most of the supported security handlers algorithm to calculate encryption key for particular object is the same.- Overrides:
setHashKeyForNextObjectin classSecurityHandler- Parameters:
objNumber- number of particular object for encryptionobjGeneration- generation of particular object for encryption
-
getEncryptionStream
Description copied from class:SecurityHandlerGets a stream wrapper, responsible for encryption.- Specified by:
getEncryptionStreamin classSecurityHandler- Parameters:
os-OutputStreamto be wrapped- Returns:
OutputStreamEncryption, responsible for encryption.
-
getDecryptor
Description copied from class:SecurityHandlerGets decryptor object.- Specified by:
getDecryptorin classSecurityHandler- Returns:
IDecryptor
-
setPermissions
Updates encryption dictionary with the security permissions provided.- Overrides:
setPermissionsin classStandardSecurityHandler- Parameters:
permissions- new permissions to setencryptionDictionary- 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) -
isPdf2
-
initMd5MessageDigest
protected void initMd5MessageDigest()Init md5 message digest.- Overrides:
initMd5MessageDigestin classSecurityHandler
-
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
-
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
-
truncateArray
private byte[] truncateArray(byte[] array)
-