Beispiel #1
0
        public static Tpm2bDigest[] SafePcrRead(Tpm2 tpm, PcrSelection sel)
        {
            PcrSelection[] selOut;
            var            selIn     = new PcrSelection[] { sel.Copy() };
            var            pcrValues = new Tpm2bDigest[0];

            do
            {
                Tpm2bDigest[] vals;
                tpm.PcrRead(selIn, out selOut, out vals);
                pcrValues = pcrValues.Concat(vals).ToArray();
                Debug.Assert(selOut.Length == 1);
                // The first part of the while condition is used to by pass not
                // implemented PCRs
            } while (!Globs.IsZeroBuffer(selOut[0].pcrSelect) &&
                     selIn[0].Clear(selOut[0]));
            Debug.Assert(selIn[0].GetSelectedPcrs().Length == 0);
            Debug.Assert(sel.GetSelectedPcrs().Length == pcrValues.Length);
            return(pcrValues);
        }