BSB Developer Docs
Loading...
Searching...
No Matches
furi_hal_crypto_storage.h
1#pragma once
2#include <furi.h>
3#include "furi_hal_crypto.h"
4
5#define FURI_HAL_CRYPTO_STORAGE_START_ADDRESS (0UL)
6#define FURI_HAL_CRYPTO_STORAGE_END_ADDRESS (0x00005000UL) // 20KB partition
7
8#define FURI_HAL_CRYPTO_STORAGE_PARTITION_MAIN_START_ADDRESS (0x00000000UL)
9#define FURI_HAL_CRYPTO_STORAGE_PARTITION_MAIN_END_ADDRESS (0x00003FFFUL) // 16KB partition
10
11#define FURI_HAL_CRYPTO_STORAGE_PARTITION_USER_START_ADDRESS (0x00004000UL)
12#define FURI_HAL_CRYPTO_STORAGE_PARTITION_USER_END_ADDRESS (0x00004FFFUL) // 4KB partition
13
14typedef enum {
15 FuriHalCryptoPartitionMain,
16 FuriHalCryptoPartitionUser,
17 FuriHalCryptoPartitionMax,
18} FuriHalCryptoPartition;
19
20typedef struct {
21 uint32_t magic_number;
22 uint16_t reserved;
23 uint16_t size;
24 FuriHalCryptoKeyType type;
25 FuriHalCryptoKeyFlag flags;
26 uint32_t id;
27 uint32_t reserved1;
28 uint32_t crc32;
29} FURI_PACKED FuriHalCryptoKeySlotHeader;
30_Static_assert(
31 sizeof(FuriHalCryptoKeySlotHeader) == 28,
32 "Size check for 'FuriHalCryptoKeySlotHeader' failed.");
33
35 FuriHalCryptoPartition partition;
36 uint32_t offset; // Address in NWP flash where the key is stored (offset from partition start)
38
39typedef struct FuriHalCryptoKeySlot {
40 FuriHalCryptoKeySlotHeader header;
43
44typedef struct {
47
48typedef enum FuriHalCryptoStorageAccessMode {
49 FuriHalCryptoStorageAccessModeReadOnly = 0,
50 FuriHalCryptoStorageAccessModeReadWrite = 1,
51} FuriHalCryptoStorageAccessMode;
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56
62FURI_CHECK_RETURN
63FuriHalCryptoStatus furi_hal_crypto_storage_set_access_mode(FuriHalCryptoStorageAccessMode mode);
64
66FuriHalCryptoStorageAccessMode furi_hal_crypto_storage_get_access_mode(void);
67
76FURI_CHECK_RETURN
77FuriHalCryptoStatus furi_hal_crypto_storage_wipe(FuriHalCryptoPartition partition);
78
82FuriHalCryptoKeyIter furi_hal_crypto_key_iter_init(FuriHalCryptoPartition partition);
83
91FURI_CHECK_RETURN
92FuriHalCryptoStatus furi_hal_crypto_key_iter_get_and_advance(
94 FuriHalCryptoKey** key_out,
95 FuriHalCryptoKeySlot* slot_out);
96
106FURI_CHECK_RETURN
107FuriHalCryptoStatus furi_hal_crypto_storage_write(
108 const FuriHalCryptoKey* key,
109 FuriHalCryptoPartition partition,
110 uint32_t id);
111
122FURI_CHECK_RETURN
123FuriHalCryptoStatus furi_hal_crypto_storage_write_ex(
124 const FuriHalCryptoKey* key,
125 FuriHalCryptoPartition partition,
126 uint32_t id,
127 FuriHalCryptoKeySlot* slot_out);
128
136FURI_CHECK_RETURN
137FuriHalCryptoStatus furi_hal_crypto_storage_read(
138 FuriHalCryptoKey** key,
139 FuriHalCryptoPartition partition,
140 FuriHalCryptoKeyType type,
141 uint32_t id);
142
152FURI_CHECK_RETURN
153FuriHalCryptoStatus furi_hal_crypto_storage_read_ex(
154 FuriHalCryptoKey** key,
156 FuriHalCryptoPartition partition,
157 FuriHalCryptoKeyType type,
158 uint32_t id);
159#ifdef __cplusplus
160}
161#endif
Frame header with fields which help control frame exchange.
Definition ble_intercom_types.h:40
Definition furi_hal_crypto_storage.h:34
Definition furi_hal_crypto.h:104
Definition furi_hal_crypto_storage.h:44
Definition furi_hal_crypto_storage.h:39