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 //--------------------------------------------------------------------------------------------------
45 /**
46  * Type for handler called when a server disconnects.
47  */
48 //--------------------------------------------------------------------------------------------------
49 typedef void (*le_iks_hmac_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_hmac_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  * Process message chunks. This function may be called multiple times to process the entire
129  * message but once a message has been completely processed and le_iks_hmac_Done() or
130  * le_iks_hmac_Verify() has been called this function should not be called again with the same
131  * session.
132  *
133  * @return
134  * LE_OK if successful.
135  * LE_BAD_PARAMETER if the session reference is invalid
136  * or if the key type is invalid
137  * or if msgChunkPtr is NULL.
138  * LE_UNSUPPORTED if underlying resource does not support this operation.
139  * LE_FAULT if no more messages can be processed, ie. le_iks_hmac_Done() or
140  * le_iks_hmac_Verify() has already been called,
141  * or if there was an internal error.
142  */
143 //--------------------------------------------------------------------------------------------------
145 (
146  uint64_t session,
147  ///< [IN] Session reference.
148  const uint8_t* msgChunkPtr,
149  ///< [IN] Message chunk.
150  size_t msgChunkSize
151  ///< [IN]
152 );
153 
154 //--------------------------------------------------------------------------------------------------
155 /**
156  * Complete message processing and get the processed message's authentication tag.
157  *
158  * The maximum size of the authentication tag is the size of the output of the underlying hash
159  * function. For example, if the key is of type KEY_TYPE_HMAC_SHA256 then the maximum tag size
160  * is 32 bytes.
161  *
162  * If the supplied buffer is larger than or equal to the maximum authentication tag size then the
163  * full authentication tag is copied to the buffer and the rest of the buffer is left unmodified.
164  *
165  * If the supplied buffer is smaller than the maximum tag size then the tag will be truncated.
166  * However, all tags produced using the same key must use the same tag size. It is up to the caller
167  * to ensure this.
168  *
169  * @return
170  * LE_OK if successful.
171  * LE_BAD_PARAMETER if the session reference is invalid
172  * or if the key type is invalid
173  * or if bufPtr is NULL.
174  * LE_UNSUPPORTED if underlying resource does not support this operation.
175  * LE_FAULT if no message was processed or le_iks_hmac_Done() or
176  * le_iks_hmac_Verify() has already been called,
177  * or if there was an internal error.
178  */
179 //--------------------------------------------------------------------------------------------------
181 (
182  uint64_t session,
183  ///< [IN] Session reference.
184  uint8_t* tagBufPtr,
185  ///< [OUT] Buffer to hold the authentication tag.
186  size_t* tagBufSizePtr
187  ///< [INOUT]
188 );
189 
190 //--------------------------------------------------------------------------------------------------
191 /**
192  * Complete message processing and compare the resulting authentication tag with the supplied tag.
193  *
194  * The maximum size of the authentication tag is the size of the output of the underlying hash
195  * function. For example, if the key is of type KEY_TYPE_HMAC_SHA256 then the maximum tag size
196  * is 32 bytes.
197  *
198  * If the supplied tag is larger than or equal to the maximum authentication tag size then the
199  * authentication will fail.
200  *
201  * If the supplied tag is smaller than the maximum tag size then only the first tagSize bytes will
202  * be compared.
203  *
204  * All tags produced using the same key must use the same tag size. It is up to the caller
205  * to ensure this.
206  *
207  * @return
208  * LE_OK if the specified tag matches the calculated message tag.
209  * LE_BAD_PARAMETER if the session reference is invalid
210  * or if the key type is invalid
211  * or if tagPtr is NULL or tagSize is zero.
212  * LE_UNSUPPORTED if underlying resource does not support this operation.
213  * LE_FAULT if the specified tag does not match the calculated message tag,
214  * or if no message was processed or le_iks_hmac_Done() or
215  * or le_iks_hmac_Verify() has already been called,
216  * or if there was an internal error.
217  */
218 //--------------------------------------------------------------------------------------------------
220 (
221  uint64_t session,
222  ///< [IN] Session reference.
223  const uint8_t* tagBufPtr,
224  ///< [IN] Authentication tag to check against.
225  size_t tagBufSize
226  ///< [IN]
227 );
228 
229 #endif // LE_IKS_HMAC_INTERFACE_H_INCLUDE_GUARD
le_result_t
Definition: le_basics.h:45
le_result_t le_iks_hmac_Done(uint64_t session, uint8_t *tagBufPtr, size_t *tagBufSizePtr)
void(* le_iks_hmac_DisconnectHandler_t)(void *)
Definition: le_iks_hmac_interface.h:49
LE_FULL_API void le_iks_hmac_SetServerDisconnectHandler(le_iks_hmac_DisconnectHandler_t disconnectHandler, void *contextPtr)
le_result_t le_iks_hmac_TryConnectService(void)
void le_iks_hmac_ConnectService(void)
#define LE_FULL_API
Definition: le_apiFeatures.h:40
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 le_iks_hmac_Verify(uint64_t session, const uint8_t *tagBufPtr, size_t tagBufSize)