Tpm2Lib.Tpm2.GetProperty C# (CSharp) Method

GetProperty() public static method

public static GetProperty ( Tpm2 tpm, Pt prop ) : uint
tpm Tpm2
prop Pt
return uint
        public static uint GetProperty(Tpm2 tpm, Pt prop)
        {
            ICapabilitiesUnion caps;
            tpm.GetCapability(Cap.TpmProperties, (uint)prop, 1, out caps);
            var props = (TaggedTpmPropertyArray)caps;
            TaggedProperty[] arr = props.tpmProperty;
            if (arr.Length != 1)
            {
                Globs.Throw("Unexpected return from GetCapability");
                if (arr.Length == 0)
                    return 0;
            }

            uint val = arr[0].value;
            return val;
        }

Usage Example

Exemplo n.º 1
0
 /// <summary>
 /// Check if this TPM implements the given command.
 /// The method sends the GetCapability command the first time it is called,
 /// and reuses its results during subsequent invocations.
 /// </summary>
 /// <param name="commandCode">The command code to check.</param>
 /// <returns>true if the given command is supported by this TPM instance.</returns>
 public bool IsImplemented(TpmCc commandCode)
 {
     if (ImplementedCommands == null || ImplementedCommands.Length == 0)
     {
         ICapabilitiesUnion caps;
         uint totalCommands = Tpm2.GetProperty(Tpm, Pt.TotalCommands);
         Tpm.GetCapability(Cap.Commands, (uint)TpmCc.First, totalCommands, out caps);
         ImplementedCommands = Globs.ConvertAll((caps as CcaArray).commandAttributes,
                                                cmdAttr => (TpmCc)(cmdAttr & CcAttr.commandIndexBitMask))
                               .ToArray();
         Debug.Assert(ImplementedCommands.Length != 0);
     }
     return(ImplementedCommands.Contains(commandCode));
 }
Tpm2