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

CycloneBOOT Image management. More...

#include "boot_config.h"
#include "compiler_port.h"
#include "core/cboot_error.h"
#include "image_format.h"
#include "core/crypto.h"
#include "memory/memory.h"
#include "core/verify.h"
#include "security/cipher.h"

Go to the source code of this file.

Classes

struct  Image
 Image context definition. More...
 
struct  ImageProcessContext
 Image Process context definition. More...
 

Macros

#define IMAGE_INPUT_ENCRYPTED   DISABLED
 
#define IMAGE_OUTPUT_ENCRYPTED   DISABLED
 
#define IMAGE_MAX_CHECK_DATA_SIZE   512
 
#define IMAGE_HEADER_VERSION_MAJOR   1
 
#define IMAGE_HEADER_VERSION_MINOR   3
 
#define IMAGE_HEADER_VERSION_PATCH   0
 
#define IMAGE_HEADER_VERSION
 
#define IMAGE_HEADER_VERSION_GET_MAJOR(version)   (((version) >> 16) & 0xFF)
 
#define IMAGE_HEADER_VERSION_GET_MINOR(version)   (((version) >> 8) & 0xFF)
 
#define IMAGE_HEADER_VERSION_GET_PATCH(version)   ((version) & 0xFF)
 

Typedefs

typedef bool_t(* ImageAntiRollbackCallback) (ImageVersion currentAppVersion, ImageVersion updateAppVersion)
 Image Anti-Rollback callback definition.
 

Enumerations

enum  ImageState {
  IMAGE_STATE_IDLE , IMAGE_STATE_RECV_APP_HEADER , IMAGE_STATE_RECV_APP_DATA , IMAGE_STATE_RECV_APP_CHECK ,
  IMAGE_STATE_VALIDATE_APP , IMAGE_STATE_APP_REBOOT , IMAGE_STATE_WRITE_APP_INIT , IMAGE_STATE_WRITE_APP_HEADER ,
  IMAGE_STATE_WRITE_APP_DATA , IMAGE_STATE_WRITE_APP_CHECK , IMAGE_STATE_WRITE_APP_END
}
 Image states.
 
enum  ImageVersionComparisonFlag { IMAGE_VERSION_EQUAL , IMAGE_VERSION_SUPERIOR , IMAGE_VERSION_INFERIOR }
 Image version comparison flags definition.
 

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 management.

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

Macro Definition Documentation

◆ IMAGE_HEADER_VERSION

#define IMAGE_HEADER_VERSION
Value:
(uint32_t)(((IMAGE_HEADER_VERSION_MAJOR & 0xFF) << 16) | \
((IMAGE_HEADER_VERSION_MINOR & 0xFF) << 8) | (IMAGE_HEADER_VERSION_PATCH & 0xFF))

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)