Example #1
0
        /// <summary>
        /// Reads the configured tpm devices from the configuration and
        /// sets up the corresponding tpm contexts
        /// </summary>
        private void SetupTPMContexts()
        {
            IConnectionsConfiguration connectionConfig = (IConnectionsConfiguration)ConfigurationManager.GetSection("connections");

            foreach (Iaik.Tc.TPM.Configuration.DotNetConfiguration.TPMDevice device in connectionConfig.TpmDevices)
            {
                try
                {
                    _logger.InfoFormat("Setting up tpm context '{0}'", device.TPMName);
                    TPMWrapper tpmDevice = new TPMWrapper();
                    tpmDevice.Init(device.TPMType, device.Parameters);
                    TPMContext tpmContext = new TPMContext(device.TPMName, tpmDevice);
                    _tpmContexts.Add(device.TPMName, tpmContext);

                    _logger.InfoFormat("Flushing device '{0}'", device.TPMName);
                    foreach (TPMResourceType resourceType in new TPMResourceType[] {
                        TPMResourceType.TPM_RT_AUTH, TPMResourceType.TPM_RT_KEY
                    })
                    {
                        Parameters listLoadedHandlesParameters = new Parameters();
                        listLoadedHandlesParameters.AddPrimitiveType("capArea", CapabilityData.TPMCapabilityArea.TPM_CAP_HANDLE);
                        listLoadedHandlesParameters.AddPrimitiveType("handle_type", resourceType);
                        TPMCommandRequest listLoadedHandlesRequest = new TPMCommandRequest(TPMCommandNames.TPM_CMD_GetCapability,
                                                                                           listLoadedHandlesParameters);
                        TPMCommandResponse response = tpmDevice.Process(listLoadedHandlesRequest);

                        if (response.Status == false)
                        {
                            throw new Exception("An unknown tpm exception while flushing occured");
                        }

                        foreach (uint handle in response.Parameters.GetValueOf <HandleList> ("handles"))
                        {
                            Parameters flushParameters = new Parameters();
                            flushParameters.AddValue("handle", HandleFactory.Create(resourceType, handle));
                            TPMCommandRequest  flushRequest  = new TPMCommandRequest(TPMCommandNames.TPM_CMD_FlushSpecific, flushParameters);
                            TPMCommandResponse flushResponse = tpmDevice.Process(flushRequest);

                            if (flushResponse.Status == false)
                            {
                                throw new Exception("Something went wrong while flushing");
                            }
                        }
                    }

                    _logger.InfoFormat("Successfully setup tpm context '{0}' with type '{1}'", device.TPMName, device.TPMType);
                }
                catch (Exception ex)
                {
                    _logger.FatalFormat("Error setting up tpm device '{0}', the device will not be available ({1})", device.TPMName, ex);
                }

                ///Set the Assembly search order for incoming Parameters so that core classes are always at first
                Parameters.AssemblySearchOrder = new Assembly[] {
                    typeof(TPMWrapper).Assembly,                     //lib core
                    typeof(ITypedParameter).Assembly
                };                                                   //lib common
            }
        }
Example #2
0
 public ProccessFileCommandService(
     IDataService dataService,
     TPMContext tpmCtx,
     ILogger <ProccessFileCommandService> logger
     )
 {
     this.DataService = dataService;
     this.TPMContext  = tpmCtx;
     this.Logger      = logger;
 }
Example #3
0
 public FileUploadController(
     TPMContext tpmCtx,
     IBackgroundQueue <ICommand> fileCommandQueue,
     ILogger <FileUploadController> logger,
     IConfiguration config
     ) : base(logger)
 {
     this.TPMContext           = tpmCtx;
     this.FileCommandQueue     = fileCommandQueue;
     this.StorageDirectoryPath = config.GetValue <string>("StorageDirectory");
 }
Example #4
0
 public ImportController(
     IDataService dataService,
     TPMContext tpmCtx,
     IMapper mapper,
     ILogger <ImportController> logger
     ) : base(logger)
 {
     this.DataService = dataService;
     this.TPMContext  = tpmCtx;
     this.Mapper      = mapper;
 }
 public ImportResultConfiguration(TPMContext ctx)
 {
     this.DbContext = ctx;
 }
 public UploadHistoryQueryConfiguration(TPMContext ctx)
 {
     this.DbContext = ctx;
 }
Example #7
0
 public UserConfiguration(TPMContext ctx)
 {
     this.DbContext = ctx;
 }
 public OperatorConfiguration(TPMContext ctx)
 {
     this.DbContext = ctx;
 }
Example #9
0
 public DataService(TPMContext tpmCtx)
 {
     this.TPMContext = tpmCtx;
 }
 public SwitchConfiguration(TPMContext ctx)
 {
     this.DbContext = ctx;
 }