Subject: [Suit] Discussion points for IETF106

From: Brendan Moran <[email-masked]>
Date: Fri, 8 Nov 2019 17:06:43 +0000

There are several ideas I’d like to discuss with the wg at IETF 106:

First, I’d like feedback on what to do with the serialisation examples section:

  *   Is there an example you’d like to see?
  *   Should the examples be moved into an appendix?
  *   Should the examples be moved into a separate draft with more extensive use-case information?

Second, I’d like to propose adding a new flow control primitive to the manifest encoding.

The primitive is Map-Test-Execute (a relative of map-filter-reduce). The intent of the primitive is to loop through a set of component indices, each with a set of parameter values. In each case write the parameter values to the component’s parameter storage. Next, run a soft-fail sequence, this is intended for tests. A failure here terminates the current loop iteration, and starts the next iteration. Finally, run a hard-fail sequence. A failure here causes a hard termination of the Map-Test-Execute primitive.

[
    map: # List of component ID : {parameter set} pairs
    test: # Command sequence that can soft fail (goes to next map pair)
    execute: # Command sequence that does not soft fail (error causes termination)
]

In python-esque pseudocode, the primitive would look like the following:

def map_test_exec(components, pairs, testfn, execfn):
    for c,vars in pairs:
        components[c].context.update(vars)
        try:
            testfn(components[c].context)
        except:
            continue
        execfn(components[c].context)

The CDDL would be:

Map_Test_Execute = [
    parameter-list : [ + (uint, nil/{ + SUIT_Parameters }) ],
    ? test-sequence : nil/bstr .cbor SUIT_Command_Sequence,
    ? exec-sequence : bstr .cbor SUIT_Command_Sequence
]

This structure is fairly straight-forward to process. It typically reduces encoding size.

This could be used in the following situations:

  1.  Set up the variables for a list of components
  2.  Apply a specified sequence to a list of components
  3.  Choose which of a set of variables to use based on tests

Because the update() necessarily happens before the test-sequence, this has some side-effects: a failed test still applies variables. This doesn’t seem like the right answer. It might be that the right answer is to treat the parameters as temporary until the test is complete. This would be:

def map_test_exec(components, pairs, testfn, execfn):
    for c,vars in pairs:
        tmp_context = components[c].context.copy()
        tmp_context.update(vars)
        try:
            testfn(tmp_context)
        except:
            continue
        components[c].context.update(vars)
        execfn(components[c].context)

However this approach is slightly more complex to implement: it requires sufficient memory to add one more parameter set (N+1 parameter sets, where N components are supported).

A second possibility is to provide a loop “break" command, so that the map can stop when a successful test is made. However, I don’t like this approach since it will probably violate the principle of least surprise: leaving traces of failed tests in the parameter sets seems like it would be unexpected.

A third possibility would be to add a second set of parameters, which is applied after the test sequence, if successful. This should produce less surprising results.

Map_Test_Execute = [
    parameter-list : [ + [
        component: uint,
        ? test-parameters: nil/{ + SUIT_Parameters },
        ? exec-parameters: { + SUIT_Parameters }
    ] ],
    ? test-sequence : nil/bstr .cbor SUIT_Command_Sequence,
    ? exec-sequence : bstr .cbor SUIT_Command_Sequence
]

I think that this primitive has value. I think that it would be fairly straight-forward to implement if N+1 parameter sets are possible. The test-parameters + exec-parameters variant is cheaper in memory, slightly more complex in encoding, but still fairly straight-forward to implement.

Best Regards,
Brendan
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.