Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Support for SUIT in the Firmware Update API #174

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

athoelke
Copy link
Contributor

This is a draft PR that creates an RFC proposal document, considering how to implement full support for SUIT in the Firmware Update API.

Reading the proposal is easiest by viewing the document in its branch: rfc-01-fwu-suit

Please provide feedback on the analysis, the draft proposal, and any of the currently open issues (end of the document right now); either in the PR discussion thread, or as review comments against the 'Files changed'.

@athoelke athoelke added enhancement New feature or request API design Related the design of the API Firmware Update API Issue or PR related to the Firmware Update API proposal An RFC, or proposal for discussion labels Feb 15, 2024
@athoelke athoelke requested a review from ndevillard February 15, 2024 17:57
@athoelke athoelke self-assigned this Feb 15, 2024
   * Reworked the state model and API based on detailed understanding of the Multiple Trust Domain extension to the base SUIT specification.
   * Added component state information to the detailed sequence graphic to clarify the programming model.
   * Aligned the document with the details of the SUIT specifications.
   * Provided more detail on how the API design supports the alternative flow scenarios.
@athoelke
Copy link
Contributor Author

athoelke commented Mar 7, 2024

I've updated the proposal following initial discussion, and further, detailed reading of some of the additional SUIT specifications relating to nested/dependency manifests.

  • Reworked the state model and API based on detailed understanding of the Multiple Trust Domain extension to the base SUIT specification.
  • Added component state information to the detailed sequence graphic to clarify the programming model.
  • Aligned the document with the details of the SUIT specifications.
  • Provided more detail on how the API design supports the alternative flow scenarios.

Much of the text has been altered or completely rewritten - if you have read v1, it may be worthwhile reading the whole new proposal, instead of reviewing the diffs.

More sequence flows, including fetch-during-install, and clarity on component identifiers
@athoelke
Copy link
Contributor Author

athoelke commented Apr 3, 2024

A second update to the proposal.

  • I have added graphics to show flows for fetching payloads during suit-install, and not just the suit-payload-fetch command sequence. And text to explain the rationale for this support.
  • I have added some information about Firmware Update API component identifier usage.

A few key open issues remain:

  • Component identifier definition (in particular the C type)
  • Need for additional component information in response to a status query
  • API for processing SUIT fetch commands during suit-payload-fetch and suit-install misaligns with existing per-component transfer, but all-CANDIDATE installation APIs.

@athoelke athoelke force-pushed the fwu-suit-rfc branch 2 times, most recently from 369a74d to 9668daa Compare April 17, 2024 19:37
* Removed the FETCHING state
* Addressed the issues relating to the use of payload fetching during the suit-install sequence.
* Added extra flow diagrams
* Further clarification of component ids
* Realised that an alternate flow might be a better API fit - see the Appendix with alternate sequence diagrams.
@athoelke
Copy link
Contributor Author

Version 0.4 uploaded. Revision notes:

  • Resolved issue: Removed FETCHING state from the envelope.

  • Resolved issue: API design for handling fetching during suit-install:

    • Restrict the API: only a single top-level SUIT envelope component can be install at a time. If two MUST be installed together (due to interdependency) they SHOULD be dependencies within a single, separate Dependent manifest.
    • Remove the envelope component id parameter from psa_fwu_process(). As there is only one envelope being installed, the client does not need to indicate what needs to be processed.
  • Resolved issue: Make psa_fwu_component_t a 32-bit integral type. In the v1.0 API it only appears as a function parameter, so widen the type does not affect source compatibility for the API.

  • Described different strategies for envelope id allocation, and use of additional component ids for querying the firmware status of the system.

Note also: Alternative flow is possible with one-at-a-time restriction. See the appendix in the proposal for details.

Resolution of all substantial open issues:

* The alternative flow in v0.4 is not viable as it combines the payload phase with the install phase. This prevents the use case where the decision to apply/install the update can be separated from the delivery of the update.

     The associated appendix has been removed.

* The two phases of payload fetching need to have distinct states for the envelope component. The first phase is non-destructive of the current firmware, so the work to abandon an update is different in these two phases.

     PROCESSING state is now FETCHING and INSTALLING states.

* Added the suit-resolve-dependencies and suit-candidate-validation to the sequence diagrams to clarify where these SUIT command sequences fit.

* Added detail to the error, cancellation, and restart sections relating to the FETCHING and INSTALLING states, and the ability to cancel and restart the current payload fetch.
@athoelke
Copy link
Contributor Author

Updated to v0.5 - see commit or revision history for update notes.

@athoelke athoelke force-pushed the fwu-suit-rfc branch 3 times, most recently from ed8bdda to c7c37a6 Compare April 25, 2024 12:35
@athoelke
Copy link
Contributor Author

v0.6: I've made an attempt to define the API. This raises a few additional issues to resolve relating to detailed API design.


* 8: If a payload is required that is detached from the Envelope, the call to ``psa_fwu_process()`` returns with a new status code, ``PSA_FWU_PAYLOAD_REQUIRED``. The call to ``psa_fwu_process()`` includes an output parameter, which the service uses to provide the details of the payload to be transferred, including a component identifier for the payload (for use with ``psa_fwu_start()`` etc), and a URI for the payload.

