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