Tpm2Lib.Tbs.SlotTypeFromHandle C# (CSharp) 메소드

SlotTypeFromHandle() 정적인 개인적인 메소드

static private SlotTypeFromHandle ( TpmHandle h ) : SlotType
h TpmHandle
리턴 SlotType
        internal static SlotType SlotTypeFromHandle(TpmHandle h)
        {
            switch (h.GetType())
            {
                case Ht.Transient:
                    return SlotType.ObjectSlot;
                case Ht.PolicySession:
                case Ht.HmacSession:
                    return SlotType.SessionSlot;
                default:
                    return SlotType.NoSlot;
            }
        }

Usage Example

예제 #1
0
        /// <summary>
        /// This TBS returns a random handle value in the desired handle range (ugh).
        /// </summary>
        /// <param name="owner"></param>
        /// <param name="tpmHandle"></param>
        /// <returns></returns>
        private uint GetFreeHandle(Tbs.TbsContext owner, TpmHandle tpmHandle)
        {
            Tbs.SlotType neededType = Tbs.SlotTypeFromHandle(tpmHandle);
            if (neededType == Tbs.SlotType.NoSlot)
            {
                return(tpmHandle.handle);
            }

            int numTries = 0;

            while (true)
            {
                Ht   handleType      = tpmHandle.GetType();
                var  randomPos       = (uint)Globs.GetRandomInt((int)TpmHandle.GetRangeLength(tpmHandle.GetType()));
                uint candidateHandle = ((uint)handleType << 24) + randomPos;

                if (!OwnerHandleInUse(owner, candidateHandle))
                {
                    return(candidateHandle);
                }

                numTries++;
                if (numTries >= 1000)
                {
                    break;
                }
            }
            throw new Exception("Too many TBS contexts");
        }
All Usage Examples Of Tpm2Lib.Tbs::SlotTypeFromHandle