eapol/eapol_framework/eapol_common/core/eapol_rc4_key_header.cpp
changeset 33 938269283a16
parent 2 1c7bc153c08e
child 46 c74b3d9f6b9e
equal deleted inserted replaced
22:093cf0757204 33:938269283a16
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 11 %
    19 * %version: %
    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 = ((*data) & ~m_flag_mask_key_flag) | static_cast<u8_t>((((flags << m_flag_shift_key_flag) & m_flag_mask_key_flag)));
   311 		*data = static_cast<u8_t>(((*data) & ~m_flag_mask_key_flag)
       
   312 								  | static_cast<u8_t>((flags << m_flag_shift_key_flag) & m_flag_mask_key_flag));
   312 		return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
   313 		return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
   313 	}
   314 	}
   314 	else
   315 	else
   315 	{
   316 	{
   316 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
   317 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
   322 EAP_FUNC_EXPORT eap_status_e eapol_RC4_key_header_c::set_key_index(u8_t index)
   323 EAP_FUNC_EXPORT eap_status_e eapol_RC4_key_header_c::set_key_index(u8_t index)
   323 {
   324 {
   324 	u8_t * const data = get_header_offset(m_offset_key_index, sizeof(u8_t));
   325 	u8_t * const data = get_header_offset(m_offset_key_index, sizeof(u8_t));
   325 	if (data != 0)
   326 	if (data != 0)
   326 	{
   327 	{
   327 		*data = ((*data) & m_flag_mask_key_flag) | static_cast<u8_t>((index & ~m_flag_mask_key_flag));
   328 		*data = static_cast<u8_t>(((*data) & m_flag_mask_key_flag)
       
   329 								  | static_cast<u8_t>((index & ~m_flag_mask_key_flag)));
   328 		return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
   330 		return EAP_STATUS_RETURN(m_am_tools, eap_status_ok);
   329 	}
   331 	}
   330 	else
   332 	else
   331 	{
   333 	{
   332 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);
   334 		return EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error);