示例#1
0
        public int NumEntitiesInTpm()
        {
            int num1 = GetLoadedEntities(Tpm, Ht.Transient).Length;
            int num2 = GetLoadedEntities(Tpm, Ht.LoadedSession).Length;
            int num3 = GetLoadedEntities(Tpm, TpmHelpers.GetEnumerator <Ht>("ActiveSession", "SavedSession")).Length;

            return(num1 + num2 + num3);
        }
示例#2
0
        private TpmHandle[] GetAllLoadedEntities(Tpm2 tpm)
        {
            var handles = new List <TpmHandle>();

            handles.AddRange(GetLoadedEntities(tpm, Ht.Transient));
            handles.AddRange(GetLoadedEntities(tpm, Ht.LoadedSession));
            handles.AddRange(GetLoadedEntities(tpm, TpmHelpers.GetEnumerator <Ht>("ActiveSession", "SavedSession")));
            return(handles.ToArray());
        }
示例#3
0
        private void CleanTpm()
        {
            var loaded = new TpmHandle[3][];

            loaded[0] = GetLoadedEntities(Tpm, Ht.Transient);
            loaded[1] = GetLoadedEntities(Tpm, Ht.LoadedSession);
            loaded[2] = GetLoadedEntities(Tpm, TpmHelpers.GetEnumerator <Ht>("ActiveSession", "SavedSession"));
            foreach (TpmHandle[] arr in loaded)
            {
                foreach (TpmHandle h in arr)
                {
                    Tpm.FlushContext(h);
                }
            }
        }
示例#4
0
        private void CheckConsistency(string message = "")
        {
            TpmHandle[] loadedObjects        = GetLoadedEntities(Tpm, Ht.Transient);
            TpmHandle[] loadedSessions       = GetLoadedEntities(Tpm, Ht.LoadedSession);
            TpmHandle[] contextSavedSessions = GetLoadedEntities(Tpm, TpmHelpers.GetEnumerator <Ht>("ActiveSession", "SavedSession"));

            int numLoadedObject = 0, numLoadedSession = 0, numSavedSession = 0;

            foreach (ObjectContext o in ContextManager.ObjectContexts)
            {
                if (o.TheSlotType == SlotType.ObjectSlot)
                {
                    if (!o.Loaded)
                    {
                        continue;
                    }
                    Debug.Assert(loadedObjects.Contains(o.TheTpmHandle));
                    numLoadedObject++;
                }

                if (o.TheSlotType == SlotType.SessionSlot)
                {
                    if (o.Loaded)
                    {
                        Debug.Assert(loadedSessions.Contains(o.TheTpmHandle));
                        numLoadedSession++;
                    }
                    else
                    {
                        TpmHandle translatedHandle = new TpmHandle(Ht.LoadedSession, o.Context.savedHandle.GetOffset());
                        Debug.Assert(contextSavedSessions.Contains(translatedHandle));
                        numSavedSession++;
                    }
                }
            }

            Debug.Assert(numLoadedObject == loadedObjects.Length);
            Debug.Assert(numLoadedSession == loadedSessions.Length);
            Debug.Assert(numSavedSession == contextSavedSessions.Length);
        }