eapol/eapol_framework/eapol_symbian/am/type/tls_peap/symbian/plugin/inc/EapTlsPeapUtils.h
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 #ifndef _EAPTLSPEAPUTILS_H_
       
    20 #define _EAPTLSPEAPUTILS_H_
       
    21 
       
    22 // INCLUDES
       
    23 #include <d32dbms.h>
       
    24 #include <EapType.h>
       
    25 #include "eap_am_tools_symbian.h"
       
    26 #include <CertEntry.h>
       
    27 
       
    28 #include <unifiedcertstore.h>
       
    29 #include <mctwritablecertstore.h>
       
    30 
       
    31 #ifndef USE_EAP_EXPANDED_TYPES
       
    32 // This dependencay is needed only for non-expanded EAP types.
       
    33 #include <wdbifwlansettings.h>
       
    34 #endif //#ifndef USE_EAP_EXPANDED_TYPES
       
    35 
       
    36 #include "eap_type_tls_peap_types.h"
       
    37 #include "eap_header.h"
       
    38 
       
    39 // LOCAL CONSTANTS
       
    40 
       
    41 #ifdef USE_EAP_EXPANDED_TYPES
       
    42 
       
    43 // Size of Expanded EAP Type
       
    44 const TUint8 KExpandedEAPTypeSize = 8;
       
    45 
       
    46 struct SExpandedEAPType
       
    47 {
       
    48 	// Unique ID for an expanded EAp type.
       
    49 	// This includes, Type (1 byte), Vendor-Id (3bytes) and Vendor-Type (4bytes).
       
    50 	TBuf8<KExpandedEAPTypeSize>    iExpandedEAPType;
       
    51 };
       
    52 
       
    53 typedef RPointerArray<SExpandedEAPType> RExpandedEapTypePtrArray;
       
    54 
       
    55 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
    56 
       
    57 #ifdef SYMBIAN_SECURE_DBMS
       
    58 // For EAP TLS, PEAP, TTLS, FAST secure databases.
       
    59 // Full path is not needed. The database eaptls.dat will be saved in the 
       
    60 // data cage path for DBMS. So it will be in "\private\100012a5\eaptls.dat" in C: drive.
       
    61 // The maximum length of database name is 0x40 (KDbMaxName) , which is defined in d32dbms.h.
       
    62 
       
    63 _LIT(KTlsDatabaseName, "c:eaptls.dat");
       
    64 _LIT(KPeapDatabaseName, "c:eappeap.dat");
       
    65 _LIT(KTtlsDatabaseName, "c:eapttls.dat");
       
    66 _LIT(KFastDatabaseName, "c:eapfast.dat");
       
    67 
       
    68 _LIT(KSecureUIDFormat, "SECURE[102072e9]"); // For the security policy.
       
    69 
       
    70 #else
       
    71 
       
    72 _LIT(KTlsDatabaseName, "c:\\system\\data\\eaptls.dat");
       
    73 _LIT(KPeapDatabaseName, "c:\\system\\data\\eappeap.dat");
       
    74 _LIT(KTtlsDatabaseName, "c:\\system\\data\\eapttls.dat");
       
    75 _LIT(KFastDatabaseName, "c:\\system\\data\\eapfast.dat");
       
    76 
       
    77 #endif // #ifdef SYMBIAN_SECURE_DBMS
       
    78 
       
    79 // For TLS.
       
    80 _LIT(KTlsDatabaseTableName, "eaptls");
       
    81 _LIT(KTlsAllowedUserCertsDatabaseTableName, "eaptls_usercerts");
       
    82 _LIT(KTlsAllowedCACertsDatabaseTableName, "eaptls_cacerts");
       
    83 _LIT(KTlsAllowedCipherSuitesDatabaseTableName, "eaptls_ciphersuites");
       
    84 
       
    85 // For PEAP.
       
    86 _LIT(KPeapDatabaseTableName, "eappeap");
       
    87 _LIT(KPeapAllowedUserCertsDatabaseTableName, "eappeap_usercerts");
       
    88 _LIT(KPeapAllowedCACertsDatabaseTableName, "eappeap_cacerts");
       
    89 _LIT(KPeapAllowedCipherSuitesDatabaseTableName, "eappeap_ciphersuites");
       
    90 
       
    91 // For TTLS.
       
    92 _LIT(KTtlsDatabaseTableName, "eapttls");
       
    93 _LIT(KTtlsAllowedUserCertsDatabaseTableName, "eapttls_usercerts");
       
    94 _LIT(KTtlsAllowedCACertsDatabaseTableName, "eapttls_cacerts");
       
    95 _LIT(KTtlsAllowedCipherSuitesDatabaseTableName, "eapttls_ciphersuites");
       
    96 
       
    97 // For FAST.
       
    98 _LIT(KFastGeneralSettingsDBTableName, "eapfast_general_settings"); // Generic settings (similar to TTLS etc) for EAP-FAST.
       
    99 _LIT(KFastSpecialSettingsDBTableName, "eapfast_special_settings"); // Only for EAP-FAST specific (PAC etc) settings.
       
   100 _LIT(KFastAllowedUserCertsDatabaseTableName, "eapfast_usercerts");
       
   101 _LIT(KFastAllowedCACertsDatabaseTableName, "eapfast_cacerts");
       
   102 _LIT(KFastAllowedCipherSuitesDatabaseTableName, "eapfast_ciphersuites");
       
   103 
       
   104 enum TAlterTableCmd
       
   105 {
       
   106 EAddColumn,
       
   107 ERemoveColumn
       
   108 };
       
   109 
       
   110 // CLASS DECLARATION
       
   111 class EapTlsPeapUtils 
       
   112 {
       
   113 public:	
       
   114 	static void OpenDatabaseL(
       
   115 		RDbNamedDatabase& aDatabase, 
       
   116 		RDbs& aSession, 
       
   117 		const TIndexType aIndexType, 
       
   118 		const TInt aIndex,
       
   119 		const eap_type_value_e aTunnelingType,
       
   120 		eap_type_value_e aEapType);
       
   121 
       
   122 	/**
       
   123 	* Changes the settings' index
       
   124 	*/	
       
   125 	static void SetIndexL(
       
   126 		RDbNamedDatabase& aDatabase,
       
   127 		const TDesC& aTableName,	
       
   128 		const TIndexType aIndexType,
       
   129 		const TInt aIndex,
       
   130 		const eap_type_value_e aTunnelingType,
       
   131 		const TIndexType aNewIndexType,
       
   132 		const TInt aNewIndex,
       
   133 		const eap_type_value_e aNewTunnelingType);
       
   134 		
       
   135 	static void SetConfigurationL(
       
   136 		RDbNamedDatabase& aDatabase,
       
   137 		const EAPSettings& aSettings, 
       
   138 		const TIndexType aIndexType,
       
   139 		const TInt aIndex,
       
   140 		const eap_type_value_e aTunnelingType,
       
   141 		const eap_type_value_e aEapType);
       
   142 
       
   143 	static void GetConfigurationL(
       
   144 		RDbNamedDatabase& aDatabase,
       
   145 		EAPSettings& aSettings, 
       
   146 		const TIndexType aIndexType,
       
   147 		const TInt aIndex,
       
   148 		const eap_type_value_e aTunnelingType,
       
   149 		const eap_type_value_e aEapType);
       
   150 
       
   151 	static void CopySettingsL(
       
   152 		RDbNamedDatabase& aDatabase,
       
   153 		const TDesC& aTableName,
       
   154 		const TIndexType aSrcIndexType,
       
   155 		const TInt aSrcIndex,
       
   156 		const eap_type_value_e aSrcTunnelingType,
       
   157 		const TIndexType aDestIndexType,
       
   158 		const TInt aDestIndex,
       
   159 		const eap_type_value_e aDestTunnelingType);
       
   160 
       
   161 	static void DeleteConfigurationL(		
       
   162 		const TIndexType aIndexType,
       
   163 		const TInt aIndex,
       
   164 		const eap_type_value_e aTunnelingType,
       
   165 		const eap_type_value_e aEapType);
       
   166 
       
   167 	static void ReadCertRowsToArrayL(
       
   168 		RDbNamedDatabase& aDatabase,
       
   169 		eap_am_tools_symbian_c * const aTools,
       
   170 		const TDesC& aTableName, 
       
   171 		const TIndexType aIndexType,
       
   172 		const TInt aIndex,
       
   173 		const eap_type_value_e aTunnelingType,
       
   174 		RArray<SCertEntry>& aArray);
       
   175 
       
   176 	static void ReadUintRowsToArrayL(
       
   177 		RDbNamedDatabase& aDatabase,
       
   178 		eap_am_tools_symbian_c * const aTools,
       
   179 		const TDesC& aTableName, 
       
   180 		const TDesC& aColumnName,	
       
   181 		const TIndexType aIndexType,
       
   182 		const TInt aIndex,
       
   183 		const eap_type_value_e aTunnelingType,
       
   184 		RArray<TUint>& aArray);
       
   185 
       
   186 #ifdef USE_EAP_EXPANDED_TYPES
       
   187 	
       
   188 	// Stores the tunneled EAP type (expanded) to the database.
       
   189 	static void SetTunnelingExpandedEapDataL(
       
   190 		RDbNamedDatabase& aDatabase,
       
   191 		eap_am_tools_symbian_c * const aTools,
       
   192 		RExpandedEapTypePtrArray &aEnabledEAPArrary,
       
   193 		RExpandedEapTypePtrArray &aDisabledEAPArrary,
       
   194 		const TIndexType aIndexType,
       
   195 		const TInt aIndex,
       
   196 		const eap_type_value_e aTunnelingType,
       
   197 		const eap_type_value_e aEapType);
       
   198 
       
   199 	// Retrieves the tunneled EAP type (expanded) from the database	.
       
   200 	static void GetTunnelingExpandedEapDataL(
       
   201 		RDbNamedDatabase& aDatabase,
       
   202 		eap_am_tools_symbian_c * const aTools,
       
   203 		RExpandedEapTypePtrArray &aEnabledEAPArrary,
       
   204 		RExpandedEapTypePtrArray &aDisabledEAPArrary,
       
   205 		const TIndexType aIndexType,
       
   206 		const TInt aIndex,
       
   207 		const eap_type_value_e aTunnelingType,
       
   208 		const eap_type_value_e aEapType);
       
   209 
       
   210 #else // For normal EAP types.
       
   211 
       
   212 	// This sets only the tunneling EAP types.
       
   213 	static void SetEapDataL(
       
   214 		RDbNamedDatabase& aDatabase,
       
   215 		eap_am_tools_symbian_c * const aTools,
       
   216 		TEapArray &aEaps,
       
   217 		const TIndexType aIndexType,
       
   218 		const TInt aIndex,
       
   219 		const eap_type_value_e aTunnelingType,
       
   220 		const eap_type_value_e aEapType);
       
   221 	
       
   222 	// This gets only the tunneling EAP types.	
       
   223 	static void GetEapDataL(
       
   224 		RDbNamedDatabase& aDatabase,
       
   225 		eap_am_tools_symbian_c * const aTools,
       
   226 		TEapArray &aEaps,
       
   227 		const TIndexType aIndexType,
       
   228 		const TInt aIndex,
       
   229 		const eap_type_value_e aTunnelingType,
       
   230 		const eap_type_value_e aEapType);
       
   231 
       
   232 #endif //#ifdef USE_EAP_EXPANDED_TYPES
       
   233 
       
   234 	static TBool CompareTCertLabels(
       
   235 		const TCertLabel& item1, 
       
   236 		const TCertLabel& item2);
       
   237 
       
   238 	static TBool CompareSCertEntries(const SCertEntry& item1, const SCertEntry& item2);
       
   239 
       
   240 	static TBool CipherSuiteUseRSAKeys(tls_cipher_suites_e aCipherSuite);
       
   241 
       
   242 	static TBool CipherSuiteUseDSAKeys(tls_cipher_suites_e aCipherSuite);
       
   243 	
       
   244 	static TBool CipherSuiteIsEphemeralDHKeyExchange(tls_cipher_suites_e aCipherSuite);
       
   245 	
       
   246 	static void GetEapSettingsDataL(
       
   247 		RDbNamedDatabase& aDatabase,
       
   248 		const TIndexType aIndexType,
       
   249 		const TInt aIndex,
       
   250 		const eap_type_value_e aTunnelingType,
       
   251 		const eap_type_value_e aEapType,
       
   252 		const TDesC& aDbColumnName,
       
   253 		eap_variable_data_c * const aDbColumnValue);			
       
   254 
       
   255 	static void SetEapSettingsDataL(
       
   256 		RDbNamedDatabase& aDatabase,
       
   257 		const TIndexType aIndexType,
       
   258 		const TInt aIndex,
       
   259 		const eap_type_value_e aTunnelingType,
       
   260 		const eap_type_value_e aEapType,
       
   261 		const TDesC& aDbColumnName,
       
   262 		const eap_variable_data_c * const aDbColumnValue);		
       
   263 
       
   264 private:
       
   265 	static void OpenTlsDatabaseL(
       
   266 		RDbNamedDatabase& aDatabase, 
       
   267 		RDbs& aSession, 
       
   268 		const TIndexType aIndexType, 
       
   269 		const TInt aIndex,
       
   270 		const eap_type_value_e aTunnelingType);
       
   271 
       
   272 	static void OpenPeapDatabaseL(
       
   273 		RDbNamedDatabase& aDatabase, 
       
   274 		RDbs& aSession, 
       
   275 		const TIndexType aIndexType, 
       
   276 		const TInt aIndex,
       
   277 		const eap_type_value_e aTunnelingType);
       
   278 
       
   279 #if defined(USE_TTLS_EAP_TYPE)
       
   280 	static void OpenTtlsDatabaseL(
       
   281 		RDbNamedDatabase& aDatabase, 
       
   282 		RDbs& aSession, 
       
   283 		const TIndexType aIndexType, 
       
   284 		const TInt aIndex,
       
   285 		const eap_type_value_e aTunnelingType);
       
   286 #endif // #if defined(USE_TTLS_EAP_TYPE)
       
   287 
       
   288 #if defined(USE_FAST_EAP_TYPE)
       
   289 
       
   290 	static void OpenFastDatabaseL(
       
   291 		RDbNamedDatabase& aDatabase, 
       
   292 		RDbs& aSession, 
       
   293 		const TIndexType aIndexType, 
       
   294 		const TInt aIndex,
       
   295 		const eap_type_value_e aTunnelingType);
       
   296 
       
   297 #endif // #if defined(USE_FAST_EAP_TYPE)
       
   298 
       
   299 	static void AddExtraCertColumnsL(
       
   300 		RDbNamedDatabase& aDatabase, 
       
   301 		TDesC& aTableName);	
       
   302 
       
   303 private:
       
   304 
       
   305 	static void AlterTableL(
       
   306 			RDbNamedDatabase& aDb,
       
   307 			TAlterTableCmd aCmd,
       
   308 			const TDesC& aTableName,
       
   309 			const TDesC& aColumnName,
       
   310 			const TDesC& aColumnDef );
       
   311 
       
   312 };
       
   313 
       
   314 #endif // _EAPTLSPEAPUTILS_H_
       
   315 
       
   316 // End of file