<span style=" font-size:10pt;font-family:sans-serif">Cool,</span>
<br>
<br><span style=" font-size:10pt;font-family:sans-serif">do we currently
have any indefinite-length items in BPv7 / BPSEC besides the bundle itself?
Maybe this exception is not needed,</span>
<br>
<br><span style=" font-size:10pt;font-family:sans-serif">(I have been planning
to use indefinite-length arrays in the compressed reporting block as it
could be more efficient in terms of size but I would be happy to go to
definite-length).</span>
<br>
<br><span style=" font-size:10pt;font-family:sans-serif">Regards,</span>
<br><span style=" font-size:10pt;font-family:sans-serif">Felix</span>
<br>
<br>
<br>
<br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">From:
       </span><span style=" font-size:9pt;font-family:sans-serif">"Birrane,
Edward J." <Edward.Birrane@jhuapl.edu></span>
<br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">To:
       </span><span style=" font-size:9pt;font-family:sans-serif">"Felix.Flentge@esa.int"
<Felix.Flentge@esa.int>, "sis-dtn@mailman.ccsds.org" <sis-dtn@mailman.ccsds.org></span>
<br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">Cc:
       </span><span style=" font-size:9pt;font-family:sans-serif">"sburleig.sb@gmail.com"
<sburleig.sb@gmail.com>, "kfall+rcs@kfall.com"    
   <kfall+rcs@kfall.com></span>
<br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">Date:
       </span><span style=" font-size:9pt;font-family:sans-serif">18/11/2021
15:18</span>
<br><span style=" font-size:9pt;color:#5f5f5f;font-family:sans-serif">Subject:
       </span><span style=" font-size:9pt;font-family:sans-serif">RE:
