openwrtv3/package/system/fwtool/src/fwimage.h
Felix Fietkau 929641fa1f fwtool: add utility for appending and extracting firmware metadata/signatures
This will be used to append extra information to images which allows the
system to verify if an image is compatible with the system.

The extra data is appended to the end of the image, where it will be
ignored when upgrading from systems that do not process this data yet:

If the image is a squashfs or jffs2 image, the extra data will land
after the end-of-filesystem marker, where it will be overwritten once
the system boots for the first timee.

If the image is a sysupgrade tar file, tar will simply ignore the extra
data when unpacking.

The layout of the metadata/signature chunks is constructed in a way
that the last part contains just a magic and size information, so that
the tool can quickly check if any valid data is present without having
to do a pattern search throughout the full image.

Chunks also contain CRC32 information to detect file corruption, even
when the image is not signed.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2016-11-19 11:24:09 +01:00

39 lines
861 B
C

/*
* Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __FWIMAGE_H
#define __FWIMAGE_H
#include <stdint.h>
#define FWIMAGE_MAGIC 0x46577830 /* FWx0 */
struct fwimage_header {
uint32_t version;
uint32_t flags;
char data[];
};
struct fwimage_trailer {
uint32_t magic;
uint32_t crc32;
uint8_t type;
uint8_t __pad[3];
uint32_t size;
};
enum fwimage_type {
FWIMAGE_SIGNATURE,
FWIMAGE_INFO,
};
#endif