void ISerializable.Serialize(BEWriter writer) { writer.Write(Id); writer.Write((ushort)Action); writer.Write(PointX); writer.Write(PointY); }
public override void Serialize(BEWriter writer) { writer.Write(Timestamp); writer.Write(AngularVelocityX); writer.Write(AngularVelocityY); writer.Write(AngularVelocityZ); }
public override void Serialize(BEWriter writer) { var messageWriter = new BEWriter(); base.Serialize(messageWriter); var message = messageWriter.ToArray(); var initVectorSource = message.Take(16).ToArray(); var initVector = Crypto.CreateDerivedInitVector(initVectorSource); var fragmentWriter = new BEWriter(); fragmentWriter.WriteWithPaddingAlignment( Fragment, payloadSizeAlignment); var encryptedFragment = Crypto.EncryptWithoutPadding(fragmentWriter.ToArray(), initVector); Header.Serialize(writer); writer.Write(encryptedFragment); var signature = Crypto.CalculateMessageSignature(writer.ToArray()); writer.Write(signature); }
public override void Serialize(BEWriter writer) { writer.Write(Timestamp); writer.Write(AccelerationX); writer.Write(AccelerationY); writer.Write(AccelerationZ); }
public void Serialize(BEWriter writer) { writer.Write((ushort)Type); writer.Write(PayloadLength); writer.Write(ProtectedPayloadLength); writer.Write(Version); }
public override void Serialize(BEWriter writer) { writer.Write(TextSessionId); writer.Write(TextBufferVersion); writer.Write(Start); writer.Write(Length); }
public override void Serialize(BEWriter writer) { writer.Write(Timestamp); writer.Write(Pitch); writer.Write(Roll); writer.Write(Yaw); }
protected override void SerializePayload(BEWriter writer) { writer.Write(Flags); writer.Write((ushort)DeviceType); writer.Write(MinVersion); writer.Write(MaxVersion); }
public override void Serialize(BEWriter writer) { writer.Write(SequenceBegin); writer.Write(SequenceEnd); writer.Write((ushort)Data.Length); writer.Write(Data); }
public override void Serialize(BEWriter writer) { writer.Write(TextSessionId); writer.Write(TextVersion); writer.Write(Flags); writer.Write((uint)Result); }
public override void Serialize(BEWriter writer) { writer.Write(TextSessionId); writer.Write(TextBufferVersion); writer.Write((ushort)Result); writer.WriteUInt16Prefixed(Text); }
protected override void SerializeProtectedPayload(BEWriter writer) { writer.WriteUInt16Prefixed(UserHash); writer.WriteUInt16Prefixed(Authorization); writer.Write(SequenceNumber); writer.Write(SequenceBegin); writer.Write(SequenceEnd); }
public override void Serialize(BEWriter writer) { writer.Write(Timestamp); writer.Write((ushort)Touchpoints.Length); foreach (TouchPoint p in Touchpoints) { ((ISerializable)p).Serialize(writer); } }
protected override void SerializePayload(BEWriter writer) { writer.Write(DeviceId.ToByteArray()); writer.Write(new byte[2]); writer.Write(PublicKey); writer.Write(InitVector); }
protected override void SerializePayload(BEWriter writer) { writer.Write(DeviceId.ToByteArray()); writer.Write((ushort)PublicKeyType); writer.Write(PublicKey); writer.Write(InitVector); }
public override void Serialize(BEWriter writer) { writer.Write(ChannelRequestId); writer.Write(TitleId); var uuidBytes = ServiceUuids[ServiceType]; writer.Write(uuidBytes); writer.Write(ActivityId); }
public override void Serialize(BEWriter writer) { var id = requestId++; writer.Write(id); writer.Write(State.TitleId); writer.Write((uint)State.Command); if (State.Command == MediaControlCommands.Seek) { writer.Write(State.SeekPosition); } }
public async Task SendAsync(byte[] bytes) { logger.LogTrace($"Sending auxiliary stream buffer: {bytes.Length} bytes"); var writer = new BEWriter(); writer.Write(new byte[] { 0xde, 0xad }); writer.Write((ushort)bytes.Length); writer.Write(_cryptoContext.Encrypt(bytes)); writer.Write(_cryptoContext.CalculateMessageSignature(writer.ToArray())); var buffer = writer.ToArray(); await _client.GetStream().WriteAsync(buffer, 0, buffer.Length); }
public static byte[] AssemblePacket(INanoPacket packet, NanoChannelContext context) { if (packet.Channel == NanoChannel.Unknown) { throw new NanoPackingException("AssemblePacket: INanoPacket.Channel is UNKNOWN"); } BEWriter packetWriter = new BEWriter(); BinaryWriter payloadWriter = new BinaryWriter(new MemoryStream()); packet.Serialize(payloadWriter); byte[] padding = Padding.CreatePaddingData( PaddingType.ANSI_X923, payloadWriter.ToBytes(), alignment: 4); payloadWriter.Write(padding); if (padding.Length > 0) { packet.Header.Padding = true; } packet.Header.ChannelId = context.GetChannelId(packet.Channel); packet.Header.Serialize(packetWriter); packetWriter.Write(payloadWriter.ToBytes()); return(packetWriter.ToBytes()); }
public override void Serialize(BEWriter writer) { writer.Write((ushort)DeviceType); writer.Write(NativeWidth); writer.Write(NativeHeight); writer.Write(DpiX); writer.Write(DpiY); writer.Write((long)DeviceCapabilities); writer.Write(ClientVersion); writer.Write(OsMajorVersion); writer.Write(OsMinorVersion); writer.Write(DisplayName); }
public override void Serialize(BEWriter writer) { writer.Write(TextSessionId); writer.Write(BaseVersion); writer.Write(SubmittedVersion); writer.Write(TotalTextBytelength); writer.Write(SelectionStart); writer.Write(SelectionLength); writer.Write(Flags); writer.Write(TextChunkByteStart); writer.Write(TextChunk); // writer.Write(Delta); }
public void Serialize(BEWriter 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.Write((ushort)flags); writer.Write(SequenceNumber); writer.Write(Timestamp); writer.Write(ConnectionId); writer.Write(ChannelId); }
public override void Serialize(BEWriter writer) { var protectedPayloadWriter = new BEWriter(); SerializeProtectedPayload(protectedPayloadWriter); var protectedPayload = protectedPayloadWriter.ToArray(); Header.ProtectedPayloadLength = (ushort)protectedPayload.Length; var encryptedPayload = protectedPayload.Length > 0 ? Crypto.Encrypt(protectedPayload, InitVector) : new byte[] {}; base.Serialize(writer); writer.Write(encryptedPayload); var signature = Crypto.CalculateMessageSignature(writer.ToArray()); writer.Write(signature); }
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()); }
public virtual void Serialize(BEWriter writer) { var payloadWriter = new BEWriter(); SerializePayload(payloadWriter); var payload = payloadWriter.ToArray(); Header.PayloadLength = (ushort)payload.Length; Header.Serialize(writer); writer.Write(payload); }
public override void Serialize(BEWriter writer) { writer.Write(State.Timestamp); writer.Write((ushort)State.Buttons); writer.Write(State.LeftTrigger); writer.Write(State.RightTrigger); writer.Write(State.LeftThumbstickX); writer.Write(State.LeftThumbstickY); writer.Write(State.RightThumbstickX); writer.Write(State.RightThumbstickY); }
public byte[] Encrypt(byte[] data) { var writer = new BEWriter(); byte[] padding = Padding.CreatePaddingData( PaddingType.PKCS7, data, alignment: 16); writer.Write(data); writer.Write(padding); var paddedData = writer.ToBytes(); var output = new byte[paddedData.Length]; for (var i = 0; i < paddedData.Length; i += 16) { _clientCipher.ProcessBlock(paddedData, i, output, i); } return(output); }
public override void Serialize(BEWriter writer) { writer.Write(Timestamp); writer.Write(RotationMatrixValue); writer.Write(RotationW); writer.Write(RotationX); writer.Write(RotationY); writer.Write(RotationZ); }
public void Serialize(BEWriter writer) { writer.Write((ushort)Type); writer.Write(PayloadLength); writer.Write(SequenceNumber); writer.Write(TargetParticipantId); writer.Write(SourceParticipantId); writer.Write((ushort)((ushort)SessionMessageType + ((IsFragment ? 1 : 0) << 12) + ((RequestAcknowledge ? 1 : 0) << 13) + (Version << 14))); writer.Write(ChannelId); }
public void Serialize(BEWriter bw) { BinaryWriter payloadWriter = new BinaryWriter(new MemoryStream()); Payload.Serialize(payloadWriter); byte[] padding = Padding.CreatePaddingData( PaddingType.ANSI_X923, payloadWriter.ToBytes(), alignment: 4); payloadWriter.Write(padding); if (padding.Length > 0) { Header.Padding = true; } Header.Serialize(bw); bw.Write(payloadWriter.ToBytes()); }