[EXT] [Sis-dtn] Deterministic CBOR encoding</span>
<br>
<hr noshade>
<br>
<br>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;color:#004080;font-family:Calibri">Felix,</span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;color:#004080;font-family:Calibri"> </span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;color:#004080;font-family:Calibri"> 
I had almost this exact conversation with Scott Burleigh and Kevin Fall
yesterday.</span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;color:#004080;font-family:Calibri"> </span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;color:#004080;font-family:Calibri"> 
The approach to addressing this is to clarify what is meant by Canonical
CBOR as part of AUTH48, with a statement of something like the following:</span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;color:#004080;font-family:Calibri"> </span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:12pt;font-family:Times New Roman">“the
CBOR representations of the values of all fields in all blocks must conform
to the Core Deterministic Encoding Requirements as specified in [RFC8949]
except that indefinite-length items are not prohibited."</span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;color:#004080;font-family:Calibri"> </span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;color:#004080;font-family:Calibri"> 
The intent of the BPv7 spec is clearly to allow some indefinite length
items, as the spec uses indefinite-length items, and the wording in Section
4.1 is meant to describe the encoding of fields within block otherwise.
The exact wording will be figured out once we have the RFC-editor version
of the text to review.</span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;color:#004080;font-family:Calibri"> </span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;color:#004080;font-family:Calibri">-Ed</span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;color:#004080;font-family:Calibri"> </span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:10pt;color:#004080;font-family:Calibri">Edward
J. Birrane, III, Ph.D. (he/him/his)</span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:10pt;color:#004080;font-family:Calibri">Chief
Engineer, Space Constellation Networking</span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:10pt;color:#004080;font-family:Calibri">Space
Exploration Sector</span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:10pt;color:#004080;font-family:Calibri">Johns
Hopkins Applied Physics Laboratory<br>
(W) 443-778-7423 / (C) 443-690-8272</span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;color:#004080;font-family:Calibri"> </span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:11pt;font-family:Calibri"><b>From:</b>
SIS-DTN <sis-dtn-bounces@mailman.ccsds.org> <b>On Behalf Of </b>Felix.Flentge@esa.int<b><br>
Sent:</b> Thursday, November 18, 2021 7:02 AM<b><br>
To:</b> sis-dtn@mailman.ccsds.org<b><br>
Subject:</b> [EXT] [Sis-dtn] Deterministic CBOR encoding</span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:12pt;font-family:Times New Roman"> </span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:10pt;font-family:Arial">Dear
All,</span><span style=" font-size:12pt;font-family:Times New Roman"> <br>
</span><span style=" font-size:10pt;font-family:Arial"><br>
I have spend some time this morning to understand the requirements we get
for the BPv7 CBOR encoding from draft-ietf-dtn-bpbis-31.txt, RFC 8949,
and draft-ietf-dtn-bpsec-27 (actually, I have been worried about a potential
issue with the current BPv7 spec; now I think it is probably ok). Anyway,
this is my understanding of the current situation. Please let me know whether
you share it or not.</span><span style=" font-size:12pt;font-family:Times New Roman">
<br>
</span><span style=" font-size:10pt;font-family:Courier New"><b><br>
draft-ietf-dtn-bpbis-31.txt</b></span><span style=" font-size:10pt;font-family:Arial">:</span><span style=" font-size:12pt;font-family:Times New Roman">
<br>
</span><span style=" font-size:10pt;font-family:Arial"><br>
We have:</span><span style=" font-size:12pt;font-family:Times New Roman">
<br>
</span><span style=" font-size:12pt;color:blue;font-family:Times New Roman"><u><br>
</u></span><a href="https://datatracker.ietf.org/doc/html/draft-ietf-dtn-bpbis-31#section-4"><span style=" font-size:10pt;color:blue;font-family:Courier New"><b><u>4</u></b></span></a><span style=" font-size:10pt;font-family:Courier New"><b>.
Bundle Format</b><br>
</span><span style=" font-size:12pt;color:blue;font-family:Times New Roman"><u><br>
</u></span><a href="https://datatracker.ietf.org/doc/html/draft-ietf-dtn-bpbis-31#section-4.1"><span style=" font-size:10pt;color:blue;font-family:Courier New"><b><u>4.1</u></b></span></a><span style=" font-size:10pt;font-family:Courier New"><b>.
Bundle Structure</b><br>
<br>
  <b>The format of bundles SHALL conform to the Concise Binary Object<br>
  Representation (CBOR [</b></span><a href=https://datatracker.ietf.org/doc/html/rfc8949><span style=" font-size:10pt;color:blue;font-family:Courier New"><b><u>RFC8949</u></b></span></a><span style=" font-size:10pt;font-family:Courier New"><b>]).</b><br>
<br>
  Cryptographic verification of a block is possible only if the<br>
  sequence of octets on which the verifying node computes its hash
-<br>
  the canonicalized representation of the block - is identical to
the<br>
  sequence of octets on which the hash declared for that block was<br>
  computed.  <b>To ensure that blocks are always in canonical<br>
  representation when they are transmitted and received, the CBOR<br>
  representations of the values of all fields in all blocks must<br>
  conform to the rules for Canonical CBOR as specified in [</b></span><a href=https://datatracker.ietf.org/doc/html/rfc8949><span style=" font-size:10pt;color:blue;font-family:Courier New"><b><u>RFC8949</u></b></span></a><span style=" font-size:10pt;font-family:Courier New"><b>].</b></span><span style=" font-size:12pt;font-family:Times New Roman">
<br>
</span><span style=" font-size:10pt;font-family:Arial"><br>
 There are two small issues here:</span><span style=" font-size:12pt;font-family:Times New Roman">
</span><span style=" font-size:10pt;font-family:Arial"><br>
- Only the first statement is a real requirement for BPv7, the 'must' in
the last sentence is not capitalised meaning it is not normative (AFAIK).</span><span style=" font-size:12pt;font-family:Times New Roman">
</span><span style=" font-size:10pt;font-family:Arial"><br>
- RFC8949 does not really specify 'Canonical CBOR': <br>
Section 4.2.3 contains the following note:</span><span style=" font-size:12pt;font-family:Times New Roman">
</span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:10pt;font-family:Courier New"> 
    |  <b>Although [</b></span><a href="https://datatracker.ietf.org/doc/html/rfc7049#section-3"><span style=" font-size:10pt;color:blue;font-family:Courier New"><b><u>RFC7049</u></b></span></a><span style=" font-size:10pt;font-family:Courier New"><b>]
used the term "Canonical CBOR" for its form<br>
     |  of requirements on deterministic encoding, this
document avoids<br>
     |  this term because "canonicalization" is
often associated with<br>
     |  specific uses of deterministic encoding only.  The
terms are<br>
     |  essentially interchangeable, however, and the set
of core<br>
     |  requirements in this document could also be called
"Canonical<br>
     |  CBOR",</b> while the length-first-ordered version
of that could be<br>
     |  called "Old Canonical CBOR".</span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:10pt;font-family:Arial">and
G.3:</span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:12pt;font-family:Times New Roman"> </span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:10pt;font-family:Courier New"> 
 For a single value in the data model, CBOR often provides multiple<br>
  encoding options.  A new section (</span><a href="https://datatracker.ietf.org/doc/html/rfc8949#section-4"><span style=" font-size:10pt;color:blue;font-family:Courier New"><u>Section
4</u></span></a><span style=" font-size:10pt;font-family:Courier New">)
introduces the term<br>
  "preferred serialization" (</span><a href="https://datatracker.ietf.org/doc/html/rfc8949#section-4.1"><span style=" font-size:10pt;color:blue;font-family:Courier New"><u>Section
4.1</u></span></a><span style=" font-size:10pt;font-family:Courier New">)
and defines it for various<br>
  kinds of data items.  On the basis of this terminology, the
section<br>
  then discusses how a CBOR-based protocol can define "deterministic<br>
  encoding" (</span><a href="https://datatracker.ietf.org/doc/html/rfc8949#section-4.2"><span style=" font-size:10pt;color:blue;font-family:Courier New"><u>Section
4.2</u></span></a><span style=" font-size:10pt;font-family:Courier New">),
which avoids terms "canonical" and<br>
  "canonicalization" from </span><a href="https://datatracker.ietf.org/doc/html/rfc7049#section-3"><span style=" font-size:10pt;color:blue;font-family:Courier New"><u>RFC
7049</u></span></a><span style=" font-size:10pt;font-family:Courier New">.
 The suggestion of "Core<br>
  Deterministic Encoding Requirements" (</span><a href="https://datatracker.ietf.org/doc/html/rfc8949#section-4.2.1"><span style=" font-size:10pt;color:blue;font-family:Courier New"><u>Section
4.2.1</u></span></a><span style=" font-size:10pt;font-family:Courier New">)
enables generic<br>
  support for such protocol-defined encoding requirements.  This<br>
  document further eases the implementation of deterministic encoding<br>
  by simplifying the map ordering suggested in </span><a href="https://datatracker.ietf.org/doc/html/rfc7049#section-3"><span style=" font-size:10pt;color:blue;font-family:Courier New"><u>RFC
7049</u></span></a><span style=" font-size:10pt;font-family:Courier New">
to a simple<br>
  lexicographic ordering of encoded keys.  A description of the
older<br>
  suggestion is kept as an alternative, now termed "length-first
map<br>
  key ordering" (</span><a href="https://datatracker.ietf.org/doc/html/rfc8949#section-4.2.3"><span style=" font-size:10pt;color:blue;font-family:Courier New"><u>Section
4.2.3</u></span></a><span style=" font-size:10pt;font-family:Courier New">).</span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:10pt;font-family:Arial"><br>
 Anyway, for our purposes we probably can understand 'rules for Canonical
