lib/deltas: Add inline signature for static-delta superblock

While the commits contained in the single static-delta file are signed so
we can check them and operate on trusted data, the superblock isn't signed
in any way, so it end up operating on untrusted data to:
 1. actually find where the trusted data is, and
 2. check whether the update is fit for the current device by looking at
    the collection id stored in the metadata

This commit generates signatures of all static data, and concatenate them
to the existing static delta format, i.e. as a GVariant layout `a{sv}ay`
where
 - a{sv}: signatures
 - ay: existing delta variant

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
This commit is contained in:
Frédéric Danis committed 2020-09-14 09:27:19 +02:00
1 parent 9c040c1a73
commit 46667567c5
2 files changed
+110 -6

No files matched your search

@@ -104,6 +104,25 @@ G_BEGIN_DECLS
*/
#define OSTREE_STATIC_DELTA_SUPERBLOCK_FORMAT "(a{sv}tayay" OSTREE_COMMIT_GVARIANT_STRING "aya" OSTREE_STATIC_DELTA_META_ENTRY_FORMAT "a" OSTREE_STATIC_DELTA_FALLBACK_FORMAT ")"
/**
* OSTREE_STATIC_DELTA_SIGNED_FORMAT
*
* magic: t magic number, 8 bytes for alignment
* superblock: ay delta supeblock variant
* signatures: a{sv}
*
* The signed static delta starts with the 'OSTSGNDT' magic number followed by
* the array of bytes containing the superblock used for the signature.
*
* Then, the signatures array contains the signatures of the superblock. A
* signature has the following form:
* type: signature key
* signature: variant depending on type used
*/
#define OSTREE_STATIC_DELTA_SIGNED_FORMAT "(taya{sv})"
#define OSTREE_STATIC_DELTA_SIGNED_MAGIC 0x4F535453474E4454 /* OSTSGNDT */
typedef enum {
OSTREE_STATIC_DELTA_OPEN_FLAGS_NONE = 0,
OSTREE_STATIC_DELTA_OPEN_FLAGS_SKIP_CHECKSUM = (1 << 0),