eapol/eapol_framework/eapol_common/am/include/eap_am_crypto_sha_256.h
changeset 52 c23bdf5a328a
parent 33 938269283a16
equal deleted inserted replaced
51:e863583e6720 52:c23bdf5a328a
    23 #define _EAP_AM_CRYPTO_SHA_256_H_
    23 #define _EAP_AM_CRYPTO_SHA_256_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_SHA_256_H)
       
    30 	#define EAP_CLASS_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H EAP_NONSHARABLE 
       
    31 	#define EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H 
       
    32 	#define EAP_C_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H 
       
    33 	#define EAP_FUNC_EXPORT_EAP_AM_CRYPTO_SHA_256_H 
       
    34 	#define EAP_C_FUNC_EXPORT_EAP_AM_CRYPTO_SHA_256_H 
       
    35 #elif defined(EAP_EXPORT_EAP_AM_CRYPTO_SHA_256_H)
       
    36 	#define EAP_CLASS_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H EAP_EXPORT 
       
    37 	#define EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H EAP_FUNC_EXPORT 
       
    38 	#define EAP_C_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H EAP_C_FUNC_EXPORT 
       
    39 	#define EAP_FUNC_EXPORT_EAP_AM_CRYPTO_SHA_256_H EAP_FUNC_EXPORT 
       
    40 	#define EAP_C_FUNC_EXPORT_EAP_AM_CRYPTO_SHA_256_H EAP_C_FUNC_EXPORT 
       
    41 #else
       
    42 	#define EAP_CLASS_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H EAP_IMPORT 
       
    43 	#define EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H EAP_FUNC_IMPORT 
       
    44 	#define EAP_C_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H EAP_C_FUNC_IMPORT 
       
    45 	#define EAP_FUNC_EXPORT_EAP_AM_CRYPTO_SHA_256_H 
       
    46 	#define EAP_C_FUNC_EXPORT_EAP_AM_CRYPTO_SHA_256_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_sha_256_c class includes the state of 
    54 /// The eap_am_crypto_sha_256_c class includes the state of 
    34 /// one instance of SHA_256 algorithm.
    55 /// one instance of SHA_256 algorithm.
    35 class EAP_EXPORT eap_am_crypto_sha_256_c
    56 class EAP_CLASS_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H eap_am_crypto_sha_256_c
    36 {
    57 {
    37 
    58 
    38 private:
    59 private:
    39 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    60 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    40 
    61 
    98 		);
   119 		);
    99 
   120 
   100 	/// @param W is an array of modulo 16 input 32-bit unsigned integers
   121 	/// @param W is an array of modulo 16 input 32-bit unsigned integers
   101 	/// in host order.
   122 	/// in host order.
   102 	/// @param W_count is count of integers in W array.
   123 	/// @param W_count is count of integers in W array.
   103 	EAP_FUNC_IMPORT eap_status_e eap_sha_256_process_data_host_order(
   124 	EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H eap_status_e eap_sha_256_process_data_host_order(
   104 		const u32_t * W,
   125 		const u32_t * W,
   105 		u32_t W_count
   126 		u32_t W_count
   106 		);
   127 		);
   107 
   128 
   108 	/// @param W is an array of modulo 16 input 32-bit unsigned integers
   129 	/// @param W is an array of modulo 16 input 32-bit unsigned integers
   109 	/// in host order.
   130 	/// in host order.
   110 	/// @param W_count is count of integers in W array.
   131 	/// @param W_count is count of integers in W array.
   111 	EAP_FUNC_IMPORT eap_status_e eap_sha_256_process_data_network_order(
   132 	EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H eap_status_e eap_sha_256_process_data_network_order(
   112 		const u32_t * W,
   133 		const u32_t * W,
   113 		u32_t W_count
   134 		u32_t W_count
   114 		);
   135 		);
   115 
   136 
   116 	/**
   137 	/**
   117 	 * This function cleans up the SHA_256 context.
   138 	 * This function cleans up the SHA_256 context.
   118 	 */
   139 	 */
   119 	EAP_FUNC_IMPORT eap_status_e hash_cleanup();
   140 	EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H eap_status_e hash_cleanup();
   120 
   141 
   121 	/**
   142 	/**
   122 	 * This function copies the message digest to output buffer.
   143 	 * This function copies the message digest to output buffer.
   123 	 */
   144 	 */
   124 	EAP_FUNC_IMPORT eap_status_e copy_message_digest(
   145 	EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H eap_status_e copy_message_digest(
   125 		void * const output,
   146 		void * const output,
   126 		u32_t * const max_output_size);
   147 		u32_t * const max_output_size);
   127 
   148 
   128 
   149 
   129 	/**
   150 	/**
   130 	 * The set_is_invalid() function sets the state of the eap_am_crypto_md4_c
   151 	 * The set_is_invalid() function sets the state of the eap_am_crypto_md4_c
   131 	 * object invalid. 
   152 	 * object invalid. 
   132 	 * The eap_am_crypto_md4_c object calls this function after it is
   153 	 * The eap_am_crypto_md4_c object calls this function after it is
   133 	 * initialized.
   154 	 * initialized.
   134 	 */
   155 	 */
   135 	EAP_FUNC_IMPORT void set_is_invalid();
   156 	EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H void set_is_invalid();
   136 
   157 
   137 	/**
   158 	/**
   138 	 * The set_is_valid() function sets the state of the eap_am_crypto_md4_c
   159 	 * The set_is_valid() function sets the state of the eap_am_crypto_md4_c
   139 	 * object valid. 
   160 	 * object valid. 
   140 	 * The eap_am_crypto_md4_c object calls this function after it is
   161 	 * The eap_am_crypto_md4_c object calls this function after it is
   141 	 * initialized.
   162 	 * initialized.
   142 	 */
   163 	 */
   143 	EAP_FUNC_IMPORT void set_is_valid();
   164 	EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H void set_is_valid();
   144 
   165 
   145 	/**
   166 	/**
   146 	 * This function copies the context of SHA_256.
   167 	 * This function copies the context of SHA_256.
   147 	 */
   168 	 */
   148 	EAP_FUNC_IMPORT eap_status_e copy_context(
   169 	EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H eap_status_e copy_context(
   149 		const eap_variable_data_c * const saved_data,
   170 		const eap_variable_data_c * const saved_data,
   150 		const u64_t full_hashed_data_length,
   171 		const u64_t full_hashed_data_length,
   151 		const u32_t * const H,
   172 		const u32_t * const H,
   152 		const u32_t * const T,
   173 		const u32_t * const T,
   153 		const u32_t * const W_in_host_order);
   174 		const u32_t * const W_in_host_order);
   157 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   178 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   158 
   179 
   159 	/**
   180 	/**
   160 	 * Destructor does nothing special.
   181 	 * Destructor does nothing special.
   161 	 */
   182 	 */
   162 	EAP_FUNC_IMPORT virtual ~eap_am_crypto_sha_256_c();
   183 	EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H virtual ~eap_am_crypto_sha_256_c();
   163 
   184 
   164 	/**
   185 	/**
   165 	 * Constructor initializes the member attributes.
   186 	 * Constructor initializes the member attributes.
   166 	 */
   187 	 */
   167 	EAP_FUNC_IMPORT eap_am_crypto_sha_256_c(abs_eap_am_tools_c * const tools);
   188 	EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H eap_am_crypto_sha_256_c(abs_eap_am_tools_c * const tools);
   168 
   189 
   169 	/**
   190 	/**
   170 	 * The get_is_valid() function returns the status of the
   191 	 * The get_is_valid() function returns the status of the
   171 	 * eap_am_crypto_md4_c object. 
   192 	 * eap_am_crypto_md4_c object. 
   172 	 * True indicates the object is allocated successfully.
   193 	 * True indicates the object is allocated successfully.
   173 	 */
   194 	 */
   174 	EAP_FUNC_IMPORT bool get_is_valid();
   195 	EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H bool get_is_valid();
   175 
   196 
   176 	/**
   197 	/**
   177 	 * This function returns the size of message digest of HASH-algorithm.
   198 	 * This function returns the size of message digest of HASH-algorithm.
   178 	 */
   199 	 */
   179 	EAP_FUNC_IMPORT u32_t get_digest_length();
   200 	EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H u32_t get_digest_length();
   180 
   201 
   181 	/**
   202 	/**
   182 	 * This function returns the size of block of HASH-algorithm.
   203 	 * This function returns the size of block of HASH-algorithm.
   183 	 */
   204 	 */
   184 	EAP_FUNC_IMPORT u32_t get_block_size();
   205 	EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H u32_t get_block_size();
   185 
   206 
   186 	/**
   207 	/**
   187 	 * This function initializes the context of SHA_256-algorithm.
   208 	 * This function initializes the context of SHA_256-algorithm.
   188 	 */
   209 	 */
   189 	EAP_FUNC_IMPORT eap_status_e hash_init();
   210 	EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H eap_status_e hash_init();
   190 
   211 
   191 	/**
   212 	/**
   192 	 * This function updates the context of SHA_256-algorithm with data.
   213 	 * This function updates the context of SHA_256-algorithm with data.
   193 	 */
   214 	 */
   194 	EAP_FUNC_IMPORT eap_status_e hash_update(
   215 	EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H eap_status_e hash_update(
   195 		const void * const data,
   216 		const void * const data,
   196 		const u32_t data_length);
   217 		const u32_t data_length);
   197 
   218 
   198 	/**
   219 	/**
   199 	 * This function writes the message digest to buffer.
   220 	 * This function writes the message digest to buffer.
   200 	 * @param Length is set if md_length_or_null is non-NULL.
   221 	 * @param Length is set if md_length_or_null is non-NULL.
   201 	 */
   222 	 */
   202 	EAP_FUNC_IMPORT eap_status_e hash_final(
   223 	EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H eap_status_e hash_final(
   203 		void * const message_digest,
   224 		void * const message_digest,
   204 		u32_t *md_length_or_null);
   225 		u32_t *md_length_or_null);
   205 
   226 
   206 	/**
   227 	/**
   207 	 * This function copies the context of SHA_256.
   228 	 * This function copies the context of SHA_256.
   208 	 */
   229 	 */
   209 	EAP_FUNC_IMPORT eap_am_crypto_sha_256_c * copy();
   230 	EAP_FUNC_VISIBILITY_EAP_AM_CRYPTO_SHA_256_H eap_am_crypto_sha_256_c * copy();
   210 
   231 
   211 };
   232 };
   212 
   233 
   213 //--------------------------------------------------
   234 //--------------------------------------------------
   214 
   235