/// <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));
}