[Cbor] Invalid decimal fraction / big float?

Laurence Lundblade <lgl@island-resort.com> Sun, 25 August 2019 09:58 UTC

Return-Path: <lgl@island-resort.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 3D10F1200D6 for <cbor@ietfa.amsl.com>; Sun, 25 Aug 2019 02:58:00 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.896
X-Spam-Level:
X-Spam-Status: No, score=-1.896 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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 1GVscEUUVmoc for <cbor@ietfa.amsl.com>; Sun, 25 Aug 2019 02:57:58 -0700 (PDT)
Received: from p3plsmtpa08-02.prod.phx3.secureserver.net (p3plsmtpa08-02.prod.phx3.secureserver.net [173.201.193.103]) (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 AF28312007A for <cbor@ietf.org>; Sun, 25 Aug 2019 02:57:58 -0700 (PDT)
Received: from [10.17.0.190] ([45.56.150.72]) by :SMTPAUTH: with ESMTPA id 1pHYiSCFeANse1pHYi1Hkx; Sun, 25 Aug 2019 02:57:57 -0700
From: Laurence Lundblade <lgl@island-resort.com>
Content-Type: multipart/alternative; boundary="Apple-Mail=_6E2B8B57-FE5D-433A-ABC1-0CC7EA90D774"
Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\))
Message-Id: <D4C38A34-F601-4173-A686-362DDE4E8BEE@island-resort.com>
Date: Sun, 25 Aug 2019 02:57:56 -0700
To: cbor@ietf.org
X-Mailer: Apple Mail (2.3445.104.11)
X-CMAE-Envelope: MS4wfMNzSyxiQJwy7EV2rcGVA6aK17UFHuoLxsZJj1yLUww3Enflm3eVgMW3QAaeX+OpB3nV1XZsYZBJbbS1iAQC0ZP0LVGHxY5Y78zDKLktXMg7LQnpNh2T bp8A6SDX8setH7TSc+Idy2AmleFN6ZyfA16cg9EPb/XYC9OVR4MYiAHp
Archived-At: <https://mailarchive.ietf.org/arch/msg/cbor/XCv4HMZaq4adaXHim_AVkFZlpxA>
Subject: [Cbor] Invalid decimal fraction / big float?
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: Sun, 25 Aug 2019 09:58:00 -0000

Here’s text from section 3.4.5:

   The exponent e MUST be represented in an integer of major
   type 0 or 1, while the mantissa also can be a bignum (Section 3.4.4 <https://tools.ietf.org/html/draft-ietf-cbor-7049bis-06#section-3.4.4>).
   Contained items with other structures are invalid.

For the most part it seems clear. If the second item in the array is not an integer or a bignum the decimal fraction / big float is invalid.

However, I’ve heard comments that tags are only hints and might be optional if the meaning is clear without them. For example CWT prohibits using the tag value 1 with “exp”, “nbf” and “iat” claims.  In the case of a bignum vs an integer, the meaning is clear without a tag value 2 or 3 explicitly indicating it is a bignum.

Is this a valid decimal fraction?

C4            # tag(4)
   82         # array(2)
      01      # unsigned(1)
      42      # bytes(2)
         0102 # "\x01\x02"

Presumably this is valid, but if we did like CWT, it would be invalid.

C4               # tag(4)
   82            # array(2)
      01         # unsigned(1)
      C2         # tag(2)
         42      # bytes(2)
            0102 # "\x01\x02"

My inclination would be that they are both valid. If that is the choice, then decoders MUST handle both and that is not obvious from the text.

LL