Class PdfEncryption
java.lang.Object
com.aowagie.text.pdf.PdfEncryption
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate final ARCFOUREncryptionprivate intprivate byte[]private booleanIndicates if the encryption is only necessary for embedded files.private booleanprivate final byte[]Work area to prepare the object/generation bytesprivate byte[]The encryption key for a particular object/generationprivate intThe generic key length.private intThe encryption key length for a particular object/generationprivate MessageDigestThe message digest algorithm MD5private static final byte[]private byte[]The global encryption keyprivate byte[]The encryption key for the ownerprivate static final byte[]private intprivate PdfPublicKeySecurityHandlerThe public key security handler for certificate encryptionprivate intprivate static final byte[]private static longprivate static final intprivate static final int(package private) byte[]The encryption key for the user -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRecipient(Certificate cert, int permission) (package private) intcalculateStreamSize(int n) private byte[]computeOwnerKey(byte[] userPad, byte[] ownerPad) static byte[]static PdfObjectcreateInfoId(byte[] id) byte[]decryptByteArray(byte[] b) (package private) byte[]encryptByteArray(byte[] b) intbooleanIndicates if only the embedded files have to be encrypted.booleanprivate byte[]padPassword(byte[] userPassword) voidsetCryptoMode(int mode, int kl) voidsetHashKey(int number, int generation) voidsetupAllKeys(byte[] userPassword, byte[] ownerPassword, int permissions) voidsetupByEncryptionKey(byte[] key, int keylength) private voidsetupByOwnerPad(byte[] documentID, byte[] ownerPad, byte[] userKey, byte[] ownerKey, int permissions) voidsetupByOwnerPassword(byte[] documentID, byte[] ownerPassword, byte[] userKey, byte[] ownerKey, int permissions) private voidsetupByUserPad(byte[] documentID, byte[] userPad, byte[] ownerKey, int permissions) voidsetupByUserPassword(byte[] documentID, byte[] userPassword, byte[] ownerKey, int permissions) private voidsetupGlobalEncryptionKey(byte[] documentID, byte[] userPad, byte[] ownerKey, int permissions) ownerKey, documentID must be setupprivate voidmkey must be setup
-
Field Details
-
STANDARD_ENCRYPTION_40
private static final int STANDARD_ENCRYPTION_40- See Also:
-
STANDARD_ENCRYPTION_128
private static final int STANDARD_ENCRYPTION_128- See Also:
-
AES_128
private static final int AES_128- See Also:
-
pad
private static final byte[] pad -
salt
private static final byte[] salt -
metadataPad
private static final byte[] metadataPad -
key
private byte[] keyThe encryption key for a particular object/generation -
keySize
private int keySizeThe encryption key length for a particular object/generation -
mkey
private byte[] mkeyThe global encryption key -
extra
private final byte[] extraWork area to prepare the object/generation bytes -
md5
The message digest algorithm MD5 -
ownerKey
private byte[] ownerKeyThe encryption key for the owner -
userKey
byte[] userKeyThe encryption key for the user -
publicKeyHandler
The public key security handler for certificate encryption -
permissions
private int permissions -
documentID
private byte[] documentID -
seq
private static long seq -
revision
private int revision -
arcfour
-
keyLength
private int keyLengthThe generic key length. It may be 40 or 128. -
encryptMetadata
private boolean encryptMetadata -
embeddedFilesOnly
private boolean embeddedFilesOnlyIndicates if the encryption is only necessary for embedded files.- Since:
- 2.1.3
-
cryptoMode
private int cryptoMode
-
-
Constructor Details
-
PdfEncryption
public PdfEncryption() -
PdfEncryption
-
-
Method Details
-
setCryptoMode
public void setCryptoMode(int mode, int kl) -
getCryptoMode
public int getCryptoMode() -
isMetadataEncrypted
public boolean isMetadataEncrypted() -
isEmbeddedFilesOnly
public boolean isEmbeddedFilesOnly()Indicates if only the embedded files have to be encrypted.- Returns:
- if true only the embedded files will be encrypted
- Since:
- 2.1.3
-
padPassword
private byte[] padPassword(byte[] userPassword) -
computeOwnerKey
private byte[] computeOwnerKey(byte[] userPad, byte[] ownerPad) -
setupGlobalEncryptionKey
private void setupGlobalEncryptionKey(byte[] documentID, byte[] userPad, byte[] ownerKey, int permissions) ownerKey, documentID must be setup -
setupUserKey
private void setupUserKey()mkey must be setup -
setupAllKeys
public void setupAllKeys(byte[] userPassword, byte[] ownerPassword, int permissions) -
createDocumentId
public static byte[] createDocumentId() -
setupByUserPassword
public void setupByUserPassword(byte[] documentID, byte[] userPassword, byte[] ownerKey, int permissions) -
setupByUserPad
private void setupByUserPad(byte[] documentID, byte[] userPad, byte[] ownerKey, int permissions) -
setupByOwnerPassword
public void setupByOwnerPassword(byte[] documentID, byte[] ownerPassword, byte[] userKey, byte[] ownerKey, int permissions) -
setupByOwnerPad
private void setupByOwnerPad(byte[] documentID, byte[] ownerPad, byte[] userKey, byte[] ownerKey, int permissions) -
setupByEncryptionKey
public void setupByEncryptionKey(byte[] key, int keylength) -
setHashKey
public void setHashKey(int number, int generation) -
createInfoId
-
getEncryptionDictionary
-
getFileID
-
getEncryptionStream
-
calculateStreamSize
int calculateStreamSize(int n) -
encryptByteArray
byte[] encryptByteArray(byte[] b) -
getDecryptor
-
decryptByteArray
public byte[] decryptByteArray(byte[] b) -
addRecipient
-