|
CycloneBOOT 2.6.6
Secure Bootloader for ARM Cortex-M MCU
|
Utility functions used throughout the application. More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include "debug.h"#include "core/crypto.h"#include "hash/hash_algorithms.h"#include "main.h"#include "header.h"#include "body.h"Go to the source code of this file.
Classes | |
| struct | UpdateImage |
Functions | |
| int | read_file (const char *file_path, char **file_contents, size_t *file_size) |
| Read a file. | |
| int | blockify (size_t blockSize, char **input, size_t inputSize, char **output, size_t *outputSize) |
| Slice a given buffer in to a blocks of a given size. | |
| void | imageBuildCleanup (ImageBuild *build) |
| Release all working buffers. | |
| const HashAlgo * | hash_algo_by_name (const char *name) |
| Map a hash/checksum algorithm name to its HashAlgo. | |
| int | init_crypto (CipherInfo *cipherInfo) |
| int | encrypt (char *plainData, size_t plainDataSize, char *cipherData, CipherInfo cipherInfo) |
| int | sign (CipherInfo *cipherInfo, CheckDataInfo *checkDataInfo, char *data, size_t dataLen, char **signData, size_t *signDataLen) |
| int | write_image_to_file (UpdateImage *image, CipherInfo *cipherInfo, const char *output_file_path) |
| Write the update image to a file. | |
| int | generate_key_pair (struct builder_cli_configuration *cli_options, CipherInfo *cipherInfo) |
| void | dump_buffer (void *buffer, size_t buffer_size) |
| void | dump_buffer_2 (void *buffer, size_t buffer_size, size_t columSize) |
| void | dumpHeader (ImageHeader *header) |
| void | dumpBody (ImageBody *body) |
| void | dumpFooter (char *check_data, size_t check_data_size) |
| int | seedInitVector (uint8_t *buffer, size_t length) |
| Generate an initialization vector with random data. | |
| void | dump_cleartext_image (void *buffer, size_t buffer_size) |
| void | dump_ciphertext_image (void *buffer, size_t buffer_size) |
| uint32_t | version_string_to_int (const char *version) |
| void | parse_firmware_version (const char *version, ImageVersion *imageVersion) |
| Parse a "MA.MI.RE.BUILD" firmware version, BUILD in hex. | |
| int | is_hex (const char *str) |
| int | hex_string_to_byte_array (const char *hexString, unsigned char **byteArray, size_t *byteArraySize) |
Utility functions used throughout the application.
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2021-2026 Oryx Embedded SARL. All rights reserved.
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.
| int blockify | ( | size_t | blockSize, |
| char ** | input, | ||
| size_t | inputSize, | ||
| char ** | output, | ||
| size_t * | outputSize | ||
| ) |
Slice a given buffer in to a blocks of a given size.
| [in] | blockSize | Size of the blocks |
| [in] | input | Input buffer |
| [in] | inputSize | Size of the input buffer |
| [in] | output | Output buffer |
| [in] | outputSize | Size of the output buffer |
| const HashAlgo * hash_algo_by_name | ( | const char * | name | ) |
Map a hash/checksum algorithm name to its HashAlgo.
| [in] | name | Algorithm name: crc32, md5, sha1, sha224, sha256, sha384 or sha512. |
| void parse_firmware_version | ( | const char * | version, |
| ImageVersion * | imageVersion | ||
| ) |
Parse a "MA.MI.RE.BUILD" firmware version, BUILD in hex.
| [in] | version | Firmware version string |
| [out] | imageVersion | Parsed version |
| int read_file | ( | const char * | file_path, |
| char ** | file_contents, | ||
| size_t * | file_size | ||
| ) |
Read a file.
| [in] | file_path | Path to the file to be read |
| [in] | file_contents | Buffer to store content of the file read |
| [in] | file_size | Pointer to the file size |
| int seedInitVector | ( | uint8_t * | buffer, |
| size_t | length | ||
| ) |
Generate an initialization vector with random data.
| [in] | buffer | Buffer containing initialization vector |
| [in] | length | Buffer length |
| int write_image_to_file | ( | UpdateImage * | image, |
| CipherInfo * | cipherInfo, | ||
| const char * | output_file_path | ||
| ) |
Write the update image to a file.
| [in] | image | Pointer containing the update image to be rewritten to disk |
| [in] | cipherInfo | Crypto related information |
| [in] | output_file_path | Path to write the image |