Package com.aowagie.text.pdf
Class PdfEncryption
- java.lang.Object
-
- com.aowagie.text.pdf.PdfEncryption
-
class PdfEncryption extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static int
AES_128
private ARCFOUREncryption
arcfour
private int
cryptoMode
private byte[]
documentID
private boolean
embeddedFilesOnly
Indicates if the encryption is only necessary for embedded files.private boolean
encryptMetadata
private byte[]
extra
Work area to prepare the object/generation bytesprivate byte[]
key
The encryption key for a particular object/generationprivate int
keyLength
The generic key length.private int
keySize
The encryption key length for a particular object/generationprivate java.security.MessageDigest
md5
The message digest algorithm MD5private static byte[]
metadataPad
private byte[]
mkey
The global encryption keyprivate byte[]
ownerKey
The encryption key for the ownerprivate static byte[]
pad
private int
permissions
private PdfPublicKeySecurityHandler
publicKeyHandler
The public key security handler for certificate encryptionprivate int
revision
private static byte[]
salt
private static long
seq
private static int
STANDARD_ENCRYPTION_128
private static int
STANDARD_ENCRYPTION_40
(package private) byte[]
userKey
The encryption key for the user
-
Constructor Summary
Constructors Constructor Description PdfEncryption()
PdfEncryption(PdfEncryption enc)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRecipient(java.security.cert.Certificate cert, int permission)
(package private) int
calculateStreamSize(int n)
private byte[]
computeOwnerKey(byte[] userPad, byte[] ownerPad)
static byte[]
createDocumentId()
static PdfObject
createInfoId(byte[] id)
byte[]
decryptByteArray(byte[] b)
(package private) byte[]
encryptByteArray(byte[] b)
int
getCryptoMode()
StandardDecryption
getDecryptor()
PdfDictionary
getEncryptionDictionary()
OutputStreamEncryption
getEncryptionStream(java.io.OutputStream os)
PdfObject
getFileID()
boolean
isEmbeddedFilesOnly()
Indicates if only the embedded files have to be encrypted.boolean
isMetadataEncrypted()
private byte[]
padPassword(byte[] userPassword)
void
setCryptoMode(int mode, int kl)
void
setHashKey(int number, int generation)
void
setupAllKeys(byte[] userPassword, byte[] ownerPassword, int permissions)
void
setupByEncryptionKey(byte[] key, int keylength)
private void
setupByOwnerPad(byte[] documentID, byte[] ownerPad, byte[] userKey, byte[] ownerKey, int permissions)
void
setupByOwnerPassword(byte[] documentID, byte[] ownerPassword, byte[] userKey, byte[] ownerKey, int permissions)
private void
setupByUserPad(byte[] documentID, byte[] userPad, byte[] ownerKey, int permissions)
void
setupByUserPassword(byte[] documentID, byte[] userPassword, byte[] ownerKey, int permissions)
private void
setupGlobalEncryptionKey(byte[] documentID, byte[] userPad, byte[] ownerKey, int permissions)
ownerKey, documentID must be setupprivate void
setupUserKey()
mkey must be setup
-
-
-
Field Detail
-
STANDARD_ENCRYPTION_40
private static final int STANDARD_ENCRYPTION_40
- See Also:
- Constant Field Values
-
STANDARD_ENCRYPTION_128
private static final int STANDARD_ENCRYPTION_128
- See Also:
- Constant Field Values
-
AES_128
private static final int AES_128
- See Also:
- Constant Field Values
-
pad
private static final byte[] pad
-
salt
private static final byte[] salt
-
metadataPad
private static final byte[] metadataPad
-
key
private byte[] key
The encryption key for a particular object/generation
-
keySize
private int keySize
The encryption key length for a particular object/generation
-
mkey
private byte[] mkey
The global encryption key
-
extra
private final byte[] extra
Work area to prepare the object/generation bytes
-
md5
private java.security.MessageDigest md5
The message digest algorithm MD5
-
ownerKey
private byte[] ownerKey
The encryption key for the owner
-
userKey
byte[] userKey
The encryption key for the user
-
publicKeyHandler
private PdfPublicKeySecurityHandler 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
private final ARCFOUREncryption arcfour
-
keyLength
private int keyLength
The generic key length. It may be 40 or 128.
-
encryptMetadata
private boolean encryptMetadata
-
embeddedFilesOnly
private boolean embeddedFilesOnly
Indicates if the encryption is only necessary for embedded files.- Since:
- 2.1.3
-
cryptoMode
private int cryptoMode
-
-
Constructor Detail
-
PdfEncryption
public PdfEncryption()
-
PdfEncryption
public PdfEncryption(PdfEncryption enc)
-
-
Method Detail
-
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
public static PdfObject createInfoId(byte[] id)
-
getEncryptionDictionary
public PdfDictionary getEncryptionDictionary()
-
getFileID
public PdfObject getFileID()
-
getEncryptionStream
public OutputStreamEncryption getEncryptionStream(java.io.OutputStream os)
-
calculateStreamSize
int calculateStreamSize(int n)
-
encryptByteArray
byte[] encryptByteArray(byte[] b)
-
getDecryptor
public StandardDecryption getDecryptor()
-
decryptByteArray
public byte[] decryptByteArray(byte[] b)
-
addRecipient
public void addRecipient(java.security.cert.Certificate cert, int permission)
-
-