[ot_certs,rom_ext] optimize on-device certificate generation code-size #24558
Labels
Manufacturing
Issues related to manufacturing tasks (hw or sw)
SW:ROM_EXT
ROM_EXT related issues
Type:Enhancement
Feature requests, enhancements
Milestone
Description
Currently, there exists opentitantool support (
opentitantool certificate codegen ...
) for generating device libraries that may be used to generate X.509 certificate binary blobs. The libraries make use of a manually crafted device library that can encode simple ASN.1 structures. While this mechanism is extremely flexible, i.e., new certificate extensions can be easily crafted, it comes at a cost of code-size. Specifically, when analyzing the size-breakdown of various components in the ROM_EXT, we can see that:for a grand total of ~6.5kb.
Moreover, we are currently attempting to add support for other DICE certificate extensions, and encodings (i.e., CBOR). If we continue to use the same approach, where we use host tools to generate device code that generates certificates on-device by calling into an additional CBOR device lib, then we could end up bloating the ROM_EXT (if we aim to provide a flexible ROM_EXT that can support multiple DICE certificate formats).
We should investigate a more efficient way to generate certificates on-device.
One approach could be to use an auto-generated fixed-size array template that various fields can be mem-copied into. The original rationale for not using such an approach was that doing so would require all fields in the TBS region to be fixed size, otherwise it is impossible to generate a fixed-sized template array. The biggest issue was that the serial number field in X.509 certs is encoded as an ASN.1 integer type, that does not allow 0 padding on the MSb side. One way around this is to just automatically set the MSb, since serial numbers are not crytpographic, rather just unique values (currently the serial number for OT certs is just a truncated SHA256 of the pub key). Other ideas/suggestions are also welcome.
Marking this lower priority for the time being, as I think we should investigate the size of the additional CBOR encoding libraries that are being vendored-in/implemented, and what room for code we have in ROM_EXT, and the impact the additional CBOR cert generation feature has on ROM_EXT code size before making a decision to pursue additional optimization work.
CC: @cfrantz
The text was updated successfully, but these errors were encountered: