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(); }
public Tbs(Tpm2Device theUnderlyingTpm, bool tpmHasRm) { TpmDevice = theUnderlyingTpm; Tpm = new Tpm2(TpmDevice); ContextManager = new ObjectContextManager(); if (!tpmHasRm) { CleanTpm(); } }
protected override void Dispose(bool disposing) { Close(); if (disposing) { if (_tpmIO != null) { _tpmIO.Dispose(); _tpmIO = null; } if (TrmDevice != null) { TrmDevice.Dispose(); TrmDevice = null; } } }
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(); }
public void DestroyContext(Tpm2Device tpmDevice) { throw new NotImplementedException(""); }
public TpmPassThroughDevice(Tpm2Device underlyingDevice) { Device = underlyingDevice; }
/// <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); }
public void Dispose() { if (Device != null) { Device.Dispose(); } Device = null; }