private static bool CanReadNtlmMessage(ReadOnlyMemory <byte> ntlm, out byte[] actualSignature, out BinaryReader reader, out AsnReader asnReader) { asnReader = null; reader = new BinaryReader(new MemoryStream(ntlm.ToArray())); actualSignature = reader.ReadBytes(MessageSignature.Length); if (actualSignature.SequenceEqual(MessageSignature)) { return(true); } asnReader = new AsnReader(ntlm, AsnEncodingRules.DER); var peekTag = asnReader.PeekTag(); if (AsnReader.IsExpectedTag(peekTag, GssApplicationTag, UniversalTagNumber.Sequence)) { return(false); } return(AsnReader.IsExpectedTag(peekTag, NtlmContextTag, UniversalTagNumber.Sequence)); }