public void TestBytes() { byte[] expect = new byte[] { 0x04, 0x00, 0x00, 0x00, 0x41, 0x42, 0x43, 0x44 }; Assert.Equal <byte[]>(expect, _reader.ReadBytes(8)); }
public void Deserialize(BEReader reader) { ServerTcpPort = reader.ReadUInt16(); ServerUdpPort = reader.ReadUInt16(); SessionId = new Guid(reader.ReadBytes(16)); RenderWidth = reader.ReadUInt16(); RenderHeight = reader.ReadUInt16(); MasterSessionKey = reader.ReadBytes(32); }
void ISerializable.Deserialize(BEReader reader) { TitleId = reader.ReadUInt32(); // This is weird: HasFocus = reader.ReadByte() == 128; TitleLocation = (ActiveTitleLocation)reader.ReadByte(); ProductId = new Guid(reader.ReadBytes(16)); SandboxId = new Guid(reader.ReadBytes(16)); AumId = reader.ReadString(); }
protected override void DeserializePayload(BEReader reader) { reader.ReadBytes(2); Flags = (DeviceFlags)reader.ReadUInt16(); DeviceType = (DeviceType)reader.ReadUInt16(); Name = reader.ReadString(); HardwareId = Guid.Parse(reader.ReadString()); reader.ReadBytes(4); Certificate = CryptoExtensions.DeserializeCertificateAsn(reader.ReadBlob()); }
void ISerializable.Deserialize(BEReader reader) { TitleId = reader.ReadUInt32(); ushort titleDisposition = reader.ReadUInt16(); HasFocus = (titleDisposition & 0x8000) == 0x8000; TitleLocation = (ActiveTitleLocation)(titleDisposition & 0x7FFF); ProductId = new Guid(reader.ReadBytes(16)); SandboxId = new Guid(reader.ReadBytes(16)); AumId = reader.ReadUInt16PrefixedString(); }
private byte[] ReadAndDecryptChunk(Stream stream) { var reader = new BEReader(stream); // 0xde, 0xad reader.ReadBytes(2); var length = reader.ReadUInt16(); var encryptedPayloadLength = length + BinaryExtensions.CalculatePaddingSize(length, 16); var encryptedPayloadBytes = new byte[encryptedPayloadLength]; var encryptedPayloadPosition = 0; while (encryptedPayloadPosition < encryptedPayloadLength - 1) { var received = reader.ReadBytes(encryptedPayloadLength - encryptedPayloadPosition); received.CopyTo(encryptedPayloadBytes, encryptedPayloadPosition); encryptedPayloadPosition += received.Length; } var signature = reader.ReadBytes(32); var bodyWriter = new BEWriter(); bodyWriter.Write(new byte[] { 0xde, 0xad }); bodyWriter.Write(length); bodyWriter.Write(encryptedPayloadBytes); var messageSignature = _cryptoContext.CalculateMessageSignature(bodyWriter.ToArray()); if (!signature.SequenceEqual(messageSignature)) { throw new InvalidDataException("Invalid message signature."); } var decryptedPayload = _cryptoContext.Decrypt(encryptedPayloadBytes); return(decryptedPayload.Take(length).ToArray()); }
protected override void DeserializePayload(BEReader reader) { InitVector = reader.ReadBytes(16); }