|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 */ |
|
19 |
|
20 #include <testconfigfileparser.h> |
|
21 #include "CSimPhone.h" |
|
22 #include "Simlog.h" |
|
23 #include "csimsmartcardauth.h" |
|
24 #include "utils.h" |
|
25 |
|
26 CSimSmartCardAuth* CSimSmartCardAuth::NewL(CSimPhone *aPhone) |
|
27 { |
|
28 CSimSmartCardAuth* obj = new(ELeave) CSimSmartCardAuth(aPhone); |
|
29 CleanupStack::PushL(obj); |
|
30 obj->ConstructL(); |
|
31 CleanupStack::Pop(obj); |
|
32 return obj; |
|
33 } |
|
34 |
|
35 CSimSmartCardAuth::CSimSmartCardAuth(CSimPhone *aPhone) |
|
36 : iPhone(aPhone) |
|
37 { |
|
38 iGBAAuthInfoList = new (ELeave) CArrayFixFlat<TGBAAuthInfo> (1); |
|
39 iMBMSInfoList = new (ELeave) CArrayFixFlat<TMBMSInfo> (1); |
|
40 } |
|
41 |
|
42 void CSimSmartCardAuth::ConstructL() |
|
43 { |
|
44 ParseAuthInfoL(); |
|
45 ParseGBAAuthInfoL(); |
|
46 ParseMBMSAuthInfoL(); |
|
47 LOGPHONE1("CSimSmartCardAuth created"); |
|
48 } |
|
49 |
|
50 CSimSmartCardAuth::~CSimSmartCardAuth() |
|
51 { |
|
52 iAuthInfoList.Close(); |
|
53 if(iGBAAuthInfoList) |
|
54 { |
|
55 iGBAAuthInfoList->Delete(0,iGBAAuthInfoList->Count()); |
|
56 delete iGBAAuthInfoList; |
|
57 } |
|
58 if(iMBMSInfoList) |
|
59 { |
|
60 iMBMSInfoList->Delete(0,iMBMSInfoList->Count()); |
|
61 delete iMBMSInfoList; |
|
62 } |
|
63 LOGPHONE1("CSimSmartCardAuth destroyed"); |
|
64 } |
|
65 |
|
66 TInt CSimSmartCardAuth::GetScAuthenticationData(const TTsyReqHandle aTsyReqHandle, TDes8* aPckg1, const RMobilePhone::TAID* aAID) |
|
67 { |
|
68 |
|
69 LOGPHONE1("CSimSmartCardAuth::GetScAuthenticationData called"); |
|
70 |
|
71 RMobilePhone::TSmartCardAuthenticateDataV6Pckg |
|
72 * authenticateDataPckgd =reinterpret_cast<RMobilePhone::TSmartCardAuthenticateDataV6Pckg*>(aPckg1); |
|
73 RMobilePhone::TSmartCardAuthenticateDataV6& authenticateData=(*authenticateDataPckgd) (); |
|
74 |
|
75 // Check that the data structure is supported by the simulated TSY version |
|
76 TInt err = iPhone->CheckSimTsyVersion (authenticateData); |
|
77 if ( err != KErrNone) |
|
78 { |
|
79 iPhone->ReqCompleted (aTsyReqHandle, err); |
|
80 return KErrNone; |
|
81 } |
|
82 |
|
83 |
|
84 if ( authenticateData.ExtensionId ()== RMobilePhone::KETelMobileGbaBootstrapAuthDataV8) |
|
85 { |
|
86 RMobilePhone::TGbaBootstrapAuthDataV8Pckg |
|
87 * tGbaBootstrapAuthDataV8Pckgd =reinterpret_cast<RMobilePhone::TGbaBootstrapAuthDataV8Pckg*> (aPckg1); |
|
88 RMobilePhone::TGbaBootstrapAuthDataV8 tGbaBootstrapAuthDataV8 = (*tGbaBootstrapAuthDataV8Pckgd) (); |
|
89 |
|
90 // This is the USIM authorisation. |
|
91 if ( ((aAID == NULL) || (*aAID == iGBAAuthInfoList->At(index).iAID)) |
|
92 &&tGbaBootstrapAuthDataV8.iAUTN == iGBAAuthInfoList->At(index).iAUTN |
|
93 &&tGbaBootstrapAuthDataV8.iRAND == iGBAAuthInfoList->At(index).iRAND) |
|
94 { |
|
95 TInt ret = iGBAAuthInfoList->At(index).iAuthErr; |
|
96 if ( ret != KErrNone) |
|
97 { |
|
98 // Return the AUTS and blank everything else |
|
99 tGbaBootstrapAuthDataV8.iAUTS = iGBAAuthInfoList->At(index).iAUTS; |
|
100 tGbaBootstrapAuthDataV8.iRES = _L8(""); |
|
101 tGbaBootstrapAuthDataV8.iIK = _L8(""); |
|
102 tGbaBootstrapAuthDataV8.iCK = _L8(""); |
|
103 if ( ret == KErrMMEtelScApplicationNotActive) |
|
104 { |
|
105 if ( !(iGBAAuthInfoList->At(index).iApplnActive == EFalse)) |
|
106 { |
|
107 iPhone->ReqCompleted (aTsyReqHandle, KErrCorrupt); |
|
108 return KErrNone; |
|
109 } |
|
110 } |
|
111 } |
|
112 else |
|
113 { |
|
114 tGbaBootstrapAuthDataV8.iRES = iGBAAuthInfoList->At(index).iRES; |
|
115 tGbaBootstrapAuthDataV8.iAUTS = _L8(""); |
|
116 tGbaBootstrapAuthDataV8.iIK = _L8(""); |
|
117 tGbaBootstrapAuthDataV8.iCK = _L8(""); |
|
118 } |
|
119 |
|
120 iPhone->ReqCompleted (aTsyReqHandle, ret); |
|
121 //iGBAAuthInfoList->Delete(index); |
|
122 return KErrNone; |
|
123 } |
|
124 iPhone->ReqCompleted (aTsyReqHandle, KErrArgument); |
|
125 return KErrNone; |
|
126 } |
|
127 else if (authenticateData.ExtensionId ()== RMobilePhone::KETelMobileGbaNafAuthDataV8) |
|
128 { |
|
129 RMobilePhone::TGbaNafAuthDataV8Pckg *gbaNafAuthPckg = |
|
130 reinterpret_cast<RMobilePhone::TGbaNafAuthDataV8Pckg*>(aPckg1); |
|
131 |
|
132 RMobilePhone::TGbaNafAuthDataV8 &gbaNafAuthData= (*gbaNafAuthPckg)(); |
|
133 // This is the USIM authorisation. |
|
134 if ( ((aAID == NULL) || (*aAID == iGBAAuthInfoList->At(index).iAID)) |
|
135 &&gbaNafAuthData.iImpi == iGBAAuthInfoList->At(index).iIMPI |
|
136 &&gbaNafAuthData.iNafId == iGBAAuthInfoList->At(index).iNAFID) |
|
137 { |
|
138 TInt ret = iGBAAuthInfoList->At(index).iAuthErr; |
|
139 if ( ret != KErrNone) |
|
140 { |
|
141 // return the Ks_Ext_NAF as NULL |
|
142 gbaNafAuthData.iKsExtNaf = _L8(""); |
|
143 if ( ret == KErrMMEtelAuthKeyNotFound) |
|
144 { |
|
145 if ( !(iGBAAuthInfoList->At(index).iRAND == _L8("INV_RAND"))) |
|
146 { |
|
147 iPhone->ReqCompleted (aTsyReqHandle, KErrCorrupt); |
|
148 return KErrNone; |
|
149 } |
|
150 } |
|
151 if ( ret == KErrMMEtelScApplicationNotActive) |
|
152 { |
|
153 if ( !(iGBAAuthInfoList->At(index).iApplnActive == EFalse)) |
|
154 { |
|
155 iPhone->ReqCompleted (aTsyReqHandle, KErrCorrupt); |
|
156 return KErrNone; |
|
157 } |
|
158 } |
|
159 } |
|
160 else |
|
161 { |
|
162 gbaNafAuthData.iKsExtNaf = iGBAAuthInfoList->At(index).iKsExtNaf; |
|
163 } |
|
164 |
|
165 iPhone->ReqCompleted (aTsyReqHandle, ret); |
|
166 return KErrNone; |
|
167 } |
|
168 iPhone->ReqCompleted (aTsyReqHandle, KErrArgument); |
|
169 return KErrNone; |
|
170 } |
|
171 else if ( authenticateData.ExtensionId ()== RMobilePhone::KETelMobileMbmsMskUpdateDataV8) |
|
172 { |
|
173 RMobilePhone::TMbmsMskUpdateDataV8Pckg |
|
174 *tTMbmsMskUpdateDataV8Pckg =reinterpret_cast<RMobilePhone::TMbmsMskUpdateDataV8Pckg*> (aPckg1); |
|
175 |
|
176 RMobilePhone::TMbmsMskUpdateDataV8 &tTMbmsMskUpdateDataV8= (*tTMbmsMskUpdateDataV8Pckg) (); |
|
177 |
|
178 if ( ((aAID == NULL) || (*aAID == iMBMSInfoList->At(index).iAID)) |
|
179 && tTMbmsMskUpdateDataV8.iInputMikey == iMBMSInfoList->At(index).iInputMikey) |
|
180 { |
|
181 TInt ret = iMBMSInfoList->At(index).iAuthErr; |
|
182 if ( ret != KErrNone) |
|
183 { |
|
184 // return the Ks_Ext_NAF as NULL |
|
185 tTMbmsMskUpdateDataV8.iOutputMikey = _L8 (""); |
|
186 if ( ret == KErrMMEtelAuthKeyNotFound) |
|
187 { |
|
188 /* Checking for the hardcoded (existing) KsIntNAF with the one in config file |
|
189 * If different, it means that the KsIntNaf has been overwritten |
|
190 */ |
|
191 if ((iMBMSInfoList->At(index).iKsIntNaf == _L8("CORRECT_KS_INT"))) |
|
192 { |
|
193 iPhone->ReqCompleted (aTsyReqHandle,KErrCorrupt); |
|
194 index++; |
|
195 return KErrNone; |
|
196 } |
|
197 if(!(iMBMSInfoList->At(index).iMukIdTlv == _L8("INVALID_MUKID"))) |
|
198 { |
|
199 iPhone->ReqCompleted (aTsyReqHandle,KErrCorrupt); |
|
200 index++; |
|
201 return KErrNone; |
|
202 } |
|
203 } |
|
204 if ( ret == KErrMMEtelScApplicationNotActive) |
|
205 { |
|
206 if ( !(iMBMSInfoList->At(index).iApplnActive == EFalse)) |
|
207 { |
|
208 iPhone->ReqCompleted (aTsyReqHandle,KErrCorrupt); |
|
209 index++; |
|
210 return KErrNone; |
|
211 } |
|
212 } |
|
213 } |
|
214 else |
|
215 { |
|
216 tTMbmsMskUpdateDataV8.iOutputMikey = iMBMSInfoList->At(index).iOutputMikey; |
|
217 } |
|
218 |
|
219 iPhone->ReqCompleted (aTsyReqHandle, ret); |
|
220 index++; |
|
221 return KErrNone; |
|
222 } |
|
223 |
|
224 iPhone->ReqCompleted (aTsyReqHandle, KErrArgument); |
|
225 index++; |
|
226 return KErrNone; |
|
227 } |
|
228 else if ( authenticateData.ExtensionId ()== RMobilePhone::KETelMobileMbmsMtkGenerateDataV8) |
|
229 { |
|
230 RMobilePhone::TMbmsMtkGenerateDataV8Pckg |
|
231 *tTMbmsMtkGenerateDataV8Pckg =reinterpret_cast<RMobilePhone::TMbmsMtkGenerateDataV8Pckg*> (aPckg1); |
|
232 |
|
233 RMobilePhone::TMbmsMtkGenerateDataV8 &tTMbmsMtkGenerateDataV8= (*tTMbmsMtkGenerateDataV8Pckg) (); |
|
234 |
|
235 if ( ((aAID == NULL) || (*aAID == iMBMSInfoList->At(index).iAID)) |
|
236 && tTMbmsMtkGenerateDataV8.iMikey == iMBMSInfoList->At(index).iInputMikey) |
|
237 { |
|
238 TInt ret = iMBMSInfoList->At(index).iAuthErr; |
|
239 if ( ret != KErrNone) |
|
240 { |
|
241 // return the Ks_Ext_NAF as NULL |
|
242 tTMbmsMtkGenerateDataV8.iMtk = _L8 (""); |
|
243 tTMbmsMtkGenerateDataV8.iSaltKey = _L8 (""); |
|
244 if ( ret == KErrMMEtelScApplicationNotActive) |
|
245 { |
|
246 if ( !(iMBMSInfoList->At(index).iApplnActive == EFalse)) |
|
247 { |
|
248 iPhone->ReqCompleted (aTsyReqHandle,KErrCorrupt); |
|
249 index++; |
|
250 return KErrNone; |
|
251 } |
|
252 } |
|
253 } |
|
254 else |
|
255 { |
|
256 tTMbmsMtkGenerateDataV8.iMtk = iMBMSInfoList->At(index).iMtk; |
|
257 tTMbmsMtkGenerateDataV8.iSaltKey = iMBMSInfoList->At(index).iSaltkey; |
|
258 } |
|
259 iPhone->ReqCompleted (aTsyReqHandle, ret); |
|
260 index++; |
|
261 return KErrNone; |
|
262 } |
|
263 |
|
264 iPhone->ReqCompleted (aTsyReqHandle, KErrArgument); |
|
265 index++; |
|
266 return KErrNone; |
|
267 } |
|
268 else if ( authenticateData.ExtensionId ()== RMobilePhone::KETelMobileMbmsMskDeleteDataV8) |
|
269 { |
|
270 RMobilePhone::TMbmsMskDeleteDataV8Pckg |
|
271 *tTMbmsMskDeleteDataV8Pckg =reinterpret_cast<RMobilePhone::TMbmsMskDeleteDataV8Pckg*> (aPckg1); |
|
272 |
|
273 RMobilePhone::TMbmsMskDeleteDataV8 &tTMbmsMskDeleteDataV8= (*tTMbmsMskDeleteDataV8Pckg) (); |
|
274 |
|
275 if ( ((aAID == NULL) || (*aAID == iMBMSInfoList->At(index).iAID)) |
|
276 && tTMbmsMskDeleteDataV8.iMskIdKeyGroup == iMBMSInfoList->At(index).iMskIdGrp |
|
277 && tTMbmsMskDeleteDataV8.iKeyDomainId == iMBMSInfoList->At(index).iKeyDmn) |
|
278 { |
|
279 TInt ret = iMBMSInfoList->At(index).iAuthErr; |
|
280 if ( ret != KErrNone) |
|
281 { |
|
282 if ( ret == KErrMMEtelScApplicationNotActive) |
|
283 { |
|
284 if ( !(iMBMSInfoList->At(index).iApplnActive == EFalse)) |
|
285 { |
|
286 iPhone->ReqCompleted (aTsyReqHandle,KErrCorrupt); |
|
287 index++; |
|
288 return KErrNone; |
|
289 } |
|
290 } |
|
291 } |
|
292 else |
|
293 { |
|
294 // MSK IDs are successfully deleted from the EFs. |
|
295 } |
|
296 iPhone->ReqCompleted (aTsyReqHandle, ret); |
|
297 index++; |
|
298 return KErrNone; |
|
299 } |
|
300 |
|
301 iPhone->ReqCompleted (aTsyReqHandle, KErrArgument); |
|
302 index++; |
|
303 return KErrNone; |
|
304 } |
|
305 else if ( authenticateData.ExtensionId ()== RMobilePhone::KETelMobileMbmsMukDeleteDataV8) |
|
306 { |
|
307 RMobilePhone::TMbmsMukDeleteDataV8Pckg |
|
308 *tTMbmsMukDeleteDataV8Pckg =reinterpret_cast<RMobilePhone::TMbmsMukDeleteDataV8Pckg*> (aPckg1); |
|
309 |
|
310 RMobilePhone::TMbmsMukDeleteDataV8 &tTMbmsMukDeleteDataV8= (*tTMbmsMukDeleteDataV8Pckg) (); |
|
311 |
|
312 if ( ((aAID == NULL) || (*aAID == iMBMSInfoList->At(index).iAID)) |
|
313 && tTMbmsMukDeleteDataV8.iMukIdTlv == iMBMSInfoList->At(index).iMukIdTlv) |
|
314 { |
|
315 TInt ret = iMBMSInfoList->At(index).iAuthErr; |
|
316 if ( ret != KErrNone) |
|
317 { |
|
318 if ( ret == KErrMMEtelScApplicationNotActive) |
|
319 { |
|
320 if ( !(iMBMSInfoList->At(index).iApplnActive == EFalse)) |
|
321 { |
|
322 iPhone->ReqCompleted (aTsyReqHandle,KErrCorrupt); |
|
323 index++; |
|
324 return KErrNone; |
|
325 } |
|
326 } |
|
327 } |
|
328 else |
|
329 { |
|
330 // MUK IDs are successfully deleted from the EFs. |
|
331 } |
|
332 iPhone->ReqCompleted (aTsyReqHandle, ret); |
|
333 index++; |
|
334 return KErrNone; |
|
335 } |
|
336 |
|
337 iPhone->ReqCompleted (aTsyReqHandle, KErrArgument); |
|
338 index++; |
|
339 return KErrNone; |
|
340 } |
|
341 else |
|
342 { |
|
343 if(authenticateData.iCK==KConfigScWlan()) |
|
344 { |
|
345 if(*aAID==KWlanAid()) |
|
346 { |
|
347 if(authenticateData.iAUTN == KConfigScWlanAuthAUTN() && authenticateData.iRAND == KConfigScWlanAuthRAND()) |
|
348 { |
|
349 authenticateData.iRES=KConfigScWlanAuthRES(); |
|
350 authenticateData.iIK=KConfigScWlanAuthIK(); |
|
351 authenticateData.iCK=KConfigScWlanAuthCK(); |
|
352 iPhone->ReqCompleted (aTsyReqHandle, KErrNone); |
|
353 } |
|
354 else if(authenticateData.iAUTN == KConfigScWlanAuthAUTN()) |
|
355 { |
|
356 iPhone->ReqCompleted (aTsyReqHandle, KErrMMEtelSqnVerificationFailed); |
|
357 } |
|
358 else |
|
359 { |
|
360 iPhone->ReqCompleted (aTsyReqHandle, KErrMMEtelMacVerificationFailed); |
|
361 } |
|
362 } |
|
363 else |
|
364 { |
|
365 iPhone->ReqCompleted (aTsyReqHandle, KErrMMEtelScApplicationNotActive); |
|
366 } |
|
367 } |
|
368 else if(authenticateData.iCK==KConfigScWlanNotSupported()) |
|
369 { |
|
370 iPhone->ReqCompleted (aTsyReqHandle, KErrNotSupported); |
|
371 } |
|
372 else if ( authenticateData.iAUTN == _L8("")) |
|
373 { |
|
374 // Authenticate if EAP-SIM is being used. |
|
375 |
|
376 // Find the iRAND value |
|
377 index = 0; |
|
378 while ( (index < iAuthInfoList.Count()) && (authenticateData.iRAND != iAuthInfoList[index].iRAND)) |
|
379 { |
|
380 index++; |
|
381 } |
|
382 |
|
383 if ( index == iAuthInfoList.Count ()) |
|
384 { |
|
385 // The approriate iRAND value could not be found, so return KErrCorrupt. |
|
386 iPhone->ReqCompleted (aTsyReqHandle, KErrCorrupt); |
|
387 index++; |
|
388 return KErrNone; |
|
389 } |
|
390 else |
|
391 { |
|
392 // Return the iRES and KC values that match the iRAND given, and blank everything else |
|
393 authenticateData.iAUTS = _L8(""); |
|
394 authenticateData.iRES = iAuthInfoList[index].iRES; |
|
395 authenticateData.iIK = _L8(""); |
|
396 authenticateData.iCK = _L8(""); |
|
397 authenticateData.iKc = iAuthInfoList[index].iKc; |
|
398 |
|
399 iPhone->ReqCompleted (aTsyReqHandle, KErrNone); |
|
400 } |
|
401 } |
|
402 else |
|
403 { |
|
404 for (index = 0; index < iAuthInfoList.Count (); index++) |
|
405 { |
|
406 // This is the USIM authorisation. |
|
407 if ( authenticateData.iAUTN == iAuthInfoList[index].iAUTN &&authenticateData.iRAND == iAuthInfoList[index].iRAND &&((aAID == NULL) || (*aAID == iAuthInfoList[index].iAID))) |
|
408 { |
|
409 TInt ret = iAuthInfoList[index].iAuthErr; |
|
410 if ( ret != KErrNone) |
|
411 { |
|
412 // Return the AUTS and blank everything else |
|
413 authenticateData.iAUTS = iAuthInfoList[index].iAUTS; |
|
414 authenticateData.iRES = _L8(""); |
|
415 authenticateData.iIK = _L8(""); |
|
416 authenticateData.iCK = _L8(""); |
|
417 authenticateData.iKc = _L8(""); |
|
418 } |
|
419 else |
|
420 { |
|
421 authenticateData.iRES = iAuthInfoList[index].iRES; |
|
422 authenticateData.iIK = iAuthInfoList[index].iIK; |
|
423 authenticateData.iCK = iAuthInfoList[index].iCK; |
|
424 authenticateData.iKc = iAuthInfoList[index].iKc; |
|
425 } |
|
426 |
|
427 iPhone->ReqCompleted (aTsyReqHandle, ret); |
|
428 iAuthInfoList.Remove (index); |
|
429 iAuthInfoList.Compress (); |
|
430 index++; |
|
431 return KErrNone; |
|
432 } |
|
433 iPhone->ReqCompleted (aTsyReqHandle, KErrCorrupt); |
|
434 } |
|
435 } |
|
436 } |
|
437 index++; |
|
438 return KErrNone; |
|
439 } |
|
440 |
|
441 TInt CSimSmartCardAuth::GetScAuthenticationDataCancel(const TTsyReqHandle aTsyReqHandle) |
|
442 { |
|
443 LOGPHONE1("CSimSmartCardAuth::GetScAuthenticationDataCancel called"); |
|
444 iPhone->ReqCompleted(aTsyReqHandle, KErrCancel); |
|
445 return KErrNone; |
|
446 } |
|
447 |
|
448 const CTestConfigSection* CSimSmartCardAuth::CfgFile() |
|
449 { |
|
450 return iPhone->CfgFile(); |
|
451 } |
|
452 |
|
453 /** |
|
454 Parses the list of SmartCardAuthInfo tags from the config.txt file. |
|
455 */ |
|
456 void CSimSmartCardAuth::ParseAuthInfoL() |
|
457 { |
|
458 LOGPHONE1("CSimSmartCardAuth::ParseAuthInfoL called"); |
|
459 |
|
460 CTestConfigItem* item = NULL; |
|
461 |
|
462 LOGPHONE1("Starting to Parse Smart Card Authentication Info"); |
|
463 TInt count = CfgFile()->ItemCount(KScAuthInfo); |
|
464 |
|
465 TInt index; |
|
466 for(index = 0; index < count; index++) |
|
467 { |
|
468 item = const_cast<CTestConfigItem*>(CfgFile()->Item(KScAuthInfo, index)); |
|
469 if(item == NULL) |
|
470 { |
|
471 break; |
|
472 } |
|
473 CleanupStack::PushL(item); |
|
474 |
|
475 TInt ret = KErrNone, authErr = KErrNone; |
|
476 TPtrC8 AUTN, RAND, RES, IK, CK, Kc, AUTS, appId; |
|
477 TAuthInfo authInfo; |
|
478 TInt dataFrmt; |
|
479 |
|
480 //Get the data format |
|
481 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 8, appId); |
|
482 if(ret != KErrNone) |
|
483 { |
|
484 LOGPARSERR("appId",ret,8,&KScAuthInfo); |
|
485 _LIT8(emptyAID, ""); |
|
486 appId.Set(emptyAID); |
|
487 } |
|
488 else |
|
489 { |
|
490 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 9, dataFrmt); |
|
491 if(ret != KErrNone) |
|
492 { |
|
493 LOGPARSERR("dataFrmt",ret,9,&KScAuthInfo); |
|
494 } |
|
495 else if (dataFrmt >= EMaxConfigDataFormat) |
|
496 { |
|
497 LOGPHONE1("WARNING IN CONFIGURATION FILE PARSING - Invalid format for SC Authenticate tag"); |
|
498 dataFrmt = EConfigDataFormatAscii; |
|
499 } |
|
500 |
|
501 authInfo.iAID.Copy(appId); |
|
502 |
|
503 switch (dataFrmt) |
|
504 { |
|
505 case EConfigDataFormatMixedBinaryAndAscii: |
|
506 ParseMixedBinaryAsciiDataL(authInfo.iAID); |
|
507 break; |
|
508 //case EConfigDataFormatAscii: // Do nothing |
|
509 //default: |
|
510 } |
|
511 } |
|
512 |
|
513 //Get the AUTN |
|
514 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, AUTN); |
|
515 if(ret != KErrNone) |
|
516 { |
|
517 LOGPARSERR("AUTN",ret,0,&KScAuthInfo); |
|
518 continue; |
|
519 } |
|
520 else |
|
521 { |
|
522 authInfo.iAUTN.Copy(AUTN); |
|
523 |
|
524 switch (dataFrmt) |
|
525 { |
|
526 case EConfigDataFormatMixedBinaryAndAscii: |
|
527 ParseMixedBinaryAsciiDataL(authInfo.iAUTN); |
|
528 break; |
|
529 //case EConfigDataFormatAscii: // Do nothing |
|
530 //default: |
|
531 } |
|
532 } |
|
533 |
|
534 //Get the RAND |
|
535 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 1, RAND); |
|
536 if(ret != KErrNone) |
|
537 { |
|
538 LOGPARSERR("RAND",ret,1,&KScAuthInfo); |
|
539 continue; |
|
540 } |
|
541 else |
|
542 { |
|
543 authInfo.iRAND.Copy(RAND); |
|
544 |
|
545 switch (dataFrmt) |
|
546 { |
|
547 case EConfigDataFormatMixedBinaryAndAscii: |
|
548 ParseMixedBinaryAsciiDataL(authInfo.iRAND); |
|
549 break; |
|
550 //case EConfigDataFormatAscii: // Do nothing |
|
551 //default: |
|
552 } |
|
553 } |
|
554 |
|
555 //Get the RES |
|
556 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 2, RES); |
|
557 if(ret != KErrNone) |
|
558 { |
|
559 LOGPARSERR("RES",ret,2,&KScAuthInfo); |
|
560 continue; |
|
561 } |
|
562 else |
|
563 { |
|
564 authInfo.iRES.Copy(RES); |
|
565 |
|
566 switch (dataFrmt) |
|
567 { |
|
568 case EConfigDataFormatMixedBinaryAndAscii: |
|
569 ParseMixedBinaryAsciiDataL(authInfo.iRES); |
|
570 break; |
|
571 //case EConfigDataFormatAscii: // Do nothing |
|
572 //default: |
|
573 } |
|
574 } |
|
575 |
|
576 //Get the IK |
|
577 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 3, IK); |
|
578 if(ret != KErrNone) |
|
579 { |
|
580 LOGPARSERR("IK",ret,3,&KScAuthInfo); |
|
581 continue; |
|
582 } |
|
583 else |
|
584 { |
|
585 authInfo.iIK.Copy(IK); |
|
586 |
|
587 switch (dataFrmt) |
|
588 { |
|
589 case EConfigDataFormatMixedBinaryAndAscii: |
|
590 ParseMixedBinaryAsciiDataL(authInfo.iIK); |
|
591 break; |
|
592 //case EConfigDataFormatAscii: // Do nothing |
|
593 //default: |
|
594 } |
|
595 } |
|
596 |
|
597 //Get the CK |
|
598 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 4, CK); |
|
599 if(ret != KErrNone) |
|
600 { |
|
601 LOGPARSERR("CK",ret,4,&KScAuthInfo); |
|
602 continue; |
|
603 } |
|
604 else |
|
605 { |
|
606 authInfo.iCK.Copy(CK); |
|
607 |
|
608 switch (dataFrmt) |
|
609 { |
|
610 case EConfigDataFormatMixedBinaryAndAscii: |
|
611 ParseMixedBinaryAsciiDataL(authInfo.iCK); |
|
612 break; |
|
613 //case EConfigDataFormatAscii: // Do nothing |
|
614 //default: |
|
615 } |
|
616 } |
|
617 |
|
618 //Get the CK |
|
619 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 5, Kc); |
|
620 if(ret != KErrNone) |
|
621 { |
|
622 LOGPARSERR("Kc",ret,5,&KScAuthInfo); |
|
623 continue; |
|
624 } |
|
625 else |
|
626 { |
|
627 authInfo.iKc.Copy(Kc); |
|
628 |
|
629 switch (dataFrmt) |
|
630 { |
|
631 case EConfigDataFormatMixedBinaryAndAscii: |
|
632 ParseMixedBinaryAsciiDataL(authInfo.iKc); |
|
633 break; |
|
634 //case EConfigDataFormatAscii: // Do nothing |
|
635 //default: |
|
636 } |
|
637 } |
|
638 |
|
639 //Get the AUTS |
|
640 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 6, AUTS); |
|
641 if(ret != KErrNone) |
|
642 { |
|
643 LOGPARSERR("AUTS",ret,6,&KScAuthInfo); |
|
644 continue; |
|
645 } |
|
646 else |
|
647 { |
|
648 authInfo.iAUTS.Copy(AUTS); |
|
649 |
|
650 switch (dataFrmt) |
|
651 { |
|
652 case EConfigDataFormatMixedBinaryAndAscii: |
|
653 ParseMixedBinaryAsciiDataL(authInfo.iAUTS); |
|
654 break; |
|
655 //case EConfigDataFormatAscii: // Do nothing |
|
656 //default: |
|
657 } |
|
658 } |
|
659 |
|
660 //Get authentication error |
|
661 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 7, authErr); |
|
662 if(ret != KErrNone) |
|
663 { |
|
664 LOGPARSERR("authErr",ret,7,&KScAuthInfo); |
|
665 continue; |
|
666 } |
|
667 else |
|
668 { |
|
669 authInfo.iAuthErr = authErr; |
|
670 } |
|
671 |
|
672 iAuthInfoList.Append(authInfo); |
|
673 CleanupStack::Pop(item); |
|
674 } // end FOR Loop |
|
675 } |
|
676 |
|
677 /** |
|
678 Parses the list of GBAAuthInfo tags from the config.txt file. |
|
679 */ |
|
680 void CSimSmartCardAuth::ParseGBAAuthInfoL() |
|
681 { |
|
682 LOGPHONE1("CSimSmartCardAuth::ParseGBAAuthInfoL called"); |
|
683 |
|
684 CTestConfigItem* item = NULL; |
|
685 |
|
686 LOGPHONE1("Starting to Parse GBA Authentication Info"); |
|
687 TInt count = CfgFile()->ItemCount(KGBAAuthInfo); |
|
688 |
|
689 TInt index; |
|
690 for(index = 0; index < count; index++) |
|
691 { |
|
692 item = const_cast<CTestConfigItem*>(CfgFile()->Item(KGBAAuthInfo, index)); |
|
693 if(item == NULL) |
|
694 { |
|
695 break; |
|
696 } |
|
697 CleanupStack::PushL(item); |
|
698 |
|
699 TInt ret = KErrNone, authErr = KErrNone; |
|
700 TPtrC8 AUTN, RAND, appId, RES, AUTS, NAFID,IMPI, KSExtNaf, BtID, KeyLifeTime ; |
|
701 TBool OtherApplnBusy, applnActive; |
|
702 TGBAAuthInfo authInfo; |
|
703 |
|
704 |
|
705 //Get the AUTN |
|
706 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 0, AUTN); |
|
707 if(ret != KErrNone) |
|
708 { |
|
709 LOGPARSERR("AUTN",ret,0,&KGBAAuthInfo); |
|
710 continue; |
|
711 } |
|
712 else |
|
713 { |
|
714 authInfo.iAUTN.Copy(AUTN); |
|
715 } |
|
716 |
|
717 //Get the RAND |
|
718 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 1, RAND); |
|
719 if(ret != KErrNone) |
|
720 { |
|
721 LOGPARSERR("RAND",ret,1,&KGBAAuthInfo); |
|
722 continue; |
|
723 } |
|
724 else |
|
725 { |
|
726 authInfo.iRAND.Copy(RAND); |
|
727 } |
|
728 |
|
729 //Get the APPID |
|
730 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 2, appId); |
|
731 if(ret != KErrNone) |
|
732 { |
|
733 LOGPARSERR("APPID",ret,2,&KGBAAuthInfo); |
|
734 continue; |
|
735 } |
|
736 else |
|
737 { |
|
738 authInfo.iAID.Copy(appId); |
|
739 } |
|
740 |
|
741 //Get the RES |
|
742 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 3, RES); |
|
743 if(ret != KErrNone) |
|
744 { |
|
745 LOGPARSERR("RES",ret,3,&KGBAAuthInfo); |
|
746 continue; |
|
747 } |
|
748 else |
|
749 { |
|
750 authInfo.iRES.Copy(RES); |
|
751 } |
|
752 |
|
753 //Get the AUTS |
|
754 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 4, AUTS); |
|
755 if(ret != KErrNone) |
|
756 { |
|
757 LOGPARSERR("AUTS",ret,4,&KGBAAuthInfo); |
|
758 continue; |
|
759 } |
|
760 else |
|
761 { |
|
762 authInfo.iAUTS.Copy(AUTS); |
|
763 } |
|
764 |
|
765 //Get the NAFID |
|
766 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 5, NAFID); |
|
767 if(ret != KErrNone) |
|
768 { |
|
769 LOGPARSERR("NAFID",ret,5,&KGBAAuthInfo); |
|
770 continue; |
|
771 } |
|
772 else |
|
773 { |
|
774 authInfo.iNAFID.Copy(NAFID); |
|
775 } |
|
776 |
|
777 //Get the IMPI |
|
778 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 6, IMPI); |
|
779 if(ret != KErrNone) |
|
780 { |
|
781 LOGPARSERR("IMPI",ret,6,&KGBAAuthInfo); |
|
782 continue; |
|
783 } |
|
784 else |
|
785 { |
|
786 authInfo.iIMPI.Copy(IMPI); |
|
787 } |
|
788 |
|
789 //Get the KsExtNaf |
|
790 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 7, KSExtNaf); |
|
791 if(ret != KErrNone) |
|
792 { |
|
793 LOGPARSERR("KSExtNaf",ret,7,&KGBAAuthInfo); |
|
794 continue; |
|
795 } |
|
796 else |
|
797 { |
|
798 authInfo.iKsExtNaf.Copy(KSExtNaf); |
|
799 } |
|
800 |
|
801 //Get the BtID |
|
802 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 8, BtID); |
|
803 if(ret != KErrNone) |
|
804 { |
|
805 LOGPARSERR("BtID",ret,8,&KGBAAuthInfo); |
|
806 continue; |
|
807 } |
|
808 else |
|
809 { |
|
810 authInfo.iBtid.Copy(BtID); |
|
811 } |
|
812 |
|
813 //Get the KeyLifeTime |
|
814 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 9, KeyLifeTime); |
|
815 if(ret != KErrNone) |
|
816 { |
|
817 LOGPARSERR("KeyLifeTime",ret,9,&KGBAAuthInfo); |
|
818 continue; |
|
819 } |
|
820 else |
|
821 { |
|
822 authInfo.iKeyLifeTime.Copy(KeyLifeTime); |
|
823 } |
|
824 |
|
825 //Get the OtherApplnBusy |
|
826 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 10, OtherApplnBusy); |
|
827 if(ret != KErrNone) |
|
828 { |
|
829 LOGPARSERR("OtherApplnBusy",ret,10,&KGBAAuthInfo); |
|
830 continue; |
|
831 } |
|
832 else |
|
833 { |
|
834 authInfo.iOtherApplnBusy = OtherApplnBusy; |
|
835 } |
|
836 |
|
837 //Get the CurrentApplnActive |
|
838 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 11, applnActive); |
|
839 if(ret != KErrNone) |
|
840 { |
|
841 LOGPARSERR("applnActive",ret,11,&KGBAAuthInfo); |
|
842 continue; |
|
843 } |
|
844 else |
|
845 { |
|
846 authInfo.iApplnActive = applnActive; |
|
847 } |
|
848 |
|
849 //Get authentication error |
|
850 ret = CTestConfig::GetElement(item->Value(), KStdDelimiter, 12, authErr); |
|
851 if(ret != KErrNone) |
|
852 { |
|
853 LOGPARSERR("authErr",ret,12,&KGBAAuthInfo); |
|
854 continue; |
|
855 } |
|
856 else |
|
857 { |
|
858 authInfo.iAuthErr = authErr; |
|
859 } |
|
860 |
|
861 iGBAAuthInfoList->AppendL(authInfo); |
|
862 CleanupStack::Pop(item); |
|
863 } // end FOR Loop |
|
864 } |
|
865 |
|
866 /** |
|
867 Parses the list of MBMSAuthInfo tags from the config.txt file. |
|
868 */ |
|
869 void CSimSmartCardAuth::ParseMBMSAuthInfoL() |
|
870 { |
|
871 LOGPHONE1 ("CSimSmartCardAuth::ParseMBMSAuthInfoL called"); |
|
872 |
|
873 CTestConfigItem* item = NULL; |
|
874 |
|
875 LOGPHONE1 ("Starting to Parse MBMS Authentication Info"); |
|
876 |
|
877 TInt count = CfgFile()->ItemCount (KMBMSInfo); |
|
878 TMBMSInfo tMbmsInfo; |
|
879 |
|
880 for (TInt index = 0; index < count; index++) |
|
881 { |
|
882 item = const_cast<CTestConfigItem*>(CfgFile()->Item(KMBMSInfo, index)); |
|
883 if ( item == NULL) |
|
884 { |
|
885 break; |
|
886 } |
|
887 CleanupStack::PushL (item); |
|
888 |
|
889 TInt ret = KErrNone; |
|
890 TPtrC8 iMikey, oMikey, mtk, saltKey, keyDmn, MskIdgrp; |
|
891 TPtrC8 MukId, MukIdi, MukIdr, MukTimeStamp, appId, KSIntNaf; |
|
892 TBool applnActive; |
|
893 TInt authErr; |
|
894 |
|
895 //Get the input Mikey |
|
896 ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 0, iMikey); |
|
897 if ( ret != KErrNone) |
|
898 { |
|
899 LOGPARSERR ("iMikey", ret, 0, &KMBMSInfo); |
|
900 continue; |
|
901 } |
|
902 else |
|
903 { |
|
904 tMbmsInfo.iInputMikey.Copy (iMikey); |
|
905 } |
|
906 |
|
907 //Get the output Mikey |
|
908 ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 1, oMikey); |
|
909 if ( ret != KErrNone) |
|
910 { |
|
911 LOGPARSERR ("oMikey", ret, 1, &KMBMSInfo); |
|
912 continue; |
|
913 } |
|
914 else |
|
915 { |
|
916 tMbmsInfo.iOutputMikey.Copy (oMikey); |
|
917 } |
|
918 |
|
919 //Get the MTK |
|
920 ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 2, mtk); |
|
921 if ( ret != KErrNone) |
|
922 { |
|
923 LOGPARSERR ("MTK", ret, 2, &KMBMSInfo); |
|
924 continue; |
|
925 } |
|
926 else |
|
927 { |
|
928 tMbmsInfo.iMtk.Copy (mtk); |
|
929 } |
|
930 |
|
931 //Get the SaltKey |
|
932 ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 3, |
|
933 saltKey); |
|
934 if ( ret != KErrNone) |
|
935 { |
|
936 LOGPARSERR ("saltKey", ret, 3, &KMBMSInfo); |
|
937 continue; |
|
938 } |
|
939 else |
|
940 { |
|
941 tMbmsInfo.iSaltkey.Copy (saltKey); |
|
942 } |
|
943 |
|
944 //Get the KeyDomain |
|
945 ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 4, keyDmn); |
|
946 if ( ret != KErrNone) |
|
947 { |
|
948 LOGPARSERR ("keyDmn ", ret, 4, &KMBMSInfo); |
|
949 continue; |
|
950 } |
|
951 else |
|
952 { |
|
953 tMbmsInfo.iKeyDmn.Copy (keyDmn); |
|
954 } |
|
955 |
|
956 //Get the MskIdgrp |
|
957 ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 5, |
|
958 MskIdgrp); |
|
959 if ( ret != KErrNone) |
|
960 { |
|
961 LOGPARSERR ("MskIdgrp", ret, 5, &KMBMSInfo); |
|
962 continue; |
|
963 } |
|
964 else |
|
965 { |
|
966 tMbmsInfo.iMskIdGrp.Copy (MskIdgrp); |
|
967 } |
|
968 |
|
969 //Get the iMukIdTlv |
|
970 ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 6, MukId); |
|
971 if ( ret != KErrNone) |
|
972 { |
|
973 LOGPARSERR ("MukId ", ret, 6, &KMBMSInfo); |
|
974 continue; |
|
975 } |
|
976 else |
|
977 { |
|
978 tMbmsInfo.iMukIdTlv.Copy (MukId); |
|
979 } |
|
980 |
|
981 //Get the MukIdi |
|
982 ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 7, MukIdi); |
|
983 if ( ret != KErrNone) |
|
984 { |
|
985 LOGPARSERR ("MukIdi", ret, 7, &KMBMSInfo); |
|
986 continue; |
|
987 } |
|
988 else |
|
989 { |
|
990 tMbmsInfo.iMukIdi.Copy (MukIdi); |
|
991 } |
|
992 |
|
993 //Get the MukIdr |
|
994 ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 8, MukIdr); |
|
995 if ( ret != KErrNone) |
|
996 { |
|
997 LOGPARSERR ("MukIdr ", ret, 8, &KMBMSInfo); |
|
998 continue; |
|
999 } |
|
1000 else |
|
1001 { |
|
1002 tMbmsInfo.iMukIdr.Copy (MukIdr); |
|
1003 } |
|
1004 |
|
1005 //Get the MukTimeStamp |
|
1006 ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 9,MukTimeStamp); |
|
1007 if ( ret != KErrNone) |
|
1008 { |
|
1009 LOGPARSERR ("iMikey", ret, 9, &KMBMSInfo); |
|
1010 continue; |
|
1011 } |
|
1012 else |
|
1013 { |
|
1014 tMbmsInfo.iMukTimestamp.Copy (MukTimeStamp); |
|
1015 } |
|
1016 |
|
1017 //Get the APPID |
|
1018 ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 10, appId); |
|
1019 if ( ret != KErrNone) |
|
1020 { |
|
1021 LOGPARSERR ("APPID", ret, 10, &KMBMSInfo); |
|
1022 continue; |
|
1023 } |
|
1024 else |
|
1025 { |
|
1026 tMbmsInfo.iAID.Copy (appId); |
|
1027 } |
|
1028 |
|
1029 //Get the KsIntNaf |
|
1030 ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 11,KSIntNaf); |
|
1031 if ( ret != KErrNone) |
|
1032 { |
|
1033 LOGPARSERR ("KSIntNaf", ret, 11, &KMBMSInfo); |
|
1034 continue; |
|
1035 } |
|
1036 else |
|
1037 { |
|
1038 tMbmsInfo.iKsIntNaf.Copy (KSIntNaf); |
|
1039 } |
|
1040 |
|
1041 //Get the CurrentApplnActive |
|
1042 ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 12,applnActive); |
|
1043 if ( ret != KErrNone) |
|
1044 { |
|
1045 LOGPARSERR ("applnActive", ret, 12, &KMBMSInfo); |
|
1046 continue; |
|
1047 } |
|
1048 else |
|
1049 { |
|
1050 tMbmsInfo.iApplnActive = applnActive; |
|
1051 } |
|
1052 |
|
1053 //Get authentication error |
|
1054 ret = CTestConfig::GetElement (item->Value (), KStdDelimiter, 13,authErr); |
|
1055 if ( ret != KErrNone) |
|
1056 { |
|
1057 LOGPARSERR ("authErr", ret, 13, &KMBMSInfo); |
|
1058 continue; |
|
1059 } |
|
1060 else |
|
1061 { |
|
1062 tMbmsInfo.iAuthErr = authErr; |
|
1063 } |
|
1064 |
|
1065 iMBMSInfoList->AppendL(tMbmsInfo); |
|
1066 CleanupStack::Pop (item); |
|
1067 } |
|
1068 } |
|
1069 |
|
1070 |
|
1071 |
|
1072 |