/// <summary>
        /// Try and parse data into an SChannel authentication token.
        /// </summary>
        /// <param name="data">The data to parse.</param>
        /// <param name="token">The SChannel authentication token.</param>
        /// <param name="client">True if this is a token from a client.</param>
        /// <param name="token_count">The token count number.</param>
        /// <returns>True if parsed successfully.</returns>
        internal static bool TryParse(byte[] data, int token_count, bool client, out SchannelAuthenticationToken token)
        {
            token = null;
            MemoryStream     stm     = new MemoryStream(data);
            BinaryReader     reader  = new BinaryReader(stm);
            List <TlsRecord> records = new List <TlsRecord>();

            while (stm.RemainingLength() > 0)
            {
                if (!TlsRecord.TryParse(reader, out TlsRecord record))
                {
                    return(false);
                }
                records.Add(record);
            }
            token = new SchannelAuthenticationToken(data, records);
            return(true);
        }
 internal static bool TryParse(BinaryReader reader, out TlsRecord record)
 {
     record = null;
     try
     {
         TlsRecordType type          = (TlsRecordType)reader.ReadByte();
         int           major_version = reader.ReadByte();
         int           minor_version = reader.ReadByte();
         int           length        = (reader.ReadByte() << 8) | reader.ReadByte();
         byte[]        data          = reader.ReadAllBytes(length);
         record = new TlsRecord(data, type, major_version, minor_version, data);
         return(true);
     }
     catch (EndOfStreamException)
     {
         return(false);
     }
 }