예제 #1
0
 void ISerializable.Serialize(EndianWriter writer)
 {
     writer.WriteBE(Id);
     writer.WriteBE((ushort)Action);
     writer.WriteBE(PointX);
     writer.WriteBE(PointY);
 }
예제 #2
0
 public override void Serialize(EndianWriter writer)
 {
     writer.WriteBE(Timestamp);
     writer.WriteBE(Pitch);
     writer.WriteBE(Roll);
     writer.WriteBE(Yaw);
 }
예제 #3
0
 public void Serialize(EndianWriter writer)
 {
     writer.WriteBE((ushort)Type);
     writer.WriteBE(PayloadLength);
     writer.WriteBE(ProtectedPayloadLength);
     writer.WriteBE(Version);
 }
예제 #4
0
 public override void Serialize(EndianWriter writer)
 {
     writer.WriteBE(TextSessionId);
     writer.WriteBE(TextBufferVersion);
     writer.WriteBE((ushort)Result);
     writer.WriteUInt16BEPrefixed(Text);
 }
 public override void Serialize(EndianWriter writer)
 {
     writer.WriteBE(Timestamp);
     writer.WriteBE(AccelerationX);
     writer.WriteBE(AccelerationY);
     writer.WriteBE(AccelerationZ);
 }
 public override void Serialize(EndianWriter writer)
 {
     writer.WriteBE(TextSessionId);
     writer.WriteBE(TextBufferVersion);
     writer.WriteBE(Start);
     writer.WriteBE(Length);
 }
 protected override void SerializePayload(EndianWriter writer)
 {
     writer.WriteBE(Flags);
     writer.WriteBE((ushort)DeviceType);
     writer.WriteBE(MinVersion);
     writer.WriteBE(MaxVersion);
 }
예제 #8
0
 public override void Serialize(EndianWriter writer)
 {
     writer.WriteBE(Timestamp);
     writer.WriteBE(AngularVelocityX);
     writer.WriteBE(AngularVelocityY);
     writer.WriteBE(AngularVelocityZ);
 }
 public override void Serialize(EndianWriter writer)
 {
     writer.WriteBE(TextSessionId);
     writer.WriteBE(TextVersion);
     writer.WriteBE(Flags);
     writer.WriteBE((uint)Result);
 }
예제 #10
0
 public override void Serialize(EndianWriter writer)
 {
     writer.WriteBE(SequenceBegin);
     writer.WriteBE(SequenceEnd);
     writer.WriteBE((ushort)Data.Length);
     writer.Write(Data);
 }
        protected override void SerializeProtectedPayload(EndianWriter writer)
        {
            writer.WriteUInt16BEPrefixed(UserHash);
            writer.WriteUInt16BEPrefixed(Authorization);

            writer.WriteBE(SequenceNumber);
            writer.WriteBE(SequenceBegin);
            writer.WriteBE(SequenceEnd);
        }
예제 #12
0
 public override void Serialize(EndianWriter writer)
 {
     writer.WriteBE(Timestamp);
     writer.WriteBE((ushort)Touchpoints.Length);
     foreach (TouchPoint p in Touchpoints)
     {
         ((ISerializable)p).Serialize(writer);
     }
 }
예제 #13
0
        public override void Serialize(EndianWriter writer)
        {
            writer.WriteBE(ChannelRequestId);
            writer.WriteBE(TitleId);

            var uuidBytes = ServiceUuids[ServiceType];

            writer.Write(uuidBytes);

            writer.WriteBE(ActivityId);
        }
예제 #14
0
        public override void Serialize(EndianWriter writer)
        {
            var id = requestId++;

            writer.WriteBE(id);
            writer.WriteBE(State.TitleId);
            writer.WriteBE((uint)State.Command);

            if (State.Command == MediaControlCommands.Seek)
            {
                writer.WriteBE(State.SeekPosition);
            }
        }
예제 #15
0
        public void Serialize(EndianWriter writer)
        {
            var flags = 0;

            flags |= (Version & 3) << 14;
            flags |= (Padding ? 1 : 0) << 13;
            flags |= (Extension ? 1 : 0) << 12;
            flags |= (CsrcCount & 0xF) << 8;
            flags |= (Marker ? 1 : 0) << 7;
            flags |= (byte)PayloadType & 0x7F;

            writer.WriteBE((ushort)flags);
            writer.WriteBE(SequenceNumber);
            writer.WriteBE(Timestamp);
            writer.WriteBE(ConnectionId);
            writer.WriteBE(ChannelId);
        }
        protected override void SerializePayload(EndianWriter writer)
        {
            writer.Write(DeviceId.ToByteArray());

            writer.WriteBE((ushort)PublicKeyType);
            writer.Write(PublicKey);

            writer.Write(InitVector);
        }
예제 #17
0
        public override void Serialize(EndianWriter writer)
        {
            writer.WriteBE((ushort)DeviceType);
            writer.WriteBE(NativeWidth);
            writer.WriteBE(NativeHeight);
            writer.WriteBE(DpiX);
            writer.WriteBE(DpiY);

            writer.WriteBE((long)DeviceCapabilities);

            writer.WriteBE(ClientVersion);
            writer.WriteBE(OsMajorVersion);
            writer.WriteBE(OsMinorVersion);

            writer.WriteUInt16BEPrefixed(DisplayName);
        }
