Re: [Cbor] Invalid tag (issue 176); notable tags draft

Thiago Macieira <thiago.macieira@intel.com> Tue, 12 May 2020 22:09 UTC

Return-Path: <thiago.macieira@intel.com>
X-Original-To: cbor@ietfa.amsl.com
Delivered-To: cbor@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id D68763A0C3B for <cbor@ietfa.amsl.com>; Tue, 12 May 2020 15:09:33 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.899
X-Spam-Level:
X-Spam-Status: No, score=-1.899 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KT4OWVVn7Hak for <cbor@ietfa.amsl.com>; Tue, 12 May 2020 15:09:32 -0700 (PDT)
Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 2ECF83A0C38 for <cbor@ietf.org>; Tue, 12 May 2020 15:09:31 -0700 (PDT)
IronPort-SDR: ecbkWBjQ6FijIKOLXYoTs57X59+7eDdy17tsxeqcFg6bw7e474KRCHiuIKmWfmQVmCkTJrE4wI axRhhsnptmvQ==
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2020 15:09:31 -0700
IronPort-SDR: Kj6NAwwdJV2HMLodqtUMSoo1gYrUyqYDvYZCCjX1B4/A+rgWJh5TRMPIRzSdpG7t79ihMpEcrB +Yd0HaM9JYVQ==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.73,385,1583222400"; d="scan'208";a="298167202"
Received: from orsmsx101.amr.corp.intel.com ([10.22.225.128]) by orsmga008.jf.intel.com with ESMTP; 12 May 2020 15:09:31 -0700
Received: from tjmaciei-mobl1.localnet (10.254.96.85) by ORSMSX101.amr.corp.intel.com (10.22.225.128) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 12 May 2020 15:09:30 -0700
From: Thiago Macieira <thiago.macieira@intel.com>
To: cbor@ietf.org
Date: Tue, 12 May 2020 15:09:30 -0700
Message-ID: <3461942.bKgpO4XBJ3@tjmaciei-mobl1>
Organization: Intel Corporation
In-Reply-To: <9B6B7286-F934-4576-86E4-D8654293A9FC@tzi.org>
References: <9B6B7286-F934-4576-86E4-D8654293A9FC@tzi.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"
X-Originating-IP: [10.254.96.85]
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/EoNHwgNZlY5EG_UFsHR3Yu46LIs>
Subject: Re: [Cbor] Invalid tag (issue 176); notable tags draft
X-BeenThere: cbor@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Concise Binary Object Representation \(CBOR\)" <cbor.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/cbor>, <mailto:cbor-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/cbor/>
List-Post: <mailto:cbor@ietf.org>
List-Help: <mailto:cbor-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/cbor>, <mailto:cbor-request@ietf.org?subject=subscribe>
X-List-Received-Date: Tue, 12 May 2020 22:09:34 -0000

On Tuesday, 12 May 2020 13:28:47 PDT Carsten Bormann wrote:
> As we discussed in conjunction with
> https://github.com/cbor-wg/CBORbis/issues/176, we need a registration for
> an invalid tag, which is reserved so it can be used in an implementation to
> store the absence of a tag into an integer that would otherwise carry the
> number of that tag.
> 
> I have put the text for a specification for that registration in:
> 
> https://www.ietf.org/id/draft-bormann-cbor-notable-tags-00.html#name-iana-co
> nsiderations
> 
> I have also applied for the tag number at IANA.

The best tag number for this would be 0, since it allows a bzero'ed structure 
to indicate the invalid tag, but that's already taken. The second best would 
be ~uint64_t(0), which would also allow the same property, just by making the 
implementation store the actual tag number plus 1 (0 is -1, 1 is 0, etc.). So 
why limit it to 16-bit?

Anyway, more importantly for me is a bit of text explaining what 
implementations should do when seeing this tag. This is similar to the 
Undefined simple type, which is very concrete and yet has special roles.

For example, in Qt, these two methods exist:

    QJsonObject::insert(QStringView key, const QJsonValue &value)
    QCborMap::insert(QStringView key, const QCborValue &value)

But they differ in behaviour if the value is Undefined. The JSON method, upon 
receiving a value that is undefined, will remove the key from the map, as JSON 
does not support undefined values. QCborMap, on the other hand, stores a CBOR 
value of type Undefined.

If this discussion is of interest, I'll start a new thread to talk about 
Undefined. But for the invalid tag, let's make sure we have some wording to 
indicate its usage. I suggest something along the lines of:

"Implementations MAY choose to discard this tag, as if it were not present. 
Therefore, CBOR interchange may not rely on this tag being processed by the 
recipient in any particular form: the decoder may pass it on to a higher layer 
for processing or it may discard. Similarly, encoders receiving this tag from 
a higher layer may opt not to encode it in the byte stream."

For me, I won't treat it in any special way. If it is present, the decoder 
will see a QCborTag(0xffff) and I will add a QCborKnownTags::Invalid to Qt and 
CborInvalidTag to TinyCBOR (if it fits into 32-bit).

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products