Skip to content

Commit 2c65295

Browse files
oyvindronningstadhakonfam
authored andcommitted
b0: bl_crypto: Add RST docs for bl_crypto
Also fix doxygen text and tagging inside bl_crypto.h Signed-off-by: Øyvind Rønningstad <[email protected]>
1 parent c9a20e5 commit 2c65295

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

include/bl_crypto.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,18 @@
77
#ifndef BOOTLOADER_CRYPTO_H__
88
#define BOOTLOADER_CRYPTO_H__
99

10+
#ifdef __cplusplus
11+
extern "C" {
12+
#endif
13+
1014
#include <zephyr/types.h>
1115
#include <fw_info.h>
1216

17+
18+
/** @defgroup bl_crypto Bootloader crypto functions
19+
* @{
20+
*/
21+
1322
/* Placeholder defines. Values should be updated, if no existing errors can be
1423
* used instead. */
1524
#define EHASHINV 101
@@ -196,13 +205,19 @@ typedef int (*bl_secp256r1_validate_t)(
196205
const u8_t *public_key);
197206

198207

208+
/**
209+
* @brief Structure describing the BL_ROT_VERIFY EXT_API.
210+
*/
199211
struct bl_rot_verify_ext_api {
200212
struct fw_info_ext_api header;
201213
struct {
202214
bl_root_of_trust_verify_t bl_root_of_trust_verify;
203215
} ext_api;
204216
};
205217

218+
/**
219+
* @brief Structure describing the BL_SHA256 EXT_API.
220+
*/
206221
struct bl_sha256_ext_api {
207222
struct fw_info_ext_api header;
208223
struct {
@@ -214,13 +229,20 @@ struct bl_sha256_ext_api {
214229
} ext_api;
215230
};
216231

232+
/**
233+
* @brief Structure describing the BL_SECP256R1 EXT_API.
234+
*/
217235
struct bl_secp256r1_ext_api {
218236
struct fw_info_ext_api header;
219237
struct {
220238
bl_secp256r1_validate_t bl_secp256r1_validate;
221239
} ext_api;
222240
};
223241

242+
/** @} */
224243

244+
#ifdef __cplusplus
245+
}
225246
#endif
226247

248+
#endif

include/bl_crypto.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
.. _doc_bl_crypto:
2+
3+
Bootloader crypto
4+
#################
5+
6+
The bootloader crypto library is the cryptography library that is used by the :ref:`bootloader`.
7+
8+
The API is public because applications that are booted by the immutable bootloader can call functions from this library via the bootloader's code, through external APIs.
9+
See :ref:`doc_fw_info_ext_api` for more information.
10+
11+
The library provides the following functionality:
12+
13+
* SHA256 hashing
14+
* SECP256R1 signature validation
15+
* Root-of-trust firmware validation, which is the function the bootloader uses to validate a firmware's signature and digest, using the SHA256 and SECP256R1 algorithms
16+
17+
These functions are available as separate external APIs.
18+
The API can be used the same way regardless of which backend is used.
19+
20+
Backends
21+
********
22+
23+
When using the library, you can choose between the following backends:
24+
25+
* Hardware backend :ref:`nrf_cc310_bl_readme` (can only be used if Arm CryptoCell CC310 is available)
26+
* Software backend :ref:`nrf_oberon_readme`
27+
* Another image's instance of the bootloader crypto library, called via external APIs.
28+
The other image chooses its own backend.
29+
30+
To configure which backend is used for hashing, set one of the following configuration options:
31+
32+
* :option:`CONFIG_SB_CRYPTO_OBERON_SHA256`
33+
* :option:`CONFIG_SB_CRYPTO_CC310_SHA256`
34+
* :option:`CONFIG_SB_CRYPTO_CLIENT_SHA256`
35+
36+
To configure which backend is used for firmware verification, set one of the following configuration options:
37+
38+
* :option:`CONFIG_SB_CRYPTO_CC310_ECDSA_SECP256R1`
39+
* :option:`CONFIG_SB_CRYPTO_OBERON_ECDSA_SECP256R1`
40+
* :option:`CONFIG_SB_CRYPTO_CLIENT_ECDSA_SECP256R1`
41+
42+
43+
44+
API documentation
45+
*****************
46+
47+
| Header file: :file:`include/bl_crypto.h`
48+
| Source files: :file:`subsys/bootloader/bl_crypto/` and :file:`subsys/bootloader/bl_crypto_client/`
49+
50+
.. doxygengroup:: bl_crypto
51+
:project: nrf
52+
:members:

0 commit comments

Comments
 (0)