CBOR' as the Core Deterministic Requirements in Section 4.2.1 (at least
as long as we don't use maps, see 4.2.3). This view would be supported
by draft-ietf-dtn-bpsec-27: </span><span style=" font-size:12pt;color:blue;font-family:Times New Roman"><u><br>
</u></span><a href="https://datatracker.ietf.org/doc/html/draft-ietf-dtn-bpsec-27#section-4"><span style=" font-size:10pt;color:blue;font-family:Courier New"><b><u>4</u></b></span></a><span style=" font-size:10pt;font-family:Courier New"><b>.
 Canonical Forms</b><br>
<br>
 [...]<br>
<br>
  The canonical form of the primary block is as specified in<br>
  [</span><a href="https://datatracker.ietf.org/doc/html/draft-ietf-dtn-bpsec-27#ref-I-D.ietf-dtn-bpbis"><span style=" font-size:10pt;color:blue;font-family:Courier New"><u>I-D.ietf-dtn-bpbis</u></span></a><span style=" font-size:10pt;font-family:Courier New">]
with the following constraint.<br>
<br>
  o  <b>CBOR values from the primary block MUST be canonicalized
using the<br>
     rules for Deterministically Encoded CBOR, as specified in<br>
     [</b></span><a href=https://datatracker.ietf.org/doc/html/rfc8949><span style=" font-size:10pt;color:blue;font-family:Courier New"><b><u>RFC8949</u></b></span></a><span style=" font-size:10pt;font-family:Courier New"><b>].</b><br>
<br>
  All non-primary blocks share the same block structure and are<br>
  canonicalized as specified in [</span><a href="https://datatracker.ietf.org/doc/html/draft-ietf-dtn-bpsec-27#ref-I-D.ietf-dtn-bpbis"><span style=" font-size:10pt;color:blue;font-family:Courier New"><u>I-D.ietf-dtn-bpbis</u></span></a><span style=" font-size:10pt;font-family:Courier New">]
with the following<br>
  constraints.<br>
<br>
  o  <b>CBOR values from the non-primary block MUST be canonicalized
using<br>
     the rules for Deterministically Encoded CBOR, as specified
in<br>
     [</b></span><a href=https://datatracker.ietf.org/doc/html/rfc8949><span style=" font-size:10pt;color:blue;font-family:Courier New"><b><u>RFC8949</u></b></span></a><span style=" font-size:10pt;font-family:Courier New"><b>].</b></span><span style=" font-size:12pt;font-family:Times New Roman">
<br>
</span><span style=" font-size:10pt;font-family:Arial"><br>
(It would be even better if there would be an explicit reference to Section
4.2.1.) </span><span style=" font-size:12pt;font-family:Times New Roman"><br>
</span><span style=" font-size:10pt;font-family:Arial"><br>
So, for CCSDS the main questions seems to be whether we are happy enough
with the core deterministic requirements in RFC8949, Section 4.2.1, basically:</span><span style=" font-size:12pt;font-family:Times New Roman">
</span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:10pt;font-family:Courier New">*
 Preferred serialization MUST be used.  In particular, this means<br>
     that arguments (see </span><a href="https://datatracker.ietf.org/doc/html/rfc8949#section-3"><span style=" font-size:10pt;color:blue;font-family:Courier New"><u>Section
3</u></span></a><span style=" font-size:10pt;font-family:Courier New">)
<b>for integers, lengths in major<br>
     types 2 through 5, and tags MUST be as short as possible</b>,
for<br>
     instance:<br>
[...]<br>
<br>
  *  <b>Indefinite-length items MUST NOT appear</b>.  They
can be encoded as<br>
     definite-length items instead.<br>
<br>
  *  The keys in every map MUST be sorted in the bytewise lexicographic<br>
     order of their deterministic encodings. [...]</span></p>
<p style="margin-top:0px;margin-Bottom:0px"><span style=" font-size:12pt;font-family:Times New Roman"><br>
</span><span style=" font-size:10pt;font-family:Arial"><br>
We are not using maps (currently; and may want to avoid in the future)
and shall not use indefinite-length items in (extension) blocks (the whole
indefinite length bundle array should be ok). I would suggest that we consult
with more hardware-oriented people whether the '... as short as possible
...' requirements would be a problem. If not, I would suggest that we explicitly
require Deterministically Encoded CBOR according to RFC8949, 4.2.1. Otherwise,
we might have to define something more CCSDS-specific (and would risk loosing
interoperability with other implementations, in particular, regarding bundle
security).</span><span style=" font-size:12pt;font-family:Times New Roman">
<br>
</span><span style=" font-size:10pt;font-family:Arial"><br>
Regards,</span><span style=" font-size:12pt;font-family:Times New Roman">
</span><span style=" font-size:10pt;font-family:Arial"><br>
Felix </span><span style=" font-size:12pt;font-family:Times New Roman"><br>
<br>
</span><span style=" font-size:9pt;color:#808080;font-family:Arial"><b><i><br>
Disclaimer</i></b></span><span style=" font-size:12pt;font-family:Times New Roman">
</span><span style=" font-size:7pt;color:#808080;font-family:Arial"><i><br>
This message is intended only for the recipient(s) named above. It may
contain proprietary information and/or protected content. Any unauthorised
disclosure, use, retention or dissemination is prohibited. If you have
received this e-mail in error, please notify the sender immediately. ESA
applies appropriate organisational measures to protect personal data, in
case of data privacy queries, please contact the ESA Data Protection Officer
(</i></span><a href=mailto:dpo@esa.int><span style=" font-size:7pt;color:blue;font-family:Arial"><i><u>dpo@esa.int</u></i></span></a><span style=" font-size:7pt;color:#808080;font-family:Arial"><i>).</i></span></p>
<p style="margin-top:0px;margin-Bottom:0px"></p>
<p style="margin-top:0px;margin-Bottom:0px"></p>