microsoft / TSS.MSR

The TPM Software Stack from Microsoft Research
Other
428 stars 161 forks source link

TSS.Net - would be great to support NativeAOT; current AOT builds with a few warnings and constructs invalid packets #199

Open wisemoth opened 1 month ago

wisemoth commented 1 month ago

When TSS.Net is built for AOT there are a few warnings (after setting <TrimmerSingleWarn>false</TrimmerSingleWarn>) and, for example, the Tpm2StartupRequest command on the wire is invalid - it is missing the startupType field:

80 01 00 00 00 0A 00 00 01 44

When built to CLR, the field is present:

80 01 00 00 00 0C 00 00 01 44 00 00

minimal repro (with MS TPM Simulator on 127.0.0.1:2321):

using System;
using Tpm2Lib;

namespace TpmTest
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var tpmDevice = new TcpTpmDevice("127.0.0.1", 2321);
            tpmDevice.Connect();

            var tpm = new Tpm2(tpmDevice);
            Console.WriteLine("Power cycle TPM");
            tpmDevice.PowerCycle();

            Console.WriteLine("TPM powered up");
            tpm.Startup(Su.Clear);             // works in CLR, fails in AOT

            Console.WriteLine("TPM started up");
        }
    }
}