| java.lang.Object org.pdfbox.encryption.PDFEncryption
Field Summary | |
final public static byte[] | ENCRYPT_PADDING The encryption padding defined in the PDF 1.4 Spec algorithm 3.2. |
Method Summary | |
final public byte[] | computeEncryptedKey(byte[] password, byte[] o, int permissions, byte[] id, int revision, int length) This will compute the encrypted key.
Parameters: password - The password used to compute the encrypted key. Parameters: o - The owner password hash. Parameters: permissions - The permissions for the document. Parameters: id - The document id. Parameters: revision - The security revision. Parameters: length - The length of the encryption key. | final public byte[] | computeOwnerPassword(byte[] ownerPassword, byte[] userPassword, int revision, int length) This algorithm is taked from PDF Reference 1.4 Algorithm 3.3 Page 79.
Parameters: ownerPassword - The plain owner password. Parameters: userPassword - The plain user password. Parameters: revision - The version of the security. Parameters: length - The length of the document. | final public byte[] | computeUserPassword(byte[] password, byte[] o, int permissions, byte[] id, int revision, int length) This will compute the user password hash.
Parameters: password - The plain text password. Parameters: o - The owner password hash. Parameters: permissions - The document permissions. Parameters: id - The document id. Parameters: revision - The revision of the encryption. Parameters: length - The length of the encryption key. | final public void | encryptData(long objectNumber, long genNumber, byte[] key, InputStream data, OutputStream output) This will encrypt a piece of data. | final public byte[] | getUserPassword(byte[] ownerPassword, byte[] o, int revision, long length) This will get the user password from the owner password and the documents o value.
Parameters: ownerPassword - The plaintext owner password. Parameters: o - The document's o entry. Parameters: revision - The document revision number. Parameters: length - The length of the encryption. | final public boolean | isOwnerPassword(byte[] ownerPassword, byte[] u, byte[] o, int permissions, byte[] id, int revision, int length) This will tell if this is the owner password or not.
Parameters: ownerPassword - The plaintext owner password. Parameters: u - The U value from the PDF Document. Parameters: o - The owner password hash. Parameters: permissions - The document permissions. Parameters: id - The document id. Parameters: revision - The revision of the encryption. Parameters: length - The length of the encryption key. | final public boolean | isUserPassword(byte[] password, byte[] u, byte[] o, int permissions, byte[] id, int revision, int length) This will tell if this is a valid user password.
Algorithm 3.6 pg 80
Parameters: password - The password to test. Parameters: u - The U value from the PDF Document. Parameters: o - The owner password hash. Parameters: permissions - The document permissions. Parameters: id - The document id. Parameters: revision - The revision of the encryption. Parameters: length - The length of the encryption key. |
ENCRYPT_PADDING | final public static byte[] ENCRYPT_PADDING(Code) | | The encryption padding defined in the PDF 1.4 Spec algorithm 3.2.
|
computeEncryptedKey | final public byte[] computeEncryptedKey(byte[] password, byte[] o, int permissions, byte[] id, int revision, int length) throws CryptographyException(Code) | | This will compute the encrypted key.
Parameters: password - The password used to compute the encrypted key. Parameters: o - The owner password hash. Parameters: permissions - The permissions for the document. Parameters: id - The document id. Parameters: revision - The security revision. Parameters: length - The length of the encryption key. The encryption key. throws: CryptographyException - If there is an error computing the key. |
computeOwnerPassword | final public byte[] computeOwnerPassword(byte[] ownerPassword, byte[] userPassword, int revision, int length) throws CryptographyException, IOException(Code) | | This algorithm is taked from PDF Reference 1.4 Algorithm 3.3 Page 79.
Parameters: ownerPassword - The plain owner password. Parameters: userPassword - The plain user password. Parameters: revision - The version of the security. Parameters: length - The length of the document. The computed owner password. throws: CryptographyException - If there is an error computing O. throws: IOException - If there is an error computing O. |
computeUserPassword | final public byte[] computeUserPassword(byte[] password, byte[] o, int permissions, byte[] id, int revision, int length) throws CryptographyException, IOException(Code) | | This will compute the user password hash.
Parameters: password - The plain text password. Parameters: o - The owner password hash. Parameters: permissions - The document permissions. Parameters: id - The document id. Parameters: revision - The revision of the encryption. Parameters: length - The length of the encryption key. The user password. throws: CryptographyException - If there is an error computing the user password. throws: IOException - If there is an IO error. |
encryptData | final public void encryptData(long objectNumber, long genNumber, byte[] key, InputStream data, OutputStream output) throws CryptographyException, IOException(Code) | | This will encrypt a piece of data.
Parameters: objectNumber - The id for the object. Parameters: genNumber - The generation id for the object. Parameters: key - The key used to encrypt the data. Parameters: data - The data to encrypt/decrypt. Parameters: output - The stream to write to. throws: CryptographyException - If there is an error encrypting the data. throws: IOException - If there is an io error. |
getUserPassword | final public byte[] getUserPassword(byte[] ownerPassword, byte[] o, int revision, long length) throws CryptographyException, IOException(Code) | | This will get the user password from the owner password and the documents o value.
Parameters: ownerPassword - The plaintext owner password. Parameters: o - The document's o entry. Parameters: revision - The document revision number. Parameters: length - The length of the encryption. The plaintext padded user password. throws: CryptographyException - If there is an error getting the user password. throws: IOException - If there is an error reading data. |
isOwnerPassword | final public boolean isOwnerPassword(byte[] ownerPassword, byte[] u, byte[] o, int permissions, byte[] id, int revision, int length) throws CryptographyException, IOException(Code) | | This will tell if this is the owner password or not.
Parameters: ownerPassword - The plaintext owner password. Parameters: u - The U value from the PDF Document. Parameters: o - The owner password hash. Parameters: permissions - The document permissions. Parameters: id - The document id. Parameters: revision - The revision of the encryption. Parameters: length - The length of the encryption key. true if the owner password matches the one from the document. throws: CryptographyException - If there is an error while executing crypt functions. throws: IOException - If there is an error while checking owner password. |
isUserPassword | final public boolean isUserPassword(byte[] password, byte[] u, byte[] o, int permissions, byte[] id, int revision, int length) throws CryptographyException, IOException(Code) | | This will tell if this is a valid user password.
Algorithm 3.6 pg 80
Parameters: password - The password to test. Parameters: u - The U value from the PDF Document. Parameters: o - The owner password hash. Parameters: permissions - The document permissions. Parameters: id - The document id. Parameters: revision - The revision of the encryption. Parameters: length - The length of the encryption key. true If this is the correct user password. throws: CryptographyException - If there is an error computing the value. throws: IOException - If there is an IO error while computing the owners password. |
|
|