Subject: [Cose] Issue: Reuse the Enrypt structure for recipients

From: "Jim Schaad" <[email-masked]>
Date: Thu, 30 Apr 2015 16:00:01 -0700

Question:  Reuse Encrypt body map for recipients

Discussion:

The concept of using the same structure for both recipients and the base
encryption map was introduced to the JOSE working group at the Denver
meeting.  The JOSE working group rejected the idea as being too much of a
change to make in the current working code.  The concept is that the same
data structure, with the same elements is used to encode both the content
encryption and each of the recipient structures.  While in JOSE, many of the
same elements are not present in the recipient structure (i.e. iv and aad),
some of these elements later appeared as part of algorithm descriptions (iv
is a header parameter defined for AES-GCM key wrapping).

Using the same structure for encrypting content as well as encrypting keys
allows for some neat tricks to be played at a later date if needed.  One
example is that you could separate the key wrapping algorithm, and the
ECDH-KDF algorithm pair into separate layers.  This allows one to move
towards a Chinese Menu method of selecting and using algorithms rather than
the current algorithm suite method.  While I would not recommend that this
happen in the current specification, it might be nice to keep it open as an
option to be used in the future as new algorithms are added.

Another advantage of doing this folding is in code size.  In my
implementation, I have created the recipient class as inheriting from the
encryption body class.  The recipient class contains only code that deals
with the cryptography of key management.  All of the encoding/decoding is
handled by the base encryption class.   If the structures are kept separate
as they are today then that code would need to be added to the recipient
class.  While my code does not currently deal with idea of having multiple
layers of key management.  I believe that this would be a minimal addition
to the current code base.