Subject: [Cose] Issue: Encoding for a single recipient or structure

From: "Jim Schaad" <[email-masked]>
Date: Thu, 30 Apr 2015 15:59:07 -0700

Question: Flattened encoding -
a)  Roll into parent map
b)  Just be a map
c)  Single element in array

Discussion:

A late addition to the JOSE specification was the ability to fold a single
recipient map into the base encryption or signature map.  This is doable
because the keys for all of the maps in question are unique.  This would not
be true if the issue on reusing the encryption body for the recipient
structure is accepted.  This issue is being discussed in a separate mail
thread (but is current).  If arrays were to be used at the top level, one
just appends the elements to the end of the base structure  (see examples in
the current document).

There are three different options that can be selected at this point:

1)  The recipient/signature map is folded into the encryption/signing
message top level.  If we accept the change for using the same structure for
both the encryption body and the recipients, this is not a viable option due
to collisions of keys in the map.

2)  The recipient/signature element in the base map is permitted to be
either an array of recipient/signature elements or a single
recipient/signature map.  This option was rejected by the JOSE group as
being too complicated for programmers to deal with.  The cost of this option
is 2 bytes over option one.  (One byte for the recipients key, one byte for
the map marker.) 

CDDL grammar would be:  recipients: [+[recipient_data]] / {recipient_data}

3)  We do not support any special form of dealing with a single recipient.
The cost of this option is 3 bytes over option one.  (One byte for the
recipients key, one byte for the array marker, one byte for the map marker.)

CDDL grammar would be:  recipients: [+[recpient_data]]