public PcrSelection[] GetPcrSelectionArray()
{
// find all referenced algorithms
var referencedAlgs = new List<TpmAlgId>();
foreach (PcrValue v in Values)
{
// todo reference or value contains?
if (!referencedAlgs.Contains(v.value.HashAlg))
{
referencedAlgs.Add(v.value.HashAlg);
}
}
var selection = new PcrSelection[referencedAlgs.Count];
int count = 0;
foreach (TpmAlgId algId in referencedAlgs)
{
selection[count++] = new PcrSelection(algId, new uint[0]);
}
uint bankNum = 0;
foreach (TpmAlgId algId in referencedAlgs)
{
foreach (PcrValue val in Values)
{
if (val.value.HashAlg != algId)
{
continue;
}
// Do we already have a PcrValue with the same {alg, pcrNum?}
if (selection[bankNum].IsPcrSelected(val.index))
{
Globs.Throw("PcrValueCollection.GetPcrSelectionArray: PCR is referenced more than once");
}
// Else select it
selection[bankNum].SelectPcr(val.index);
}
bankNum++;
}
return selection;
}