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 // Internal includes for this interface
105 #include "le_secStore_common.h"
106 /** @addtogroup le_secStore le_secStore API Reference
107  * @{
108  * @file le_secStore_common.h
109  * @file le_secStore_interface.h **/
110 //--------------------------------------------------------------------------------------------------
111 /**
112  * Type for handler called when a server disconnects.
113  */
114 //--------------------------------------------------------------------------------------------------
115 typedef void (*le_secStore_DisconnectHandler_t)(void *);
116 
117 //--------------------------------------------------------------------------------------------------
118 /**
119  *
120  * Connect the current client thread to the service providing this API. Block until the service is
121  * available.
122  *
123  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
124  * called before any other functions in this API. Normally, ConnectService is automatically called
125  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
126  *
127  * This function is created automatically.
128  */
129 //--------------------------------------------------------------------------------------------------
131 (
132  void
133 );
134 
135 //--------------------------------------------------------------------------------------------------
136 /**
137  *
138  * Try to connect the current client thread to the service providing this API. Return with an error
139  * if the service is not available.
140  *
141  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
142  * called before any other functions in this API. Normally, ConnectService is automatically called
143  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
144  *
145  * This function is created automatically.
146  *
147  * @return
148  * - LE_OK if the client connected successfully to the service.
149  * - LE_UNAVAILABLE if the server is not currently offering the service to which the client is
150  * bound.
151  * - LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
152  * - LE_COMM_ERROR if the Service Directory cannot be reached.
153  */
154 //--------------------------------------------------------------------------------------------------
156 (
157  void
158 );
159 
160 //--------------------------------------------------------------------------------------------------
161 /**
162  * Set handler called when server disconnection is detected.
163  *
164  * When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants
165  * to continue without exiting, it should call longjmp() from inside the handler.
166  */
167 //--------------------------------------------------------------------------------------------------
169 (
170  le_secStore_DisconnectHandler_t disconnectHandler,
171  void *contextPtr
172 );
173 
174 //--------------------------------------------------------------------------------------------------
175 /**
176  *
177  * Disconnect the current client thread from the service providing this API.
178  *
179  * Normally, this function doesn't need to be called. After this function is called, there's no
180  * longer a connection to the service, and the functions in this API can't be used. For details, see
181  * @ref apiFilesC_client.
182  *
183  * This function is created automatically.
184  */
185 //--------------------------------------------------------------------------------------------------
187 (
188  void
189 );
190 
191 
192 //--------------------------------------------------------------------------------------------------
193 /**
194  * Writes an item to secure storage. If the item already exists, it'll be overwritten with
195  * the new value. If the item doesn't already exist, it'll be created.
196  * If the item name is not valid or the buffer is NULL, this function will kill the calling client.
197  *
198  * @return
199  * LE_OK if successful.
200  * LE_NO_MEMORY if there isn't enough memory to store the item.
201  * LE_UNAVAILABLE if the secure storage is currently unavailable.
202  * LE_FAULT if there was some other error.
203  */
204 //--------------------------------------------------------------------------------------------------
206 (
207  const char* LE_NONNULL name,
208  ///< [IN] Name of the secure storage item.
209  const uint8_t* bufPtr,
210  ///< [IN] Buffer containing the data to store.
211  size_t bufSize
212  ///< [IN]
213 );
214 
215 //--------------------------------------------------------------------------------------------------
216 /**
217  * Reads an item from secure storage.
218  * If the item name is not valid or the buffer is NULL, this function will kill the calling client.
219  *
220  * @return
221  * LE_OK if successful.
222  * LE_OVERFLOW if the buffer is too small to hold the entire item. No data will be written to
223  * the buffer in this case.
224  * LE_NOT_FOUND if the item doesn't exist.
225  * LE_UNAVAILABLE if the secure storage is currently unavailable.
226  * LE_FAULT if there was some other error.
227  */
228 //--------------------------------------------------------------------------------------------------
230 (
231  const char* LE_NONNULL name,
232  ///< [IN] Name of the secure storage item.
233  uint8_t* bufPtr,
234  ///< [OUT] Buffer to store the data in.
235  size_t* bufSizePtr
236  ///< [INOUT]
237 );
238 
239 //--------------------------------------------------------------------------------------------------
240 /**
241  * Deletes an item from secure storage.
242  * If the item name is not valid, this function will kill the calling client.
243  *
244  * @return
245  * LE_OK if successful.
246  * LE_NOT_FOUND if the item doesn't exist.
247  * LE_UNAVAILABLE if the secure storage is currently unavailable.
248  * LE_FAULT if there was some other error.
249  */
250 //--------------------------------------------------------------------------------------------------
252 (
253  const char* LE_NONNULL name
254  ///< [IN] Name of the secure storage item.
255 );
256 
257 /** @} **/
258 
259 #endif // LE_SECSTORE_INTERFACE_H_INCLUDE_GUARD
le_result_t
Definition: le_basics.h:46
le_result_t le_secStore_Delete(const char *LE_NONNULL name)
void le_secStore_DisconnectService(void)
le_result_t le_secStore_Write(const char *LE_NONNULL name, const uint8_t *bufPtr, size_t bufSize)
void(* le_secStore_DisconnectHandler_t)(void *)
Definition: le_secStore_interface.h:115
#define LE_FULL_API
Definition: le_apiFeatures.h:40
void le_secStore_ConnectService(void)
LE_FULL_API void le_secStore_SetServerDisconnectHandler(le_secStore_DisconnectHandler_t disconnectHandler, void *contextPtr)
le_result_t le_secStore_Read(const char *LE_NONNULL name, uint8_t *bufPtr, size_t *bufSizePtr)
le_result_t le_secStore_TryConnectService(void)