computeEncryptedKey
public final byte[] computeEncryptedKey(byte[] password,
byte[] o,
int permissions,
byte[] id,
int revision,
int length)
throws CryptographyException This will compute the encrypted key.
password - The password used to compute the encrypted key.o - The owner password hash.permissions - The permissions for the document.id - The document id.revision - The security revision.length - The length of the encryption key.
computeOwnerPassword
public final byte[] computeOwnerPassword(byte[] ownerPassword,
byte[] userPassword,
int revision,
int length)
throws CryptographyException,
IOException This algorithm is taked from PDF Reference 1.4 Algorithm 3.3 Page 79.
ownerPassword - The plain owner password.userPassword - The plain user password.revision - The version of the security.length - The length of the document.
- The computed owner password.
computeUserPassword
public final byte[] computeUserPassword(byte[] password,
byte[] o,
int permissions,
byte[] id,
int revision,
int length)
throws CryptographyException,
IOException This will compute the user password hash.
password - The plain text password.o - The owner password hash.permissions - The document permissions.id - The document id.revision - The revision of the encryption.length - The length of the encryption key.
encryptData
public final void encryptData(long objectNumber,
long genNumber,
byte[] key,
InputStream data,
OutputStream output)
throws CryptographyException,
IOException This will encrypt a piece of data.
objectNumber - The id for the object.genNumber - The generation id for the object.key - The key used to encrypt the data.data - The data to encrypt/decrypt.output - The stream to write to.
getUserPassword
public final byte[] getUserPassword(byte[] ownerPassword,
byte[] o,
int revision,
long length)
throws CryptographyException,
IOException This will get the user password from the owner password and the documents o value.
ownerPassword - The plaintext owner password.o - The document's o entry.revision - The document revision number.length - The length of the encryption.
- The plaintext padded user password.
isOwnerPassword
public final boolean isOwnerPassword(byte[] ownerPassword,
byte[] u,
byte[] o,
int permissions,
byte[] id,
int revision,
int length)
throws CryptographyException,
IOException This will tell if this is the owner password or not.
ownerPassword - The plaintext owner password.u - The U value from the PDF Document.o - The owner password hash.permissions - The document permissions.id - The document id.revision - The revision of the encryption.length - The length of the encryption key.
- true if the owner password matches the one from the document.
isUserPassword
public final boolean isUserPassword(byte[] password,
byte[] u,
byte[] o,
int permissions,
byte[] id,
int revision,
int length)
throws CryptographyException,
IOException This will tell if this is a valid user password.
Algorithm 3.6 pg 80
password - The password to test.u - The U value from the PDF Document.o - The owner password hash.permissions - The document permissions.id - The document id.revision - The revision of the encryption.length - The length of the encryption key.
- true If this is the correct user password.