public void prepareARCFOURKey(byte[] key) { prepareARCFOURKey(key, 0, key.length); }
public void prepareARCFOURKey(byte key[]) { prepareARCFOURKey(key, 0, key.length); }
public void prepareARCFOURKey(byte key[]) { prepareARCFOURKey(key, 0, key.length); }
/** Creates a new instance of StandardDecryption */ public StandardDecryption(byte key[], int off, int len, int revision) { aes = revision == AES_128; if (aes) { this.key = new byte[len]; System.arraycopy(key, off, this.key, 0, len); } else { arcfour = new ARCFOUREncryption(); arcfour.prepareARCFOURKey(key, off, len); } }
/** Creates a new instance of StandardDecryption */ public StandardDecryption(byte key[], int off, int len, int revision) { aes = revision == AES_128; if (aes) { this.key = new byte[len]; System.arraycopy(key, off, this.key, 0, len); } else { arcfour = new ARCFOUREncryption(); arcfour.prepareARCFOURKey(key, off, len); } }
/** Creates a new instance of StandardDecryption */ public StandardDecryption(byte[] key, int off, int len, int revision) { aes = revision == AES_128; if (aes) { this.key = new byte[len]; System.arraycopy(key, off, this.key, 0, len); } else { arcfour = new ARCFOUREncryption(); arcfour.prepareARCFOURKey(key, off, len); } }
/** */ private byte[] computeOwnerKey(byte userPad[], byte ownerPad[]) { byte ownerKey[] = new byte[32]; byte digest[] = md5.digest(ownerPad); if (revision == STANDARD_ENCRYPTION_128 || revision == AES_128) { byte mkey[] = new byte[keyLength / 8]; // only use for the input as many bit as the key consists of for (int k = 0; k < 50; ++k) System.arraycopy(md5.digest(digest), 0, digest, 0, mkey.length); System.arraycopy(userPad, 0, ownerKey, 0, 32); for (int i = 0; i < 20; ++i) { for (int j = 0; j < mkey.length; ++j) mkey[j] = (byte) (digest[j] ^ i); arcfour.prepareARCFOURKey(mkey); arcfour.encryptARCFOUR(ownerKey); } } else { arcfour.prepareARCFOURKey(digest, 0, 5); arcfour.encryptARCFOUR(userPad, ownerKey); } return ownerKey; }
/** */ private byte[] computeOwnerKey(byte userPad[], byte ownerPad[]) { byte ownerKey[] = new byte[32]; byte digest[] = md5.digest(ownerPad); if (revision == STANDARD_ENCRYPTION_128 || revision == AES_128) { byte mkey[] = new byte[keyLength / 8]; // only use for the input as many bit as the key consists of for (int k = 0; k < 50; ++k) System.arraycopy(md5.digest(digest), 0, digest, 0, mkey.length); System.arraycopy(userPad, 0, ownerKey, 0, 32); for (int i = 0; i < 20; ++i) { for (int j = 0; j < mkey.length; ++j) mkey[j] = (byte) (digest[j] ^ i); arcfour.prepareARCFOURKey(mkey); arcfour.encryptARCFOUR(ownerKey); } } else { arcfour.prepareARCFOURKey(digest, 0, 5); arcfour.encryptARCFOUR(userPad, ownerKey); } return ownerKey; }
/** */ private byte[] computeOwnerKey(byte[] userPad, byte[] ownerPad) { byte[] ownerKey = new byte[32]; byte[] digest = md5.digest(ownerPad); if (revision == STANDARD_ENCRYPTION_128 || revision == AES_128) { byte[] mkey = new byte[keyLength / 8]; // only use for the input as many bit as the key consists of for (int k = 0; k < 50; ++k) System.arraycopy(md5.digest(digest), 0, digest, 0, mkey.length); System.arraycopy(userPad, 0, ownerKey, 0, 32); for (int i = 0; i < 20; ++i) { for (int j = 0; j < mkey.length; ++j) mkey[j] = (byte) (digest[j] ^ i); arcfour.prepareARCFOURKey(mkey); arcfour.encryptARCFOUR(ownerKey); } } else { arcfour.prepareARCFOURKey(digest, 0, 5); arcfour.encryptARCFOUR(userPad, ownerKey); } return ownerKey; }
/** * * mkey must be setup */ // use the revision to choose the setup method private void setupUserKey() { if (revision == STANDARD_ENCRYPTION_128 || revision == AES_128) { md5.update(pad); byte digest[] = md5.digest(documentID); System.arraycopy(digest, 0, userKey, 0, 16); for (int k = 16; k < 32; ++k) userKey[k] = 0; for (int i = 0; i < 20; ++i) { for (int j = 0; j < mkey.length; ++j) digest[j] = (byte) (mkey[j] ^ i); arcfour.prepareARCFOURKey(digest, 0, mkey.length); arcfour.encryptARCFOUR(userKey, 0, 16); } } else { arcfour.prepareARCFOURKey(mkey); arcfour.encryptARCFOUR(pad, userKey); } }
/** * * mkey must be setup */ // use the revision to choose the setup method private void setupUserKey() { if (revision == STANDARD_ENCRYPTION_128 || revision == AES_128) { md5.update(pad); byte[] digest = md5.digest(documentID); System.arraycopy(digest, 0, userKey, 0, 16); for (int k = 16; k < 32; ++k) userKey[k] = 0; for (int i = 0; i < 20; ++i) { for (int j = 0; j < mkey.length; ++j) digest[j] = (byte) (mkey[j] ^ i); arcfour.prepareARCFOURKey(digest, 0, mkey.length); arcfour.encryptARCFOUR(userKey, 0, 16); } } else { arcfour.prepareARCFOURKey(mkey); arcfour.encryptARCFOUR(pad, userKey); } }
/** * * mkey must be setup */ // use the revision to choose the setup method private void setupUserKey() { if (revision == STANDARD_ENCRYPTION_128 || revision == AES_128) { md5.update(pad); byte digest[] = md5.digest(documentID); System.arraycopy(digest, 0, userKey, 0, 16); for (int k = 16; k < 32; ++k) userKey[k] = 0; for (int i = 0; i < 20; ++i) { for (int j = 0; j < mkey.length; ++j) digest[j] = (byte) (mkey[j] ^ i); arcfour.prepareARCFOURKey(digest, 0, mkey.length); arcfour.encryptARCFOUR(userKey, 0, 16); } } else { arcfour.prepareARCFOURKey(mkey); arcfour.encryptARCFOUR(pad, userKey); } }
/** Creates a new instance of OutputStreamCounter */ public OutputStreamEncryption(OutputStream out, byte[] key, int off, int len, int revision) { try { this.out = out; aes = revision == AES_128; if (aes) { byte[] iv = IVGenerator.getIV(); byte[] nkey = new byte[len]; System.arraycopy(key, off, nkey, 0, len); cipher = new AESCipher(true, nkey, iv); write(iv); } else { arcfour = new ARCFOUREncryption(); arcfour.prepareARCFOURKey(key, off, len); } } catch (Exception ex) { throw new ExceptionConverter(ex); } }
/** Creates a new instance of OutputStreamCounter */ public OutputStreamEncryption(OutputStream out, byte key[], int off, int len, int revision) { try { this.out = out; aes = revision == AES_128; if (aes) { byte[] iv = IVGenerator.getIV(); byte[] nkey = new byte[len]; System.arraycopy(key, off, nkey, 0, len); cipher = new AESCipher(true, nkey, iv); write(iv); } else { arcfour = new ARCFOUREncryption(); arcfour.prepareARCFOURKey(key, off, len); } } catch (Exception ex) { throw new ExceptionConverter(ex); } }
/** Creates a new instance of OutputStreamCounter */ public OutputStreamEncryption(OutputStream out, byte key[], int off, int len, int revision) { try { this.out = out; aes = revision == AES_128; if (aes) { byte[] iv = IVGenerator.getIV(); byte[] nkey = new byte[len]; System.arraycopy(key, off, nkey, 0, len); cipher = new AESCipher(true, nkey, iv); write(iv); } else { arcfour = new ARCFOUREncryption(); arcfour.prepareARCFOURKey(key, off, len); } } catch (Exception ex) { throw new ExceptionConverter(ex); } }