eapol/eapol_framework/eapol_symbian/am/common/DSS_random/dss_random_symbian.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: 10.1.4 %
    19 * %version: 12 %
    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
    75  *      w[0] || w[1]= 2070b322 3dba372f de1c0ffc 7b2e3b49 8b260614
    75  *      w[0] || w[1]= 2070b322 3dba372f de1c0ffc 7b2e3b49 8b260614
    76  *                    3c6c18ba cb0f6c55 babb1378 8e20d737 a3275116
    76  *                    3c6c18ba cb0f6c55 babb1378 8e20d737 a3275116
    77  *      X= 47c27eb6 16dba413 91e5165b e9c5e397 7e39a15d
    77  *      X= 47c27eb6 16dba413 91e5165b e9c5e397 7e39a15d
    78  *  @endcode
    78  *  @endcode
    79 */
    79 */
    80 eap_status_e dss_random_G(abs_eap_am_tools_c * const m_am_tools, u8_t *out, u32_t out_length, const u8_t *c, u32_t c_length)
    80 void dss_random_G(abs_eap_am_tools_c * const m_am_tools, u8_t *out, u32_t out_length, const u8_t *c, u32_t c_length)
    81 {
    81 {
    82 	u32_t *out_array = reinterpret_cast<u32_t *>(out);
    82 	u32_t *out_array = reinterpret_cast<u32_t *>(out);
    83 
    83 
    84 	eap_am_crypto_sha1_c sha1(m_am_tools);
    84 	eap_am_crypto_sha1_c sha1(m_am_tools);
    85 	u32_t output_length = out_length;
    85 	u32_t output_length = out_length;
    90 		out_array,
    90 		out_array,
    91 		&output_length
    91 		&output_length
    92 		);
    92 		);
    93 	if (status != eap_status_ok)
    93 	if (status != eap_status_ok)
    94 	{
    94 	{
    95 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_EAP_AM_CRYPTO, (EAPL("ERROR: eap_sha1_dss_G_function(): status = %d"),
    95 		EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_EAP_AM_CRYPTO, (EAPL("eap_sha1_dss_G_function(): status = %d"),
    96 			status));
    96 			status));
    97 		return status;
       
    98 	}
    97 	}
    99 
    98 
   100 	EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_EAP_AM_CRYPTO, (EAPL("dss_random_G(): out_array"),
    99 	EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_EAP_AM_CRYPTO, (EAPL("dss_random_G(): out_array"),
   101 		out_array, sizeof(out_array)*5));
   100 		out_array, sizeof(out_array)*5));
   102 
   101 
   103 	return status;
       
   104 }
   102 }
   105 
   103 
   106 /**
   104 /**
   107  *  dss_pseudo_random() implements pseudo random function for key generation of EAP/SIM.
   105  *  dss_pseudo_random() implements pseudo random function for key generation of EAP/SIM.
   108  *  @code
   106  *  @code
   114  *  Step 3. For j = 0 to m - 1 do
   112  *  Step 3. For j = 0 to m - 1 do
   115  *              c. xj = G(t,XKEY).
   113  *              c. xj = G(t,XKEY).
   116  *              d. XKEY = (1 + XKEY + xj) mod 2^b.
   114  *              d. XKEY = (1 + XKEY + xj) mod 2^b.
   117  *  @endcode
   115  *  @endcode
   118 */
   116 */
   119 EAP_FUNC_EXPORT eap_status_e dss_pseudo_random(abs_eap_am_tools_c * const m_am_tools, u8_t *out, u32_t out_length, u8_t *xkey, u32_t xkey_length)
   117 eap_status_e dss_pseudo_random(abs_eap_am_tools_c * const m_am_tools, u8_t *out, u32_t out_length, u8_t *xkey, u32_t xkey_length)
   120 {
   118 {
   121 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   119 	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
   122 	eap_status_e status = eap_status_ok;
   120 	eap_status_e status = eap_status_ok;
   123 	__UHEAP_MARK;
   121 	__UHEAP_MARK;
   124 
   122 
   181 
   179 
   182 	CleanupStack::PushL(bn_mod);
   180 	CleanupStack::PushL(bn_mod);
   183 
   181 
   184 	for (u32_t ind = 0; ind < block_count; ind++)
   182 	for (u32_t ind = 0; ind < block_count; ind++)
   185 	{
   183 	{
   186 		eap_status_e status = dss_random_G(m_am_tools, &(out[ind*BLOCK_SIZE]), BLOCK_SIZE, tmp_xkey.Ptr(), BLOCK_SIZE);
   184 		dss_random_G(m_am_tools, &(out[ind*BLOCK_SIZE]), BLOCK_SIZE, tmp_xkey.Ptr(), BLOCK_SIZE);
   187 		if (status != eap_status_ok)
       
   188 		{
       
   189 			EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_EAP_AM_CRYPTO, (EAPL("ERROR: dss_random_G(): status = %d"),
       
   190 																	status));
       
   191 			User::Leave(KErrGeneral);
       
   192 		}
       
   193 
   185 
   194 		EAP_TRACE_DATA_DEBUG(
   186 		EAP_TRACE_DATA_DEBUG(
   195 			m_am_tools,
   187 			m_am_tools,
   196 			TRACE_FLAGS_EAP_AM_CRYPTO,
   188 			TRACE_FLAGS_EAP_AM_CRYPTO,
   197 			(EAPL("dss_pseudo_random(): xj = G(xkey)"),
   189 			(EAPL("dss_pseudo_random(): xj = G(xkey)"),