2017-04-01 10:57:14 +00:00
|
|
|
#ifndef __TREZORHAL_IMAGE_H__
|
|
|
|
#define __TREZORHAL_IMAGE_H__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint32_t magic;
|
|
|
|
uint32_t hdrlen;
|
|
|
|
uint32_t expiry;
|
|
|
|
uint32_t codelen;
|
|
|
|
uint32_t version;
|
|
|
|
// uint8_t reserved[427];
|
|
|
|
uint8_t sigmask;
|
|
|
|
uint8_t sig[64];
|
|
|
|
} image_header;
|
|
|
|
|
2017-04-05 15:41:10 +00:00
|
|
|
#define MAX_VENDOR_PUBLIC_KEYS 8
|
|
|
|
|
2017-04-01 17:24:41 +00:00
|
|
|
typedef struct {
|
|
|
|
uint32_t magic;
|
|
|
|
uint32_t hdrlen;
|
|
|
|
uint32_t expiry;
|
|
|
|
uint16_t version;
|
|
|
|
uint8_t vsig_m;
|
|
|
|
uint8_t vsig_n;
|
2017-10-05 15:31:05 +00:00
|
|
|
uint8_t vtrust;
|
|
|
|
// uint8_t reserved[16];
|
2017-04-05 15:41:10 +00:00
|
|
|
const uint8_t *vpub[MAX_VENDOR_PUBLIC_KEYS];
|
2017-04-01 17:24:41 +00:00
|
|
|
uint8_t vstr_len;
|
|
|
|
const uint8_t *vstr;
|
|
|
|
const uint8_t *vimg;
|
|
|
|
uint8_t sigmask;
|
|
|
|
uint8_t sig[64];
|
|
|
|
} vendor_header;
|
|
|
|
|
2017-10-19 16:45:57 +00:00
|
|
|
bool image_parse_header(const uint8_t * const data, const uint32_t magic, const uint32_t maxsize, image_header * const hdr);
|
2017-04-01 10:57:14 +00:00
|
|
|
|
2017-09-29 15:31:59 +00:00
|
|
|
bool image_check_signature(const uint8_t *data, const image_header *hdr, uint8_t key_m, uint8_t key_n, const uint8_t * const *keys);
|
2017-04-01 10:57:14 +00:00
|
|
|
|
2017-10-19 16:45:57 +00:00
|
|
|
bool vendor_parse_header(const uint8_t * const data, vendor_header * const vhdr);
|
2017-04-01 17:24:41 +00:00
|
|
|
|
2017-09-29 15:31:59 +00:00
|
|
|
bool vendor_check_signature(const uint8_t *data, const vendor_header *vhdr, uint8_t key_m, uint8_t key_n, const uint8_t * const *keys);
|
2017-04-01 17:24:41 +00:00
|
|
|
|
2017-04-01 10:57:14 +00:00
|
|
|
#endif
|