Ejemplo n.º 1
0
        public static T DecodeNegotiationToken <T>(byte[] token) where T : class
        {
            var negotiationToken = new NegotiationToken();

            negotiationToken.BerDecode(new Asn1DecodingBuffer(token));

            var data = negotiationToken.GetData();

            if (data is T)
            {
                return(data as T);
            }
            else
            {
                return(null);
            }
        }
        public static byte[] DecodeNegotiationToken(byte[] token)
        {
            NegotiationToken decoder = new NegotiationToken();

            decoder.BerDecode(new Asn1DecodingBuffer(token));

            Asn1Object type = decoder.GetData();

            switch (decoder.SelectedChoice)
            {
            case NegotiationToken.negTokenInit:
                return(((NegTokenInit)type).mechToken.ByteArrayValue);

            case NegotiationToken.negTokenResp:
                return(((NegTokenResp)type).responseToken.ByteArrayValue);

            case NegotiationToken.negTokenInit2:
                return(((NegTokenInit2)type).mechToken.ByteArrayValue);

            default:
                return(null);
            }
        }