Skip to content

Commit c2f7005

Browse files
committed
boot/bootutil: Split private image API out of image.h
image.h will now only contain applicaiton image related structures and defines. The split has been done to reduce need for including extra headers, for example FIH support and mcuboot_config.h into software that needs the same defining as MCUboot but implements own functions. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 3a33d4f commit c2f7005

File tree

4 files changed

+67
-20
lines changed

4 files changed

+67
-20
lines changed

boot/bootutil/include/bootutil/boot_hooks.h

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
#ifndef H_BOOTUTIL_HOOKS
3535
#define H_BOOTUTIL_HOOKS
3636

37+
#include <bootutil/image.h>
38+
#include <bootutil/image_api_priv.h>
39+
3740
#ifdef MCUBOOT_IMAGE_ACCESS_HOOKS
3841

3942
#define BOOT_HOOK_CALL(f, ret_default, ...) f(__VA_ARGS__)

boot/bootutil/include/bootutil/image.h

-20
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
#include <inttypes.h>
3232
#include <stdbool.h>
33-
#include "bootutil/fault_injection_hardening.h"
3433

3534
#ifdef __cplusplus
3635
extern "C" {
@@ -192,13 +191,6 @@ struct image_tlv {
192191
_Static_assert(sizeof(struct image_header) == IMAGE_HEADER_SIZE,
193192
"struct image_header not required size");
194193

195-
struct enc_key_data;
196-
fih_ret bootutil_img_validate(struct enc_key_data *enc_state, int image_index,
197-
struct image_header *hdr,
198-
const struct flash_area *fap,
199-
uint8_t *tmp_buf, uint32_t tmp_buf_sz,
200-
uint8_t *seed, int seed_len, uint8_t *out_hash);
201-
202194
struct image_tlv_iter {
203195
const struct image_header *hdr;
204196
const struct flash_area *fap;
@@ -209,18 +201,6 @@ struct image_tlv_iter {
209201
uint32_t tlv_end;
210202
};
211203

212-
int bootutil_tlv_iter_begin(struct image_tlv_iter *it,
213-
const struct image_header *hdr,
214-
const struct flash_area *fap, uint16_t type,
215-
bool prot);
216-
int bootutil_tlv_iter_next(struct image_tlv_iter *it, uint32_t *off,
217-
uint16_t *len, uint16_t *type);
218-
int bootutil_tlv_iter_is_prot(struct image_tlv_iter *it, uint32_t off);
219-
220-
int32_t bootutil_get_img_security_cnt(struct image_header *hdr,
221-
const struct flash_area *fap,
222-
uint32_t *security_cnt);
223-
224204
#ifdef __cplusplus
225205
}
226206
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* Copyright (c) 2016-2019 Linaro LTD
5+
* Copyright (c) 2016-2019 JUUL Labs
6+
* Copyright (c) 2019-2023 Arm Limited
7+
* Copyright (c) 2023 Nordic Semiconductor ASA
8+
*
9+
* Original license:
10+
*
11+
* Licensed to the Apache Software Foundation (ASF) under one
12+
* or more contributor license agreements. See the NOTICE file
13+
* distributed with this work for additional information
14+
* regarding copyright ownership. The ASF licenses this file
15+
* to you under the Apache License, Version 2.0 (the
16+
* "License"); you may not use this file except in compliance
17+
* with the License. You may obtain a copy of the License at
18+
*
19+
* http://www.apache.org/licenses/LICENSE-2.0
20+
*
21+
* Unless required by applicable law or agreed to in writing,
22+
* software distributed under the License is distributed on an
23+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
24+
* KIND, either express or implied. See the License for the
25+
* specific language governing permissions and limitations
26+
* under the License.
27+
*/
28+
29+
#ifndef H_IMAGE_API_PRIV_
30+
#define H_IMAGE_API_PRIV_
31+
32+
#include <inttypes.h>
33+
#include <stdbool.h>
34+
#include <bootutil/image.h>
35+
#include <bootutil/fault_injection_hardening.h>
36+
37+
#ifdef __cplusplus
38+
extern "C" {
39+
#endif
40+
41+
struct enc_key_data;
42+
fih_ret bootutil_img_validate(struct enc_key_data *enc_state, int image_index,
43+
struct image_header *hdr,
44+
const struct flash_area *fap,
45+
uint8_t *tmp_buf, uint32_t tmp_buf_sz,
46+
uint8_t *seed, int seed_len, uint8_t *out_hash);
47+
48+
int bootutil_tlv_iter_begin(struct image_tlv_iter *it,
49+
const struct image_header *hdr,
50+
const struct flash_area *fap, uint16_t type,
51+
bool prot);
52+
int bootutil_tlv_iter_next(struct image_tlv_iter *it, uint32_t *off,
53+
uint16_t *len, uint16_t *type);
54+
55+
int32_t bootutil_get_img_security_cnt(struct image_header *hdr,
56+
const struct flash_area *fap,
57+
uint32_t *security_cnt);
58+
59+
#ifdef __cplusplus
60+
}
61+
#endif
62+
63+
#endif

boot/bootutil/src/image_validate.c

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#include "bootutil/image.h"
3636
#include "bootutil/crypto/sha.h"
37+
#include "bootutil/image_api_priv.h"
3738
#include "bootutil/sign_key.h"
3839
#include "bootutil/security_cnt.h"
3940
#include "bootutil/fault_injection_hardening.h"

0 commit comments

Comments
 (0)