@staticmethod
def _decode_length(buf):
    """return -- mlen length, mlen value"""
    if buf[0] == 0:
        return 1, 0
    buf_idx = 0
    current_bt = buf[buf_idx]
    retval = current_bt & 127
    while current_bt & 128 != 0 and buf_idx < len(buf):
        buf_idx += 1
        current_bt = buf[buf_idx]
        retval += (current_bt & 127) << 7 * buf_idx
    return 1 + buf_idx, retval
