summaryrefslogtreecommitdiff
path: root/include/image.h
AgeCommit message (Collapse)Author
2022-11-22image: Correct strncpy() warning with image_set_name()Simon Glass
gcc 12 seems to warn on strncpy() as a matter of course. Rewrite the code a different way to do the same thing, to avoid the warning. Signed-off-by: Simon Glass <[email protected]>
2022-10-31image: Allow loading a FIT image for a particular phaseSimon Glass
Add support for filtering out FIT images by phase. Rather than adding yet another argument to this already overloaded function, use a composite value, where the phase is only added in if needed. The FIT config is still selected (and verified) as normal, but the images are selected based on the phase. Tests for this come in a little later, as part of the updated VPL test. Signed-off-by: Simon Glass <[email protected]>
2022-10-31image: Add the concept of a phase to FITSimon Glass
We want to be able to mark an image as related to a phase, so we can easily load all the images for SPL or for U-Boot proper. Add this to the FIT specification, along with some access functions. Signed-off-by: Simon Glass <[email protected]>
2022-10-31image: Move comment for fit_conf_find_compat()Simon Glass
Move this comment to the header file, where the APIs should be defined. Signed-off-by: Simon Glass <[email protected]>
2022-10-11image-pre-load: Move macros/definitions to image.hSteven Lawrance
Putting these definitions in a header will allow signatures to be validated independently of bootm. Signed-off-by: Steven Lawrance <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2022-09-29treewide: Drop image_header_t typedefSimon Glass
This is not needed and we should avoid typedefs. Use the struct instead and rename it to indicate that it really is a legacy struct. Signed-off-by: Simon Glass <[email protected]>
2022-09-29treewide: Drop image_info_t typedefSimon Glass
This is not needed and we should avoid typedefs. Use the struct instead. Signed-off-by: Simon Glass <[email protected]>
2022-09-29treewide: Drop bootm_headers_t typedefSimon Glass
This is not needed and we should avoid typedefs. Use the struct instead. Signed-off-by: Simon Glass <[email protected]>
2022-09-29image: Fix BOOTM_STATE valuesSimon Glass
Tidy up the code style for these. Signed-off-by: Simon Glass <[email protected]>
2022-09-19Merge branch 'master' into nextTom Rini
Signed-off-by: Tom Rini <[email protected]>
2022-09-14image: Drop some other #ifdefs in image-board.cSimon Glass
Remove all but a few that are difficult, relying on legacy CONFIG options or optional global_data fields. Drop the duplicate function name in the comment for boot_get_cmdline(). Signed-off-by: Simon Glass <[email protected]>
2022-09-07image: fit: Add some helpers for getting dataSean Anderson
Several different firmware users have repetitive code to extract the firmware data from a FIT. Add some helper functions to reduce the amount of repetition. fit_conf_get_prop_node (eventually) calls fdt_check_node_offset_, so we can avoid an explicit if. In general, this version avoids printing on error because the callers are typically library functions, and because the FIT code generally has (debug) prints of its own. One difference in these helpers is that they use fit_image_get_data_and_size instead of fit_image_get_data, as the former handles external data correctly. Signed-off-by: Sean Anderson <[email protected]> Reviewed-by: Simon Glass <[email protected]> Signed-off-by: Peng Fan <[email protected]>
2022-04-11lib: rsa: Fix const-correctness of rsassa_pss functionsSESA644425
Prior to introduction of modifications in rsassa_pss functions related to padding verification, doing a pass to update const-correctness in targeted functions to comply with coding-rules and avoid const-cast Signed-off-by: SESA644425 <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2022-04-05Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sunxiTom Rini
A big part is the DM pinctrl driver, which allows us to get rid of quite some custom pinmux code and make the whole port much more robust. Many thanks to Samuel for that nice contribution! There are some more or less cosmetic warnings about missing clocks right now, I will send the trivial fixes for that later. Another big chunk is the mkimage upgrade, which adds RISC-V and TOC0 (secure images) support. Both features are unused at the moment, but I have an always-secure board that will use that once the DT lands in the kernel. On top of those big things we have some smaller fixes, improving the I2C DM support, fixing some H6/H616 early clock setup and improving the eMMC boot partition support. The gitlab CI completed successfully, including the build test for all 161 sunxi boards. I also boot tested on a A64, A20, H3, H6, and F1C100 board. USB, SD card, eMMC, and Ethernet all work there (where applicable).
2022-04-04tools: mkimage: Add Allwinner TOC0 supportSamuel Holland
Most Allwinner sunxi SoCs have separate boot ROMs in non-secure and secure mode. The "non-secure" or "normal" boot ROM (NBROM) uses the existing sunxi_egon image type. The secure boot ROM (SBROM) uses a completely different image type, known as TOC0. A TOC0 image is composed of a header and two or more items. One item is the firmware binary. The others form a chain linking the firmware signature to the root-of-trust public key (ROTPK), which has its hash burned in the SoC's eFuses. Signatures are made using RSA-2048 + SHA256. The pseudo-ASN.1 structure is manually assembled; this is done to work around bugs/quirks in the boot ROM, which vary between SoCs. This TOC0 implementation has been verified to work with the A50, A64, H5, H6, and H616 SBROMs, and it may work with other SoCs. Signed-off-by: Samuel Holland <[email protected]> Acked-by: Andre Przywara <[email protected]> Signed-off-by: Andre Przywara <[email protected]>
2022-03-31mkimage: add public key for image pre-load stagePhilippe Reynes
This commit enhances mkimage to update the node /image/pre-load/sig with the public key. Reviewed-by: Simon Glass <[email protected]> Signed-off-by: Philippe Reynes <[email protected]>
2022-03-31cmd: bootm: add a stage pre-loadPhilippe Reynes
Add a stage pre-load to the command bootm. Right now, this stage may be used to read a header and check the signature of the full image. Reviewed-by: Simon Glass <[email protected]> Signed-off-by: Philippe Reynes <[email protected]>
2022-03-31boot: image: add a stage pre-loadPhilippe Reynes
Add a stage pre-load that could check or modify an image. For the moment, only a header with a signature is supported. This header has the following format: - magic : 4 bytes - version : 4 bytes - header size : 4 bytes - image size : 4 bytes - offset image signature : 4 bytes - flags : 4 bytes - reserved0 : 4 bytes - reserved1 : 4 bytes - sha256 of the image signature : 32 bytes - signature of the first 64 bytes : n bytes - image signature : n bytes - padding : up to header size The stage uses a node /image/pre-load/sig to get some informations: - algo-name (mandatory) : name of the algo used to sign - padding-name : name of padding used to sign - signature-size : size of the signature (in the header) - mandatory : set to yes if this sig is mandatory - public-key (madatory) : value of the public key Before running the image, the stage pre-load checks the signature provided in the header. This is an initial support, later we could add the support of: - ciphering - uncompressing - ... Signed-off-by: Philippe Reynes <[email protected]>
2022-01-26tools: mkimage: Show where signatures/keys are writtenSimon Glass
At present mkimage displays the node information but it is not clear what signing action was taken. Add a message that shows it. For now it only supports showing a single signing action, since that is the common case. Sample: Signature written to 'sha1-basic/test.fit', node '/configurations/conf-1/signature' Public key written to 'sha1-basic/sandbox-u-boot.dtb', node '/signature/key-dev' Signed-off-by: Simon Glass <[email protected]>
2022-01-26image: Return destination node for add_verify_data() methodSimon Glass
It is useful to know where the verification data was written. Update the API to return this. Signed-off-by: Simon Glass <[email protected]>
2022-01-26tools: Pass the key blob aroundSimon Glass
At present we rely on the key blob being in the global_data fdt_blob pointer. This is true in U-Boot but not with tools. For clarity, pass the parameter around. Signed-off-by: Simon Glass <[email protected]>
2022-01-26tools: Improve comments in signing functionsSimon Glass
Add some more comments to explain what is going on in the signing functions. Fix two repeated typos. Signed-off-by: Simon Glass <[email protected]>
2022-01-24mkimage: Allow to specify the signature algorithm on the command lineJan Kiszka
This permits to prepare FIT image description that do not hard-code the final choice of the signature algorithm, possibly requiring the user to patch the sources. When -o <algo> is specified, this information is used in favor of the 'algo' property in the signature node. Furthermore, that property is set accordingly when writing the image. Signed-off-by: Jan Kiszka <[email protected]>
2022-01-24image-fit: Make string of algo parameter constantJan Kiszka
Modifications would be invalid. Signed-off-by: Jan Kiszka <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2022-01-19doc: replace @return by Return:Heinrich Schuchardt
Sphinx expects Return: and not @return to indicate a return value. find . -name '*.c' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; find . -name '*.h' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; Signed-off-by: Heinrich Schuchardt <[email protected]>
2021-10-31image.h: make image_sign_info.fit point to constHannu Lounento
The data blob apparently does not need to be modified through the fit field of the image_sign_info struct so make it point to const to avoid the need to cast away constness in functions that assign a pointer to const data to the field. fit_image_setup_verify already had to cast away constness as it assigned a const void * argument to the field. The cast can now be removed. Signed-off-by: Hannu Lounento <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2021-10-08image: Drop most #ifdefs in image-board.cSimon Glass
Remove ifdefs in this file, so far as possible without too much refactoring. Signed-off-by: Simon Glass <[email protected]>
2021-10-08image: Drop unnecessary #ifdefs from image.hSimon Glass
This file has a lot of conditional code and much of it is unnecessary. Clean this up to reduce the number of build combinations. Signed-off-by: Simon Glass <[email protected]>
2021-10-08image: Tidy up fit_unsupported_reset()Simon Glass
This function is only used in one place and does not need to use the preprocessor. Move it to the C file and convert it to a normal function. Drop fit_unsupported() since it is not used. Signed-off-by: Simon Glass <[email protected]>
2021-10-08image: Drop IMAGE_ENABLE_IGNORESimon Glass
We can use the new host_build() function for this, so drop it. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Alexandru Gagniuc <[email protected]>
2021-10-08image: Drop IMAGE_OF_SYSTEM_SETUPSimon Glass
This is not needed with Kconfig, since we can use IS_ENABLED() easily enough. Drop it. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Alexandru Gagniuc <[email protected]>
2021-10-08image: Drop IMAGE_OF_BOARD_SETUPSimon Glass
This is not needed with Kconfig, since we can use IS_ENABLED() easily enough. Drop it. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Alexandru Gagniuc <[email protected]>
2021-10-08image: Drop IMAGE_BOOT_GET_CMDLINESimon Glass
This is not needed with Kconfig, since we can use IS_ENABLED() easily enough and the board code is now in a separate file. Update the only place where this is used and drop it. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Alexandru Gagniuc <[email protected]>
2021-10-08image: Use Kconfig to enable FIT_RSASSA_PSS on hostSimon Glass
Add a host Kconfig for FIT_RSASSA_PSS. With this we can use CONFIG_IS_ENABLED(FIT_RSASSA_PSS) directly in the host build, so drop the forcing of this in the image.h header. Drop the #ifdef around padding_pss_verify() too since it is not needed. Use the compiler to check the config where possible, instead of the preprocessor. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Alexandru Gagniuc <[email protected]>
2021-10-08image: Use Kconfig to enable CONFIG_FIT_VERBOSE on hostSimon Glass
Add a host Kconfig for FIT_VERBOSE. With this we can use CONFIG_IS_ENABLED(FIT_VERBOSE) directly in the tools build, so drop the forcing of this in the image.h header. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Alexandru Gagniuc <[email protected]>
2021-10-08image: Drop IMAGE_ENABLE_OF_LIBFDTSimon Glass
Add a host Kconfig for OF_LIBFDT. With this we can use CONFIG_IS_ENABLED(OF_LIBFDT) directly in the tools build, so drop the unnecessary indirection. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Alexandru Gagniuc <[email protected]>
2021-10-08image: Drop IMAGE_ENABLE_FITSimon Glass
Make use of the host Kconfig for FIT. With this we can use CONFIG_IS_ENABLED(FIT) directly in the host build, so drop the unnecessary indirection. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Alexandru Gagniuc <[email protected]>
2021-10-08hash: Use Kconfig to enable hashing in host tools and SPLSimon Glass
At present when building host tools, we force CONFIG_SHAxxx to be enabled regardless of the board Kconfig setting. This is done in the image.h header file. For SPL we currently just assume the algorithm is desired if U-Boot proper enables it. Clean this up by adding new Kconfig options to enable hashing on the host, relying on CONFIG_IS_ENABLED() to deal with the different builds. Add new SPL Kconfigs for hardware-accelerated hashing, to maintain the current settings. This allows us to drop the image.h code and the I_WANT_MD5 hack. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Alexandru Gagniuc <[email protected]>
2021-09-14image: rsa: Move padding_algos to linker listsAlexandru Gagniuc
We are not guaranteed to have the padding_pkcs_15_verify symbol since commit 92c960bc1d ("lib: rsa: Remove #ifdefs from rsa.h"), and commit 61416fe9df ("Kconfig: FIT_SIGNATURE should not select RSA_VERIFY") The padding_algos only make sense with RSA verification, which can now be disabled in lieu of ECDSA. In fact this will lead to build failures because of the missing symbol mentioned earlier. To resolve this, move the padding_algos to a linker list, with declarations moved to rsa_verify.c. This is consistent with commit 6909edb4ce ("image: rsa: Move verification algorithm to a linker list") One could argue that the added #ifdef USE_HOSTCC is ugly, and should be hidden within the U_BOOT_PADDING_ALGO() macro. However, this would be inconsistent with the "cryptos" list. This logic for was not previously explored: Without knowledge of the U_BOOT_PADDING_ALGO() macro, its use is similar to something being declared. However, should #ifndef USE_HOSTCC be part of the macro, it would not be obvious that it behaves differently on host code and target code. Having the #ifndef outside the macro makes this obvious. Also, the #ifdef is not always necessary. For example ecda-verify makes use of U_BOOT_CRYPTO_ALGO() without any accompanying #ifdefs. The fundamental issue is a lack of separation of host and target code in rsa_verify. Therefore, the declaration of a padding algo with the external #ifdef is more readable and consistent. Signed-off-by: Alexandru Gagniuc <[email protected]>
2021-09-08image: Drop IMAGE_ENABLE_{MD5, CRC32} #definesAlexandru Gagniuc
These are no longer used, so drop them. Signed-off-by: Alexandru Gagniuc <[email protected]>
2021-09-08common: Move MD5 hash to hash_algo[] array.Alexandru Gagniuc
MD5 is being called directly in some places, but it is not available via hash_lookup_algo("md5"). This is inconsistent with other hasing routines. To resolve this, add an "md5" entry to hash_algos[]. The #ifdef clause looks funnier than those for other entries. This is because both MD5 and SPL_MD5 configs exist, whereas the other hashes do not have "SPL_" entries. The long term plan is to get rid of the ifdefs, so those should not be expected to survive much longer. The md5 entry does not have .hash_init/update/finish members. That's okay because hash_progressive_lookup_algo() will catch that, and return -EPROTONOSUPPORT, while hash_lookup_algo() will return the correct pointer. Signed-off-by: Alexandru Gagniuc <[email protected]> [trini: Use CONFIG_IS_ENABLED not IS_ENABLED for MD5 check] Signed-off-by: Tom Rini <[email protected]>
2021-09-08common: Remove unused CONFIG_FIT_SHAxxx selectorsAlexandru Gagniuc
Originally CONFIG_FIT_SHAxxx enabled specific SHA algos for and only for hash_calculate() in common/image-fit.c. However, since commit 14f061dcb1 ("image: Drop IMAGE_ENABLE_SHAxxx"), the correct selector was changed to CONFIG_SHAxxx. The extra "_FIT_" variants are neither used, nor needed. Remove them. One defconfig disables FIT_SHA256, which is now changed to 'SHA256'. CMD_MVEBU_BUBT needs to select select SHA256 to avoid undefined references to "sha256_*()". bubt.c needs sha256, so this selection is correct. It is not clear why this problem did not manifest before. Note that SHA selection in SPL is broken for this exact reason. There is no corresponding SPL_SHAxxx. Fixing this is is beyond the scope of this change. Also note that we make CONFIG_FIT now imply SHA256, to make up for FIT_SHA256 previously being a default y option. Signed-off-by: Alexandru Gagniuc <[email protected]> [trini: Add imply SHA256 to FIT] Signed-off-by: Tom Rini <[email protected]>
2021-07-16image: Eliminate IMAGE_ENABLE_VERIFY_ECDSA macroAlexandru Gagniuc
This macro is no longer needed for code flow or #ifdefs. Remove it. Signed-off-by: Alexandru Gagniuc <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2021-07-16image: Eliminate IMAGE_ENABLE_VERIFY macroAlexandru Gagniuc
This macro is no longer needed for code flow or #ifdefs. Remove it. Signed-off-by: Alexandru Gagniuc <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2021-07-16image: Add support for placing crypto_algo in linker listsAlexandru Gagniuc
The purpose of this change is to enable crypto algorithms to be placed in linker lists, rather than be declared as a static array. The goal is to remove the crypto_algos array in a subsequent patch. Create a new linker list named "cryptos", and search it when image_get_crypto_algo() is invoked. NOTE that adding support for manual relocation of crypto_algos within linker lists is beyond the scope of this patch. Signed-off-by: Alexandru Gagniuc <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2021-07-16image: Drop IMAGE_ENABLE_BEST_MATCHSimon Glass
This is not needed with Kconfig, since we can use IS_ENABLED() easily enough. Drop it. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Alexandru Gagniuc <[email protected]> Signed-off-by: Alexandru Gagniuc <[email protected]>
2021-07-16image: Drop IMAGE_ENABLE_SHAxxxSimon Glass
We already have a host Kconfig for these SHA options. Use CONFIG_IS_ENABLED(SHAxxx) directly in the code shared with the host build, so we can drop the unnecessary indirections. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Alexandru Gagniuc <[email protected]> Signed-off-by: Alexandru Gagniuc <[email protected]>
2021-07-16image: Drop IMAGE_ENABLE_SHA1Simon Glass
We already have a host Kconfig for SHA1. Use CONFIG_IS_ENABLED(SHA1) directly in the code shared with the host build, so we can drop the unnecessary indirection. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Alexandru Gagniuc <[email protected]> Signed-off-by: Alexandru Gagniuc <[email protected]>
2021-07-16Kconfig: Rename SPL_MD5_SUPPORT to SPL_MD5Simon Glass
Drop the _SUPPORT suffix so we can use CONFIG_IS_ENABLED() with this option. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Alexandru Gagniuc <[email protected]> Signed-off-by: Alexandru Gagniuc <[email protected]>
2021-07-16Kconfig: Rename SPL_CRC32_SUPPORT to SPL_CRC32Simon Glass
Drop the _SUPPORT suffix so we can use CONFIG_IS_ENABLED() with this option. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Alexandru Gagniuc <[email protected]> Signed-off-by: Alexandru Gagniuc <[email protected]>