eapol/eapol_framework/eapol_symbian/am/type/tls_peap/symbian/EapTlsPeapCertInterface.cpp
changeset 52 c23bdf5a328a
parent 39 fe6b6762fccd
equal deleted inserted replaced
51:e863583e6720 52:c23bdf5a328a
    14 * Description:  EAP and WLAN authentication protocols.
    14 * Description:  EAP and WLAN authentication protocols.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 38.1.26 %
    19 * %version: 38.1.28 %
    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
   224 	iKeyInfos.Reset();
   224 	iKeyInfos.Reset();
   225 
   225 
   226 	EAP_TRACE_DEBUG(
   226 	EAP_TRACE_DEBUG(
   227 		m_am_tools,
   227 		m_am_tools,
   228 		TRACE_FLAGS_DEFAULT,
   228 		TRACE_FLAGS_DEFAULT,
   229 		(EAPL("CEapTlsPeapCertInterface::~CEapTlsPeapCertInterface(): delete rest\n")));
   229 		(EAPL("CEapTlsPeapCertInterface::~CEapTlsPeapCertInterface(): delete iCertFilter\n")));
   230 
   230 
   231 	delete iCertFilter;
   231 	delete iCertFilter;
       
   232 
       
   233 	EAP_TRACE_DEBUG(
       
   234 		m_am_tools,
       
   235 		TRACE_FLAGS_DEFAULT,
       
   236 		(EAPL("CEapTlsPeapCertInterface::~CEapTlsPeapCertInterface(): delete iCertStore\n")));
       
   237 
   232 	delete iCertStore;
   238 	delete iCertStore;
       
   239 
       
   240 	EAP_TRACE_DEBUG(
       
   241 		m_am_tools,
       
   242 		TRACE_FLAGS_DEFAULT,
       
   243 		(EAPL("CEapTlsPeapCertInterface::~CEapTlsPeapCertInterface(): delete iCertChain\n")));
       
   244 
   233 	delete iCertChain;
   245 	delete iCertChain;
       
   246 
       
   247 	EAP_TRACE_DEBUG(
       
   248 		m_am_tools,
       
   249 		TRACE_FLAGS_DEFAULT,
       
   250 		(EAPL("CEapTlsPeapCertInterface::~CEapTlsPeapCertInterface(): delete iValidationResult\n")));
       
   251 
   234 	delete iValidationResult;
   252 	delete iValidationResult;
       
   253 
       
   254 	EAP_TRACE_DEBUG(
       
   255 		m_am_tools,
       
   256 		TRACE_FLAGS_DEFAULT,
       
   257 		(EAPL("CEapTlsPeapCertInterface::~CEapTlsPeapCertInterface(): delete iInputCertChain\n")));
       
   258 
   235 	delete iInputCertChain;	
   259 	delete iInputCertChain;	
       
   260 
       
   261 	EAP_TRACE_DEBUG(
       
   262 		m_am_tools,
       
   263 		TRACE_FLAGS_DEFAULT,
       
   264 		(EAPL("CEapTlsPeapCertInterface::~CEapTlsPeapCertInterface(): delete iEncodedCertificate\n")));
       
   265 
   236 	delete iEncodedCertificate;	
   266 	delete iEncodedCertificate;	
       
   267 
       
   268 	EAP_TRACE_DEBUG(
       
   269 		m_am_tools,
       
   270 		TRACE_FLAGS_DEFAULT,
       
   271 		(EAPL("CEapTlsPeapCertInterface::~CEapTlsPeapCertInterface(): delete iDataIn\n")));
       
   272 
   237 	delete iDataIn;
   273 	delete iDataIn;
       
   274 
       
   275 	EAP_TRACE_DEBUG(
       
   276 		m_am_tools,
       
   277 		TRACE_FLAGS_DEFAULT,
       
   278 		(EAPL("CEapTlsPeapCertInterface::~CEapTlsPeapCertInterface(): delete iDataOut\n")));
       
   279 
   238 	delete iDataOut;
   280 	delete iDataOut;
       
   281 
       
   282 	EAP_TRACE_DEBUG(
       
   283 		m_am_tools,
       
   284 		TRACE_FLAGS_DEFAULT,
       
   285 		(EAPL("CEapTlsPeapCertInterface::~CEapTlsPeapCertInterface(): delete iSignature\n")));
       
   286 
   239 	delete iSignature;
   287 	delete iSignature;
       
   288 
       
   289 	EAP_TRACE_DEBUG(
       
   290 		m_am_tools,
       
   291 		TRACE_FLAGS_DEFAULT,
       
   292 		(EAPL("CEapTlsPeapCertInterface::~CEapTlsPeapCertInterface(): delete iPtrOut\n")));
       
   293 
   240 	delete iPtrOut;
   294 	delete iPtrOut;
       
   295 
       
   296 	EAP_TRACE_DEBUG(
       
   297 		m_am_tools,
       
   298 		TRACE_FLAGS_DEFAULT,
       
   299 		(EAPL("CEapTlsPeapCertInterface::~CEapTlsPeapCertInterface(): delete iSignaturePtr\n")));
       
   300 
   241 	delete iSignaturePtr;
   301 	delete iSignaturePtr;
       
   302 
       
   303 	EAP_TRACE_DEBUG(
       
   304 		m_am_tools,
       
   305 		TRACE_FLAGS_DEFAULT,
       
   306 		(EAPL("CEapTlsPeapCertInterface::~CEapTlsPeapCertInterface(): delete iRSASignature\n")));
       
   307 
   242 	delete iRSASignature;
   308 	delete iRSASignature;
       
   309 
       
   310 	EAP_TRACE_DEBUG(
       
   311 		m_am_tools,
       
   312 		TRACE_FLAGS_DEFAULT,
       
   313 		(EAPL("CEapTlsPeapCertInterface::~CEapTlsPeapCertInterface(): delete iDSASignature\n")));
       
   314 
   243 	delete iDSASignature;
   315 	delete iDSASignature;
       
   316 
       
   317 	EAP_TRACE_DEBUG(
       
   318 		m_am_tools,
       
   319 		TRACE_FLAGS_DEFAULT,
       
   320 		(EAPL("CEapTlsPeapCertInterface::~CEapTlsPeapCertInterface(): delete iKeyFilter\n")));
       
   321 
   244 	delete iKeyFilter;
   322 	delete iKeyFilter;
   245 
   323 
   246 #if !defined(USE_EAP_TLS_PEAP_UNIFIED_KEY_STORE_CACHE)
   324 #if !defined(USE_EAP_TLS_PEAP_UNIFIED_KEY_STORE_CACHE)
   247 
   325 
       
   326 	EAP_TRACE_DEBUG(
       
   327 		m_am_tools,
       
   328 		TRACE_FLAGS_DEFAULT,
       
   329 		(EAPL("CEapTlsPeapCertInterface::~CEapTlsPeapCertInterface(): delete iKeyStore\n")));
       
   330 
   248 	delete iKeyStore;
   331 	delete iKeyStore;
   249 
   332 
   250 #endif //#if !defined(USE_EAP_TLS_PEAP_UNIFIED_KEY_STORE_CACHE)
   333 #endif //#if !defined(USE_EAP_TLS_PEAP_UNIFIED_KEY_STORE_CACHE)
   251 	
   334 	
       
   335 
       
   336 	EAP_TRACE_DEBUG(
       
   337 		m_am_tools,
       
   338 		TRACE_FLAGS_DEFAULT,
       
   339 		(EAPL("CEapTlsPeapCertInterface::~CEapTlsPeapCertInterface(): iFs.Close()\n")));
       
   340 
   252 	iFs.Close();
   341 	iFs.Close();
   253 
   342 
   254 	EAP_TRACE_DEBUG(
   343 	EAP_TRACE_DEBUG(
   255 		m_am_tools,
   344 		m_am_tools,
   256 		TRACE_FLAGS_DEFAULT,
   345 		TRACE_FLAGS_DEFAULT,
  1040 				
  1129 				
  1041 				RPointerArray<EapCertificateEntry> tmp(sizeof(EapCertificateEntry));
  1130 				RPointerArray<EapCertificateEntry> tmp(sizeof(EapCertificateEntry));
  1042 
  1131 
  1043 				m_am_tools->enter_global_mutex();
  1132 				m_am_tools->enter_global_mutex();
  1044 				
  1133 				
  1045 				iParent->complete_get_matching_certificates(tmp, eap_status_allocation_error); //Failure
  1134 				iParent->complete_get_matching_certificates(tmp, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1046 				
  1135 				
  1047 				m_am_tools->leave_global_mutex();
  1136 				m_am_tools->leave_global_mutex();
  1048 				break;
  1137 				break;
  1049 			}
  1138 			}
  1050 			
  1139 			
  1126 				// Timeout handles error situation
  1215 				// Timeout handles error situation
  1127 				RPointerArray<EapCertificateEntry> empty(sizeof(EapCertificateEntry));
  1216 				RPointerArray<EapCertificateEntry> empty(sizeof(EapCertificateEntry));
  1128 
  1217 
  1129 				m_am_tools->enter_global_mutex();
  1218 				m_am_tools->enter_global_mutex();
  1130 
  1219 
  1131 				iParent->complete_get_matching_certificates(empty, eap_status_illegal_certificate); //Failure
  1220 				iParent->complete_get_matching_certificates(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_certificate)); //Failure
  1132 
  1221 
  1133 				m_am_tools->leave_global_mutex();
  1222 				m_am_tools->leave_global_mutex();
  1134 
  1223 
  1135 				break;
  1224 				break;
  1136 			}
  1225 			}
  1152 
  1241 
  1153 				RPointerArray<EapCertificateEntry> empty(sizeof(EapCertificateEntry));
  1242 				RPointerArray<EapCertificateEntry> empty(sizeof(EapCertificateEntry));
  1154 
  1243 
  1155 				m_am_tools->enter_global_mutex();
  1244 				m_am_tools->enter_global_mutex();
  1156 
  1245 
  1157 				iParent->complete_get_matching_certificates(empty, eap_status_allocation_error); //Failure
  1246 				iParent->complete_get_matching_certificates(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1158 
  1247 
  1159 				m_am_tools->leave_global_mutex();
  1248 				m_am_tools->leave_global_mutex();
  1160 
  1249 
  1161 				break;
  1250 				break;
  1162 			}
  1251 			}
  1189 				
  1278 				
  1190 				RPointerArray<EapCertificateEntry> empty(sizeof(EapCertificateEntry));
  1279 				RPointerArray<EapCertificateEntry> empty(sizeof(EapCertificateEntry));
  1191 											
  1280 											
  1192 				m_am_tools->enter_global_mutex();
  1281 				m_am_tools->enter_global_mutex();
  1193 				
  1282 				
  1194 				iParent->complete_get_matching_certificates(empty, eap_status_allocation_error); //Failure
  1283 				iParent->complete_get_matching_certificates(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1195 				
  1284 				
  1196 				m_am_tools->leave_global_mutex();
  1285 				m_am_tools->leave_global_mutex();
  1197 
  1286 
  1198 				break;
  1287 				break;
  1199 			}
  1288 			}
  1205 				
  1294 				
  1206 				RPointerArray<EapCertificateEntry> empty(sizeof(EapCertificateEntry));
  1295 				RPointerArray<EapCertificateEntry> empty(sizeof(EapCertificateEntry));
  1207 
  1296 
  1208 				m_am_tools->enter_global_mutex();
  1297 				m_am_tools->enter_global_mutex();
  1209 				
  1298 				
  1210 				iParent->complete_get_matching_certificates(empty, eap_status_allocation_error); //Failure
  1299 				iParent->complete_get_matching_certificates(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1211 				
  1300 				
  1212 				m_am_tools->leave_global_mutex();
  1301 				m_am_tools->leave_global_mutex();
  1213 							
  1302 							
  1214 				break;
  1303 				break;
  1215 			}
  1304 			}
  1225 
  1314 
  1226 				RPointerArray<EapCertificateEntry> empty(sizeof(EapCertificateEntry));
  1315 				RPointerArray<EapCertificateEntry> empty(sizeof(EapCertificateEntry));
  1227 
  1316 
  1228 				m_am_tools->enter_global_mutex();
  1317 				m_am_tools->enter_global_mutex();
  1229 				
  1318 				
  1230 				iParent->complete_get_matching_certificates(empty, eap_status_allocation_error); //Failure
  1319 				iParent->complete_get_matching_certificates(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1231 				
  1320 				
  1232 				m_am_tools->leave_global_mutex();
  1321 				m_am_tools->leave_global_mutex();
  1233 
  1322 
  1234 				delete entry;
  1323 				delete entry;
  1235 
  1324 
  1246 				
  1335 				
  1247 				RPointerArray<EapCertificateEntry> empty(sizeof(EapCertificateEntry));
  1336 				RPointerArray<EapCertificateEntry> empty(sizeof(EapCertificateEntry));
  1248 
  1337 
  1249 				m_am_tools->enter_global_mutex();
  1338 				m_am_tools->enter_global_mutex();
  1250 				
  1339 				
  1251 				iParent->complete_get_matching_certificates(empty, eap_status_allocation_error); //Failure
  1340 				iParent->complete_get_matching_certificates(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1252 				
  1341 				
  1253 				m_am_tools->leave_global_mutex();
  1342 				m_am_tools->leave_global_mutex();
  1254 							
  1343 							
  1255 				delete entry;
  1344 				delete entry;
  1256 
  1345 
  1404 				
  1493 				
  1405 					RPointerArray<EapCertificateEntry> empty(sizeof(EapCertificateEntry));
  1494 					RPointerArray<EapCertificateEntry> empty(sizeof(EapCertificateEntry));
  1406 
  1495 
  1407 					m_am_tools->enter_global_mutex();
  1496 					m_am_tools->enter_global_mutex();
  1408 					
  1497 					
  1409 					iParent->complete_get_matching_certificates(empty, eap_status_allocation_error); //Failure
  1498 					iParent->complete_get_matching_certificates(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1410 					
  1499 					
  1411 					m_am_tools->leave_global_mutex();
  1500 					m_am_tools->leave_global_mutex();
  1412 					
  1501 					
  1413 					break;
  1502 					break;
  1414 				}
  1503 				}
  1451 				
  1540 				
  1452 				RPointerArray<CX509Certificate> empty;
  1541 				RPointerArray<CX509Certificate> empty;
  1453 				
  1542 				
  1454 				m_am_tools->enter_global_mutex();
  1543 				m_am_tools->enter_global_mutex();
  1455 				
  1544 				
  1456 				iParent->complete_read_own_certificate(empty, eap_status_allocation_error); //Failure
  1545 				iParent->complete_read_own_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1457 				
  1546 				
  1458 				m_am_tools->leave_global_mutex();
  1547 				m_am_tools->leave_global_mutex();
  1459 				
  1548 				
  1460 				break;
  1549 				break;
  1461 			}
  1550 			}
  1494 				
  1583 				
  1495 				RPointerArray<CX509Certificate> empty;
  1584 				RPointerArray<CX509Certificate> empty;
  1496 				
  1585 				
  1497 				m_am_tools->enter_global_mutex();
  1586 				m_am_tools->enter_global_mutex();
  1498 				
  1587 				
  1499 				iParent->complete_read_own_certificate(empty, eap_status_illegal_certificate); //Failure
  1588 				iParent->complete_read_own_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_certificate)); //Failure
  1500 				
  1589 				
  1501 				m_am_tools->leave_global_mutex();
  1590 				m_am_tools->leave_global_mutex();
  1502 
  1591 
  1503 				break;
  1592 				break;
  1504 			}
  1593 			}
  1519 				
  1608 				
  1520 				RPointerArray<CX509Certificate> empty;
  1609 				RPointerArray<CX509Certificate> empty;
  1521 								
  1610 								
  1522 				m_am_tools->enter_global_mutex();
  1611 				m_am_tools->enter_global_mutex();
  1523 				
  1612 				
  1524 				iParent->complete_read_own_certificate(empty, eap_status_allocation_error); //Failure
  1613 				iParent->complete_read_own_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1525 				
  1614 				
  1526 				m_am_tools->leave_global_mutex();
  1615 				m_am_tools->leave_global_mutex();
  1527 				
  1616 				
  1528 				break;
  1617 				break;
  1529 			}
  1618 			}
  1555 				
  1644 				
  1556 				RPointerArray<CX509Certificate> empty;
  1645 				RPointerArray<CX509Certificate> empty;
  1557 								
  1646 								
  1558 				m_am_tools->enter_global_mutex();
  1647 				m_am_tools->enter_global_mutex();
  1559 				
  1648 				
  1560 				iParent->complete_read_own_certificate(empty, eap_status_allocation_error); //Failure
  1649 				iParent->complete_read_own_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1561 				
  1650 				
  1562 				m_am_tools->leave_global_mutex();
  1651 				m_am_tools->leave_global_mutex();
  1563 				
  1652 				
  1564 				break;
  1653 				break;
  1565 			}
  1654 			}
  1572 				
  1661 				
  1573 				RPointerArray<CX509Certificate> empty;
  1662 				RPointerArray<CX509Certificate> empty;
  1574 								
  1663 								
  1575 				m_am_tools->enter_global_mutex();
  1664 				m_am_tools->enter_global_mutex();
  1576 				
  1665 				
  1577 				iParent->complete_read_own_certificate(empty, eap_status_allocation_error); //Failure
  1666 				iParent->complete_read_own_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1578 				
  1667 				
  1579 				m_am_tools->leave_global_mutex();
  1668 				m_am_tools->leave_global_mutex();
  1580 				
  1669 				
  1581 				break;
  1670 				break;
  1582 			}
  1671 			}
  1633 				
  1722 				
  1634 				RPointerArray<CX509Certificate> empty;
  1723 				RPointerArray<CX509Certificate> empty;
  1635 								
  1724 								
  1636 				m_am_tools->enter_global_mutex();
  1725 				m_am_tools->enter_global_mutex();
  1637 				
  1726 				
  1638 				iParent->complete_read_own_certificate(empty, eap_status_allocation_error); //Failure
  1727 				iParent->complete_read_own_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1639 				
  1728 				
  1640 				m_am_tools->leave_global_mutex();
  1729 				m_am_tools->leave_global_mutex();
  1641 				
  1730 				
  1642 				break;
  1731 				break;
  1643 			}
  1732 			}
  1684 				iUserCertChain.ResetAndDestroy();
  1773 				iUserCertChain.ResetAndDestroy();
  1685 
  1774 
  1686 				m_am_tools->enter_global_mutex();
  1775 				m_am_tools->enter_global_mutex();
  1687 				
  1776 				
  1688 				// Note that parent handles cert deletion from now on.
  1777 				// Note that parent handles cert deletion from now on.
  1689 				iParent->complete_read_own_certificate(iUserCertChain, eap_status_illegal_certificate);
  1778 				iParent->complete_read_own_certificate(iUserCertChain, EAP_STATUS_RETURN(m_am_tools, eap_status_illegal_certificate));
  1690 
  1779 
  1691 				m_am_tools->leave_global_mutex();
  1780 				m_am_tools->leave_global_mutex();
  1692 
  1781 
  1693 				break;
  1782 				break;
  1694 			}
  1783 			}
  1709 				
  1798 				
  1710 				RPointerArray<CX509Certificate> empty;
  1799 				RPointerArray<CX509Certificate> empty;
  1711 								
  1800 								
  1712 				m_am_tools->enter_global_mutex();
  1801 				m_am_tools->enter_global_mutex();
  1713 				
  1802 				
  1714 				iParent->complete_read_own_certificate(empty, eap_status_allocation_error); //Failure
  1803 				iParent->complete_read_own_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1715 				
  1804 				
  1716 				m_am_tools->leave_global_mutex();
  1805 				m_am_tools->leave_global_mutex();
  1717 				
  1806 				
  1718 				break;
  1807 				break;
  1719 			}
  1808 			}
  1746 				
  1835 				
  1747 				RPointerArray<CX509Certificate> empty;
  1836 				RPointerArray<CX509Certificate> empty;
  1748 								
  1837 								
  1749 				m_am_tools->enter_global_mutex();
  1838 				m_am_tools->enter_global_mutex();
  1750 				
  1839 				
  1751 				iParent->complete_read_own_certificate(empty, eap_status_allocation_error); //Failure
  1840 				iParent->complete_read_own_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1752 				
  1841 				
  1753 				m_am_tools->leave_global_mutex();
  1842 				m_am_tools->leave_global_mutex();
  1754 				
  1843 				
  1755 				break;
  1844 				break;
  1756 			}
  1845 			}
  1831 				
  1920 				
  1832 				RPointerArray<CX509Certificate> empty;
  1921 				RPointerArray<CX509Certificate> empty;
  1833 								
  1922 								
  1834 				m_am_tools->enter_global_mutex();
  1923 				m_am_tools->enter_global_mutex();
  1835 				
  1924 				
  1836 				iParent->complete_read_own_certificate(empty, eap_status_allocation_error); //Failure
  1925 				iParent->complete_read_own_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1837 				
  1926 				
  1838 				m_am_tools->leave_global_mutex();
  1927 				m_am_tools->leave_global_mutex();
  1839 				
  1928 				
  1840 				break;
  1929 				break;
  1841 			}
  1930 			}
  1849 			iCAIndex++;
  1938 			iCAIndex++;
  1850 			if (iCAIndex >= static_cast<TUint>(iCertInfos.Count()))
  1939 			if (iCAIndex >= static_cast<TUint>(iCertInfos.Count()))
  1851 			{
  1940 			{
  1852 				if(iUserCertChain.Count() == 0)
  1941 				if(iUserCertChain.Count() == 0)
  1853 				{
  1942 				{
  1854 					iParent->complete_read_own_certificate(iUserCertChain, eap_status_ca_certificate_unknown);
  1943 					iParent->complete_read_own_certificate(iUserCertChain, EAP_STATUS_RETURN(m_am_tools, eap_status_ca_certificate_unknown));
  1855 					break;
  1944 					break;
  1856 				}
  1945 				}
  1857 			
  1946 			
  1858 				// We got all. Validate.
  1947 				// We got all. Validate.
  1859 				TInt i(0);
  1948 				TInt i(0);
  1892 							{				
  1981 							{				
  1893 				
  1982 				
  1894 								RPointerArray<CX509Certificate> empty;
  1983 								RPointerArray<CX509Certificate> empty;
  1895 								m_am_tools->enter_global_mutex();
  1984 								m_am_tools->enter_global_mutex();
  1896 								
  1985 								
  1897 								iParent->complete_read_own_certificate(empty, eap_status_allocation_error); //Failure
  1986 								iParent->complete_read_own_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1898 								
  1987 								
  1899 								m_am_tools->leave_global_mutex();
  1988 								m_am_tools->leave_global_mutex();
  1900 				
  1989 				
  1901 								return;
  1990 								return;
  1902 							}					
  1991 							}					
  1906 							{				
  1995 							{				
  1907 								RPointerArray<CX509Certificate> empty;
  1996 								RPointerArray<CX509Certificate> empty;
  1908 				
  1997 				
  1909 								m_am_tools->enter_global_mutex();
  1998 								m_am_tools->enter_global_mutex();
  1910 								
  1999 								
  1911 								iParent->complete_read_own_certificate(empty, eap_status_allocation_error); //Failure
  2000 								iParent->complete_read_own_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1912 								
  2001 								
  1913 								m_am_tools->leave_global_mutex();				
  2002 								m_am_tools->leave_global_mutex();				
  1914 
  2003 
  1915 								delete dsaParams;
  2004 								delete dsaParams;
  1916 								return;
  2005 								return;
  1920 							{				
  2009 							{				
  1921 								RPointerArray<CX509Certificate> empty;
  2010 								RPointerArray<CX509Certificate> empty;
  1922 								
  2011 								
  1923 								m_am_tools->enter_global_mutex();
  2012 								m_am_tools->enter_global_mutex();
  1924 								
  2013 								
  1925 								iParent->complete_read_own_certificate(empty, eap_status_allocation_error); //Failure
  2014 								iParent->complete_read_own_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1926 								
  2015 								
  1927 								m_am_tools->leave_global_mutex();
  2016 								m_am_tools->leave_global_mutex();
  1928 				
  2017 				
  1929 								delete dsaParams;
  2018 								delete dsaParams;
  1930 								delete signParams;
  2019 								delete signParams;
  1935 							if (error != KErrNone)
  2024 							if (error != KErrNone)
  1936 							{
  2025 							{
  1937 								RPointerArray<CX509Certificate> empty;
  2026 								RPointerArray<CX509Certificate> empty;
  1938 								m_am_tools->enter_global_mutex();
  2027 								m_am_tools->enter_global_mutex();
  1939 								
  2028 								
  1940 								iParent->complete_read_own_certificate(empty, eap_status_allocation_error); //Failure
  2029 								iParent->complete_read_own_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1941 								
  2030 								
  1942 								m_am_tools->leave_global_mutex();				
  2031 								m_am_tools->leave_global_mutex();				
  1943 							
  2032 							
  1944 								delete dsaParams;
  2033 								delete dsaParams;
  1945 								delete signParams;
  2034 								delete signParams;
  1958 
  2047 
  1959 								RPointerArray<CX509Certificate> empty;
  2048 								RPointerArray<CX509Certificate> empty;
  1960 								
  2049 								
  1961 								m_am_tools->enter_global_mutex();
  2050 								m_am_tools->enter_global_mutex();
  1962 								
  2051 								
  1963 								iParent->complete_read_own_certificate(empty, eap_status_allocation_error); //Failure
  2052 								iParent->complete_read_own_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  1964 								
  2053 								
  1965 								m_am_tools->leave_global_mutex();
  2054 								m_am_tools->leave_global_mutex();
  1966 				
  2055 				
  1967 								return;
  2056 								return;
  1968 							}
  2057 							}
  2011 				
  2100 				
  2012 					RPointerArray<CX509Certificate> empty;
  2101 					RPointerArray<CX509Certificate> empty;
  2013 					
  2102 					
  2014 					m_am_tools->enter_global_mutex();
  2103 					m_am_tools->enter_global_mutex();
  2015 					
  2104 					
  2016 					iParent->complete_read_ca_certificate(empty, eap_status_allocation_error); //Failure
  2105 					iParent->complete_read_ca_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  2017 					
  2106 					
  2018 					m_am_tools->leave_global_mutex();
  2107 					m_am_tools->leave_global_mutex();
  2019 				
  2108 				
  2020 					break;
  2109 					break;
  2021 				}
  2110 				}
  2058 
  2147 
  2059 				RPointerArray<CX509Certificate> empty;
  2148 				RPointerArray<CX509Certificate> empty;
  2060 				
  2149 				
  2061 				m_am_tools->enter_global_mutex();
  2150 				m_am_tools->enter_global_mutex();
  2062 				
  2151 				
  2063 				iParent->complete_read_ca_certificate(empty, eap_status_allocation_error); //Failure
  2152 				iParent->complete_read_ca_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  2064 				
  2153 				
  2065 				m_am_tools->leave_global_mutex();
  2154 				m_am_tools->leave_global_mutex();
  2066 				break;
  2155 				break;
  2067 			}
  2156 			}
  2068 			
  2157 			
  2100 
  2189 
  2101 				RPointerArray<CX509Certificate> empty;
  2190 				RPointerArray<CX509Certificate> empty;
  2102 				
  2191 				
  2103 				m_am_tools->enter_global_mutex();
  2192 				m_am_tools->enter_global_mutex();
  2104 				
  2193 				
  2105 				iParent->complete_read_ca_certificate(empty, eap_status_allocation_error); //Failure
  2194 				iParent->complete_read_ca_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  2106 				
  2195 				
  2107 				m_am_tools->leave_global_mutex();
  2196 				m_am_tools->leave_global_mutex();
  2108 				break;
  2197 				break;
  2109 			}
  2198 			}
  2110 			
  2199 			
  2124 
  2213 
  2125 				RPointerArray<CX509Certificate> empty;
  2214 				RPointerArray<CX509Certificate> empty;
  2126 				
  2215 				
  2127 				m_am_tools->enter_global_mutex();
  2216 				m_am_tools->enter_global_mutex();
  2128 				
  2217 				
  2129 				iParent->complete_read_ca_certificate(empty, eap_status_allocation_error); //Failure
  2218 				iParent->complete_read_ca_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  2130 				
  2219 				
  2131 				m_am_tools->leave_global_mutex();
  2220 				m_am_tools->leave_global_mutex();
  2132 				break;
  2221 				break;
  2133 			}
  2222 			}
  2134 
  2223 
  2166 
  2255 
  2167 				RPointerArray<CX509Certificate> empty;
  2256 				RPointerArray<CX509Certificate> empty;
  2168 				
  2257 				
  2169 				m_am_tools->enter_global_mutex();
  2258 				m_am_tools->enter_global_mutex();
  2170 				
  2259 				
  2171 				iParent->complete_read_ca_certificate(empty, eap_status_allocation_error); //Failure
  2260 				iParent->complete_read_ca_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  2172 				
  2261 				
  2173 				m_am_tools->leave_global_mutex();
  2262 				m_am_tools->leave_global_mutex();
  2174 				break;
  2263 				break;
  2175 			}
  2264 			}
  2176 			
  2265 			
  2183 
  2272 
  2184 				RPointerArray<CX509Certificate> empty;
  2273 				RPointerArray<CX509Certificate> empty;
  2185 				
  2274 				
  2186 				m_am_tools->enter_global_mutex();
  2275 				m_am_tools->enter_global_mutex();
  2187 				
  2276 				
  2188 				iParent->complete_read_ca_certificate(empty, eap_status_allocation_error); //Failure
  2277 				iParent->complete_read_ca_certificate(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_allocation_error)); //Failure
  2189 				
  2278 				
  2190 				m_am_tools->leave_global_mutex();
  2279 				m_am_tools->leave_global_mutex();
  2191 				break;
  2280 				break;
  2192 			}
  2281 			}
  2193 			
  2282 			
  2219 
  2308 
  2220 				const CPKIXValidationResult * const empty = 0;
  2309 				const CPKIXValidationResult * const empty = 0;
  2221 				
  2310 				
  2222 				m_am_tools->enter_global_mutex();
  2311 				m_am_tools->enter_global_mutex();
  2223 
  2312 
  2224 				iParent->complete_validate_chain(empty, eap_status_ca_certificate_unknown); //Failure.
  2313 				iParent->complete_validate_chain(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_ca_certificate_unknown)); //Failure.
  2225 
  2314 
  2226 				m_am_tools->leave_global_mutex();
  2315 				m_am_tools->leave_global_mutex();
  2227 				break;
  2316 				break;
  2228 			}
  2317 			}
  2229 
  2318 
  2287 
  2376 
  2288 				EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: No cert infos\n")));
  2377 				EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: No cert infos\n")));
  2289 
  2378 
  2290 				m_am_tools->enter_global_mutex();
  2379 				m_am_tools->enter_global_mutex();
  2291 
  2380 
  2292 				iParent->complete_validate_chain(empty, eap_status_ca_certificate_unknown); //Failure.
  2381 				iParent->complete_validate_chain(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_ca_certificate_unknown)); //Failure.
  2293 
  2382 
  2294 				m_am_tools->leave_global_mutex();
  2383 				m_am_tools->leave_global_mutex();
  2295 				break;
  2384 				break;
  2296 			}
  2385 			}
  2297 
  2386 
  2312 					
  2401 					
  2313 					const CPKIXValidationResult * const empty = 0;
  2402 					const CPKIXValidationResult * const empty = 0;
  2314 					
  2403 					
  2315 					m_am_tools->enter_global_mutex();
  2404 					m_am_tools->enter_global_mutex();
  2316 
  2405 
  2317 					iParent->complete_validate_chain(empty, eap_status_ca_certificate_unknown); //Failure.
  2406 					iParent->complete_validate_chain(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_ca_certificate_unknown)); //Failure.
  2318 
  2407 
  2319 					m_am_tools->leave_global_mutex();
  2408 					m_am_tools->leave_global_mutex();
  2320 					break;
  2409 					break;
  2321 				}
  2410 				}
  2322 
  2411 
  2349 
  2438 
  2350 				const CPKIXValidationResult * const empty = 0;
  2439 				const CPKIXValidationResult * const empty = 0;
  2351 				
  2440 				
  2352 				m_am_tools->enter_global_mutex();
  2441 				m_am_tools->enter_global_mutex();
  2353 
  2442 
  2354 				iParent->complete_validate_chain(empty, eap_status_ca_certificate_unknown); //Failure.
  2443 				iParent->complete_validate_chain(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_ca_certificate_unknown)); //Failure.
  2355 
  2444 
  2356 				m_am_tools->leave_global_mutex();
  2445 				m_am_tools->leave_global_mutex();
  2357 				break;
  2446 				break;
  2358 			}
  2447 			}
  2359 		
  2448 		
  2365 
  2454 
  2366 				const CPKIXValidationResult * const empty = 0;
  2455 				const CPKIXValidationResult * const empty = 0;
  2367 				
  2456 				
  2368 				m_am_tools->enter_global_mutex();
  2457 				m_am_tools->enter_global_mutex();
  2369 
  2458 
  2370 				iParent->complete_validate_chain(empty, eap_status_ca_certificate_unknown); //Failure.
  2459 				iParent->complete_validate_chain(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_ca_certificate_unknown)); //Failure.
  2371 
  2460 
  2372 				m_am_tools->leave_global_mutex();
  2461 				m_am_tools->leave_global_mutex();
  2373 				break;
  2462 				break;
  2374 			}
  2463 			}
  2375 
  2464 
  2386 
  2475 
  2387 					const CPKIXValidationResult * const empty = 0;
  2476 					const CPKIXValidationResult * const empty = 0;
  2388 					
  2477 					
  2389 					m_am_tools->enter_global_mutex();
  2478 					m_am_tools->enter_global_mutex();
  2390 
  2479 
  2391 					iParent->complete_validate_chain(empty, eap_status_ca_certificate_unknown); //Failure.
  2480 					iParent->complete_validate_chain(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_ca_certificate_unknown)); //Failure.
  2392 
  2481 
  2393 					m_am_tools->leave_global_mutex();
  2482 					m_am_tools->leave_global_mutex();
  2394 					break;
  2483 					break;
  2395 				}
  2484 				}
  2396 
  2485 
  2412 
  2501 
  2413 					const CPKIXValidationResult * const empty = 0;
  2502 					const CPKIXValidationResult * const empty = 0;
  2414 					
  2503 					
  2415 					m_am_tools->enter_global_mutex();
  2504 					m_am_tools->enter_global_mutex();
  2416 
  2505 
  2417 					iParent->complete_validate_chain(empty, eap_status_ca_certificate_unknown); //Failure.
  2506 					iParent->complete_validate_chain(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_ca_certificate_unknown)); //Failure.
  2418 
  2507 
  2419 					m_am_tools->leave_global_mutex();
  2508 					m_am_tools->leave_global_mutex();
  2420 					break;
  2509 					break;
  2421 				}
  2510 				}
  2422 				SetActive();	// Validate.
  2511 				SetActive();	// Validate.
  2438 
  2527 
  2439 					const CPKIXValidationResult * const empty = 0;
  2528 					const CPKIXValidationResult * const empty = 0;
  2440 					
  2529 					
  2441 					m_am_tools->enter_global_mutex();
  2530 					m_am_tools->enter_global_mutex();
  2442 
  2531 
  2443 					iParent->complete_validate_chain(empty, eap_status_ca_certificate_unknown); //Failure.
  2532 					iParent->complete_validate_chain(empty, EAP_STATUS_RETURN(m_am_tools, eap_status_ca_certificate_unknown)); //Failure.
  2444 
  2533 
  2445 					m_am_tools->leave_global_mutex();
  2534 					m_am_tools->leave_global_mutex();
  2446 					break;
  2535 					break;
  2447 				}
  2536 				}
  2448 
  2537 
  2503 			iKeyFilter = new (ELeave) TCTKeyAttributeFilter;
  2592 			iKeyFilter = new (ELeave) TCTKeyAttributeFilter;
  2504 			if (!iKeyFilter)
  2593 			if (!iKeyFilter)
  2505 			{ 
  2594 			{ 
  2506 				EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: Out of memory in EAP-TLS.\n")));
  2595 				EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: Out of memory in EAP-TLS.\n")));
  2507 				RInteger tmp;
  2596 				RInteger tmp;
  2508 				iParent->complete_sign(tmp, tmp, eap_status_key_error);
  2597 				iParent->complete_sign(tmp, tmp, EAP_STATUS_RETURN(m_am_tools, eap_status_key_error));
  2509 				break;
  2598 				break;
  2510 			}
  2599 			}
       
  2600 
       
  2601 			EAP_TRACE_DATA_DEBUG(
       
  2602 				m_am_tools,
       
  2603 				TRACE_FLAGS_DEFAULT,
       
  2604 				(EAPL("SignL: iKeyIdentifier"),
       
  2605 				iKeyIdentifier.Ptr(),
       
  2606 				iKeyIdentifier.Length()));
  2511 			
  2607 			
  2512 			iKeyFilter->iKeyId = iKeyIdentifier;
  2608 			iKeyFilter->iKeyId = iKeyIdentifier;
  2513 			iKeyFilter->iPolicyFilter = TCTKeyAttributeFilter::EUsableKeys;			
  2609 			iKeyFilter->iPolicyFilter = TCTKeyAttributeFilter::EUsableKeys;			
  2514 
  2610 
  2515 			iState = ESignList;
  2611 			iState = ESignList;
  2526 			EAP_TRACE_DEBUG(
  2622 			EAP_TRACE_DEBUG(
  2527 				m_am_tools,
  2623 				m_am_tools,
  2528 				TRACE_FLAGS_DEFAULT,
  2624 				TRACE_FLAGS_DEFAULT,
  2529 				(EAPL("CEapTlsPeapCertInterface::RunL(): ESignList, iKeyInfos.Count=%d\n"),
  2625 				(EAPL("CEapTlsPeapCertInterface::RunL(): ESignList, iKeyInfos.Count=%d\n"),
  2530 				iKeyInfos.Count()));
  2626 				iKeyInfos.Count()));
  2531 				
  2627 
  2532 			if(iKeyInfos.Count() <= 0)				
  2628 			if(iKeyInfos.Count() <= 0)				
  2533 			{
  2629 			{
  2534 				RInteger tmp;
  2630 				RInteger tmp;
  2535 				iParent->complete_sign(tmp, tmp, eap_status_key_error);
  2631 				iParent->complete_sign(tmp, tmp, EAP_STATUS_RETURN(m_am_tools, eap_status_user_certificate_unknown)); // Failure
  2536 				break;
  2632 				break;
  2537 			}
  2633 			}
  2538 
  2634 
  2539 			iState = ESignOpenKeyStore;
  2635 			iState = ESignOpenKeyStore;
  2540 
  2636 
  2569 				iKeyInfos.Count()));
  2665 				iKeyInfos.Count()));
  2570 
  2666 
  2571 			if(iKeyInfos.Count() <= 0)				
  2667 			if(iKeyInfos.Count() <= 0)				
  2572 			{
  2668 			{
  2573 				RInteger tmp;
  2669 				RInteger tmp;
  2574 				iParent->complete_sign(tmp, tmp, eap_status_key_error);
  2670 				iParent->complete_sign(tmp, tmp, EAP_STATUS_RETURN(m_am_tools, eap_status_user_certificate_unknown)); // Failure
  2575 				break;
  2671 				break;
  2576 			}
  2672 			}
  2577 
  2673 
  2578 			iState = ESign;
  2674 			iState = ESign;
  2579 			
  2675 			
  2607 				iKeyInfos.Count()));
  2703 				iKeyInfos.Count()));
  2608 
  2704 
  2609 			if(iKeyInfos.Count() <= 0)				
  2705 			if(iKeyInfos.Count() <= 0)				
  2610 			{
  2706 			{
  2611 				RInteger tmp;
  2707 				RInteger tmp;
  2612 				iParent->complete_sign(tmp, tmp, eap_status_key_error);
  2708 				iParent->complete_sign(tmp, tmp, EAP_STATUS_RETURN(m_am_tools, eap_status_user_certificate_unknown)); // Failure
  2613 				break;
  2709 				break;
  2614 			}
  2710 			}
  2615 
  2711 
  2616 			CKeyInfoBase::EKeyAlgorithm rsa(static_cast<CKeyInfoBase::EKeyAlgorithm> (1));
  2712 			CKeyInfoBase::EKeyAlgorithm rsa(static_cast<CKeyInfoBase::EKeyAlgorithm> (1));
  2617 			
  2713 			
  2658 			iKeyFilter = new (ELeave) TCTKeyAttributeFilter;
  2754 			iKeyFilter = new (ELeave) TCTKeyAttributeFilter;
  2659 			if (!iKeyFilter)
  2755 			if (!iKeyFilter)
  2660 			{ 
  2756 			{ 
  2661 				EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: Out of memory in EAP-TLS.\n")));
  2757 				EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ERROR: Out of memory in EAP-TLS.\n")));
  2662 				TBuf8<1> tmp;
  2758 				TBuf8<1> tmp;
  2663 				iParent->complete_decrypt(tmp, eap_status_key_error);
  2759 				iParent->complete_decrypt(tmp, EAP_STATUS_RETURN(m_am_tools, eap_status_key_error));
  2664 				break;
  2760 				break;
  2665 			}
  2761 			}
  2666 			
  2762 			
  2667 			iKeyFilter->iKeyId = iKeyIdentifier;
  2763 			iKeyFilter->iKeyId = iKeyIdentifier;
  2668 			iKeyFilter->iPolicyFilter = TCTKeyAttributeFilter::EUsableKeys;			
  2764 			iKeyFilter->iPolicyFilter = TCTKeyAttributeFilter::EUsableKeys;			
  2685 				iKeyInfos.Count()));
  2781 				iKeyInfos.Count()));
  2686 
  2782 
  2687 			if(iKeyInfos.Count() <= 0)				
  2783 			if(iKeyInfos.Count() <= 0)				
  2688 			{
  2784 			{
  2689 				TBuf8<1> tmp;
  2785 				TBuf8<1> tmp;
  2690 				iParent->complete_decrypt(tmp, eap_status_key_error);
  2786 				iParent->complete_decrypt(tmp, EAP_STATUS_RETURN(m_am_tools, eap_status_key_error));
  2691 				break;
  2787 				break;
  2692 			}
  2788 			}
  2693 
  2789 
  2694 			iState = EDecryptOpenKeyStore;			
  2790 			iState = EDecryptOpenKeyStore;			
  2695 			
  2791