blob: c65dcf5866bc91ace7297b9e3300f9282ab19e4e [file] [log] [blame] [edit]
/*
* Copyright (c) 2019 The Fuchsia Authors
*/
#include <config.h>
#include <common.h>
#ifndef _AML_IMAGE_H_
#define _AML_IMAGE_H_
#define CONFIG_AML_SECURE_BOOT_VERSION 4
#if (CONFIG_AML_SECURE_BOOT_VERSION < 4)
typedef struct __aml_enc_blk{
unsigned int nOffset;
unsigned int nRawLength;
unsigned int nSigLength;
unsigned int nAlignment;
unsigned int nTotalLength;
unsigned char szPad[12];
unsigned char szSHA2IMG[32];
unsigned char szSHA2KeyID[32];
}t_aml_enc_blk;
#define AML_SECU_BOOT_IMG_HDR_MAGIC "AMLSECU!"
#define AML_SECU_BOOT_IMG_HDR_MAGIC_SIZE (8)
#define AML_SECU_BOOT_IMG_HDR_VESRION (0x0905)
typedef struct {
unsigned char magic[AML_SECU_BOOT_IMG_HDR_MAGIC_SIZE];//magic to identify whether it is a encrypted boot image
unsigned int version; //ersion for this header struct
unsigned int nBlkCnt;
unsigned char szTimeStamp[16];
t_aml_enc_blk amlKernel;
t_aml_enc_blk amlRamdisk;
t_aml_enc_blk amlDTB;
}AmlEncryptBootImgInfo;
typedef struct _boot_img_hdr_secure_boot
{
unsigned char reserve4ImgHdr[1024];
AmlEncryptBootImgInfo encrypteImgInfo;
}AmlSecureBootImgHeader;
#define COMPILE_TYPE_ASSERT(expr, t) typedef char t[(expr) ? 1 : -1]
COMPILE_TYPE_ASSERT(2048 >= sizeof(AmlSecureBootImgHeader), _cc);
#else /* CONFIG_AML_SECURE_BOOT_VERSION */
#define AML_BOOT_HEADER_MAGIC 0x4c4d4140
#define AML_BOOT_HEADER_IMAGE_HASH_SIZE 32
#define AML_BOOT_HEADER_RESERVED_SIZE 200
#define AML_BOOT_HEADER_RSA_SIGNATURE_SIZE 256
typedef struct {
uint32_t magic;
uint32_t version;
uint32_t flags;
uint32_t img_version;
uint32_t img_size;
uint32_t img_offset;
uint8_t img_hash[AML_BOOT_HEADER_IMAGE_HASH_SIZE];
uint8_t reserved[AML_BOOT_HEADER_RESERVED_SIZE];
uint8_t rsa_sig[AML_BOOT_HEADER_RSA_SIGNATURE_SIZE];
} aml_boot_header_t;
#endif /* CONFIG_AML_SECURE_BOOT_VERSION */
#endif /* _AML_IMAGE_H_ */