/** */ private byte[] ComputeOwnerKey(byte[] userPad, byte[] ownerPad) { byte[] ownerKey = new byte[32]; byte[] digest = DigestAlgorithms.Digest("MD5", 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) { Array.Copy(DigestAlgorithms.Digest("MD5", digest, 0, mkey.Length), 0, digest, 0, mkey.Length); } Array.Copy(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); } rc4.PrepareARCFOURKey(mkey); rc4.EncryptARCFOUR(ownerKey); } } else { rc4.PrepareARCFOURKey(digest, 0, 5); rc4.EncryptARCFOUR(userPad, ownerKey); } return(ownerKey); }
protected internal virtual byte[] ComputeOwnerKey(byte[] userPad, byte[] ownerPad) { byte[] ownerKey = new byte[32]; byte[] digest = md5.Digest(ownerPad); arcfour.PrepareARCFOURKey(digest, 0, 5); arcfour.EncryptARCFOUR(userPad, ownerKey); return(ownerKey); }
public override void Write(byte[] b, int off, int len) { if (aes) { byte[] b2 = cipher.Update(b, off, len); if (b2 == null || b2.Length == 0) { return; } outc.Write(b2, 0, b2.Length); } else { byte[] b2 = new byte[Math.Min(len, 4192)]; while (len > 0) { int sz = Math.Min(len, b2.Length); arcfour.EncryptARCFOUR(b, off, sz, b2, 0); outc.Write(b2, 0, sz); len -= sz; off += sz; } } }
public virtual byte[] Update(byte[] b, int off, int len) { byte[] b2 = new byte[len]; arcfour.EncryptARCFOUR(b, off, len, b2, 0); return(b2); }