X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=lib%2Fflash%2Fflash.c;h=707e8007f12e642ff11d52c44575dffb02181065;hb=017aada974ef9c322cad412a9832fa1df265267b;hp=464b8760b54db8cdd2d8b51564f9dbdcf5a81b26;hpb=93d41f97eedca3684922f4c3cae82d4c74b04210;p=petitboot diff --git a/lib/flash/flash.c b/lib/flash/flash.c index 464b876..707e800 100644 --- a/lib/flash/flash.c +++ b/lib/flash/flash.c @@ -31,6 +31,8 @@ #include #include +#define SECURE_BOOT_HEADERS_SIZE 4096 +#define ROM_MAGIC_NUMBER 0x17082011 struct flash_info { /* Device information */ @@ -148,6 +150,16 @@ out: return NULL; } +/* See stb_is_container() in Skiboot */ +static bool is_signed(char *buffer, uint32_t len) +{ + if (!buffer || len <= SECURE_BOOT_HEADERS_SIZE) + return false; + if (be32_to_cpu(*(uint32_t *)buffer) != ROM_MAGIC_NUMBER) + return false; + return true; +} + int flash_parse_version(void *ctx, char ***versions, bool current) { char *saveptr, *tok, **tmp, *buffer; @@ -182,6 +194,10 @@ int flash_parse_version(void *ctx, char ***versions, bool current) goto out; } + /* Check if this partition is signed */ + if (is_signed(buffer, len)) + buffer += SECURE_BOOT_HEADERS_SIZE; + /* open-power-platform */ tok = strtok_r(buffer, delim, &saveptr); if (tok) {