internal static void Decode <T>(AsnReader reader, out T decoded) where T : NegotiationToken, new() { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } decoded = new T(); Asn1Tag tag = reader.PeekTag(); AsnReader explicitReader; if (tag.HasSameClassAndValue(new Asn1Tag(TagClass.ContextSpecific, 0))) { explicitReader = reader.ReadSequence(new Asn1Tag(TagClass.ContextSpecific, 0)); NegTokenInit.Decode <NegTokenInit>(explicitReader, out NegTokenInit tmpInitialToken); decoded.InitialToken = tmpInitialToken; explicitReader.ThrowIfNotEmpty(); } else if (tag.HasSameClassAndValue(new Asn1Tag(TagClass.ContextSpecific, 1))) { explicitReader = reader.ReadSequence(new Asn1Tag(TagClass.ContextSpecific, 1)); NegTokenResp.Decode <NegTokenResp>(explicitReader, out NegTokenResp tmpResponseToken); decoded.ResponseToken = tmpResponseToken; explicitReader.ThrowIfNotEmpty(); } else { throw new CryptographicException(); } }
public NegotiateContextToken(Asn1Element sequence, string mechType) : base(sequence) { if (MechType.NTLM == mechType) { NegotiationToken = new NegTokenInit() { MechToken = new MechToken().DecodeNtlm(sequence) }; } }
protected override void ParseContextSpecific(Asn1Element element) { switch (element.ContextSpecificTag) { case 0: NegotiationToken = new NegTokenInit().Decode(element[0]); break; case 1: SubsequentContextToken = new NegTokenTarg().Decode(element[0]); break; } }