示例#1
0
        public LinuxTpmDevice(string tpmDevicePath = null)
        {
            _tpmDevicePath = tpmDevicePath ?? "/dev/tpmrm0";
            //Tpm2Device dev = new LinuxTpmDevice("/dev/tpmrm0");
            try
            {
                Connect();
            }
            catch (Exception)
            {
                //Console.WriteLine("Failed to connect to " + tpmDevicePath);

                // If the first attempt to connect was to the kernel mode TRM,
                // then try to connect to the raw TPM device, and vice versa.
                _tpmDevicePath = _tpmDevicePath.Contains("/dev/tpmrm")
                               ? _tpmDevicePath.Replace("/dev/tpmrm", "/dev/tpm") : "/dev/tpmrm0";
                try
                {
                    Connect();
                }
                catch (Exception)
                {
                    //Console.WriteLine("Failed to connect to " + tpmDevicePath);
                    Debug.Assert(_tpmIO == null);
                    TrmDevice = new TcpTpmDevice("127.0.0.1", 2323, false, true);
                    TrmDevice.Connect();
                }
            }
            Close();
        }
示例#2
0
 public Tbs(Tpm2Device theUnderlyingTpm, bool tpmHasRm)
 {
     TpmDevice      = theUnderlyingTpm;
     Tpm            = new Tpm2(TpmDevice);
     ContextManager = new ObjectContextManager();
     if (!tpmHasRm)
     {
         CleanTpm();
     }
 }
示例#3
0
 public Tbs(Tpm2Device theUnderlyingTpm, bool tpmHasRm)
 {
     TpmDevice = theUnderlyingTpm;
     Tpm = new Tpm2(TpmDevice);
     ContextManager = new ObjectContextManager();
     if (!tpmHasRm)
     {
         CleanTpm();
     }
 }
示例#4
0
 protected override void Dispose(bool disposing)
 {
     Close();
     if (disposing)
     {
         if (_tpmIO != null)
         {
             _tpmIO.Dispose();
             _tpmIO = null;
         }
         if (TrmDevice != null)
         {
             TrmDevice.Dispose();
             TrmDevice = null;
         }
     }
 }
示例#5
0
        public LinuxTpmDevice(string tpmDevicePath = null)
        {
            _tpmDevicePath = tpmDevicePath ?? "/dev/tpm0";
//            _tpmDevicePath = tpmDevicePath ?? "/dev/tpmrm0";
            try
            {
                Connect();
            }
            catch (Exception)
            {
                //Console.WriteLine("Failed to connect to " + tpmDevicePath);

                try
                {
                    TctiCtx = AbrmdWrapper.Load(out TctiCtxPtr);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Exception while loading tpm2-abrmd: {e}");
                }

                if (TctiCtx == null)
                {
                    // If the first attempt to connect was to the kernel mode TRM,
                    // then try to connect to the raw TPM device, and vice versa.
                    _tpmDevicePath = _tpmDevicePath.Contains("/dev/tpmrm")
                                   ? _tpmDevicePath.Replace("/dev/tpmrm", "/dev/tpm") : "/dev/tpmrm0";
                    try
                    {
                        Connect();
                    }
                    catch (Exception)
                    {
                        //Console.WriteLine("Failed to connect to " + tpmDevicePath);
                        Debug.Assert(_tpmIO == null);

                        TrmDevice = new TcpTpmDevice("127.0.0.1", 2323, false, true);
                        TrmDevice.Connect();
                    }
                }
            }
            Close();
        }
示例#6
0
 public void DestroyContext(Tpm2Device tpmDevice)
 {
     throw new NotImplementedException("");
 }
示例#7
0
 public TpmPassThroughDevice(Tpm2Device underlyingDevice)
 {
     Device = underlyingDevice;
 }
示例#8
0
 public void DestroyContext(Tpm2Device tpmDevice)
 {
     throw new NotImplementedException("");
 }
示例#9
0
 /// <summary>
 /// A Tpm2 must be created attached to an underlying device
 /// </summary>
 /// <param name="device"></param>
 /// <param name="mode"></param>
 public Tpm2(Tpm2Device device, Behavior b = Behavior.Default)
 {
     Device = device;
     _Behavior = b;
     Sessions = new SessionBase[0];
     Helpers = new TpmHelpers(this);
 }
示例#10
0
 public void Dispose()
 {
     if (Device != null)
     {
         Device.Dispose();
     }
     Device = null;
 }