com.lowagie.text.pdf
Class PdfEncryption

java.lang.Object
  extended bycom.lowagie.text.pdf.PdfEncryption

public class PdfEncryption
extends Object

Author:
Paulo Soares (psoares@consiste.pt), Kazuya Ujihara

Field Summary
(package private)  byte[] documentID
           
(package private)  byte[] extra
          Work area to prepare the object/generation bytes
(package private)  byte[] key
          The encryption key for a particular object/generation
(package private)  int keySize
          The encryption key length for a particular object/generation
(package private)  MessageDigest md5
          The message digest algorithm MD5
(package private)  byte[] mkey
          The global encryption key
(package private)  byte[] ownerKey
          The encryption key for the owner
(package private) static byte[] pad
           
(package private)  int permissions
           
(package private) static long seq
           
(package private)  byte[] state
           
(package private)  byte[] userKey
          The encryption key for the user
(package private)  int x
           
(package private)  int y
           
 
Constructor Summary
PdfEncryption()
           
PdfEncryption(PdfEncryption enc)
           
 
Method Summary
private  byte[] computeOwnerKey(byte[] userPad, byte[] ownerPad, boolean strength128Bits)
           
static byte[] createDocumentId()
           
static PdfObject createInfoId(byte[] id)
           
 void encryptRC4(byte[] data)
           
 void encryptRC4(byte[] dataIn, byte[] dataOut)
           
 void encryptRC4(byte[] data, int off, int len)
           
 void encryptRC4(byte[] dataIn, int off, int len, byte[] dataOut)
           
 PdfDictionary getEncryptionDictionary()
           
 PdfObject getFileID()
           
private  byte[] padPassword(byte[] userPassword)
           
 void prepareKey()
           
 void prepareRC4Key(byte[] key)
           
 void prepareRC4Key(byte[] key, int off, int len)
           
 void setHashKey(int number, int generation)
           
 void setupAllKeys(byte[] userPassword, byte[] ownerPassword, int permissions, boolean strength128Bits)
           
private  void setupByOwnerPad(byte[] documentID, byte[] ownerPad, byte[] userKey, byte[] ownerKey, int permissions, boolean strength128Bits)
           
 void setupByOwnerPassword(byte[] documentID, byte[] ownerPassword, byte[] userKey, byte[] ownerKey, int permissions, boolean strength128Bits)
           
private  void setupByUserPad(byte[] documentID, byte[] userPad, byte[] ownerKey, int permissions, boolean strength128Bits)
           
 void setupByUserPassword(byte[] documentID, byte[] userPassword, byte[] ownerKey, int permissions, boolean strength128Bits)
           
private  void setupGlobalEncryptionKey(byte[] documentID, byte[] userPad, byte[] ownerKey, int permissions, boolean strength128Bits)
          ownerKey, documentID must be setuped
private  void setupUserKey()
          mkey must be setuped
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pad

static final byte[] pad

state

byte[] state

x

int x

y

int y

key

byte[] key
The encryption key for a particular object/generation


keySize

int keySize
The encryption key length for a particular object/generation


mkey

byte[] mkey
The global encryption key


extra

byte[] extra
Work area to prepare the object/generation bytes


md5

MessageDigest md5
The message digest algorithm MD5


ownerKey

byte[] ownerKey
The encryption key for the owner


userKey

byte[] userKey
The encryption key for the user


permissions

int permissions

documentID

byte[] documentID

seq

static long seq
Constructor Detail

PdfEncryption

public PdfEncryption()

PdfEncryption

public PdfEncryption(PdfEncryption enc)
Method Detail

padPassword

private byte[] padPassword(byte[] userPassword)

computeOwnerKey

private byte[] computeOwnerKey(byte[] userPad,
                               byte[] ownerPad,
                               boolean strength128Bits)

setupGlobalEncryptionKey

private void setupGlobalEncryptionKey(byte[] documentID,
                                      byte[] userPad,
                                      byte[] ownerKey,
                                      int permissions,
                                      boolean strength128Bits)
ownerKey, documentID must be setuped


setupUserKey

private void setupUserKey()
mkey must be setuped


setupAllKeys

public void setupAllKeys(byte[] userPassword,
                         byte[] ownerPassword,
                         int permissions,
                         boolean strength128Bits)

createDocumentId

public static byte[] createDocumentId()

setupByUserPassword

public void setupByUserPassword(byte[] documentID,
                                byte[] userPassword,
                                byte[] ownerKey,
                                int permissions,
                                boolean strength128Bits)

setupByUserPad

private void setupByUserPad(byte[] documentID,
                            byte[] userPad,
                            byte[] ownerKey,
                            int permissions,
                            boolean strength128Bits)

setupByOwnerPassword

public void setupByOwnerPassword(byte[] documentID,
                                 byte[] ownerPassword,
                                 byte[] userKey,
                                 byte[] ownerKey,
                                 int permissions,
                                 boolean strength128Bits)

setupByOwnerPad

private void setupByOwnerPad(byte[] documentID,
                             byte[] ownerPad,
                             byte[] userKey,
                             byte[] ownerKey,
                             int permissions,
                             boolean strength128Bits)

prepareKey

public void prepareKey()

setHashKey

public void setHashKey(int number,
                       int generation)

createInfoId

public static PdfObject createInfoId(byte[] id)

getEncryptionDictionary

public PdfDictionary getEncryptionDictionary()

prepareRC4Key

public void prepareRC4Key(byte[] key)

prepareRC4Key

public void prepareRC4Key(byte[] key,
                          int off,
                          int len)

encryptRC4

public void encryptRC4(byte[] dataIn,
                       int off,
                       int len,
                       byte[] dataOut)

encryptRC4

public void encryptRC4(byte[] data,
                       int off,
                       int len)

encryptRC4

public void encryptRC4(byte[] dataIn,
                       byte[] dataOut)

encryptRC4

public void encryptRC4(byte[] data)

getFileID

public PdfObject getFileID()