Tpm2Lib.PcrValueCollection.GetSelectionHash C# (CSharp) Method

GetSelectionHash() public method

Get the hash of the concatenation of the values in the array order defined by the PcrSelection[] returned from GetPcrSelectionArray.
public GetSelectionHash ( TpmAlgId hashAlg ) : TpmHash
hashAlg TpmAlgId
return TpmHash
        public TpmHash GetSelectionHash(TpmAlgId hashAlg)
        {
            var m = new Marshaller();
            PcrSelection[] selections = GetPcrSelectionArray();
            foreach (PcrSelection sel in selections)
            {
                uint[] pcrIndices = sel.GetSelectedPcrs();
                foreach (uint index in pcrIndices)
                {
                    PcrValue v = GetSpecificValue(sel.hash, index);
                    m.Put(v.value.HashData, "hash");
                }
            }
            var valueHash = new TpmHash(hashAlg, CryptoLib.HashData(hashAlg, m.GetBytes()));
            return valueHash;
        }