Subject: [Tm-rid] Adam's current extended auth message

From: Robert Moskowitz <[email-masked]>
Date: Fri, 27 Sep 2019 12:36:44 -0400

I am sending this layout that Adam has been working on for people to get 
some idea of what we have been working on.  It needs fixes and details.

It uses ECDSA-384 sigs of 96bytes.  I will be recommending EdDSA25519 
sigs of 64 bytes.

What goes into making the message hashes and how are they computed? For 
the later, i recommend SHAKE128 (or cSHAKE128).

There is more, but I am short of time with Rosh Hashana Monday and 
Tuesday.  Here it is:

=================================================================
     |                        General Format                         |
=================================================================
     Page 0:
      0                   1                   2 3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-------+-------+-------+
     |  Msg. Header  | # Hashes Left | STS-P | ETS-P | H-Alg | H-Len |
+---------------+---------------+-------+-------+-------+-------+
     |         Start Timestamp       |         End Timestamp         |
+-------------------------------+-------------------------------+
     |                Hash of Previous Auth. Message                 |
+---------------------------------------------------------------+
     |                Hash of Current Auth. Message                  |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     Msg. Header: (1 byte)
         Defined by ASTM Remote ID Message protocol.
         Bits 7-4: AuthType
         Bits 3-0: Data Page
         See https://github.com/opendroneid/specs, Message for more
         details.
     # Hashes Left: (1 byte)
         A count of the number of hashes to be found in this Auth
         message. This does not include the previous or current
         Auth message hashes.
         The first page will decrement this by 2 for the next page
         in the sequence.
     STS-P, ETS-P: (4 bits), (4 bits)
         This is a precision value for the Start and End timestamps
         respectively.

         See ASTM draft, Figure 3; Timestamp/Speed Accuracy field
         for details. We are only concered about bits 7-4.
     H-Alg, H-Len: (4 bits), (4 bits)
         These are fields for relaying information of the Hash
         algorithm used for the messages and the Hash length (in octets).
         For this example of the format a length of 4 bytes is
         used.
     Start Timestamp: (2 bytes)
         Time stamp dictating that messages hashed in this Auth
         message came after this specified time, but NOT after
         End Timestamp.
         See ASTM draft for Timestamp format details.
     End Timestamp: (2 bytes)
         Time stamp dictating that messages hashed in this Auth
         message came before this specified time, but NOT before
         Start Timestamp.
         See ASTM draft for Timestamp format details.
     Hash of Previous Auth. Message: (4 bytes)
         A hash of the previous send Auth message.
     Hash of Current Auth. Message: (4 bytes)
         A hash of the current Auth message.
         A few notes on this field:
         a) First during creation and signing of this message format
         this field MUST be set to 0. So the signature will be
         based on this field being 0, as well as its own hash. It
         is an open question of if we compute the hash, then sign
         or sign then compute.
         b) There a few different ways to cycle this message. We can
         "roll up" the hash of 'current' to 'previous' when needed
         or to completely recompute the hash. This mostly depends on
         the previous note.
     Message Hash: (4 bytes)
         A hash of a previously sent message.
===============================================================================
     Page 1 to N (N<=11):
      0                   1                   2 3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------------------------------+
     |  Msg. Header  | # Hashes Left | RESERVED           |
+---------------+---------------+-------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     Msg. Header: (1 byte)
         Defined by ASTM Remote ID Message protocol.
         Bits 7-4: AuthType
         Bits 3-0: Data Page
         See https://github.com/opendroneid/specs, Message for more
         details.
     # Hashes Left: (1 byte)
         A count of the number of hashes to be found left in this
         Auth message.
         Every full page of hashes will decrement this by 5 until it
         reaches 0 (which signals the end of hashes and start of
         the Auth message signature).
         If a page has less than 5 hashes then the rest of the page
         should be padded with zeros.
     Message Hash: (4 bytes)
         A hash of a previously sent message.
==========================================================================
     Page N to K (N<=11 && K<=15):
      0                   1                   2 3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------------------------------+
     |  Msg. Header  | # Hashes Left | RESERVED           |
+---------------+---------------+-------------------------------+
     |            Length             |      Signature Algorithm      |
+-------------------------------+-------------------------------+
|                                                               |
|                                                               |
|                                                               |
     |                         HIP Signature                         |
|                                                               |
|                                                               |
|                                                               |
+---------------------------------------------------------------+
     Msg. Header: (1 byte)
         Defined by ASTM Remote ID Message protocol.
         Bits 7-4: AuthType
         Bits 3-0: Data Page
         See https://github.com/opendroneid/specs, Message for more
         details.
     # Hashes Left: (1 byte)
         A count of the number of hashes to be found in this Auth
         message. This does not include the previous or current
         Auth message hashes.
         For this page (and all subsequent pages) it SHOULD be 0.

     Length: (2 bytes)
         length is octets, excluding Length, and Padding
     Signature Algoirthm: (2 bytes)
         Self explanatory.
     HIP Signature: (96 bytes)
         Based on ECDSA-384 Signature.
         If smaller HIT based signature is used then more hashes can fit
         into the full message format across the 16 pages. With a
         ECDSA-384 signature a maximum of 64 message hashes can be sent.
         23 bytes per page * 16 pages = 368 bytes
         - 96 bytes for sig = 272 bytes
         - 8 bytes for timestamps = 264 bytes
         - 8 bytes for auth message hashs = 256 bytes
         / 4 bytes per hash = 64 hashes
         See RFC4754 for detail on ECDSA-384 and RFC7401 on HIPs use of
         ECDSA for HI/HIT.
         If the end of the signature does not fill a full page, it
         WILL be padded with zeros at the end.
