Пример #1
0
        /// <summary>
        /// Returns error number, i.e. what is left after masking out auxiliary data
        /// (such as format selector, version, and bad parameter index) from the
        /// response code returned by TPM.
        /// </summary>
        public static TpmRc ErrorNumber(TpmRc rawResponse)
        {
            if (Tpm2.IsTbsError(rawResponse) || Tpm2.IsTssError(rawResponse))
            {
                return(rawResponse);
            }

            const uint Fmt1 = (uint)TpmRc.RcFmt1;   // Format 1 code (TPM 2 only)
            const uint Ver1 = (uint)TpmRc.RcVer1;   // TPM 1 code (format 0 only)
            const uint Warn = (uint)TpmRc.RcWarn;   // Code is a warning (format 0 only)
            uint       mask = IsFmt1(rawResponse) ? Fmt1 | 0x3F : Warn | Ver1 | 0x7F;

            return((TpmRc)((uint)rawResponse & mask));
        }