*The Update service might also have information about the size and digest of the payload to be fetched. These could be optionally be provided with the payload URI: are there benefits in using this information to eliminate or detect incorrect or malicious transfers prior to transfer to the Update service?*

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That functionality may cause confusions. In SUIT, a digest value (or expected payload size) in not a fixed property of component but rather an argument to directive-override-parameters ‘, so:

  • Expected digest value (or expected payload size) may be unknown at time of execution of ‘directive-fetch‘ – there is nothing what enforces a manifest creator to call ‘directive-override-parameters’ prior to ‘directive-fetch‘
  • Manifest may be crafted in a way that it accepts alternative payloads represented by single URI. In such case manifest may evaluate several digest values on fetched payload.
  • Methods of digest calculation for regular image and dependency manifest differs.
  • Manifest may be crafted in a way that it repeats fetching in case if recently downloaded payload is damaged, so some resiliency mechanisms are already in-place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not unlikely that the digest parameter will already be set when calling suit-directive-fetch:

  • One of the optimisations suggested for a SUIT processor when restarting a command sequence after interruption, is to elide the fetching of a payload that has already been transferred, by matching a stored payload using the digest of the requested payload.

  • This optimisation depends on the component's digest parameter being set prior to the suit-directive-fetch command. In the absence of the digest parameter the optimisation is disabled, and the payload will always be fetched.

I can see that for some systems, being able to detect a non-matching image before download, might avoid costly download or store-to-flash overheads. This could improve long-term-reliability, but only if having incorrect payload images on the update server is considered to be probable. It does not significantly mitigate security concerns, as an attacker can present an acceptable digest, but an invalid image, and would still result in the download and transfer of the image before the SUIT digest verification reports an error.

Conclusion

Adding these might be beneficial for some systems/deployments, but the availability of these attributes is not guaranteed. Therefore, if we add them to the payload information, then they must be optional, and we need another field in the payload information to individually indicate if these parameters are present in the information.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now (from v0.8 of the proposal) optionally provided in the payload information, with a flag to indicate its presence.

* 7: If processing is required, the Update client then calls ``psa_fwu_process()`` to begin manifest processing. At this point the Update service will do the following:

* Verify and authenticate the manifest.
* Process the Update command sequences: system validation, dependency resolution, payload fetch, payload verification.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no dedicated ‘system validation’ sequence defined in SUIT specification. Maybe it is worth to remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think when I first wrote this I was thinking about checking that the update matches the system (device type, etc.) - but that would be integrated into one of the other sequences.

Fixed.


* 22: To proceed with the installation, the Update client now calls ``psa_fwu_install()``.

* 23: The flow in Figure 3 shows a system which requires a reboot to continue with the installation. The suit-install SUIT command sequences will be processed after the reboot.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suit-candidate-validation and suit-install?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected

Dependency manifests
~~~~~~~~~~~~~~~~~~~~

In SUIT, a dependency manifest (one nested within a dependent manifest) is not processed in an isolated manner. Instead, all dependency manifests, including those nested at deeper levels, are identified and fetched before any other payload. Then the full set of manifests is involved in each of the subsequent command processing stages of the SUIT top-level (root) manifest.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Then the full set of manifests is involved...," Actually - Currently processed command sequence MAY execute 'process-dependency' on any dependencies of currently processed manifests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected/clarified.

athoelke added 2 commits May 1, 2024 14:38
Update to the API:

* Describe a third (preferred) option for the payload information discovery API, OPTION C. This is also reflected in updated sequence diagrams.
* Permit an implementation to optionally provide additional payload size and digest information. (Only coded into Option C).
@athoelke
Copy link
Contributor Author

Updated the proposal to v0.8:

  • Describe a third (now preferred) option for the payload information discovery API, OPTION C. The additional function used in this option is also reflected in updated sequence diagrams.
  • Permit an implementation to optionally provide additional payload size and digest information. (Only coded into the payload information structure in Option C).

@athoelke
Copy link
Contributor Author

The Open Issues remaining:

  • Final naming of API elements. The names seemed to have settled - but the new API psa_fwu_payload() to retrieve the payload parameters might not be ideal yet. I have renamed the structure for payload information to psa_fwu_payload_info_t to match the existing psa_fwu_component_info_t.

  • We don't think there additional attributes for components that need to be included in the psa_fwu_component_info_t. Specifically, we don't expect Update clients to implement a SUIT processor - the new API design is based around the processor being inside the implementation.

  • The psa_fwu_payload() function (in Option C) is unusual in returning a variable length buffer, but without returning the actual length written to the buffer. The length is returned by the preceding call to psa_fwu_process(). If we add the parameter, the API now returns this length twice (which is also slightly odd).

  • I have considered merging the action of the call to psa_fwu_start(payload_id, 0, 0) into psa_fwu_payload(payload_id, ...), which must always follow it (maybe calling it psa_fwu_start_payload(payload_id, ...)).

    This would reduce the functions called, and does not affect the size of the API, but would make the image transfer for payloads slightly different to that for other component images, potentially reducing the ability to share code for these activities.

    For now, the API reuses the same psa_fwu_start() call for initiating payload transfer after the call to psa_fwu_payload().

athoelke added 5 commits May 23, 2024 17:02
The alternative options for the API design (A and B) have been retired to an appendix, so that the API definition is clearer.
Minor updates to finalize API details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API design Related the design of the API enhancement New feature or request Firmware Update API Issue or PR related to the Firmware Update API proposal An RFC, or proposal for discussion
Projects
Development

Successfully merging this pull request may close these issues.

2 participants