Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            try
            {
                using (var client = TpmClient.CreateSimulatorClient())
                {
                    //var endAuth = client.Tpm.EndorsementAuth;

                    //AuthSession s = client.Tpm.StartAuthSessionEx(TpmSe.Hmac, TpmAlgId.Sha256, SessionAttr.ContinueSession);

                    //client.Tpm.OwnerAuth = new AuthValue(new byte[] { 1, 2, 3 });

                    //client.Tpm._Behavior.Strict = true;

                    var helloWorld = Encoding.UTF8.GetBytes("Hello World");

                    var cipher   = RsaEncrypt(client.Tpm[Auth.Default], helloWorld);
                    var decipher = RsaDecrypt(client.Tpm[Auth.Default], cipher);

                    var helloWorld2 = Encoding.UTF8.GetString(decipher);

                    return;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Environment.Exit(500);
            }

            Environment.Exit(0);
        }
Ejemplo n.º 2
0
        internal static TpmClient CreateDeviceClient()
        {
            Tpm2Device tpmDevice = new TbsDevice();

            tpmDevice.Connect();

            var tpm = new Tpm2(tpmDevice);

            TpmClient client = new TpmClient(tpmDevice, tpm);

            return(client);
        }
Ejemplo n.º 3
0
        internal static TpmClient CreateSimulatorClient()
        {
            Tpm2Device tpmDevice = new TcpTpmDevice(DefaultSimulatorName, DefaultSimulatorPort);

            tpmDevice.Connect();

            var tpm = new Tpm2(tpmDevice);

            tpmDevice.PowerCycle();
            tpm.Startup(Su.Clear);

            TpmClient client = new TpmClient(tpmDevice, tpm);

            return(client);
        }