Memory API¶
Manifest¶
-
platform_t
get_platform
(const manifest_t *mt)¶
-
uint8_t *
get_server_key_x
(const manifest_t *mt)¶
-
uint8_t *
get_server_key_y
(const manifest_t *mt)¶
-
uint8_t *
get_digest
(const manifest_t *mt)¶
-
uint8_t *
get_vendor_signature_r
(const manifest_t *mt, uint8_t *size)¶
-
uint8_t *
get_vendor_signature_s
(const manifest_t *mt, uint8_t *size)¶
-
uint8_t *
get_server_signature_r
(const manifest_t *mt, uint8_t *size)¶
-
uint8_t *
get_server_signature_s
(const manifest_t *mt, uint8_t *size)¶
-
void
set_platform
(manifest_t *mt, platform_t platform)¶
-
void
set_server_key_x
(manifest_t *mt, uint8_t *server_key_x)¶
-
void
set_server_key_y
(manifest_t *mt, uint8_t *server_key_y)¶
-
void
set_digest
(manifest_t *mt, uint8_t *digest)¶
-
int
set_vendor_signature_r
(manifest_t *mt, uint8_t *vendor_signature_r, uint8_t size)¶
-
int
set_vendor_signature_s
(manifest_t *mt, uint8_t *vendor_signature_s, uint8_t size)¶
-
int
set_server_signature_r
(manifest_t *mt, uint8_t *server_signature_r, uint8_t size)¶
-
int
set_server_signature_s
(manifest_t *mt, uint8_t *server_signature_s, uint8_t size)¶
-
void
print_manifest
(const manifest_t *mt)¶ Print manifest known values.
- Parameters
mt
: Pointer to a manifest structure.
-
identity_t
get_identity
(const manifest_t *mt)¶
-
void
set_identity
(manifest_t *mt, identity_t identity)¶
-
pull_error
verify_signature
(manifest_t *mt, digest_func df, const uint8_t *pub_x, const uint8_t *pub_y, ecc_func_t ef)¶
-
FOREACH_ITEM
(ITEM)¶
-
DEFINE_GETTER
(type, name)¶ The scope of this file is to define the interface of a manifest. It can be implemented using different encodings, but each approach should implement this interface to be usable by the library
-
DEFINE_SETTER
(type, name)¶
-
DEFINE_GETTER_MEMORY
(type, name)¶
-
DEFINE_SETTER_MEMORY
(type, name)¶
Memory Interface¶
-
enum
mem_memint
::
mem_mode_t
¶ Values:
-
READ_ONLY
= 0¶
-
WRITE_CHUNK
= 1¶
-
WRITE_ALL
= 2¶
-
SEQUENTIAL_REWRITE
= 3¶
-
-
typedef struct mem_object_t
mem_object_t
¶
-
typedef struct mem_slot_t
mem_slot_t
¶
-
pull_error
memory_open
(mem_object_t *ctx, mem_id_t id, mem_mode_t mode)¶ Open a memory object.
The implementation of this function should open a memory object given the id. This can be mapped to any phisical object, such as a file, a ROM or even an allocated memory object. It depends on the needs of the platform and the application.
- Return
- PULL_SUCCESS if the memory was correctly open or the specific erro
- Parameters
ctx
: An unitialized memory objectid
: The id of the memory object. The obj_id enum must be defined when implementing this interface.mode
: The mode used to open the memory_object (i.e. READ, WRITE, etc)
-
int
memory_read
(mem_object_t *ctx, void *memory_buffer, size_t size, address_t offset)¶ Read bytes from a memory object.
This function reads size bytes from a memory object at the specified offset into the given memory buffer.
- Return
- The number of readed bytes or a negative number in case of error.
- Parameters
ctx
: The already opened memory object.memory_buffer
: The memory buffer acting as destination.size
: The number of bytes to read.offset
: The offset in the memory object from where to start reading.
-
int
memory_write
(mem_object_t *ctx, const void *memory_buffer, size_t size, address_t offset)¶ Write bytes into a memory object.
This function writes size bytes into an opened memory object at the offset specified.
- Return
- The number of written bytes or a negative number in case of error.
- Parameters
ctx
: An opened memory object.memory_buffer
: The memory buffer to be written.size
: The size of the memory buffer.offset
: The offset into the memory object.
-
pull_error
memory_close
(mem_object_t *ctx)¶ Close the memory object.
This should close and deallocate all the initialized resources.
- Return
- PULL_SUCCESS on success or a specific error otherwise.
- Parameters
ctx
: The memory object.
Memory Objects¶
-
pull_error
get_newest_firmware
(mem_id_t *id, version_t *version, mem_object_t *obj_t, bool prefer_bootable)¶ Get the id of the memory object containing the newest firmware.
- Return
- PULL_SUCCESS on success or a specific error otherwise.
- Parameters
id
: The id of the newest object.version
: The version of the newest object.obj_t
: A temporary mem_object_t used by the function.
-
pull_error
get_oldest_firmware
(mem_id_t *obj, version_t *version, mem_object_t *obj_t, bool prefer_bootable)¶ Get the id of the memory object containing the oldest firmware.
- Return
- PULL_SUCCESS on success or a specific error otherwise.
- Parameters
obj
: The id of the oldest objectversion
: The version of the oldest object.obj_t
: A temporary mem_object_t used by the function.
-
pull_error
copy_firmware
(mem_object_t *src, mem_object_t *dst, uint8_t *buffer, size_t buffer_size)¶ Copy the firmware s into the firmware d.
This function will use the size specified in the s firmware manifest to correcly copy the firmware.
- Note
- The buffer will be used to read from object s and to write to obejct d. If you are working with flash and your memory implementation is not buffered you can pass a buffer with size equal to the size of a flash page.
- Return
- PULL_SUCCESS on success or a specific error otherwise.
- Parameters
src
: The source memory object.dst
: The destination memory object.buffer
: Buffer used to copy the objectbuffer_size
: The size of the buffer
-
pull_error
swap_slots
(mem_object_t *obj1, mem_object_t *obj2, mem_object_t *obj_swap, size_t swap_size, uint8_t *buffer, size_t buffer_size)¶ Swap two slots using a swap memory_object.
This function swaps two slots using a memory objects with id SWAP
This functions assumes that the size of the SWAP memory object is is at least as big as the buffer_size and that the swap size is a multiple of the buffer size, such that swap_size % buffer_size == 0
- Note
- The buffer will be used to read from object s and to write to obejct d. If you are working with flash and your memory implementation is not buffered you can pass a buffer with size equal to the size of a flash page.
- Parameters
obj1
: The fist memory objectobj2
: The second memory objectobj_swap
: The memory object used for swappingswap_size
: The size of the swapping memory objectbuffer
: Buffer used to copy the objectbuffer_size
: The size of the buffer
- Return
- PULL_SUCCESS on success or a specific error otherwise.
-
pull_error
read_firmware_manifest
(mem_object_t *obj, manifest_t *mt)¶ Read the manifest of the memory object.
This function will use the size specified in the s firmware manifest to correcly copy the firmware.
- Return
- PULL_SUCCESS on success or a specific error otherwise.
- Parameters
obj_t
: The memory object where the manifeset is stored.mt
: manifest of the memory object.
-
pull_error
write_firmware_manifest
(mem_object_t *obj_t, const manifest_t *mt)¶ Write the manifest into the memory object.
- Return
- PULL_SUCCESS on success or a specific error otherwise.
- Parameters
obj_t
: The memory object where the manifeset must be stored.mt
: The manifest to be written.
-
pull_error
invalidate_object
(mem_id_t id, mem_object_t *obj_t)¶ Invalidate a memory object.
- Return
- Parameters
id
: Id of the object to invalidate.obj_t
: temporary variable used to open the object.