|
CycloneBOOT 2.6.6
Secure Bootloader for ARM Cortex-M MCU
|
CycloneBOOT Encryption & Decryption handling. More...
Macros | |
| #define | TRACE_LEVEL CBOOT_TRACE_LEVEL |
Functions | |
| cboot_error_t | cipherInit (CipherEngine *engine, const CipherAlgo *algo, CipherMode mode, const uint8_t *key, size_t keyLen) |
| Initialize cipher engine context. | |
| cboot_error_t | cipherSetIv (CipherEngine *engine, uint8_t *iv, size_t ivLen) |
| Set cipher initialization vector. | |
| cboot_error_t | cipherEncryptData (CipherEngine *engine, uint8_t *data, size_t length) |
| Encrypt given data using cipher engine. | |
| cboot_error_t | cipherDecryptData (CipherEngine *engine, uint8_t *data, size_t length) |
| Decrypt given encrypted data using cipher engine. | |
| __weak_func cboot_error_t | cipherGenerateIv (uint8_t *iv, size_t ivLen) |
| Generate the initialization vector of an image about to be encrypted. The default implementation generates nothing, so that a build without a source of randomness refuses to encrypt rather than reusing a fixed vector. Override it with the entropy source of the platform, for example its TRNG. The vector is stored with the image, so it needs to differ between images, not to be secret. | |
| cboot_error_t | cipherCheckMagicNumberCrc (uint32_t magicNumberCrc, bool_t *magicNumberIsValid) |
| cboot_error_t | cipherComputeMagicNumberCrc (uint32_t *magicNumberCrc) |
CycloneBOOT Encryption & Decryption handling.
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.
| cboot_error_t cipherCheckMagicNumberCrc | ( | uint32_t | magicNumberCrc, |
| bool_t * | magicNumberIsValid | ||
| ) |
| magicNumberCrc | |
| keyIsValid |
| cboot_error_t cipherComputeMagicNumberCrc | ( | uint32_t * | magicNumberCrc | ) |
| magicNumberCrc |
| cboot_error_t cipherDecryptData | ( | CipherEngine * | engine, |
| uint8_t * | data, | ||
| size_t | length | ||
| ) |
Decrypt given encrypted data using cipher engine.
| [in] | engine | Pointer to the cipher Engine context |
| [in,out] | data | Buffer that initially contains encrypted data and then will hold plaintext data resulting for decryption |
| [in] | length | Length of the plaintext data buffer |
| cboot_error_t cipherEncryptData | ( | CipherEngine * | engine, |
| uint8_t * | data, | ||
| size_t | length | ||
| ) |
Encrypt given data using cipher engine.
| [in] | engine | Pointer to the cipher Engine context |
| [in,out] | data | Buffer that initially contains plaintext data and then will hold ciphertext data resulting from encryption |
| [in] | length | Length of the plaintext data buffer |
| __weak_func cboot_error_t cipherGenerateIv | ( | uint8_t * | iv, |
| size_t | ivLen | ||
| ) |
Generate the initialization vector of an image about to be encrypted. The default implementation generates nothing, so that a build without a source of randomness refuses to encrypt rather than reusing a fixed vector. Override it with the entropy source of the platform, for example its TRNG. The vector is stored with the image, so it needs to differ between images, not to be secret.
| [out] | iv | Buffer receiving the initialization vector |
| [in] | ivLen | Length of the initialization vector, in bytes |
| cboot_error_t cipherInit | ( | CipherEngine * | engine, |
| const CipherAlgo * | algo, | ||
| CipherMode | mode, | ||
| const uint8_t * | key, | ||
| size_t | keyLen | ||
| ) |
Initialize cipher engine context.
| [in] | engine | Pointer to the cipher Engine context to initialize |
| [in] | algo | Cipher algorithm to be used for encryption/decryption. |
| [in] | mode | Cipher mode to be used with cipher algorithm |
| [in] | key | Pointer to the cipher key |
| [in] | keyLen | Length of the cipher key |
| cboot_error_t cipherSetIv | ( | CipherEngine * | engine, |
| uint8_t * | iv, | ||
| size_t | ivLen | ||
| ) |
Set cipher initialization vector.
| [in] | engine | Pointer to the cipher Engine context |
| [in] | iv | Initialization vector to use for encryption |
| [in] | ivLen | Length of the cipher initialization vector |