예제 #18
0
 public override void Serialize(EndianWriter writer)
 {
     writer.WriteBE(TextSessionId);
     writer.WriteBE(BaseVersion);
     writer.WriteBE(SubmittedVersion);
     writer.WriteBE(TotalTextBytelength);
     writer.WriteBE(SelectionStart);
     writer.WriteBE(SelectionLength);
     writer.WriteBE(Flags);
     writer.WriteBE(TextChunkByteStart);
     writer.WriteUInt16BEPrefixed(TextChunk);
     // writer.Write(Delta);
 }
예제 #19
0
        public override void Serialize(EndianWriter writer)
        {
            writer.WriteBE(State.Timestamp);

            writer.WriteBE((ushort)State.Buttons);

            writer.WriteBE(State.LeftTrigger);
            writer.WriteBE(State.RightTrigger);

            writer.WriteBE(State.LeftThumbstickX);
            writer.WriteBE(State.LeftThumbstickY);

            writer.WriteBE(State.RightThumbstickX);
            writer.WriteBE(State.RightThumbstickY);
        }
예제 #20
0
 public override void Serialize(EndianWriter writer)
 {
     writer.WriteBE(Timestamp);
     writer.WriteBE(RotationMatrixValue);
     writer.WriteBE(RotationW);
     writer.WriteBE(RotationX);
     writer.WriteBE(RotationY);
     writer.WriteBE(RotationZ);
 }
        /// <summary>
        /// Sends an auxiliary chunk.
        /// </summary>
        /// <returns>The async.</returns>
        /// <param name="bytes">Plaintext bytes.</param>
        public async Task SendAsync(byte[] bytes)
        {
            logger.LogTrace($"Sending auxiliary stream buffer: {bytes.Length} bytes");

            var writer = new EndianWriter();

            writer.Write(new byte[] { 0xde, 0xad });
            writer.WriteBE((ushort)bytes.Length);
            writer.Write(_cryptoContext.Encrypt(bytes));
            writer.Write(_cryptoContext.CalculateMessageSignature(writer.ToBytes()));

            var buffer = writer.ToBytes();

            await _client.GetStream().WriteAsync(buffer, 0, buffer.Length);
        }
예제 #22
0
        public void Serialize(EndianWriter writer)
        {
            writer.WriteBE((ushort)Type);
            writer.WriteBE(PayloadLength);
            writer.WriteBE(SequenceNumber);
            writer.WriteBE(TargetParticipantId);
            writer.WriteBE(SourceParticipantId);

            writer.WriteBE((ushort)((ushort)SessionMessageType +
                                    ((IsFragment ? 1 : 0) << 12) +
                                    ((RequestAcknowledge ? 1 : 0) << 13) +
                                    (Version << 14)));

            writer.WriteBE(ChannelId);
        }
        /// <summary>
        /// Reads and decrypts auxiliary channel chunk.
        /// </summary>
        /// <returns>Decrypted chunk.</returns>
        /// <param name="stream">Stream.</param>
        private byte[] ReadAndDecryptChunk(Stream stream)
        {
            var reader = new EndianReader(stream);

            // 0xde, 0xad
            reader.ReadBytes(2);

            var length = reader.ReadUInt16BE();

            var encryptedPayloadLength = length + Padding.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 EndianWriter();

            bodyWriter.Write(new byte[] { 0xde, 0xad });
            bodyWriter.WriteBE(length);
            bodyWriter.Write(encryptedPayloadBytes);

            var messageSignature = _cryptoContext.CalculateMessageSignature(bodyWriter.ToBytes());

            if (!signature.SequenceEqual(messageSignature))
            {
                throw new InvalidDataException("Invalid message signature.");
            }

            var decryptedPayload = _cryptoContext.Decrypt(encryptedPayloadBytes);

            return(decryptedPayload.Take(length).ToArray());
        }
 public override void Serialize(EndianWriter writer)
 {
     writer.WriteBE(ChannelIdToStop);
 }
 public override void Serialize(EndianWriter writer)
 {
     writer.WriteBE(TitleId);
 }
예제 #26
0
 public override void Serialize(EndianWriter writer)
 {
     writer.WriteBE(Timestamp);
     writer.WriteBE(MagneticNorth);
     writer.WriteBE(TrueNorth);
 }
예제 #27
0
 public override void Serialize(EndianWriter writer)
 {
     writer.WriteBE(LowWatermark);
     writer.WriteBE(ProcessedList);
     writer.WriteBE(RejectedList);
 }
예제 #28
0
 public override void Serialize(EndianWriter writer)
 {
     writer.WriteBE((uint)Reason);
     writer.WriteBE(ErrorCode);
 }
예제 #29
0
 public override void Serialize(EndianWriter writer)
 {
     writer.WriteBE(TextSessionId);
     writer.WriteBE(TextVersionAck);
 }
 public override void Serialize(EndianWriter writer)
 {
     writer.WriteBE(StartTimeDelta);
     writer.WriteBE(EndTimeDelta);
 }