#include <imx_container.h>
-int ahab_auth_cntr_hdr(struct container_hdr *container, u16 length);
+void *ahab_auth_cntr_hdr(struct container_hdr *container, u16 length);
int ahab_auth_release(void);
int ahab_verify_cntr_image(struct boot_img_t *img, int image_index);
printf("%s\n", ele_ind_str[get_idx(ele_ind, resp_ind, ARRAY_SIZE(ele_ind))]);
}
-int ahab_auth_cntr_hdr(struct container_hdr *container, u16 length)
+void *ahab_auth_cntr_hdr(struct container_hdr *container, u16 length)
{
int err;
u32 resp;
printf("Authenticate container hdr failed, return %d, resp 0x%x\n",
err, resp);
display_ahab_auth_ind(resp);
+ return NULL;
}
- return err;
+ return (void *)IMG_CONTAINER_BASE; /* Return authenticated container header */
}
int ahab_auth_release(void)
{
struct container_hdr *phdr;
int i, ret = 0;
- int err;
u16 length;
struct boot_img_t *img;
unsigned long s, e;
debug("container length %u\n", length);
- err = ahab_auth_cntr_hdr(phdr, length);
- if (err) {
+ phdr = ahab_auth_cntr_hdr(phdr, length);
+ if (!phdr) {
ret = -EIO;
goto exit;
}
/* Copy images to dest address */
for (i = 0; i < phdr->num_images; i++) {
- img = (struct boot_img_t *)(addr +
+ img = (struct boot_img_t *)((ulong)phdr +
sizeof(struct container_hdr) +
i * sizeof(struct boot_img_t));
#define AHAB_HASH_TYPE_MASK 0x00000700
#define AHAB_HASH_TYPE_SHA256 0
-int ahab_auth_cntr_hdr(struct container_hdr *container, u16 length)
+void *ahab_auth_cntr_hdr(struct container_hdr *container, u16 length)
{
int err;
err = sc_seco_authenticate(-1, SC_SECO_AUTH_CONTAINER,
SECO_LOCAL_SEC_SEC_SECURE_RAM_BASE);
- if (err)
+ if (err) {
printf("Authenticate container hdr failed, return %d\n", err);
+ return NULL;
+ }
- return err;
+ return (void *)SEC_SECURE_RAM_BASE; /* Return authenticated container header */
}
int ahab_auth_release(void)
{
struct container_hdr *phdr;
int i, ret = 0;
- int err;
+ __maybe_unused int err;
u16 length;
struct boot_img_t *img;
unsigned long s, e;
debug("container length %u\n", length);
- err = ahab_auth_cntr_hdr(phdr, length);
- if (err) {
+ phdr = ahab_auth_cntr_hdr(phdr, length);
+ if (!phdr) {
ret = -EIO;
goto exit;
}
/* Copy images to dest address */
for (i = 0; i < phdr->num_images; i++) {
- img = (struct boot_img_t *)(addr +
+ img = (struct boot_img_t *)((ulong)phdr +
sizeof(struct container_hdr) +
i * sizeof(struct boot_img_t));
struct spl_load_info *info, ulong offset)
{
struct container_hdr *container = NULL;
+ struct container_hdr *authhdr;
u16 length;
int i, size, ret = 0;
}
}
+ authhdr = container;
+
#ifdef CONFIG_AHAB_BOOT
- ret = ahab_auth_cntr_hdr(container, length);
- if (ret)
+ authhdr = ahab_auth_cntr_hdr(authhdr, length);
+ if (!authhdr) {
+ ret = -EINVAL;
goto end_auth;
+ }
#endif
- for (i = 0; i < container->num_images; i++) {
+ for (i = 0; i < authhdr->num_images; i++) {
struct boot_img_t *image = read_auth_image(spl_image, info,
- container, i,
+ authhdr, i,
offset);
if (!image) {