eapol/eapol_framework/eapol_common/core/eapol_rc4_key_header.cpp
branchRCL_3
changeset 46 c74b3d9f6b9e
parent 45 bad0cc58d154
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: %
    19 * %version: 11 %
    20 */
    20 */
    21 
    21 
    22 // This is enumeration of EAPOL source code.
    22 // This is enumeration of EAPOL source code.
    23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
    23 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
    24 	#undef EAP_FILE_NUMBER_ENUM
    24 	#undef EAP_FILE_NUMBER_ENUM
   306 EAP_FUNC_EXPORT eap_status_e eapol_RC4_key_header_c::set_key_flag(eapol_RC4_key_flags_e flags)
   306 EAP_FUNC_EXPORT eap_status_e eapol_RC4_key_header_c::set_key_flag(eapol_RC4_key_flags_e flags)
   307 {
   307 {
   308 	u8_t * const data = get_header_offset(m_offset_key_index, sizeof(u8_t));
   308 	u8_t * const data = get_header_offset(m_offset_key_index, sizeof(u8_t));
   309 	if (data != 0)
   309 	if (data != 0)
   310 	{
   310 	{
   311 		*data = static_cast<u8_t>(((*data) & ~m_flag_mask_key_flag)
   311 		*data = ((*data) & ~m_flag_mask_key_flag) | static_cast<u8_t>((((flags << m_flag_shift_key_flag) & m_flag_mask_key_flag)));
   312 								  | static_cast<u8_t>((flags << m_flag_shift_key_flag) & m_flag_mask_key_flag));
       
   313 		return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
   312 		return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
   314 	}
   313 	}
   315 	else
   314 	else
   316 	{
   315 	{
   317 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
   316 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
   323 EAP_FUNC_EXPORT eap_status_e eapol_RC4_key_header_c::set_key_index(u8_t index)
   322 EAP_FUNC_EXPORT eap_status_e eapol_RC4_key_header_c::set_key_index(u8_t index)
   324 {
   323 {
   325 	u8_t * const data = get_header_offset(m_offset_key_index, sizeof(u8_t));
   324 	u8_t * const data = get_header_offset(m_offset_key_index, sizeof(u8_t));
   326 	if (data != 0)
   325 	if (data != 0)
   327 	{
   326 	{
   328 		*data = static_cast<u8_t>(((*data) & m_flag_mask_key_flag)
   327 		*data = ((*data) & m_flag_mask_key_flag) | static_cast<u8_t>((index & ~m_flag_mask_key_flag));
   329 								  | static_cast<u8_t>((index & ~m_flag_mask_key_flag)));
       
   330 		return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
   328 		return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
   331 	}
   329 	}
   332 	else
   330 	else
   333 	{
   331 	{
   334 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
   332 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);