public override void Write(byte[] buffer, int offset, int count) { byte[] dst = new byte[count]; Buffer.BlockCopy(buffer, offset, dst, 0, count); RC4ex.RC4(ref dst, this.RC4Key); this.stream.Write(dst, 0, count); }
private byte[] RC4HMACDecrypt(byte[] key, int keyLen, byte[] data, int dataLen, int Idk) { HMACMD5 hmacmd = new HMACMD5(key); byte[] bytes = BitConverter.GetBytes(Idk); byte[] buffer2 = hmacmd.ComputeHash(bytes, 0, 4); byte[] destinationArray = new byte[0x10]; Array.Copy(data, destinationArray, 0x10); byte[] buffer4 = new byte[data.Length - 0x10]; Array.Copy(data, 0x10, buffer4, 0, data.Length - 0x10); hmacmd.Key = buffer2; byte[] buffer5 = hmacmd.ComputeHash(destinationArray); RC4ex.RC4(ref buffer4, buffer5); return(buffer4); }
public override int Read(byte[] buffer, int offset, int count) { byte[] buffer2 = new byte[count]; int num = this.stream.Read(buffer2, 0, count); while (num != count) { int num2 = this.stream.Read(buffer2, num, count - num); if (num2 <= 0) { break; } num += num2; } RC4ex.RC4(ref buffer2, this.RC4Key); Buffer.BlockCopy(buffer2, 0, buffer, offset, num); return(num); }
private byte[] RC4HMACEncrypt(byte[] key, int keyLen, byte[] data, int dataLen, int Idk) { HMACMD5 hmacmd = new HMACMD5(key); byte[] bytes = BitConverter.GetBytes(Idk); byte[] buffer2 = hmacmd.ComputeHash(bytes, 0, 4); byte[] sourceArray = Conversion.HexStringToBytes("9b6bfacb5c488190"); byte[] destinationArray = new byte[data.Length + 8]; Array.Copy(sourceArray, destinationArray, 8); Array.Copy(data, 0, destinationArray, 8, data.Length); hmacmd.Key = buffer2; byte[] buffer = hmacmd.ComputeHash(destinationArray); byte[] buffer6 = hmacmd.ComputeHash(buffer); RC4ex.RC4(ref destinationArray, buffer6); byte[] buffer7 = new byte[dataLen + 0x18]; Array.Copy(buffer, 0, buffer7, 0, 0x10); Array.Copy(destinationArray, 0, buffer7, 0x10, destinationArray.Length); return(buffer7); }