le_iks_aesCbc_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_iks_aesCbc IoT Keystore AES CBC API
14  *
15  * @ref le_iks_aesCbc_interface.h "API Reference"
16  *
17  * <HR>
18  *
19  * Legato IoT Keystore APIs for performing AES encryption in CBC mode.
20  *
21  * <HR>
22  *
23  * Copyright (C) Sierra Wireless Inc.
24  */
25 /**
26  * @file le_iks_aesCbc_interface.h
27  *
28  * Legato @ref c_iks_aesCbc API
29  *
30  * Copyright (C) Sierra Wireless Inc.
31  */
32 
33 #ifndef LE_IKS_AESCBC_INTERFACE_H_INCLUDE_GUARD
34 #define LE_IKS_AESCBC_INTERFACE_H_INCLUDE_GUARD
35 
36 
37 #include "legato.h"
38 
39 // Interface specific includes
40 #include "le_iks_interface.h"
41 
42 // Internal includes for this interface
43 #include "le_iks_aesCbc_common.h"
44 //--------------------------------------------------------------------------------------------------
45 /**
46  * Type for handler called when a server disconnects.
47  */
48 //--------------------------------------------------------------------------------------------------
49 typedef void (*le_iks_aesCbc_DisconnectHandler_t)(void *);
50 
51 //--------------------------------------------------------------------------------------------------
52 /**
53  *
54  * Connect the current client thread to the service providing this API. Block until the service is
55  * available.
56  *
57  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
58  * called before any other functions in this API. Normally, ConnectService is automatically called
59  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
60  *
61  * This function is created automatically.
62  */
63 //--------------------------------------------------------------------------------------------------
65 (
66  void
67 );
68 
69 //--------------------------------------------------------------------------------------------------
70 /**
71  *
72  * Try to connect the current client thread to the service providing this API. Return with an error
73  * if the service is not available.
74  *
75  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
76  * called before any other functions in this API. Normally, ConnectService is automatically called
77  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
78  *
79  * This function is created automatically.
80  *
81  * @return
82  * - LE_OK if the client connected successfully to the service.
83  * - LE_UNAVAILABLE if the server is not currently offering the service to which the client is
84  * bound.
85  * - LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
86  * - LE_COMM_ERROR if the Service Directory cannot be reached.
87  */
88 //--------------------------------------------------------------------------------------------------
90 (
91  void
92 );
93 
94 //--------------------------------------------------------------------------------------------------
95 /**
96  * Set handler called when server disconnection is detected.
97  *
98  * When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants
99  * to continue without exiting, it should call longjmp() from inside the handler.
100  */
101 //--------------------------------------------------------------------------------------------------
103 (
104  le_iks_aesCbc_DisconnectHandler_t disconnectHandler,
105  void *contextPtr
106 );
107 
108 //--------------------------------------------------------------------------------------------------
109 /**
110  *
111  * Disconnect the current client thread from the service providing this API.
112  *
113  * Normally, this function doesn't need to be called. After this function is called, there's no
114  * longer a connection to the service, and the functions in this API can't be used. For details, see
115  * @ref apiFilesC_client.
116  *
117  * This function is created automatically.
118  */
119 //--------------------------------------------------------------------------------------------------
121 (
122  void
123 );
124 
125 
126 //--------------------------------------------------------------------------------------------------
127 /**
128  * Starts a process to encrypt a message with AES in CBC mode. Calling this function will cancel
129  * any previously started process using the same session.
130  *
131  * To encrypt a message the following sequence should be used:
132  *
133  * le_iks_aesCbc_StartEncrypt() // Start the encryption process.
134  * le_iks_aesCbc_Encrypt() // Call zero or more times until all plaintext is encrypted.
135  *
136  * The initialization vector, IV, does not need to be kept secret but must be unpredictable. Thus
137  * the IV must be generated from a well seeded CPRNG each time this function is called.
138  *
139  * @return
140  * LE_OK if successful.
141  * LE_BAD_PARAMETER if the session reference is invalid
142  * or if the key type is invalid
143  * or if ivPtr is NULL.
144  * LE_UNSUPPORTED if underlying resource does not support this operation.
145  * LE_FAULT if there was an internal error.
146  */
147 //--------------------------------------------------------------------------------------------------
149 (
150  uint64_t session,
151  ///< [IN] Session reference.
152  const uint8_t* ivPtr,
153  ///< [IN] Initialization vector.
154  ///< Assumed to be IV_SIZE bytes.
155  size_t ivSize
156  ///< [IN]
157 );
158 
159 //--------------------------------------------------------------------------------------------------
160 /**
161  * Encrypt a chunk of plaintext. le_iks_aesCbc_StartEncrypt() must have been previously called. The
162  * plaintest must be a multiple of the block size. It is up to the caller to pad the plaintext as
163  * needed.
164  *
165  * @return
166  * LE_OK if successful.
167  * LE_BAD_PARAMETER if the session reference is invalid
168  * or if the key type is invalid
169  * or if plaintextChunkPtr or ciphertextChunkPtr is NULL.
170  * LE_OUT_OF_RANGE if textSize is invalid.
171  * LE_UNSUPPORTED if underlying resource does not support this operation.
172  * LE_FAULT if an encryption process has not started.
173  */
174 //--------------------------------------------------------------------------------------------------
176 (
177  uint64_t session,
178  ///< [IN] Session reference.
179  const uint8_t* plaintextChunkPtr,
180  ///< [IN] Plaintext chunk.
181  size_t plaintextChunkSize,
182  ///< [IN]
183  uint8_t* ciphertextChunkPtr,
184  ///< [OUT] Buffer to hold the ciphertext chunk.
185  size_t* ciphertextChunkSizePtr
186  ///< [INOUT]
187 );
188 
189 //--------------------------------------------------------------------------------------------------
190 /**
191  * Starts a process to decrypt a message with AES in CBC mode. Calling this function will cancel
192  * any previously started process using the same session.
193  *
194  * To decrypt a message the following sequence should be used:
195  *
196  * le_iks_aesCbc_StartDecrypt() // Start the decryption process.
197  * le_iks_aesCbc_Decrypt() // Call zero or more times until all ciphertext is decrypted.
198  *
199  * @return
200  * LE_OK if successful.
201  * LE_BAD_PARAMETER if the session reference is invalid
202  * or if the key type is invalid
203  * or if ivPtr is NULL.
204  * LE_UNSUPPORTED if underlying resource does not support this operation.
205  * LE_FAULT if there was an internal error.
206  */
207 //--------------------------------------------------------------------------------------------------
209 (
210  uint64_t session,
211  ///< [IN] Session reference.
212  const uint8_t* ivPtr,
213  ///< [IN] Initialization vector.
214  ///< Assumed to be AESCBC_IV_SIZE bytes.
215  size_t ivSize
216  ///< [IN]
217 );
218 
219 //--------------------------------------------------------------------------------------------------
220 /**
221  * Decrypt a chunk of ciphertext. le_iks_aesCbc_StartDecrypt() must have been previously called to
222  * start a decryption process.
223  *
224  * @return
225  * LE_OK if successful.
226  * LE_BAD_PARAMETER if the session reference is invalid.
227  * or if the key type is invalid.
228  * or if plaintextChunkPtr or ciphertextChunkPtr is NULL.
229  * LE_OUT_OF_RANGE if textSize is invalid.
230  * LE_UNSUPPORTED if underlying resource does not support this operation.
231  * LE_FAULT if a decryption process has not started.
232  */
233 //--------------------------------------------------------------------------------------------------
235 (
236  uint64_t session,
237  ///< [IN] Session reference.
238  const uint8_t* ciphertextChunkPtr,
239  ///< [IN] Ciphertext chunk.
240  size_t ciphertextChunkSize,
241  ///< [IN]
242  uint8_t* plaintextChunkPtr,
243  ///< [OUT] Buffer to hold the plaintext chunk.
244  size_t* plaintextChunkSizePtr
245  ///< [INOUT]
246 );
247 
248 #endif // LE_IKS_AESCBC_INTERFACE_H_INCLUDE_GUARD
void le_iks_aesCbc_DisconnectService(void)
le_result_t le_iks_aesCbc_TryConnectService(void)
void le_iks_aesCbc_ConnectService(void)
le_result_t
Definition: le_basics.h:45
le_result_t le_iks_aesCbc_Encrypt(uint64_t session, const uint8_t *plaintextChunkPtr, size_t plaintextChunkSize, uint8_t *ciphertextChunkPtr, size_t *ciphertextChunkSizePtr)
le_result_t le_iks_aesCbc_StartEncrypt(uint64_t session, const uint8_t *ivPtr, size_t ivSize)
void(* le_iks_aesCbc_DisconnectHandler_t)(void *)
Definition: le_iks_aesCbc_interface.h:49
le_result_t le_iks_aesCbc_Decrypt(uint64_t session, const uint8_t *ciphertextChunkPtr, size_t ciphertextChunkSize, uint8_t *plaintextChunkPtr, size_t *plaintextChunkSizePtr)
le_result_t le_iks_aesCbc_StartDecrypt(uint64_t session, const uint8_t *ivPtr, size_t ivSize)
#define LE_FULL_API
Definition: le_apiFeatures.h:40
LE_FULL_API void le_iks_aesCbc_SetServerDisconnectHandler(le_iks_aesCbc_DisconnectHandler_t disconnectHandler, void *contextPtr)