le_iks_hmac_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_hmac IoT Keystore HMAC API
14  *
15  * @ref le_iks_hmac_interface.h "API Reference"
16  *
17  * <HR>
18  *
19  * Legato IoT Keystore APIs for generating and verifying message authentication codes using HMAC.
20  *
21  * <HR>
22  *
23  * Copyright (C) Sierra Wireless Inc.
24  */
25 /**
26  * @file le_iks_hmac_interface.h
27  *
28  * Legato @ref c_iks_hmac API
29  *
30  * Copyright (C) Sierra Wireless Inc.
31  */
32 
33 #ifndef LE_IKS_HMAC_INTERFACE_H_INCLUDE_GUARD
34 #define LE_IKS_HMAC_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_hmac_common.h"
44 /** @addtogroup le_iks_hmac le_iks_hmac API Reference
45  * @{
46  * @file le_iks_hmac_common.h
47  * @file le_iks_hmac_interface.h **/
48 //--------------------------------------------------------------------------------------------------
49 /**
50  * Type for handler called when a server disconnects.
51  */
52 //--------------------------------------------------------------------------------------------------
53 typedef void (*le_iks_hmac_DisconnectHandler_t)(void *);
54 
55 //--------------------------------------------------------------------------------------------------
56 /**
57  *
58  * Connect the current client thread to the service providing this API. Block until the service is
59  * available.
60  *
61  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
62  * called before any other functions in this API. Normally, ConnectService is automatically called
63  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
64  *
65  * This function is created automatically.
66  */
67 //--------------------------------------------------------------------------------------------------
69 (
70  void
71 );
72 
73 //--------------------------------------------------------------------------------------------------
74 /**
75  *
76  * Try to connect the current client thread to the service providing this API. Return with an error
77  * if the service is not available.
78  *
79  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
80  * called before any other functions in this API. Normally, ConnectService is automatically called
81  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
82  *
83  * This function is created automatically.
84  *
85  * @return
86  * - LE_OK if the client connected successfully to the service.
87  * - LE_UNAVAILABLE if the server is not currently offering the service to which the client is
88  * bound.
89  * - LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
90  * - LE_COMM_ERROR if the Service Directory cannot be reached.
91  */
92 //--------------------------------------------------------------------------------------------------
94 (
95  void
96 );
97 
98 //--------------------------------------------------------------------------------------------------
99 /**
100  * Set handler called when server disconnection is detected.
101  *
102  * When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants
103  * to continue without exiting, it should call longjmp() from inside the handler.
104  */
105 //--------------------------------------------------------------------------------------------------
107 (
108  le_iks_hmac_DisconnectHandler_t disconnectHandler,
109  void *contextPtr
110 );
111 
112 //--------------------------------------------------------------------------------------------------
113 /**
114  *
115  * Disconnect the current client thread from the service providing this API.
116  *
117  * Normally, this function doesn't need to be called. After this function is called, there's no
118  * longer a connection to the service, and the functions in this API can't be used. For details, see
119  * @ref apiFilesC_client.
120  *
121  * This function is created automatically.
122  */
123 //--------------------------------------------------------------------------------------------------
125 (
126  void
127 );
128 
129 
130 //--------------------------------------------------------------------------------------------------
131 /**
132  * Process message chunks. This function may be called multiple times to process the entire
133  * message but once a message has been completely processed and le_iks_hmac_Done() or
134  * le_iks_hmac_Verify() has been called this function should not be called again with the same
135  * session.
136  *
137  * @return
138  * LE_OK if successful.
139  * LE_BAD_PARAMETER if the session reference is invalid
140  * or if the key type is invalid
141  * or if msgChunkPtr is NULL.
142  * LE_UNSUPPORTED if underlying resource does not support this operation.
143  * LE_FAULT if no more messages can be processed, ie. le_iks_hmac_Done() or
144  * le_iks_hmac_Verify() has already been called,
145  * or if there was an internal error.
146  */
147 //--------------------------------------------------------------------------------------------------
149 (
150  uint64_t session,
151  ///< [IN] Session reference.
152  const uint8_t* msgChunkPtr,
153  ///< [IN] Message chunk.
154  size_t msgChunkSize
155  ///< [IN]
156 );
157 
158 //--------------------------------------------------------------------------------------------------
159 /**
160  * Complete message processing and get the processed message's authentication tag.
161  *
162  * The maximum size of the authentication tag is the size of the output of the underlying hash
163  * function. For example, if the key is of type KEY_TYPE_HMAC_SHA256 then the maximum tag size
164  * is 32 bytes.
165  *
166  * If the supplied buffer is larger than or equal to the maximum authentication tag size then the
167  * full authentication tag is copied to the buffer and the rest of the buffer is left unmodified.
168  *
169  * If the supplied buffer is smaller than the maximum tag size then the tag will be truncated.
170  * However, all tags produced using the same key must use the same tag size. It is up to the caller
171  * to ensure this.
172  *
173  * @return
174  * LE_OK if successful.
175  * LE_BAD_PARAMETER if the session reference is invalid
176  * or if the key type is invalid
177  * or if bufPtr is NULL.
178  * LE_UNSUPPORTED if underlying resource does not support this operation.
179  * LE_FAULT if no message was processed or le_iks_hmac_Done() or
180  * le_iks_hmac_Verify() has already been called,
181  * or if there was an internal error.
182  */
183 //--------------------------------------------------------------------------------------------------
185 (
186  uint64_t session,
187  ///< [IN] Session reference.
188  uint8_t* tagBufPtr,
189  ///< [OUT] Buffer to hold the authentication tag.
190  size_t* tagBufSizePtr
191  ///< [INOUT]
192 );
193 
194 //--------------------------------------------------------------------------------------------------
195 /**
196  * Complete message processing and compare the resulting authentication tag with the supplied tag.
197  *
198  * The maximum size of the authentication tag is the size of the output of the underlying hash
199  * function. For example, if the key is of type KEY_TYPE_HMAC_SHA256 then the maximum tag size
200  * is 32 bytes.
201  *
202  * If the supplied tag is larger than or equal to the maximum authentication tag size then the
203  * authentication will fail.
204  *
205  * If the supplied tag is smaller than the maximum tag size then only the first tagSize bytes will
206  * be compared.
207  *
208  * All tags produced using the same key must use the same tag size. It is up to the caller
209  * to ensure this.
210  *
211  * @return
212  * LE_OK if the specified tag matches the calculated message tag.
213  * LE_BAD_PARAMETER if the session reference is invalid
214  * or if the key type is invalid
215  * or if tagPtr is NULL or tagSize is zero.
216  * LE_UNSUPPORTED if underlying resource does not support this operation.
217  * LE_FAULT if the specified tag does not match the calculated message tag,
218  * or if no message was processed or le_iks_hmac_Done() or
219  * or le_iks_hmac_Verify() has already been called,
220  * or if there was an internal error.
221  */
222 //--------------------------------------------------------------------------------------------------
224 (
225  uint64_t session,
226  ///< [IN] Session reference.
227  const uint8_t* tagBufPtr,
228  ///< [IN] Authentication tag to check against.
229  size_t tagBufSize
230  ///< [IN]
231 );
232 
233 /** @} **/
234 
235 #endif // LE_IKS_HMAC_INTERFACE_H_INCLUDE_GUARD
void le_iks_hmac_DisconnectService(void)
le_result_t le_iks_hmac_ProcessChunk(uint64_t session, const uint8_t *msgChunkPtr, size_t msgChunkSize)
le_result_t
Definition: le_basics.h:46
void(* le_iks_hmac_DisconnectHandler_t)(void *)
Definition: le_iks_hmac_interface.h:53
le_result_t le_iks_hmac_TryConnectService(void)
void le_iks_hmac_ConnectService(void)
le_result_t le_iks_hmac_Verify(uint64_t session, const uint8_t *tagBufPtr, size_t tagBufSize)
le_result_t le_iks_hmac_Done(uint64_t session, uint8_t *tagBufPtr, size_t *tagBufSizePtr)
LE_FULL_API void le_iks_hmac_SetServerDisconnectHandler(le_iks_hmac_DisconnectHandler_t disconnectHandler, void *contextPtr)
#define LE_FULL_API
Definition: le_apiFeatures.h:40