Esempio n. 1
0
        /**
         */
        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);
 }
Esempio n. 3
0
 public OutputStreamEncryption(Stream outc, byte[] key, int off, int len, int revision)
 {
     this.outc = outc;
     aes       = (revision == AES_128 || revision == AES_256);
     if (aes)
     {
         byte[] iv   = IVGenerator.GetIV();
         byte[] nkey = new byte[len];
         System.Array.Copy(key, off, nkey, 0, len);
         cipher = new AESCipher(true, nkey, iv);
         Write(iv, 0, iv.Length);
     }
     else
     {
         arcfour = new ARCFOUREncryption();
         arcfour.PrepareARCFOURKey(key, off, len);
     }
 }
 /// <summary>Creates a new instance of StandardDecryption</summary>
 public StandardDecryptor(byte[] key, int off, int len)
 {
     arcfour = new ARCFOUREncryption();
     arcfour.PrepareARCFOURKey(key, off, len);
 }