CycloneBOOT 2.6.6
Secure Bootloader for ARM Cortex-M MCU
Loading...
Searching...
No Matches
image.c File Reference

CycloneBOOT Image managment. More...

#include "image.h"
#include "core/crc32.h"
#include "core/crypto.h"
#include "debug.h"
#include "memory/memory.h"
#include <stdlib.h>

Macros

#define TRACE_LEVEL   CBOOT_TRACE_LEVEL
 

Functions

bool_t imageSafeAdd32 (uint32_t a, uint32_t b, uint32_t *sum)
 Overflow-safe addition of two 32-bit image geometry values.
 
bool_t imageFitsSlot (const ImageHeader *header, size_t slotSize)
 Check that an image (header, data and CRC32 tag) fits in a slot.
 
bool_t imageIsBootImage (const ImageHeader *header)
 Check whether an image holds a bootloader.
 
cboot_error_t imageCheckHeader (ImageHeader *header)
 Check Internal Image header validity.
 
cboot_error_t imageGetHeader (uint8_t *buffer, size_t bufferLen, ImageHeader **header)
 Get image header from data buffer.
 
cboot_error_t imageComputeHeaderCrc (ImageHeader *header)
 Compute image header crc and store it in the image header crc field. The given input header will also be the outout image header.
 
cboot_error_t imageCheckIntegrity (Image *image)
 Verifies the complete image integrity.
 

Detailed Description

CycloneBOOT Image managment.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2021-2026 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneBOOT Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.6.6

Function Documentation

◆ imageCheckHeader()

cboot_error_t imageCheckHeader ( ImageHeader *  header)

Check Internal Image header validity.

Parameters
[in]headerPointer to the internal image header to be checked
Returns
Status code

◆ imageCheckIntegrity()

cboot_error_t imageCheckIntegrity ( Image *  image)

Verifies the complete image integrity.

Parameters
[in/out]image Pointer to the image we want to verify.
Returns
Error code

◆ imageComputeHeaderCrc()

cboot_error_t imageComputeHeaderCrc ( ImageHeader *  header)

Compute image header crc and store it in the image header crc field. The given input header will also be the outout image header.

Parameters
[in/out]header Pointer the header on which to calculate the crc.
Returns
Error code

◆ imageFitsSlot()

bool_t imageFitsSlot ( const ImageHeader *  header,
size_t  slotSize 
)

Check that an image (header, data and CRC32 tag) fits in a slot.

Parameters
[in]headerImage header
[in]slotSizeSlot size
Returns
TRUE if the image fits in the slot, FALSE otherwise

◆ imageGetHeader()

cboot_error_t imageGetHeader ( uint8_t *  buffer,
size_t  bufferLen,
ImageHeader **  header 
)

Get image header from data buffer.

Parameters
[in]bufferData buffer containing the image header
[in]bufferLenData buffer length
[out]headerPointer to the header structure to be returned
Returns
Status code

◆ imageIsBootImage()

bool_t imageIsBootImage ( const ImageHeader *  header)

Check whether an image holds a bootloader.

Parameters
[in]headerImage header
Returns
TRUE for a bootloader image, FALSE otherwise

◆ imageSafeAdd32()

bool_t imageSafeAdd32 ( uint32_t  a,
uint32_t  b,
uint32_t *  sum 
)

Overflow-safe addition of two 32-bit image geometry values.

Parameters
[in]aFirst addend
[in]bSecond addend
[out]sumReceives a + b when it fits in uint32_t
Returns
TRUE if the sum fits in uint32_t, FALSE on overflow (or sum is NULL)