eapol/eapol_framework/eapol_common/type/aka/core/eap_type_aka_authentication_vector.cpp
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     1 /*
       
     2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  EAP and WLAN authentication protocols.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // This is enumeration of EAPOL source code.
       
    20 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    21 	#undef EAP_FILE_NUMBER_ENUM
       
    22 	#define EAP_FILE_NUMBER_ENUM 65 
       
    23 	#undef EAP_FILE_NUMBER_DATE 
       
    24 	#define EAP_FILE_NUMBER_DATE 1127594498 
       
    25 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES)
       
    26 
       
    27 
       
    28 
       
    29 #include "eap_am_memory.h"
       
    30 #include "eap_type_aka_authentication_vector.h"
       
    31 #include "eap_am_tools.h"
       
    32 
       
    33 //-------------------------------------------------------------------
       
    34 
       
    35 EAP_FUNC_EXPORT eap_type_aka_authentication_vector_c::~eap_type_aka_authentication_vector_c()
       
    36 {
       
    37 }
       
    38 
       
    39 //-------------------------------------------------------------------
       
    40 
       
    41 EAP_FUNC_EXPORT eap_type_aka_authentication_vector_c::eap_type_aka_authentication_vector_c(
       
    42 	abs_eap_am_tools_c * const tools
       
    43 	)
       
    44 	: m_am_tools(tools)
       
    45 	, m_RAND(tools)
       
    46 	, m_AUTN(tools)
       
    47 	, m_RES(tools)
       
    48 	, m_CK(tools)
       
    49 	, m_IK(tools)
       
    50 	, m_AUTS(tools)
       
    51 	, m_vector_status(eap_status_process_general_error)
       
    52 	, m_is_valid(true)
       
    53 {
       
    54 }
       
    55 
       
    56 //-------------------------------------------------------------------
       
    57 
       
    58 EAP_FUNC_EXPORT eap_variable_data_c * eap_type_aka_authentication_vector_c::get_RAND() const
       
    59 {
       
    60 	return const_cast<eap_variable_data_c *>(&m_RAND);
       
    61 }
       
    62 
       
    63 //-------------------------------------------------------------------
       
    64 
       
    65 EAP_FUNC_EXPORT eap_variable_data_c * eap_type_aka_authentication_vector_c::get_AUTN() const
       
    66 {
       
    67 	return const_cast<eap_variable_data_c *>(&m_AUTN);
       
    68 }
       
    69 
       
    70 //-------------------------------------------------------------------
       
    71 
       
    72 EAP_FUNC_EXPORT eap_variable_data_c * eap_type_aka_authentication_vector_c::get_RES() const
       
    73 {
       
    74 	return const_cast<eap_variable_data_c *>(&m_RES);
       
    75 }
       
    76 
       
    77 //-------------------------------------------------------------------
       
    78 
       
    79 EAP_FUNC_EXPORT eap_variable_data_c * eap_type_aka_authentication_vector_c::get_CK() const
       
    80 {
       
    81 	return const_cast<eap_variable_data_c *>(&m_CK);
       
    82 }
       
    83 
       
    84 //-------------------------------------------------------------------
       
    85 
       
    86 EAP_FUNC_EXPORT eap_variable_data_c * eap_type_aka_authentication_vector_c::get_IK() const
       
    87 {
       
    88 	return const_cast<eap_variable_data_c *>(&m_IK);
       
    89 }
       
    90 
       
    91 //-------------------------------------------------------------------
       
    92 
       
    93 EAP_FUNC_EXPORT eap_variable_data_c * eap_type_aka_authentication_vector_c::get_AUTS() const
       
    94 {
       
    95 	return const_cast<eap_variable_data_c *>(&m_AUTS);
       
    96 }
       
    97 
       
    98 //-------------------------------------------------------------------
       
    99 
       
   100 EAP_FUNC_EXPORT eap_type_aka_authentication_vector_c * eap_type_aka_authentication_vector_c::copy() const
       
   101 {
       
   102 	eap_type_aka_authentication_vector_c * vector = new eap_type_aka_authentication_vector_c(m_am_tools);
       
   103 	if (vector == 0)
       
   104 	{
       
   105 		return 0;
       
   106 	}
       
   107 
       
   108 	eap_status_e status = eap_status_process_general_error;
       
   109 
       
   110 	if (get_RAND()->get_is_valid_data() == true)
       
   111 	{
       
   112 		status = vector->get_RAND()->set_copy_of_buffer(get_RAND());
       
   113 		if (status != eap_status_ok)
       
   114 		{
       
   115 			vector->reset();
       
   116 			delete vector;
       
   117 			return 0;
       
   118 		}
       
   119 	}
       
   120 
       
   121 	if (get_AUTN()->get_is_valid_data() == true)
       
   122 	{
       
   123 		status = vector->get_AUTN()->set_copy_of_buffer(get_AUTN());
       
   124 		if (status != eap_status_ok)
       
   125 		{
       
   126 			vector->reset();
       
   127 			delete vector;
       
   128 			return 0;
       
   129 		}
       
   130 	}
       
   131 
       
   132 	if (get_RES()->get_is_valid_data() == true)
       
   133 	{
       
   134 		status = vector->get_RES()->set_copy_of_buffer(get_RES());
       
   135 		if (status != eap_status_ok)
       
   136 		{
       
   137 			vector->reset();
       
   138 			delete vector;
       
   139 			return 0;
       
   140 		}
       
   141 	}
       
   142 
       
   143 	if (get_CK()->get_is_valid_data() == true)
       
   144 	{
       
   145 		status = vector->get_CK()->set_copy_of_buffer(get_CK());
       
   146 		if (status != eap_status_ok)
       
   147 		{
       
   148 			vector->reset();
       
   149 			delete vector;
       
   150 			return 0;
       
   151 		}
       
   152 	}
       
   153 
       
   154 	if (get_IK()->get_is_valid_data() == true)
       
   155 	{
       
   156 		status = vector->get_IK()->set_copy_of_buffer(get_IK());
       
   157 		if (status != eap_status_ok)
       
   158 		{
       
   159 			vector->reset();
       
   160 			delete vector;
       
   161 			return 0;
       
   162 		}
       
   163 	}
       
   164 
       
   165 	return vector;
       
   166 }
       
   167 
       
   168 //-------------------------------------------------------------------
       
   169 
       
   170 EAP_FUNC_EXPORT void eap_type_aka_authentication_vector_c::reset()
       
   171 {
       
   172 	m_RAND.reset();
       
   173 	m_AUTN.reset();
       
   174 	m_RES.reset();
       
   175 	m_CK.reset();
       
   176 	m_IK.reset();
       
   177 }
       
   178 
       
   179 //-------------------------------------------------------------------
       
   180 
       
   181 EAP_FUNC_EXPORT void eap_type_aka_authentication_vector_c::set_vector_status(eap_status_e vector_status)
       
   182 {
       
   183 	m_vector_status = vector_status;
       
   184 }
       
   185 
       
   186 //-------------------------------------------------------------------
       
   187 
       
   188 EAP_FUNC_EXPORT eap_status_e eap_type_aka_authentication_vector_c::get_vector_status() const
       
   189 {
       
   190 	return EAP_STATUS_RETURN(m_am_tools, m_vector_status);
       
   191 }
       
   192 
       
   193 //-------------------------------------------------------------------
       
   194 
       
   195 EAP_FUNC_EXPORT bool eap_type_aka_authentication_vector_c::get_is_valid() const
       
   196 {
       
   197 	return m_is_valid;
       
   198 }
       
   199 
       
   200 //-------------------------------------------------------------------
       
   201 
       
   202 
       
   203 
       
   204 // End.