le_secStore_interface.h

Go to the documentation of this file.
1 
2 
3 /*
4  * ====================== WARNING ======================
5  *
6  * THE CONTENTS OF THIS FILE HAVE BEEN AUTO-GENERATED.
7  * DO NOT MODIFY IN ANY WAY.
8  *
9  * ====================== WARNING ======================
10  */
11 
12 /**
13  * @page c_secStore Secure Storage
14  *
15  * @ref le_secStore_interface.h "API Reference" <br>
16  * @ref c_secStoreAdmin API <br>
17  * @ref platformConstraintsSecStorage Constraints
18  *
19  * <HR>
20  *
21  * This API for accessing secure storage.
22  *
23  * Secure storage can be used to store sensitive information like passwords, keys, certificates,
24  * etc. All data in the secure storage is in an encrypted format. Each app using this API only has
25  * access to its own secure storage data.
26  *
27  * App's items in secure storage have a name and a value. The item name is used to access the item's
28  * value and can be maximum 255 characters. The item name can contain path separators, '/', to
29  * help organize an app's data. Item names cannot contain a trailing separator.
30  *
31  * To create or update an item, use le_secStore_Write() to specify the item's name and value. If the
32  * item doesn't exist, it'll be created. Each item can be a maximum of 8192 bytes. If it's larger,
33  * le_secStore_Write() will fail.
34  *
35  * Additionally, an app's total secure storage usage is limited by the maxSecureStorageBytes setting
36  * that may be specified in the xdef files. The maxSecureStorageBytes default is 8192 bytes.
37  *
38  * Writing to secure storage may also fail if the system-wide secure storage is out of memory. The
39  * system-wide secure storage memory amount is platform dependent
40  * (see @ref platformConstraintsSecStorage).
41  *
42  * To read an item, use le_secStore_Read(), and specify the item's name. To delete an item, use
43  * le_secStore_Delete().
44  *
45  * All the functions in this API are provided by the @b secStore service.
46  *
47  * Here's a code sample binding to this service:
48  * @verbatim
49  bindings:
50  {
51  clientExe.clientComponent.le_secStore -> secStore.le_secStore
52  }
53  @endverbatim
54  *
55  * Whenever the secure storage is modified, a timer of 300 seconds is started. When the timer
56  * expires, a backup is performed to capture all changes since the previous backup. If the secure
57  * storage is not modified, then the backup is not performed.
58  * If corruption in the secure storage is detected, a restore is performed and the target device is
59  * rebooted.
60  *
61  * @section c_secStoreGlobal Global Secure Storage
62  *
63  * This same API also provides access to a global area that can be shared across the system.
64  * This interface is called @c secStoreGlobal.
65  *
66  * Here's a code sample binding to this service:
67  * @verbatim
68  bindings:
69  {
70  clientExe.clientComponent.secStoreGlobal -> secStore.secStoreGlobal
71  }
72  @endverbatim
73  *
74  * And the following code should be used to use the API from your .cdef file:
75  * @verbatim
76  requires:
77  {
78  api:
79 
80  {
81  secStoreGlobal = le_secStore.api
82  }
83  }
84  @endverbatim
85  *
86  * <HR>
87  *
88  * Copyright (C) Sierra Wireless Inc.
89  */
90 /**
91  * @file le_secStore_interface.h
92  *
93  * Legato @ref c_secStore API
94  *
95  * Copyright (C) Sierra Wireless Inc.
96  */
97 
98 #ifndef LE_SECSTORE_INTERFACE_H_INCLUDE_GUARD
99 #define LE_SECSTORE_INTERFACE_H_INCLUDE_GUARD
100 
101 
102 #include "legato.h"
103 
104 
105 //--------------------------------------------------------------------------------------------------
106 /**
107  * Type for handler called when a server disconnects.
108  */
109 //--------------------------------------------------------------------------------------------------
110 typedef void (*le_secStore_DisconnectHandler_t)(void *);
111 
112 //--------------------------------------------------------------------------------------------------
113 /**
114  *
115  * Connect the current client thread to the service providing this API. Block until the service is
116  * available.
117  *
118  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
119  * called before any other functions in this API. Normally, ConnectService is automatically called
120  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
121  *
122  * This function is created automatically.
123  */
124 //--------------------------------------------------------------------------------------------------
126 (
127  void
128 );
129 
130 //--------------------------------------------------------------------------------------------------
131 /**
132  *
133  * Try to connect the current client thread to the service providing this API. Return with an error
134  * if the service is not available.
135  *
136  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
137  * called before any other functions in this API. Normally, ConnectService is automatically called
138  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
139  *
140  * This function is created automatically.
141  *
142  * @return
143  * - LE_OK if the client connected successfully to the service.
144  * - LE_UNAVAILABLE if the server is not currently offering the service to which the client is
145  * bound.
146  * - LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
147  * - LE_COMM_ERROR if the Service Directory cannot be reached.
148  */
149 //--------------------------------------------------------------------------------------------------
151 (
152  void
153 );
154 
155 //--------------------------------------------------------------------------------------------------
156 /**
157  * Set handler called when server disconnection is detected.
158  *
159  * When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants
160  * to continue without exiting, it should call longjmp() from inside the handler.
161  */
162 //--------------------------------------------------------------------------------------------------
164 (
165  le_secStore_DisconnectHandler_t disconnectHandler,
166  void *contextPtr
167 );
168 
169 //--------------------------------------------------------------------------------------------------
170 /**
171  *
172  * Disconnect the current client thread from the service providing this API.
173  *
174  * Normally, this function doesn't need to be called. After this function is called, there's no
175  * longer a connection to the service, and the functions in this API can't be used. For details, see
176  * @ref apiFilesC_client.
177  *
178  * This function is created automatically.
179  */
180 //--------------------------------------------------------------------------------------------------
182 (
183  void
184 );
185 
186 
187 //--------------------------------------------------------------------------------------------------
188 /**
189  * Maximum number of characters and byte storage size permitted for a secure storage item name.
190  */
191 //--------------------------------------------------------------------------------------------------
192 #define LE_SECSTORE_MAX_NAME_SIZE 255
193 
194 //--------------------------------------------------------------------------------------------------
195 /**
196  */
197 //--------------------------------------------------------------------------------------------------
198 #define LE_SECSTORE_MAX_NAME_BYTES 256
199 
200 //--------------------------------------------------------------------------------------------------
201 /**
202  * Maximum number of bytes for each item in secure storage.
203  */
204 //--------------------------------------------------------------------------------------------------
205 #define LE_SECSTORE_MAX_ITEM_SIZE 8192
206 
207 //--------------------------------------------------------------------------------------------------
208 /**
209  * Writes an item to secure storage. If the item already exists, it'll be overwritten with
210  * the new value. If the item doesn't already exist, it'll be created.
211  * If the item name is not valid or the buffer is NULL, this function will kill the calling client.
212  *
213  * @return
214  * LE_OK if successful.
215  * LE_NO_MEMORY if there isn't enough memory to store the item.
216  * LE_UNAVAILABLE if the secure storage is currently unavailable.
217  * LE_FAULT if there was some other error.
218  */
219 //--------------------------------------------------------------------------------------------------
221 (
222  const char* LE_NONNULL name,
223  ///< [IN] Name of the secure storage item.
224  const uint8_t* bufPtr,
225  ///< [IN] Buffer containing the data to store.
226  size_t bufSize
227  ///< [IN]
228 );
229 
230 //--------------------------------------------------------------------------------------------------
231 /**
232  * Reads an item from secure storage.
233  * If the item name is not valid or the buffer is NULL, this function will kill the calling client.
234  *
235  * @return
236  * LE_OK if successful.
237  * LE_OVERFLOW if the buffer is too small to hold the entire item. No data will be written to
238  * the buffer in this case.
239  * LE_NOT_FOUND if the item doesn't exist.
240  * LE_UNAVAILABLE if the secure storage is currently unavailable.
241  * LE_FAULT if there was some other error.
242  */
243 //--------------------------------------------------------------------------------------------------
245 (
246  const char* LE_NONNULL name,
247  ///< [IN] Name of the secure storage item.
248  uint8_t* bufPtr,
249  ///< [OUT] Buffer to store the data in.
250  size_t* bufSizePtr
251  ///< [INOUT]
252 );
253 
254 //--------------------------------------------------------------------------------------------------
255 /**
256  * Deletes an item from secure storage.
257  * If the item name is not valid, this function will kill the calling client.
258  *
259  * @return
260  * LE_OK if successful.
261  * LE_NOT_FOUND if the item doesn't exist.
262  * LE_UNAVAILABLE if the secure storage is currently unavailable.
263  * LE_FAULT if there was some other error.
264  */
265 //--------------------------------------------------------------------------------------------------
267 (
268  const char* LE_NONNULL name
269  ///< [IN] Name of the secure storage item.
270 );
271 
272 #endif // LE_SECSTORE_INTERFACE_H_INCLUDE_GUARD
le_result_t le_secStore_Write(const char *LE_NONNULL name, const uint8_t *bufPtr, size_t bufSize)
le_result_t le_secStore_TryConnectService(void)
le_result_t
Definition: le_basics.h:35
void le_secStore_SetServerDisconnectHandler(le_secStore_DisconnectHandler_t disconnectHandler, void *contextPtr)
void le_secStore_ConnectService(void)
le_result_t le_secStore_Read(const char *LE_NONNULL name, uint8_t *bufPtr, size_t *bufSizePtr)
void(* le_secStore_DisconnectHandler_t)(void *)
Definition: le_secStore_interface.h:110
le_result_t le_secStore_Delete(const char *LE_NONNULL name)
void le_secStore_DisconnectService(void)