public override void DispatchCommand(CommandModifier active, byte[] inBuf, out byte[] outBuf) { outBuf = new byte[] { 0x80, 0x01, // TPM_ST_NO_SESSIONS 0, 0, 0, 0x0A, // length 0x40, 0x28, 0x00, 0x10 // TSS_DISPATCH_FAILED }; if (CommandStream == null) { return; } if (LinuxTrm) { if (Globs.NetToHost4U(Globs.CopyData(inBuf, 6, 4)) == (uint)TpmCc.Startup) { outBuf[6] = outBuf[7] = 0; outBuf[8] = 0x01; outBuf[9] = 0; // TPM_RC_INITIALIZE return; } } UndoCancelContext(); var b = new ByteBuf(); b.Append(Globs.HostToNet((int)TcpTpmCommands.SendCommand)); b.Append(new[] { active.ActiveLocality }); if (LinuxTrm && OldTrm) { b.Append(new byte [] { 0, 1 }); } b.Append(Globs.HostToNet(inBuf.Length)); b.Append(inBuf); Write(CommandStream, b.GetBuffer()); outBuf = ReadVarArray(CommandStream); GetAck(CommandStream, "DispatchCommand"); }
private void SendVarArrayCmdAndGetAck(NetworkStream stream, TcpTpmCommands cmd, byte[] buf) { var b = new ByteBuf(); b.Append(Globs.HostToNet((int)cmd)); b.Append(Globs.HostToNet(buf.Length)); b.Append(buf); Write(stream, b.GetBuffer()); GetAck(stream, cmd.ToString()); }
void ToNetValueType(Object o, string name) { if (Repr == DataRepresentation.Tpm) { Buffer.Append(Globs.HostToNet(o)); return; } if (Repr == DataRepresentation.LittleEndian) { Buffer.Append(Globs.GetBytes(o)); } throw new Exception("Unsupported marshaling type"); }
public override void DispatchCommand(CommandModifier active, byte[] inBuf, out byte[] outBuf) { UndoCancelContext(); var b = new ByteBuf(); b.Append(Globs.HostToNet((int)TcpTpmCommands.SendCommand)); b.Append(new[] { active.ActiveLocality }); b.Append(Globs.HostToNet(inBuf.Length)); b.Append(inBuf); Write(CommandStream, b.GetBuffer()); outBuf = ReadVarArray(CommandStream); GetAck(CommandStream, "DispatchCommand"); }