private string DecodeError()

in TpmRcDecoder/TpmRcDecoder.Universal/Decoder.cs [762:800]


        private string DecodeError(UInt32 input)
        {
            UInt32 error = input & TPM_RC_ERROR_MASK;
            if ((input & TPM_RC_VER1) == TPM_RC_VER1)
            {
                error += TPM_RC_VER1;
            }

            string output = string.Format("TPM Error (0x{0:x}):", input);

            string error20 = Enum.GetName(typeof(TPM_RC_VER1_CODES), error);
            string error12 = Enum.GetName(typeof(TPM_12_ERROR_CODES), error);

            if (!string.IsNullOrEmpty(error20))
            {
                output += "\n Error (2.0): " + error20;
                string description;
                if (TPM_RC_VER1_CODE_DESCRIPTION.TryGetValue((TPM_RC_VER1_CODES)error, out description))
                {
                    output += "\n  Description: " + description;
                }
            }
            if (!string.IsNullOrEmpty(error12))
            {
                output += "\n Error (1.2): " + error12;
                string description;
                if (TPM_12_ERROR_CODE_DESCRIPTION.TryGetValue((TPM_12_ERROR_CODES)error, out description))
                {
                    output += "\n  Description: " + description;
                }
            }
            if (string.IsNullOrEmpty(error20) &&
                string.IsNullOrEmpty(error12))
            {
                output += "\n Unknown error.";
            }

            return output;
        }