public class PdfEncryption extends Object
Modifier and Type | Field and Description |
---|---|
static int |
AES_128 |
static int |
AES_256 |
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 static int |
KEY_SALT_OFFSET |
private int |
keyLength
The generic key length.
|
(package private) int |
keySize
The encryption key length for a particular object/generation
|
(package private) MessageDigest |
md5
The message digest algorithm MD5
|
private static byte[] |
metadataPad |
(package private) byte[] |
mkey
The global encryption key
|
(package private) byte[] |
oeKey |
private static int |
OU_LENGHT |
(package private) byte[] |
ownerKey
The encryption key for the owner
|
private static byte[] |
pad |
(package private) int |
permissions |
(package private) byte[] |
perms |
protected PdfPublicKeySecurityHandler |
publicKeyHandler
The public key security handler for certificate encryption
|
private int |
revision |
private static byte[] |
salt |
private static int |
SALT_LENGHT |
(package private) static long |
seq |
static int |
STANDARD_ENCRYPTION_128 |
static int |
STANDARD_ENCRYPTION_40 |
(package private) byte[] |
ueKey |
(package private) byte[] |
userKey
The encryption key for the user
|
private static int |
VALIDATION_SALT_OFFSET |
Constructor and Description |
---|
PdfEncryption() |
PdfEncryption(PdfEncryption enc) |
Modifier and Type | Method and Description |
---|---|
void |
addRecipient(Certificate cert,
int permission) |
int |
calculateStreamSize(int n) |
private static boolean |
compareArray(byte[] a,
byte[] b,
int len) |
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(OutputStream os) |
PdfObject |
getFileID() |
int |
getPermissions() |
boolean |
isEmbeddedFilesOnly()
Indicates if only the embedded files have to be encrypted.
|
boolean |
isMetadataEncrypted() |
private byte[] |
padPassword(byte[] userPassword) |
boolean |
readKey(PdfDictionary enc,
byte[] password) |
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
public static final int AES_256
private static final byte[] pad
private static final byte[] salt
private static final byte[] metadataPad
byte[] key
int keySize
byte[] mkey
byte[] extra
MessageDigest md5
byte[] ownerKey
byte[] userKey
byte[] oeKey
byte[] ueKey
byte[] perms
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
private static final int VALIDATION_SALT_OFFSET
private static final int KEY_SALT_OFFSET
private static final int SALT_LENGHT
private static final int OU_LENGHT
public PdfEncryption()
public PdfEncryption(PdfEncryption enc)
public void setCryptoMode(int mode, int kl)
public int getCryptoMode()
public boolean isMetadataEncrypted()
public int getPermissions()
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 boolean readKey(PdfDictionary enc, byte[] password) throws BadPasswordException
BadPasswordException
private static boolean compareArray(byte[] a, byte[] b, int len)
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 OutputStreamEncryption getEncryptionStream(OutputStream os)
public int calculateStreamSize(int n)
public byte[] encryptByteArray(byte[] b)
public StandardDecryption getDecryptor()
public byte[] decryptByteArray(byte[] b)
public void addRecipient(Certificate cert, int permission)
public byte[] computeUserPassword(byte[] ownerPassword)
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses