public DecodeStream getSequence(boolean implicit) throws Asn1Exception {
        DecodeStream seqStream;

        //
        // There must be at least T and L fields available
        //
        if (residualLength < 2)
            throw new Asn1Exception("Attempt to read past end of stream");

        //
        // Validate the tag for an explicit sequence
        //
        if (!implicit && stream[next] != ASN1_SEQUENCE+ASN1_CONSTRUCTED)
            throw new Asn1Exception("Field at offset "+next+" is not a SEQUENCE");

        if ((stream[next]&ASN1_CONSTRUCTED) == 0)
            throw new Asn1Exception("SEQUENCE must be a constructed field");

        next++;
        residualLength--;

        //
        // Get the sequence length
        //
        int length = decodeLength();

        if (length > residualLength)
            throw new Asn1Exception("Attempt to read past end of stream");

        //
        // Create a DecodeStream for the body of the sequence
        //
        seqStream = new DecodeStream(stream, length, next);
        next += length;
        residualLength -= length;
        return seqStream;
    }