36 #include "cose/sign.h"
37 #include "nanocbor/nanocbor.h"
47 #ifndef SUIT_COSE_BUF_SIZE
48 #define SUIT_COSE_BUF_SIZE (180U)
54 #ifndef CONFIG_SUIT_COMPONENT_MAX
55 #define CONFIG_SUIT_COMPONENT_MAX (1U)
61 #ifndef CONFIG_SUIT_COMPONENT_MAX_NAME_LEN
62 #define CONFIG_SUIT_COMPONENT_MAX_NAME_LEN (32U)
71 #define SUIT_VERSION (1)
82 #define SUIT_STATE_HAVE_COMPONENTS (1 << 0)
87 #define SUIT_STATE_COSE_AUTHENTICATED (1 << 1)
92 #define SUIT_STATE_FULLY_AUTHENTICATED (1 << 2)
158 SUIT_PARAMETER_VENDOR_IDENTIFIER = 1,
159 SUIT_PARAMETER_CLASS_IDENTIFIER = 2,
160 SUIT_PARAMETER_IMAGE_DIGEST = 3,
161 SUIT_PARAMETER_USE_BEFORE = 4,
162 SUIT_PARAMETER_COMPONENT_OFFSET = 5,
163 SUIT_PARAMETER_STRICT_ORDER = 12,
164 SUIT_PARAMETER_SOFT_FAILURE = 13,
165 SUIT_PARAMETER_IMAGE_SIZE = 14,
166 SUIT_PARAMETER_ENCRYPTION_INFO = 18,
167 SUIT_PARAMETER_COMPRESSION_INFO = 19,
168 SUIT_PARAMETER_UNPACK_INFO = 20,
169 SUIT_PARAMETER_URI = 21,
170 SUIT_PARAMETER_SOURCE_COMPONENT = 22,
171 SUIT_PARAMETER_RUN_ARGS = 23,
172 SUIT_PARAMETER_DEVICE_IDENTIFIER = 24,
173 SUIT_PARAMETER_MINIMUM_BATTERY = 26,
174 SUIT_PARAMETER_UPDATE_PRIORITY = 27,
175 SUIT_PARAMETER_VERSION = 28,
176 SUIT_PARAMETER_WAIT_INFO = 29,
177 SUIT_PARAMETER_URI_LIST = 30,
196 #define SUIT_COMPONENT_STATE_FETCHED (1 << 0)
197 #define SUIT_COMPONENT_STATE_FETCH_FAILED (1 << 1)
198 #define SUIT_COMPONENT_STATE_VERIFIED (1 << 2)
199 #define SUIT_COMPONENT_STATE_FINALIZED (1 << 3)
207 typedef struct suit_storage suit_storage_ref_t;
255 #define SUIT_MANIFEST_COMPONENT_ALL (UINT8_MAX)
262 #define SUIT_MANIFEST_COMPONENT_NONE (SUIT_MANIFEST_COMPONENT_ALL - 1)
298 component->
state |= flag;
312 return (component->
state & flag);
325 char separator,
char *buf,
size_t buf_len);
@ SUIT_DIGEST_SHA256
SHA256.
int suit_storage_helper(void *arg, size_t offset, uint8_t *buf, size_t len, int more)
Helper function for writing bytes on flash a specified offset.
@ SUIT_ERR_SEQUENCE_NUMBER
Sequence number less or equal to current sequence number.
unsigned components_len
Current number of components.
static void suit_component_set_flag(suit_component_t *component, uint16_t flag)
Set a component flag.
@ SUIT_ERR_NOT_SUPPORTED
Unsupported features detected.
@ SUIT_DIGEST_SHA384
SHA384.
static bool suit_component_check_flag(suit_component_t *component, uint16_t flag)
Check a component flag.
int suit_policy_check(suit_manifest_t *manifest)
Check a manifest policy.
Generic storage backend state.
uint8_t component_current
Current component index.
size_t len
length of the manifest
suit_param_ref_t identifier
Component identifier.
suit_digest_type_t
SUIT payload digest types.
@ SUIT_ERR_SIGNATURE
Unable to verify signature.
@ SUIT_COMPONENT_DIGEST
Digest component.
@ SUIT_ERR_COND
Conditionals evaluate to false.
char * urlbuf
Buffer containing the manifest url.
@ SUIT_ERR_STORAGE_EXCEEDED
Backend out of space.
suit_error_t
SUIT error codes.
@ SUIT_COMPONENT_IDENTIFIER
Identifier component.
@ SUIT_ERR_STORAGE
Backend returned an error.
@ SUIT_DIGEST_TYPE_CIPHERTEXT
Ciphertext digest.
uint32_t validated
bitfield of validated policies
#define CONFIG_SUIT_COMPONENT_MAX
Maximum number of components supported in a SUIT manifest.
@ SUIT_ERR_STORAGE_UNAVAILABLE
Backend location not available.
uint32_t state
bitfield holding state information
SUIT parameter reference.
@ SUIT_COMPONENT_SIZE
Size component.
suit_storage_ref_t * storage_backend
Storage backend used.
uint16_t state
Component status flags.
suit_param_ref_t param_uri
Payload fetch URI.
const uint8_t * cose_payload
ptr to the payload of the COSE sign
@ SUIT_ERR_POLICY_FORBIDDEN
Denied because of policy mismatch.
int suit_parse(suit_manifest_t *manifest, const uint8_t *buf, size_t len)
Parse a manifest.
suit_param_ref_t param_size
Payload size.
suit_param_ref_t param_component_offset
Component offset inside the device memory.
suit_param_ref_t param_vendor_id
Vendor ID.
size_t urlbuf_len
Length of the manifest url.
size_t cose_payload_len
length of the COSE payload
@ SUIT_DIGEST_SHA512
SHA512.
@ SUIT_DIGEST_NONE
No digest algo supplied.
const uint8_t * buf
ptr to the buffer of the manifest
@ SUIT_ERR_DIGEST_MISMATCH
Digest mismatch with COSE and SUIT.
suit_param_ref_t param_digest
Payload verification digest.
suit_param_ref_t param_class_id
Class ID.
@ SUIT_DIGEST_TYPE_PREIMAGE
Pre-image digest.
@ SUIT_DIGEST_TYPE_INSTALLED
Installed firmware digest.
@ SUIT_ERR_NO_MEM
Out of memory condition.
SUIT component struct as decoded from the manifest.
@ SUIT_OK
Manifest parsed and validated.
int suit_component_name_to_string(const suit_manifest_t *manifest, const suit_component_t *component, char separator, char *buf, size_t buf_len)
Convert a component name to a string.
@ SUIT_DIGEST_TYPE_RAW
Raw payload digest.
suit_digest_t
SUIT payload digest algorithms.
@ SUIT_ERR_INVALID_MANIFEST
Unexpected CBOR structure detected.
@ SUIT_ERR_UNSUPPORTED
Unsupported SUIT feature detected.
uint16_t offset
offset to the start of the content
#define SUIT_COSE_BUF_SIZE
Buffer size used for Cose.