============================================================================
     Page 0:
      0                   1                   2 3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-------+-------+-------+
     |  Msg. Header  | # Hashes Left | STS-P | ETS-P | H-Alg | H-Len |
+---------------+---------------+-------+-------+-------+-------+
     |         Start Timestamp       |         End Timestamp         |
+-------------------------------+-------------------------------+
     |                Hash of Previous Auth. Message                 |
+---------------------------------------------------------------+
     |                Hash of Current Auth. Message                  |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     Page 1 to N (N<=11):
      0                   1                   2 3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------------------------------+
     |  Msg. Header  | # Hashes Left | RESERVED           |
+---------------+---------------+-------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     Page N to K (N<=11 && K<=15):
      0                   1                   2 3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------------------------------+
     |  Msg. Header  | # Hashes Left | RESERVED           |
+---------------+---------------+-------------------------------+
     |            Length             |      Signature Algorithm      |
+-------------------------------+-------------------------------+
|                                                               |
|                                                               |
|                                                               |
     |                         HIP Signature                         |
|                                                               |
|                                                               |
|                                                               |
+---------------------------------------------------------------+
============================================================================
     DETAILED EXAMPLE OF FULL AUTH MESSAGE FORMAT
=================================================================
     |                         AUTH PAGE 0                           |
=================================================================
      0                   1                   2 3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-------+-------+-------+
     |0 0 0 1 0 0 0 0|0 0 1 1 0 1 0 0| STS-P | ETS-P | H-Alg |0 1 0 0|
+---------------+---------------+-------+-------+-------+-------+
     |         Start Timestamp       |         End Timestamp         |
+-------------------------------+-------------------------------+
     |                Hash of Previous Auth. Message                 |
+---------------------------------------------------------------+
     |                Hash of Current Auth. Message                  |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
=================================================================
     |                         AUTH PAGE 1                           |
=================================================================
      0                   1                   2 3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------------------------------+
     |0 0 0 1 0 0 0 1|0 0 1 1 0 0 1 0| RESERVED           |
+---------------+---------------+-------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
=================================================================
     |                         AUTH PAGE 2 - 9                       |
=================================================================
      0                   1                   2 3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------------------------------+
     |0 0 0 1 0 0 1 0|0 0 0 0 0 1 0 1| RESERVED           |
+---------------+---------------+-------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
      0                   1                   2 3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------------------------------+
     |0 0 0 1 1 0 0 1|0 0 0 0 0 1 0 1| RESERVED           |
+---------------+---------------+-------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
=================================================================
     |                         AUTH PAGE 10                          |
=================================================================
      0                   1                   2 3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------------------------------+
     |0 0 0 1 1 0 1 0|0 0 0 0 0 0 0 0| RESERVED           |
+---------------+---------------+-------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
     |                          Message Hash                         |
+---------------------------------------------------------------+
=================================================================
     |                    AUTH PAGE 11 - 15 (Signature)              |
=================================================================
      0                   1                   2 3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------------------------------+
     |0 0 0 1 1 0 1 1|0 0 0 0 0 0 0 0| RESERVED           |
+---------------+---------------+-------------------------------+
     |            Length             |      Signature Algorithm      |
+-------------------------------+-------------------------------+
|                                                               |
|                                                               |
|                                                               |
     |                         HIP Signature                         |
|                                                               |
|                                                               |
|                                                               |
+---------------------------------------------------------------+
      0                   1                   2 3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+-----------------------------------------------+
     |0 0 0 1 1 1 0 0|                                               |
+---------------+                                               |
|                                                               |
|                                                               |
|                                                               |
|                                                               |
     |                         HIP Signature                         |
|                                                               |
|                                                               |
|                                                               |
|                                                               |
+---------------------------------------------------------------+
      0                   1                   2 3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+-----------------------------------------------+
     |0 0 0 1 1 1 0 1|                                               |
+---------------+                                               |
|                                                               |
|                                                               |
|                                                               |
|                                                               |
     |                         HIP Signature                         |
|                                                               |
|                                                               |
|                                                               |
|                                                               |
+---------------------------------------------------------------+
      0                   1                   2 3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+-----------------------------------------------+
     |0 0 0 1 1 1 1 0|                                               |
+---------------+                                               |
|                                                               |
|                                                               |
|                                                               |
|                                                               |
     |                         HIP Signature                         |
|                                                               |
|                                                               |
|                                                               |
|                                                               |
+---------------------------------------------------------------+
      0                   1                   2 3
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+-----------------------------------------------+
     |0 0 0 1 1 1 1 1|                                               |
+---------------+                                               |
     |                         HIP Signature                         |
|                                                               |
|                                                               |
+---------------------------------------------------------------+
|                                                               |
|                                                               |
     | Padding                            |
|                                                               |
|                                                               |
+---------------------------------------------------------------+