23 #define _EAP_AM_CRYPTO_SHA1_H_ |
23 #define _EAP_AM_CRYPTO_SHA1_H_ |
24 |
24 |
25 #include "eap_am_types.h" |
25 #include "eap_am_types.h" |
26 #include "eap_variable_data.h" |
26 #include "eap_variable_data.h" |
27 #include "eap_am_export.h" |
27 #include "eap_am_export.h" |
|
28 // Start: added by script change_export_macros.sh. |
|
29 #if defined(EAP_NO_EXPORT_EAP_AM_CRYPTO_SHA1_H) |
|
30 #define EAP_CLASS_VISIBILITY_EAP_AM_CRYPTO_SHA1_H EAP_NONSHARABLE |
|
31 #define EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H |
|
32 #define EAP_C_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H |
|
33 #define EAP_FUNC_EXPORT_EAP_AM_CRYPTO_SHA1_H |
|
34 #define EAP_C_FUNC_EXPORT_EAP_AM_CRYPTO_SHA1_H |
|
35 #elif defined(EAP_EXPORT_EAP_AM_CRYPTO_SHA1_H) |
|
36 #define EAP_CLASS_VISIBILITY_EAP_AM_CRYPTO_SHA1_H EAP_EXPORT |
|
37 #define EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H EAP_FUNC_EXPORT |
|
38 #define EAP_C_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H EAP_C_FUNC_EXPORT |
|
39 #define EAP_FUNC_EXPORT_EAP_AM_CRYPTO_SHA1_H EAP_FUNC_EXPORT |
|
40 #define EAP_C_FUNC_EXPORT_EAP_AM_CRYPTO_SHA1_H EAP_C_FUNC_EXPORT |
|
41 #else |
|
42 #define EAP_CLASS_VISIBILITY_EAP_AM_CRYPTO_SHA1_H EAP_IMPORT |
|
43 #define EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H EAP_FUNC_IMPORT |
|
44 #define EAP_C_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H EAP_C_FUNC_IMPORT |
|
45 #define EAP_FUNC_EXPORT_EAP_AM_CRYPTO_SHA1_H |
|
46 #define EAP_C_FUNC_EXPORT_EAP_AM_CRYPTO_SHA1_H |
|
47 #endif |
|
48 // End: added by script change_export_macros.sh. |
28 #include "eap_am_tools.h" |
49 #include "eap_am_tools.h" |
29 |
50 |
30 |
51 |
31 //-------------------------------------------------- |
52 //-------------------------------------------------- |
32 |
53 |
33 /// The eap_am_crypto_sha1_c class includes the state of |
54 /// The eap_am_crypto_sha1_c class includes the state of |
34 /// one instance of SHA1 algorithm. |
55 /// one instance of SHA1 algorithm. |
35 class EAP_EXPORT eap_am_crypto_sha1_c |
56 class EAP_CLASS_VISIBILITY_EAP_AM_CRYPTO_SHA1_H eap_am_crypto_sha1_c |
36 { |
57 { |
37 |
58 |
38 private: |
59 private: |
39 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
60 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
40 |
61 |
207 ); |
228 ); |
208 |
229 |
209 /// @param W is an array of modulo 16 input 32-bit unsigned integers |
230 /// @param W is an array of modulo 16 input 32-bit unsigned integers |
210 /// in host order. |
231 /// in host order. |
211 /// @param W_count is count of integers in W array. |
232 /// @param W_count is count of integers in W array. |
212 EAP_FUNC_IMPORT eap_status_e eap_sha1_process_data_host_order( |
233 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H eap_status_e eap_sha1_process_data_host_order( |
213 const u32_t * W, |
234 const u32_t * W, |
214 u32_t W_count |
235 u32_t W_count |
215 ); |
236 ); |
216 |
237 |
217 /// @param W is an array of modulo 16 input 32-bit unsigned integers |
238 /// @param W is an array of modulo 16 input 32-bit unsigned integers |
218 /// in host order. |
239 /// in host order. |
219 /// @param W_count is count of integers in W array. |
240 /// @param W_count is count of integers in W array. |
220 EAP_FUNC_IMPORT eap_status_e eap_sha1_process_data_network_order( |
241 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H eap_status_e eap_sha1_process_data_network_order( |
221 const u32_t * W, |
242 const u32_t * W, |
222 u32_t W_count |
243 u32_t W_count |
223 ); |
244 ); |
224 |
245 |
225 /** |
246 /** |
226 * This function cleans up the SHA1 context. |
247 * This function cleans up the SHA1 context. |
227 */ |
248 */ |
228 EAP_FUNC_IMPORT eap_status_e hash_cleanup(); |
249 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H eap_status_e hash_cleanup(); |
229 |
250 |
230 /** |
251 /** |
231 * This function copies the message digest to output buffer. |
252 * This function copies the message digest to output buffer. |
232 */ |
253 */ |
233 EAP_FUNC_IMPORT eap_status_e copy_message_digest( |
254 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H eap_status_e copy_message_digest( |
234 void * const output, |
255 void * const output, |
235 u32_t * const max_output_size); |
256 u32_t * const max_output_size); |
236 |
257 |
237 |
258 |
238 /** |
259 /** |
239 * The set_is_invalid() function sets the state of the eap_am_crypto_md4_c |
260 * The set_is_invalid() function sets the state of the eap_am_crypto_md4_c |
240 * object invalid. |
261 * object invalid. |
241 * The eap_am_crypto_md4_c object calls this function after it is |
262 * The eap_am_crypto_md4_c object calls this function after it is |
242 * initialized. |
263 * initialized. |
243 */ |
264 */ |
244 EAP_FUNC_IMPORT void set_is_invalid(); |
265 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H void set_is_invalid(); |
245 |
266 |
246 /** |
267 /** |
247 * The set_is_valid() function sets the state of the eap_am_crypto_md4_c |
268 * The set_is_valid() function sets the state of the eap_am_crypto_md4_c |
248 * object valid. |
269 * object valid. |
249 * The eap_am_crypto_md4_c object calls this function after it is |
270 * The eap_am_crypto_md4_c object calls this function after it is |
250 * initialized. |
271 * initialized. |
251 */ |
272 */ |
252 EAP_FUNC_IMPORT void set_is_valid(); |
273 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H void set_is_valid(); |
253 |
274 |
254 /** |
275 /** |
255 * This function copies the context of SHA1. |
276 * This function copies the context of SHA1. |
256 */ |
277 */ |
257 EAP_FUNC_IMPORT eap_status_e copy_context( |
278 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H eap_status_e copy_context( |
258 const eap_variable_data_c * const saved_data, |
279 const eap_variable_data_c * const saved_data, |
259 const u64_t full_hashed_data_length, |
280 const u64_t full_hashed_data_length, |
260 const u32_t * const H, |
281 const u32_t * const H, |
261 const u32_t * const T, |
282 const u32_t * const T, |
262 const u32_t * const W_in_host_order); |
283 const u32_t * const W_in_host_order); |
266 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
287 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
267 |
288 |
268 /** |
289 /** |
269 * Destructor does nothing special. |
290 * Destructor does nothing special. |
270 */ |
291 */ |
271 EAP_FUNC_IMPORT virtual ~eap_am_crypto_sha1_c(); |
292 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H virtual ~eap_am_crypto_sha1_c(); |
272 |
293 |
273 /** |
294 /** |
274 * Constructor initializes the member attributes. |
295 * Constructor initializes the member attributes. |
275 */ |
296 */ |
276 EAP_FUNC_IMPORT eap_am_crypto_sha1_c(abs_eap_am_tools_c * const tools); |
297 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H eap_am_crypto_sha1_c(abs_eap_am_tools_c * const tools); |
277 |
298 |
278 /** |
299 /** |
279 * The get_is_valid() function returns the status of the |
300 * The get_is_valid() function returns the status of the |
280 * eap_am_crypto_md4_c object. |
301 * eap_am_crypto_md4_c object. |
281 * True indicates the object is allocated successfully. |
302 * True indicates the object is allocated successfully. |
282 */ |
303 */ |
283 EAP_FUNC_IMPORT bool get_is_valid(); |
304 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H bool get_is_valid(); |
284 |
305 |
285 /** |
306 /** |
286 * This function returns the size of message digest of HASH-algorithm. |
307 * This function returns the size of message digest of HASH-algorithm. |
287 */ |
308 */ |
288 EAP_FUNC_IMPORT u32_t get_digest_length(); |
309 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H u32_t get_digest_length(); |
289 |
310 |
290 /** |
311 /** |
291 * This function returns the size of block of HASH-algorithm. |
312 * This function returns the size of block of HASH-algorithm. |
292 */ |
313 */ |
293 EAP_FUNC_IMPORT u32_t get_block_size(); |
314 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H u32_t get_block_size(); |
294 |
315 |
295 /** |
316 /** |
296 * This function initializes the context of SHA1-algorithm. |
317 * This function initializes the context of SHA1-algorithm. |
297 */ |
318 */ |
298 EAP_FUNC_IMPORT eap_status_e hash_init(); |
319 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H eap_status_e hash_init(); |
299 |
320 |
300 /** |
321 /** |
301 * This function updates the context of SHA1-algorithm with data. |
322 * This function updates the context of SHA1-algorithm with data. |
302 */ |
323 */ |
303 EAP_FUNC_IMPORT eap_status_e hash_update( |
324 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H eap_status_e hash_update( |
304 const void * const data, |
325 const void * const data, |
305 const u32_t data_length); |
326 const u32_t data_length); |
306 |
327 |
307 /** |
328 /** |
308 * This function writes the message digest to buffer. |
329 * This function writes the message digest to buffer. |
309 * @param Length is set if md_length_or_null is non-NULL. |
330 * @param Length is set if md_length_or_null is non-NULL. |
310 */ |
331 */ |
311 EAP_FUNC_IMPORT eap_status_e hash_final( |
332 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H eap_status_e hash_final( |
312 void * const message_digest, |
333 void * const message_digest, |
313 u32_t *md_length_or_null); |
334 u32_t *md_length_or_null); |
314 |
335 |
315 /** |
336 /** |
316 * |
337 * |
317 * eap_sha1_dss_G_function() implements the G() function using |
338 * eap_sha1_dss_G_function() implements the G() function using |
318 * modified SHA-1 using the routine in Appendix 3.3 Constructing |
339 * modified SHA-1 using the routine in Appendix 3.3 Constructing |
319 * The Function G From SHA-1 in the SECURE HASH STANDARD, FIPS PUB 180-1. |
340 * The Function G From SHA-1 in the SECURE HASH STANDARD, FIPS PUB 180-1. |
320 */ |
341 */ |
321 EAP_FUNC_IMPORT eap_status_e eap_sha1_dss_G_function( |
342 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H eap_status_e eap_sha1_dss_G_function( |
322 const void * const data, |
343 const void * const data, |
323 const u32_t data_length, |
344 const u32_t data_length, |
324 void * const output, |
345 void * const output, |
325 u32_t * const output_length |
346 u32_t * const output_length |
326 ); |
347 ); |
327 |
348 |
328 /** |
349 /** |
329 * This function copies the context of SHA1. |
350 * This function copies the context of SHA1. |
330 */ |
351 */ |
331 EAP_FUNC_IMPORT eap_am_crypto_sha1_c * copy(); |
352 EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA1_H eap_am_crypto_sha1_c * copy(); |
332 |
353 |
333 }; |
354 }; |
334 |
355 |
335 //-------------------------------------------------- |
356 //-------------------------------------------------- |
336 |
357 |