public class PdfEncryption
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
AES_128 |
private ARCFOUREncryption |
arcfour |
private int |
cryptoMode |
(package private) byte[] |
documentID |
private boolean |
embeddedFilesOnly
Indicates if the encryption is only necessary for embedded files.
|
private boolean |
encryptMetadata |
(package private) byte[] |
extra
Work area to prepare the object/generation bytes
|
(package private) byte[] |
key
The encryption key for a particular object/generation
|
private int |
keyLength
The generic key length.
|
(package private) int |
keySize
The encryption key length for a particular object/generation
|
(package private) java.security.MessageDigest |
md5
The message digest algorithm MD5
|
private static byte[] |
metadataPad |
(package private) byte[] |
mkey
The global encryption key
|
(package private) byte[] |
ownerKey
The encryption key for the owner
|
private static byte[] |
pad |
(package private) int |
permissions |
protected PdfPublicKeySecurityHandler |
publicKeyHandler
The public key security handler for certificate encryption
|
private int |
revision |
private static byte[] |
salt |
(package private) static long |
seq |
static int |
STANDARD_ENCRYPTION_128 |
static int |
STANDARD_ENCRYPTION_40 |
(package private) byte[] |
userKey
The encryption key for the user
|
Constructor and Description |
---|
PdfEncryption() |
PdfEncryption(PdfEncryption enc) |
Modifier and Type | Method and Description |
---|---|
void |
addRecipient(java.security.cert.Certificate cert,
int permission) |
int |
calculateStreamSize(int n) |
private byte[] |
computeOwnerKey(byte[] userPad,
byte[] ownerPad) |
byte[] |
computeUserPassword(byte[] ownerPassword) |
static byte[] |
createDocumentId() |
static PdfObject |
createInfoId(byte[] id) |
byte[] |
decryptByteArray(byte[] b) |
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 setup
|
private void |
setupUserKey()
mkey must be setup
|
public static final int STANDARD_ENCRYPTION_40
public static final int STANDARD_ENCRYPTION_128
public static final int AES_128
private static final byte[] pad
private static final byte[] salt
private static final byte[] metadataPad
byte[] key
int keySize
byte[] mkey
byte[] extra
java.security.MessageDigest md5
byte[] ownerKey
byte[] userKey
protected PdfPublicKeySecurityHandler publicKeyHandler
int permissions
byte[] documentID
static long seq
private int revision
private ARCFOUREncryption arcfour
private int keyLength
private boolean encryptMetadata
private boolean embeddedFilesOnly
private int cryptoMode
public PdfEncryption()
public PdfEncryption(PdfEncryption enc)
public void setCryptoMode(int mode, int kl)
public int getCryptoMode()
public boolean isMetadataEncrypted()
public boolean isEmbeddedFilesOnly()
private byte[] padPassword(byte[] userPassword)
private byte[] computeOwnerKey(byte[] userPad, byte[] ownerPad)
private void setupGlobalEncryptionKey(byte[] documentID, byte[] userPad, byte[] ownerKey, int permissions)
private void setupUserKey()
public void setupAllKeys(byte[] userPassword, byte[] ownerPassword, int permissions)
public static byte[] createDocumentId()
public void setupByUserPassword(byte[] documentID, byte[] userPassword, byte[] ownerKey, int permissions)
private void setupByUserPad(byte[] documentID, byte[] userPad, byte[] ownerKey, int permissions)
public void setupByOwnerPassword(byte[] documentID, byte[] ownerPassword, byte[] userKey, byte[] ownerKey, int permissions)
private void setupByOwnerPad(byte[] documentID, byte[] ownerPad, byte[] userKey, byte[] ownerKey, int permissions)
public void setupByEncryptionKey(byte[] key, int keylength)
public void setHashKey(int number, int generation)
public static PdfObject createInfoId(byte[] id)
public PdfDictionary getEncryptionDictionary()
public PdfObject getFileID()
public OutputStreamEncryption getEncryptionStream(java.io.OutputStream os)
public int calculateStreamSize(int n)
public byte[] encryptByteArray(byte[] b)
public StandardDecryption getDecryptor()
public byte[] decryptByteArray(byte[] b)
public void addRecipient(java.security.cert.Certificate cert, int permission)
public byte[] computeUserPassword(byte[] ownerPassword)