|
1 /* |
|
2 * Copyright (c) 2007 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 "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: Implementation of bootstrap functions |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // This component has the following responsibilities |
|
20 // 1. Allow configuration of the BSF URL |
|
21 // 2. Open http connection to bsf |
|
22 // 3. On digest auth req get nonce |
|
23 // 4. Use this to find RAND AUTN |
|
24 // 5. Execute SIM auth, get back SRES, IK,CK |
|
25 // 6. return SRES |
|
26 // 7. Store keymaterial to a token |
|
27 |
|
28 #include <imcvcodc.h> //for base64 en/decoding |
|
29 #include <ecom.h> |
|
30 #include "dataretriever.h" |
|
31 #include "bootstrap.h" |
|
32 #include "GbaCommon.h" |
|
33 #include "GBALogger.h" |
|
34 #include "GbaSession.h" |
|
35 |
|
36 const TInt KKsNAFMaxLength = 128; |
|
37 const TInt KStringLength = 80; |
|
38 const TInt KMaxLengthIMPI = 255; |
|
39 const TInt KMaxLengthNAFID = 255; |
|
40 const TInt KMaxLengthBTID = 255; |
|
41 const TInt KMaxLengthKs = 32; |
|
42 const TInt KMaxLengthRES = 16; //16 bytes for RES |
|
43 const TInt KMaxLengthAUTS = 16; //16 bytes for AUTS |
|
44 const TInt KMaxLengthEnAUTS = 20; |
|
45 const TInt KMaxLengthRAND = 16; //16 bytes for RAND |
|
46 const TInt KMaxLengthTimeString = 30 ; |
|
47 const TInt KHTTPTagLength = 7; |
|
48 const TInt KAlgorithmTybeBufferLength = 32; |
|
49 const TInt KBufferSize255 = 255; |
|
50 const TInt KVariableIndex0 = 0; |
|
51 const TInt KVariableIndex1 = 1; |
|
52 const TInt KVariableIndex2 = 2; |
|
53 const TInt KVariableIndex3 = 3; |
|
54 const TInt KVariableIndex4 = 4; |
|
55 const TInt KVariableIndex5 = 5; |
|
56 const TInt KVariableIndex6 = 6; |
|
57 |
|
58 #define GBA_UICC_INTERFACE_IMPLE 0x20029F0F |
|
59 #define GBA_SOFTISIM_INTERFACE_IMPLE 0x20029F0E |
|
60 |
|
61 // XML tags |
|
62 _LIT8(KBTIDFlag,"<btid>"); |
|
63 _LIT8(KBTIDEndFlag,"</btid>"); |
|
64 _LIT8(KLifetimeFlag,"<lifetime>"); |
|
65 _LIT8(KLifetimeEndFlag,"</lifetime>"); |
|
66 _LIT(KGbaCredentialsFileName, "GbaCredentials.dat"); |
|
67 _LIT(KGBAStoreStandardDrive, "C:"); |
|
68 _LIT(KTimeFormat, "time %d,%d,%d,%d,%d,%d"); |
|
69 _LIT(KErrorMessage, "FAILED error = %d"); |
|
70 _LIT(Kakav1, "akav1"); |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // C3GPPBootstrap::NewL() |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 C3GPPBootstrap* C3GPPBootstrap::NewL( CGbaServerSession* aSession ) |
|
77 { |
|
78 C3GPPBootstrap* self = NewLC( aSession ); |
|
79 CleanupStack::Pop(self); |
|
80 return(self) ; |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // C3GPPBootstrap::NewLC() |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 C3GPPBootstrap* C3GPPBootstrap::NewLC( CGbaServerSession* aSession ) |
|
88 { |
|
89 C3GPPBootstrap* self = new (ELeave) C3GPPBootstrap( aSession ); |
|
90 CleanupStack::PushL(self); |
|
91 self->ConstructL(); |
|
92 return self; |
|
93 } |
|
94 |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // C3GPPBootstrap::~C3GPPBootstrap() |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 C3GPPBootstrap::~C3GPPBootstrap() |
|
101 { |
|
102 REComSession::DestroyedImplementation(iDtorIDKey); |
|
103 if(IsActive()) |
|
104 Cancel(); |
|
105 if( iSmartCardInterface ) |
|
106 { |
|
107 iSmartCardInterface->Release(); |
|
108 REComSession::FinalClose(); |
|
109 } |
|
110 delete iKsNAF; |
|
111 delete iNAFID; |
|
112 delete iRand; |
|
113 delete iBTID; |
|
114 delete iIdentity; |
|
115 delete iMasterKey; |
|
116 delete iDataRetriever; |
|
117 } |
|
118 |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // C3GPPBootstrap::ConstructL() |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 void C3GPPBootstrap::ConstructL() |
|
125 { |
|
126 GBA_TRACE_BEGIN(); |
|
127 |
|
128 GBA_TRACE_DEBUG(("initializing buffers")); |
|
129 iKsNAF = HBufC8::NewL(KKsNAFMaxLength); |
|
130 iBTID = HBufC8::NewL(KMaxLengthBTID); |
|
131 iNAFID = HBufC8::NewL(KMaxLengthNAFID); |
|
132 iIdentity = HBufC8::NewL(KMaxLengthIMPI); |
|
133 iMasterKey = HBufC8::NewL(KMaxLengthKs); |
|
134 iRand = HBufC8::NewL(KMaxLengthRAND); |
|
135 |
|
136 GBA_TRACE_DEBUG(("initializing http handler")); |
|
137 iDataRetriever = CDataRetriever::NewL( this ); |
|
138 |
|
139 iImplementationUID.iUid = GBA_UICC_INTERFACE_IMPLE; |
|
140 //if want softisim for testing |
|
141 //iImplementationUID.iUid = GBA_SOFTISIM_INTERFACE_IMPLE; |
|
142 |
|
143 //Interface is initialized based on the plug in |
|
144 if ( !IsPluginExistL() ) |
|
145 { |
|
146 GBA_TRACE_DEBUG(("There aren't plug-in existing")); |
|
147 User::LeaveIfError( KErrGeneral ); |
|
148 } |
|
149 |
|
150 GBA_TRACE_DEBUG(("requesting uicc handler")); |
|
151 iSmartCardInterface = RequestUICCInterfaceL(); |
|
152 GBA_TRACE_DEBUG(("request made")); |
|
153 |
|
154 if ( !iSmartCardInterface ) |
|
155 { |
|
156 GBA_TRACE_DEBUG(("Get interface failed")); |
|
157 User::LeaveIfError( KErrGeneral ); |
|
158 } |
|
159 |
|
160 CActiveScheduler::Add( this ); |
|
161 |
|
162 GBA_TRACE_END(); |
|
163 } |
|
164 |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // C3GPPBootstrap::C3GPPBootstrap() |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 C3GPPBootstrap::C3GPPBootstrap( CGbaServerSession* aSession ): CActive( EPriorityStandard ), |
|
171 iSmartCardInterface( NULL ), iLifetime ( 0 ),iGBARunType( ENoType ), iBSState(EIdle), iSession ( aSession ) |
|
172 { |
|
173 } |
|
174 |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // CBootstrapStateMachine::InitializeL() |
|
178 // --------------------------------------------------------------------------- |
|
179 // |
|
180 void C3GPPBootstrap::InitializeL() |
|
181 { |
|
182 if ( IsActive() ) |
|
183 { |
|
184 User::LeaveIfError( KErrInUse ); |
|
185 } |
|
186 |
|
187 iBSState = EInitialize; |
|
188 GBA_TRACE_DEBUG(("Bootstrapping State machine startL()")); |
|
189 iStatus = KRequestPending; |
|
190 SetActive(); |
|
191 TRequestStatus* status = &iStatus; |
|
192 User::RequestComplete( status, KErrNone ); |
|
193 } |
|
194 |
|
195 |
|
196 // --------------------------------------------------------------------------- |
|
197 // C3GPPBootstrap::RunL() |
|
198 // --------------------------------------------------------------------------- |
|
199 // |
|
200 void C3GPPBootstrap::RunL() |
|
201 { |
|
202 GBA_TRACE_DEBUG(("C3GPPBootstrap::RunL() -enter")); |
|
203 |
|
204 GBA_TRACE_DEBUG_NUM(("C3GPPBootstrap::RunL iStatus=%d"), iStatus.Int() ); |
|
205 GBA_TRACE_DEBUG_NUM(("C3GPPBootstrap::RunL iBSState=%d"), iBSState ); |
|
206 |
|
207 if((iBSState == ECancel) & iStatus.Int() == KErrCancel) |
|
208 { |
|
209 iBSState = EIdle; |
|
210 return; |
|
211 } |
|
212 |
|
213 User::LeaveIfError( iStatus.Int() ); |
|
214 |
|
215 switch(iBSState) |
|
216 { |
|
217 case EInitialize: |
|
218 { |
|
219 GBA_TRACE_DEBUG(("C3GPPBootstrap::RunL() - EInitialize")); |
|
220 DoBootstrapL(); |
|
221 GBA_TRACE_DEBUG(("C3GPPBootstrap::RunL() - EInitialize end")); |
|
222 break; |
|
223 } |
|
224 |
|
225 case EBusy: |
|
226 { |
|
227 GBA_TRACE_DEBUG(("C3GPPBootstrap::RunL() - EBusy")); |
|
228 iSession->StateMachineCallBack( iStatus.Int() ); |
|
229 Cleanup(); |
|
230 GBA_TRACE_DEBUG(("C3GPPBootstrap::RunL() - EBusy end")); |
|
231 break; |
|
232 } |
|
233 |
|
234 default: |
|
235 GBA_TRACE_DEBUG(("C3GPPBootstrap::RunL() - default")); |
|
236 break; |
|
237 } |
|
238 GBA_TRACE_DEBUG(("C3GPPBootstrap::RunL() -exit")); |
|
239 } |
|
240 |
|
241 |
|
242 TInt C3GPPBootstrap::RunError(TInt aError) |
|
243 { |
|
244 GBA_TRACE_DEBUG_NUM(("Failed with error = %d"), aError ); |
|
245 iSession->StateMachineCallBack( aError ); |
|
246 //Back to EBootstrapIdle |
|
247 iBSState = EIdle; |
|
248 return KErrNone; |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // C3GPPBootstrap::DoCancel() |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 void C3GPPBootstrap::DoCancel() |
|
256 { |
|
257 GBA_TRACE_DEBUG(("C3GPPBootstrap::DoCancel()")); |
|
258 switch(iBSState) |
|
259 { |
|
260 case EInitialize: |
|
261 case EBusy: |
|
262 { |
|
263 GBA_TRACE_DEBUG(("C3GPPBootstrap::DoCancel() EBootstrapDone")); |
|
264 CancelBootstrap(); |
|
265 break; |
|
266 } |
|
267 default: |
|
268 break; |
|
269 }; |
|
270 Cleanup(); |
|
271 } |
|
272 |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // C3GPPBootstrap::CancelBootstrap() |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 void C3GPPBootstrap::CancelBootstrap() |
|
279 { |
|
280 GBA_TRACE_BEGIN(); |
|
281 iBSState = ECancel; |
|
282 iDataRetriever->CancelRequest(); |
|
283 GBA_TRACE_END(); |
|
284 } |
|
285 |
|
286 |
|
287 // ----------------------------------------------------------------------------- |
|
288 // C3GPPBootstrap::DoBootstrapL() |
|
289 // ----------------------------------------------------------------------------- |
|
290 // |
|
291 void C3GPPBootstrap::DoBootstrapL( ) |
|
292 { |
|
293 |
|
294 HBufC8 *BsfUrl = HBufC8::NewLC(KMaxURLLength); |
|
295 TPtr8 PtrBSFUrl( BsfUrl->Des() ); |
|
296 |
|
297 // fetch bsf address override if available |
|
298 if ( !iSession->Server()->ReadOptionL( KGbaBSFConfiguration, PtrBSFUrl ) ) |
|
299 { |
|
300 //If no preset bsf, empty the buffer |
|
301 //We will calculate the address ourselves |
|
302 PtrBSFUrl.Zero(); |
|
303 } |
|
304 |
|
305 GBA_TRACE_DEBUG((" BSF server address:")); |
|
306 GBA_TRACE_DEBUG( PtrBSFUrl ); |
|
307 |
|
308 GetBootstrappingMaterialL( |
|
309 PtrBSFUrl, |
|
310 iSession->iGbaInputParams.iNAFName, |
|
311 iSession->iGbaInputParams.iUICCLabel, |
|
312 iSession->iGbaInputParams.iFlags, |
|
313 iSession->iGbaInputParams.iProtocolIdentifier, |
|
314 iSession->iGbaOutputParams.iKNAF, |
|
315 iSession->iGbaOutputParams.iBTID, |
|
316 iSession->iGbaOutputParams.iLifetime, |
|
317 iSession->iGbaOutputParams.iGbaRunType, |
|
318 iSession->iGbaInputParams.iAPID ); |
|
319 |
|
320 GBA_TRACE_DEBUG(("Bootstrap Request is sent out, let us wait for callback ")); |
|
321 |
|
322 CleanupStack::PopAndDestroy( BsfUrl ); |
|
323 } |
|
324 |
|
325 // ----------------------------------------------------------------------------- |
|
326 // C3GPPBootstrap::GetBootstrappingMaterialL() |
|
327 // ----------------------------------------------------------------------------- |
|
328 // |
|
329 void C3GPPBootstrap::GetBootstrappingMaterialL( |
|
330 const TDesC8& aBSFAddress, |
|
331 const TDesC8& aNAFURL, |
|
332 const TDesC8& aUICC_LABEL, |
|
333 const TUint8& aFlags, |
|
334 const TDesC8& aKeyUsage, |
|
335 TDes8 &aKsNAF, |
|
336 TDes8 &aBTID, |
|
337 TTime &aLifetime, |
|
338 EGBARunType& aGBARunType, |
|
339 const TInt& aIAPID ) |
|
340 { |
|
341 GBA_TRACE_BEGIN(); |
|
342 //save the return buffer's pointer. Copy the databack when bootstrapping is done |
|
343 iCallerKsNAFBuf = &aKsNAF; |
|
344 iCallerLifetime = &aLifetime; |
|
345 iCallerBTIDBuf = &aBTID; |
|
346 iCallerGBARunType = &aGBARunType; |
|
347 |
|
348 TUriParser8 uriparser; |
|
349 |
|
350 |
|
351 GBA_TRACE_DEBUG(("the given naf url is:")); |
|
352 GBA_TRACE_DEBUG(aNAFURL); |
|
353 |
|
354 //this implementation is used to solve symbian API's problem |
|
355 // when parsing pure ip address |
|
356 if ( (aNAFURL.FindF(KHTTPTag) != KErrNotFound) || (aNAFURL.FindF(KHTTPSTag) != KErrNotFound) ) |
|
357 { |
|
358 //the naf url has http tag |
|
359 User::LeaveIfError( uriparser.Parse(aNAFURL) ); |
|
360 } |
|
361 else |
|
362 { |
|
363 GBA_TRACE_DEBUG(("the naf url has no http tag, add one for parser")); |
|
364 HBufC8* temp = HBufC8::NewL( aNAFURL.Length() + KHTTPTagLength ); |
|
365 CleanupStack::PushL(temp); |
|
366 TPtr8 ptrtemp = temp->Des(); |
|
367 ptrtemp.Copy( KHTTPTag ); |
|
368 ptrtemp.Append(aNAFURL); |
|
369 GBA_TRACE_DEBUG( *temp ); |
|
370 User::LeaveIfError( uriparser.Parse( *temp ) ); |
|
371 CleanupStack::PopAndDestroy(temp); |
|
372 } |
|
373 |
|
374 |
|
375 //Calculate the NAFID, NAFID= NAF_FQDN + keyusage |
|
376 |
|
377 TPtr8 ptrNAFID = iNAFID->Des(); |
|
378 //parse the FQDN out from NAFaddress |
|
379 ptrNAFID.Copy( uriparser.Extract(EUriHost) ); |
|
380 ptrNAFID.Append( aKeyUsage ); |
|
381 |
|
382 GBA_TRACE_DEBUG(("NAF ID =")); |
|
383 GBA_TRACE_DEBUG(*iNAFID); |
|
384 |
|
385 |
|
386 GBA_TRACE_DEBUG(("UICC label is:")); |
|
387 GBA_TRACE_DEBUG(aUICC_LABEL); |
|
388 |
|
389 // Get IMPI |
|
390 TPtr8 ptrIdentity = iIdentity->Des(); |
|
391 //Clean the buffer and Set Length to 0 |
|
392 ptrIdentity.Zero(); |
|
393 |
|
394 //get the IMPI from smart card |
|
395 iSmartCardInterface->QueryIdentityL(ptrIdentity); |
|
396 |
|
397 GBA_TRACE_DEBUG(("IMPI is:")); |
|
398 GBA_TRACE_DEBUG( *iIdentity ); |
|
399 |
|
400 // Get GBA_U availability |
|
401 // EFalse means the call is not from gba client directly. |
|
402 iGBAUAvailable = CheckGBAUAvailabilityL( EFalse ); |
|
403 |
|
404 |
|
405 if ( iGBAUAvailable ) |
|
406 { |
|
407 GBA_TRACE_DEBUG(("GBA-U is available")); |
|
408 } |
|
409 else |
|
410 { |
|
411 GBA_TRACE_DEBUG(("GBA-U is not available")); |
|
412 } |
|
413 |
|
414 // Load Credentails from store. |
|
415 // First compare the IMPI and key lifetime |
|
416 // If IMPI is different or key expires, then return EFalse to |
|
417 // start a new bootstrapping. |
|
418 |
|
419 // If IMPI & key lifetime checking both ok, |
|
420 // GBA_U will load B-TID and key lifetime and ask smart card to |
|
421 // calculate the Ks_NAF |
|
422 // GBA_ME will load Ks, Rand, B-TId and key lifetime and calculate it |
|
423 // by ourselves. |
|
424 |
|
425 // The GBA run type is also taken from cached store |
|
426 |
|
427 if( !(aFlags & EGBAForce) && LoadCredentialsL() ) |
|
428 { |
|
429 GBA_TRACE_DEBUG(("Still ok ???")); |
|
430 iStatus = KRequestPending; |
|
431 SetActive(); |
|
432 iBSState = EBusy; |
|
433 TRequestStatus* callerStatus = &iStatus; |
|
434 User::RequestComplete(callerStatus, KErrNone); |
|
435 return; |
|
436 } |
|
437 |
|
438 // check if the BSF URL was overriden |
|
439 TBuf8<KMaxURLLength> BsfUrl; |
|
440 |
|
441 if ( aBSFAddress.Length() == 0 ) |
|
442 { |
|
443 GBA_TRACE_DEBUG(("No preset BSF URL, calcuate from IMPI")); |
|
444 iSmartCardInterface->QueryHomeNetworkDnL(BsfUrl); |
|
445 } |
|
446 else |
|
447 { |
|
448 if ( iSmartCardInterface->InterfaceIs2G() ) |
|
449 { |
|
450 BsfUrl.Copy( KHTTPSTag ); |
|
451 } |
|
452 else |
|
453 { |
|
454 BsfUrl.Copy( KHTTPTag ); |
|
455 } |
|
456 BsfUrl.Append( aBSFAddress ); |
|
457 } |
|
458 |
|
459 GBA_TRACE_DEBUG(("The bsf url is:")); |
|
460 GBA_TRACE_DEBUG(BsfUrl); |
|
461 |
|
462 // dataretriever makes the actual http connection to the bsf |
|
463 // when it completes values can be retrieved |
|
464 TUriParser8 uriparser1; |
|
465 User::LeaveIfError( uriparser1.Parse(BsfUrl) ); |
|
466 |
|
467 iStatus = KRequestPending; |
|
468 SetActive(); // event should come from bootstrapper |
|
469 iBSState = EBusy; |
|
470 |
|
471 |
|
472 //set reaml as FQDN of bsf |
|
473 iDataRetriever->MakeRequestL( &iStatus, *iIdentity, uriparser1.Extract( EUriHost ), BsfUrl, aNAFURL, aIAPID ); |
|
474 GBA_TRACE_END(); |
|
475 } |
|
476 |
|
477 // ----------------------------------------------------------------------------- |
|
478 // C3GPPBootstrap::GBAUAvailabilityL() |
|
479 // ----------------------------------------------------------------------------- |
|
480 // |
|
481 TBool C3GPPBootstrap::GBAUAvailabilityL() |
|
482 { |
|
483 //the call is from gba client directly |
|
484 return CheckGBAUAvailabilityL( ETrue ); |
|
485 } |
|
486 |
|
487 // ----------------------------------------------------------------------------- |
|
488 // C3GPPBootstrap::GetState() |
|
489 // ----------------------------------------------------------------------------- |
|
490 // |
|
491 TInt C3GPPBootstrap::GetState() const |
|
492 { |
|
493 return iBSState; |
|
494 }; |
|
495 |
|
496 // ----------------------------------------------------------------------------- |
|
497 // C3GPPBootstrap::CompleteBootStrappingL() |
|
498 // This is the callback function called by datareceiver |
|
499 // when B-TID and key lifetime is received from BSF |
|
500 // ----------------------------------------------------------------------------- |
|
501 // |
|
502 void C3GPPBootstrap::CompleteBootStrappingL( TInt aError ) |
|
503 { |
|
504 // check that we have handler to receive data |
|
505 GBA_TRACE_DEBUG(("C3GPPBootstrapImpl::CompleteBootStrappingL")); |
|
506 |
|
507 // Check if triplet auth failed. |
|
508 if ( aError != KErrNone ) |
|
509 { |
|
510 GBA_TRACE_DEBUG(("Bootstrap failed")); |
|
511 return; |
|
512 } |
|
513 |
|
514 HBufC8* rspbody = iDataRetriever->QueryResponseValueL(); |
|
515 if (!rspbody) |
|
516 { |
|
517 GBA_TRACE_DEBUG(("Error no response body")); |
|
518 User::LeaveIfError( KErrGeneral ); |
|
519 } |
|
520 CleanupStack::PushL( rspbody ); |
|
521 GBA_TRACE_DEBUG(("response body is received. Loaded response:")); |
|
522 GBA_TRACE_DEBUG(*rspbody); |
|
523 |
|
524 // make sure it contains a B-TID |
|
525 TInt p = rspbody->FindC(KBTIDFlag); |
|
526 TInt e = rspbody->FindC(KBTIDEndFlag); |
|
527 if ( p != KErrNotFound && e != KErrNotFound) |
|
528 { |
|
529 p += TPtrC8(KBTIDFlag).Length(); |
|
530 TInt length = e-p; |
|
531 |
|
532 //Copy the B-TID value to caller's buffer |
|
533 //Continue getting Ks_(ext)_NAF |
|
534 iCallerBTIDBuf->Copy(rspbody->Mid(p,length)); |
|
535 |
|
536 //The B-TID needs to be stored in smart card. |
|
537 //Must save here for later use. |
|
538 TPtr8 ptrBTID = iBTID->Des(); |
|
539 ptrBTID.Copy(*iCallerBTIDBuf); |
|
540 } |
|
541 else |
|
542 { |
|
543 GBA_TRACE_DEBUG(("Error didn't contain BTID")); |
|
544 CleanupStack::PopAndDestroy(rspbody); |
|
545 User::LeaveIfError( KErrGeneral ); |
|
546 } |
|
547 |
|
548 GBA_TRACE_DEBUG(("Extracted B-TID:")); |
|
549 GBA_TRACE_DEBUG(*iBTID); |
|
550 |
|
551 TBuf8<KMaxLengthTimeString> LifetimeBuf; |
|
552 p = rspbody->FindC(KLifetimeFlag); |
|
553 e = rspbody->FindC(KLifetimeEndFlag); |
|
554 if ( p != KErrNotFound && e != KErrNotFound ) |
|
555 { |
|
556 p += TPtrC8(KLifetimeFlag).Length(); |
|
557 TInt length = e-p; |
|
558 LifetimeBuf.Copy( rspbody->Mid(p,length) ); |
|
559 } |
|
560 |
|
561 CleanupStack::PopAndDestroy(rspbody); |
|
562 |
|
563 GBA_TRACE_DEBUG(("Lifetime in string:")); |
|
564 GBA_TRACE_DEBUG(LifetimeBuf); |
|
565 |
|
566 //Convert the string to TTime object |
|
567 // |
|
568 if ( !ConvertStringToTTime( LifetimeBuf, &iLifetime ) ) |
|
569 { |
|
570 GBA_TRACE_DEBUG(("Couldn't convert lifetime")); |
|
571 User::LeaveIfError( KErrGeneral ); |
|
572 } |
|
573 |
|
574 // Set the lifetime to caller's buffer |
|
575 *iCallerLifetime = iLifetime; |
|
576 |
|
577 //After bootstrap is succesful, the B-TID and keylifetime |
|
578 //should be sent back to smart card to store in GBA_U. |
|
579 if ( iGBAUAvailable ) |
|
580 { |
|
581 HBufC8* lifetime = HBufC8::NewLC( LifetimeBuf.Length() ); |
|
582 TPtr8 lifetimePtr = lifetime->Des(); |
|
583 lifetimePtr.Copy( LifetimeBuf ); |
|
584 TInt err = iSmartCardInterface->UpdateGBADataL( *iBTID, *lifetime ); |
|
585 CleanupStack::PopAndDestroy( lifetime ); |
|
586 User::LeaveIfError( err ); |
|
587 iGBARunType = EGBAU; |
|
588 } |
|
589 else |
|
590 { |
|
591 if ( iSmartCardInterface->InterfaceIs2G() ) |
|
592 { |
|
593 iGBARunType = E2GGBA; |
|
594 } |
|
595 else |
|
596 { |
|
597 iGBARunType = E3GGBAME; |
|
598 } |
|
599 } |
|
600 |
|
601 // Set the GBA run type back to caller |
|
602 *iCallerGBARunType = iGBARunType; |
|
603 // cache the new fangled credentials |
|
604 StoreCredentialsL(); |
|
605 |
|
606 // Generate Key material and copy it to parameter being returned |
|
607 if ( GenerateKeyMaterialL() ) |
|
608 { |
|
609 |
|
610 if ( iGBAUAvailable ) |
|
611 { |
|
612 GBA_TRACE_DEBUG(("It is GBA_U mode,The ks_ext_naf is calculated by smart card")); |
|
613 GBA_TRACE_DEBUG_BINARY( *iKsNAF); |
|
614 } |
|
615 else |
|
616 { |
|
617 GBA_TRACE_DEBUG(("It is GBA_ME mode,The ks_naf is calculated by gbamodule")); |
|
618 GBA_TRACE_DEBUG_BINARY( *iKsNAF ); |
|
619 GBA_TRACE_DEBUG(("It is GBA_ME mode,The ks_naf is calculated by gbamodule 1")); |
|
620 } |
|
621 //Set KsNAF back to caller's buffer |
|
622 iCallerKsNAFBuf->Copy(*iKsNAF); |
|
623 } |
|
624 else |
|
625 { |
|
626 GBA_TRACE_DEBUG(("Error no keys")); |
|
627 User::LeaveIfError( KErrGeneral ); |
|
628 } |
|
629 GBA_TRACE_END(); |
|
630 } |
|
631 |
|
632 |
|
633 // ----------------------------------------------------------------------------- |
|
634 // C3GPPBootstrap::GetCredentialsL() |
|
635 // function GetCredentialsL |
|
636 // discussion: Gets URI, Realm, Nonce and AuthenticationType, and gives back Username and Password. |
|
637 // param: :aURI : the address of the bsf. |
|
638 // param: :aRealm : the realm of the bsf. |
|
639 // param: :aNonce : the nonce sent by the bsf. |
|
640 // param: :aAuthenticationType : the authentication type sent by the bsf. |
|
641 // param: :aUsername : Generated Username by underlying algorithm (AKA or SIM). |
|
642 // param: :aPassword : Generated Password by underlying algorithm (AKA or SIM). |
|
643 // result: The result of the operation: true for success and false for failure! |
|
644 // ----------------------------------------------------------------------------- |
|
645 TBool C3GPPBootstrap::GetCredentialsL(const TUriC8& /*aURI*/, RString aRealm, RString aNonce, |
|
646 RString aAlgorithm, |
|
647 RString& aUsername, |
|
648 RString& aPassword, |
|
649 RString& aResync, |
|
650 TBool& aResyncRequired) |
|
651 { |
|
652 GBA_TRACE_BEGIN(); |
|
653 |
|
654 // smartcard interface returns true if credentials are received |
|
655 TBool GotKeys = EFalse; |
|
656 TInt pushCount = 0; |
|
657 |
|
658 HBufC *algType=HBufC::NewLC( KAlgorithmTybeBufferLength ); |
|
659 pushCount++; |
|
660 |
|
661 TPtr pAlgType(algType->Des()); |
|
662 pAlgType.Copy(aAlgorithm.DesC()); |
|
663 pAlgType.LowerCase(); |
|
664 |
|
665 TInt SecurityAlgorithm; |
|
666 |
|
667 //AuthenticationType MUST be AKAV1-MD5 |
|
668 //Find() function returns the offset of the data sequence from the beginning of |
|
669 //this descriptor's data. KErrNotFound, if the data sequence cannot be found. |
|
670 if ( pAlgType.Find(Kakav1) != KErrNotFound ) |
|
671 { |
|
672 GBA_TRACE_DEBUG((" algorithm is akav1")); |
|
673 SecurityAlgorithm = EAKAv1; |
|
674 } |
|
675 else |
|
676 { |
|
677 GBA_TRACE_DEBUG((" algorithm is unknown")); |
|
678 SecurityAlgorithm = ESecAlgUnknown; |
|
679 } |
|
680 |
|
681 HBufC8 *nonce = HBufC8::NewLC(KStringLength); |
|
682 pushCount++; |
|
683 |
|
684 TPtr8 ptrNonce = nonce->Des(); |
|
685 ptrNonce.Copy(aNonce.DesC()); |
|
686 |
|
687 GBA_TRACE_DEBUG((" The base64 encoded nonce value from BSF server (RAND + AUTN)")); |
|
688 GBA_TRACE_DEBUG(aNonce.DesC()); |
|
689 GBA_TRACE_DEBUG((" The base64 encoded nonce value after copying into buffer:")); |
|
690 GBA_TRACE_DEBUG(*nonce); |
|
691 |
|
692 //buffer used to store decoded nonce value |
|
693 HBufC8 *decodedNonce = HBufC8::NewLC(KStringLength); |
|
694 pushCount++; |
|
695 |
|
696 TPtr8 ptrDecNonce = decodedNonce->Des(); |
|
697 |
|
698 //fill the buffer with zeros. |
|
699 ptrDecNonce.FillZ(); |
|
700 |
|
701 // decodes the base64 nonce |
|
702 TImCodecB64 b64coder; |
|
703 b64coder.Initialise(); |
|
704 b64coder.Decode( *nonce, ptrDecNonce ); |
|
705 |
|
706 GBA_TRACE_DEBUG((" The decoded nonce value in binary")); |
|
707 GBA_TRACE_DEBUG_BINARY( *decodedNonce ); |
|
708 |
|
709 //Allocate buffer RES, password for http digest |
|
710 HBufC8* RES = HBufC8::NewLC( KMaxLengthRES ); |
|
711 pushCount++; |
|
712 TPtr8 ptrRES = RES->Des(); |
|
713 |
|
714 //Allocate buffer AUTS, if the out of sync happens |
|
715 HBufC8* AUTS = HBufC8::NewLC( KMaxLengthAUTS ); |
|
716 pushCount++; |
|
717 TPtr8 ptrAUTS = AUTS->Des(); |
|
718 |
|
719 GBA_TRACE_DEBUG((" check algorithm value")); |
|
720 switch (SecurityAlgorithm) |
|
721 { |
|
722 case EAKAv1: |
|
723 { |
|
724 GBA_TRACE_DEBUG((" EAKAv1")); |
|
725 aResyncRequired = EFalse; |
|
726 //Set the RAND AUTN to smart card |
|
727 GotKeys = iSmartCardInterface->QueryAuthenticationL( *decodedNonce, ptrRES, ptrAUTS ); |
|
728 |
|
729 TBool AUTSBufEmpty = EFalse; |
|
730 |
|
731 // No out of sync detected |
|
732 if ( GotKeys || AUTS->Length() == 0 ) |
|
733 { |
|
734 GBA_TRACE_DEBUG(("AUTS is not returned. No out of sync detected")); |
|
735 AUTSBufEmpty = ETrue; |
|
736 } |
|
737 |
|
738 if ( !GotKeys && !AUTSBufEmpty && AUTS->Length()>0 ) |
|
739 { |
|
740 aResyncRequired = ETrue; |
|
741 GBA_TRACE_DEBUG(("AUTS is returned. Resync is required")); |
|
742 GBA_TRACE_DEBUG_BINARY(*AUTS); |
|
743 } |
|
744 |
|
745 // keep rand |
|
746 // as the first 16 bytes in Nonce as RAND |
|
747 TPtr8 ptrRand = iRand->Des(); |
|
748 ptrRand.Copy( ptrDecNonce.Left(KMaxLengthRAND) ); |
|
749 |
|
750 GBA_TRACE_DEBUG(("RAND is:")); |
|
751 GBA_TRACE_DEBUG_BINARY(*iRand); |
|
752 |
|
753 //if GBA_U is available, we donot need to save the |
|
754 //Ks. It is stored on smart card |
|
755 |
|
756 if( GotKeys && !iGBAUAvailable ) |
|
757 { |
|
758 // keep master key |
|
759 TPtr8 ptrMasterKey = iMasterKey->Des(); |
|
760 if ( !iSmartCardInterface->QueryKs( ptrMasterKey ) ) |
|
761 { |
|
762 User::LeaveIfError( KErrGeneral ); |
|
763 } |
|
764 } |
|
765 } |
|
766 break; |
|
767 |
|
768 case ESecAlgUnknown: |
|
769 { |
|
770 User::LeaveIfError( KErrArgument ); |
|
771 } |
|
772 break; |
|
773 |
|
774 default: |
|
775 { |
|
776 User::LeaveIfError( KErrArgument ); |
|
777 } |
|
778 break; |
|
779 } |
|
780 |
|
781 |
|
782 GBA_TRACE_DEBUG(("AKA password RES for BSF")); |
|
783 GBA_TRACE_DEBUG_BINARY( *RES ); |
|
784 |
|
785 // if received keys or auts then we can attempt to authenticate towards the BSF |
|
786 // is this code setting the password? Password should be the RES or empty |
|
787 |
|
788 if ( aResyncRequired ) |
|
789 //AUTS returned |
|
790 { |
|
791 _LIT8(KEmptyPwd,""); |
|
792 aPassword = aRealm.Pool().OpenStringL(KEmptyPwd); |
|
793 } |
|
794 |
|
795 if(GotKeys) |
|
796 { |
|
797 //Set RES as password |
|
798 TRAPD( err,aPassword = aRealm.Pool().OpenStringL(*RES) ); |
|
799 err = err; |
|
800 GBA_TRACE_DEBUG_NUM((" Set RES as password error %d"), err ); |
|
801 } |
|
802 |
|
803 //Set IMPI as username |
|
804 aUsername = aRealm.Pool().OpenStringL(iIdentity->Des()); |
|
805 |
|
806 // convert received auts into a string |
|
807 if ( aResyncRequired ) |
|
808 { |
|
809 GBA_TRACE_DEBUG(("adding auts to the headers")); |
|
810 HBufC8 *encodedAUTS = HBufC8::NewLC( KMaxLengthEnAUTS ); |
|
811 pushCount++; |
|
812 TPtr8 ptrEncAUTS = encodedAUTS->Des(); |
|
813 ptrEncAUTS.FillZ(); |
|
814 |
|
815 b64coder.Encode( *AUTS, ptrEncAUTS ); |
|
816 |
|
817 GBA_TRACE_DEBUG(*encodedAUTS); |
|
818 |
|
819 aResync = aRealm.Pool().OpenStringL(*encodedAUTS); |
|
820 } |
|
821 |
|
822 CleanupStack::PopAndDestroy(pushCount); |
|
823 GBA_TRACE_END(); |
|
824 return GotKeys; |
|
825 } |
|
826 |
|
827 // ----------------------------------------------------------------------------- |
|
828 // C3GPPBootstrap::GenerateKeyMaterialL() |
|
829 // ----------------------------------------------------------------------------- |
|
830 TBool C3GPPBootstrap::GenerateKeyMaterialL() |
|
831 { |
|
832 TPtr8 derivedKey(iKsNAF->Des()); |
|
833 |
|
834 if ( iGBAUAvailable ) |
|
835 { |
|
836 iSmartCardInterface->QueryKeyMaterialL( |
|
837 KNullDesC8, |
|
838 KNullDesC8, |
|
839 iIdentity->Des(), |
|
840 *iNAFID, |
|
841 derivedKey |
|
842 ); |
|
843 return ETrue; |
|
844 } |
|
845 else |
|
846 { |
|
847 iSmartCardInterface->QueryKeyMaterialL( |
|
848 iMasterKey->Des(), |
|
849 iRand->Des(), |
|
850 iIdentity->Des(), |
|
851 *iNAFID, |
|
852 derivedKey |
|
853 ); |
|
854 return ETrue; |
|
855 } |
|
856 } |
|
857 |
|
858 |
|
859 // ----------------------------------------------------------------------------- |
|
860 // C3GPPBootstrap::Cleanup() |
|
861 // ----------------------------------------------------------------------------- |
|
862 void C3GPPBootstrap::Cleanup() |
|
863 { |
|
864 GBA_TRACE_DEBUG(("Enter ")); |
|
865 iBSState = EIdle; |
|
866 iGBAUAvailable = EFalse; |
|
867 iGBARunType = ENoType; |
|
868 |
|
869 iKsNAF->Des().Zero(); |
|
870 iBTID->Des().Zero(); |
|
871 iLifetime = 0; |
|
872 |
|
873 iIdentity->Des().Zero(); //buffer for impi |
|
874 iNAFID->Des().Zero(); //buffer for nafid |
|
875 iRand->Des().Zero(); //buffer for rand |
|
876 iMasterKey->Des().Zero(); //buffer for Ks |
|
877 GBA_TRACE_DEBUG(("Exit ")); |
|
878 } |
|
879 |
|
880 |
|
881 // ----------------------------------------------------------------------------- |
|
882 // C3GPPBootstrap::LoadCredentials() |
|
883 // GBA_ME, load the cached credentails to calculate ks_naf |
|
884 // ----------------------------------------------------------------------------- |
|
885 TBool C3GPPBootstrap::LoadCredentialsL() |
|
886 { |
|
887 GBA_TRACE_DEBUG(("Enter ")); |
|
888 TBool result = EFalse; |
|
889 |
|
890 // check if the values are in memory |
|
891 // IsStillValid needs to be implemented |
|
892 //if( iMasterKey && IsStillValid( &iLifetime )) |
|
893 //{ |
|
894 //GBA_TRACE_DEBUG(("using the Ks in memory")); |
|
895 //return ETrue; |
|
896 //} |
|
897 |
|
898 GBA_TRACE_DEBUG(("Checking if the credtials are stored")); |
|
899 |
|
900 RFs fs; |
|
901 User::LeaveIfError( fs.Connect() ); |
|
902 CleanupClosePushL(fs); |
|
903 TFindFile folder( fs ); |
|
904 |
|
905 TFileName fullPath; |
|
906 |
|
907 MakePrivateFilenameL(fs, KGbaCredentialsFileName, fullPath); |
|
908 GBA_TRACE_DEBUG(fullPath); |
|
909 |
|
910 TInt err = folder.FindByDir( fullPath, KNullDesC); |
|
911 |
|
912 if ( err != KErrNone ) |
|
913 { |
|
914 GBA_TRACE_DEBUG(("No credentials store available")); |
|
915 CleanupStack::PopAndDestroy(&fs); |
|
916 return result; |
|
917 } |
|
918 else |
|
919 { |
|
920 GBA_TRACE_DEBUG(("Found credentials store ")); |
|
921 CDictionaryFileStore* pStore = CDictionaryFileStore::OpenLC(fs,fullPath,KUidGBACredRoot); |
|
922 |
|
923 TInt length = 0; |
|
924 HBufC8* tmpIdentity = NULL; |
|
925 |
|
926 //Read IMPI |
|
927 if ( pStore->IsPresentL( KUidIMPI ) ) |
|
928 { |
|
929 GBA_TRACE_DEBUG(("IMPI is present ")); |
|
930 RDictionaryReadStream reader; |
|
931 CleanupClosePushL(reader); |
|
932 reader.OpenL(*pStore,KUidIMPI); |
|
933 length = reader.ReadInt32L(); |
|
934 tmpIdentity = HBufC8::NewL(length); |
|
935 TPtr8 ptrtmpIdentity = tmpIdentity->Des(); |
|
936 |
|
937 reader.ReadL(ptrtmpIdentity,length); |
|
938 GBA_TRACE_DEBUG(("IMPI = ")); |
|
939 GBA_TRACE_DEBUG(ptrtmpIdentity); |
|
940 CleanupStack::PopAndDestroy( &reader ); |
|
941 } |
|
942 |
|
943 //Read ks |
|
944 if ( pStore->IsPresentL( KUidKs ) ) |
|
945 { |
|
946 GBA_TRACE_DEBUG(("Ks is present, the cached credentials are from GBA_ME ")); |
|
947 GBA_TRACE_DEBUG(("Ks is present ")); |
|
948 RDictionaryReadStream reader1; |
|
949 CleanupClosePushL(reader1); |
|
950 reader1.OpenL(*pStore,KUidKs); |
|
951 length = reader1.ReadInt32L(); |
|
952 |
|
953 TPtr8 ptrmk = iMasterKey->Des(); |
|
954 ptrmk.Zero(); |
|
955 reader1.ReadL(ptrmk,length); |
|
956 ptrmk.SetLength(length); |
|
957 GBA_TRACE_DEBUG(("Ks = ")); |
|
958 GBA_TRACE_DEBUG_BINARY(ptrmk); |
|
959 CleanupStack::PopAndDestroy( &reader1 ); |
|
960 } |
|
961 |
|
962 |
|
963 //Read rand |
|
964 if ( pStore->IsPresentL( KUidRand ) ) |
|
965 { |
|
966 GBA_TRACE_DEBUG(("Rand is present ")); |
|
967 RDictionaryReadStream reader2; |
|
968 CleanupClosePushL(reader2); |
|
969 reader2.OpenL(*pStore,KUidRand); |
|
970 length = reader2.ReadInt32L(); |
|
971 |
|
972 TPtr8 ptrRand = iRand->Des(); |
|
973 ptrRand.Zero(); |
|
974 reader2.ReadL(ptrRand,length); |
|
975 ptrRand.SetLength(length); |
|
976 GBA_TRACE_DEBUG(("Rand = ")); |
|
977 GBA_TRACE_DEBUG_BINARY(ptrRand); |
|
978 CleanupStack::PopAndDestroy( &reader2 ); |
|
979 } |
|
980 |
|
981 //Read BTID |
|
982 if ( pStore->IsPresentL( KUidBTID ) ) |
|
983 { |
|
984 GBA_TRACE_DEBUG(("B-TID is present ")); |
|
985 RDictionaryReadStream reader3; |
|
986 CleanupClosePushL(reader3); |
|
987 reader3.OpenL(*pStore,KUidBTID); |
|
988 length = reader3.ReadInt32L(); |
|
989 |
|
990 TPtr8 ptrBTID = iBTID->Des(); |
|
991 ptrBTID.Zero(); |
|
992 reader3.ReadL(ptrBTID,length); |
|
993 ptrBTID.SetLength(length); |
|
994 GBA_TRACE_DEBUG(("BTID = ")); |
|
995 GBA_TRACE_DEBUG(ptrBTID); |
|
996 CleanupStack::PopAndDestroy( &reader3 ); |
|
997 } |
|
998 |
|
999 //Read key lifetime |
|
1000 if ( pStore->IsPresentL( KUidkeylifetime ) ) |
|
1001 { |
|
1002 GBA_TRACE_DEBUG(("key lifetime is present ")); |
|
1003 RDictionaryReadStream reader4; |
|
1004 CleanupClosePushL(reader4); |
|
1005 reader4.OpenL(*pStore,KUidkeylifetime); |
|
1006 iLifetime = NULL; |
|
1007 TPtr8 ptrkeylifetime((TUint8*)&iLifetime,sizeof(TTime)); |
|
1008 |
|
1009 reader4.ReadL(ptrkeylifetime,sizeof(TTime)); |
|
1010 GBA_TRACE_DEBUG(("keylifetime = ")); |
|
1011 GBA_TRACE_TIME( iLifetime ); |
|
1012 CleanupStack::PopAndDestroy( &reader4 ); |
|
1013 } |
|
1014 |
|
1015 //Read GBA run type |
|
1016 if ( pStore->IsPresentL( KUidGBARunType ) ) |
|
1017 { |
|
1018 GBA_TRACE_DEBUG(("GBARunType is present ")); |
|
1019 RDictionaryReadStream reader5; |
|
1020 CleanupClosePushL(reader5); |
|
1021 reader5.OpenL(*pStore,KUidGBARunType); |
|
1022 iGBARunType = (EGBARunType)reader5.ReadInt8L(); |
|
1023 CleanupStack::PopAndDestroy( &reader5 ); |
|
1024 } |
|
1025 |
|
1026 |
|
1027 //done with store |
|
1028 CleanupStack::PopAndDestroy( pStore ); |
|
1029 CleanupStack::PopAndDestroy(&fs); |
|
1030 |
|
1031 result = IsStillValid( &iLifetime ) && *tmpIdentity == *iIdentity; |
|
1032 |
|
1033 //smart card has been changed |
|
1034 if ( *tmpIdentity != *iIdentity ) |
|
1035 { |
|
1036 iSmartCardInterface->NotifyCardChangeL(); |
|
1037 } |
|
1038 |
|
1039 GBA_TRACE_DEBUG(("Cached IMPI = ")); |
|
1040 GBA_TRACE_DEBUG(*tmpIdentity); |
|
1041 GBA_TRACE_DEBUG(("IMPI from smart card = ")); |
|
1042 GBA_TRACE_DEBUG(*iIdentity); |
|
1043 |
|
1044 // this has served its purpose |
|
1045 delete tmpIdentity; |
|
1046 |
|
1047 // if the credentials aren't valid delete the old key |
|
1048 if ( !result ) |
|
1049 { |
|
1050 GBA_TRACE_DEBUG(("clean buffers since the key wasn't valid anymore or the card had been changed")); |
|
1051 // clean up the created buffers; |
|
1052 iMasterKey->Des().Zero(); |
|
1053 iRand->Des().Zero(); |
|
1054 iBTID->Des().Zero(); |
|
1055 iLifetime = NULL; |
|
1056 } |
|
1057 else |
|
1058 { |
|
1059 GBA_TRACE_DEBUG(("cached keys were still valid")); |
|
1060 GBA_TRACE_DEBUG(("Cached B-TID is:")); |
|
1061 GBA_TRACE_DEBUG(*iBTID ); |
|
1062 |
|
1063 iCallerBTIDBuf->Copy( *iBTID ); |
|
1064 |
|
1065 // Set the run type |
|
1066 *iCallerGBARunType = iGBARunType; |
|
1067 |
|
1068 //Set key life time |
|
1069 *iCallerLifetime = iLifetime; |
|
1070 |
|
1071 // generate material based on the stored credentials |
|
1072 if ( GenerateKeyMaterialL() ) |
|
1073 { |
|
1074 if ( iGBAUAvailable ) |
|
1075 { |
|
1076 GBA_TRACE_DEBUG(("Calu from Cached Ks: It is GBA_U mode,The ks_ext_naf is calculated by smart card")); |
|
1077 GBA_TRACE_DEBUG_BINARY( *iKsNAF ); |
|
1078 GBA_TRACE_DEBUG(("Calu test11")); |
|
1079 |
|
1080 } |
|
1081 else |
|
1082 { |
|
1083 GBA_TRACE_DEBUG(("Calu from Cached Ks. It is GBA_ME mode,The ks_naf is calculated by gbamodule")); |
|
1084 GBA_TRACE_DEBUG_BINARY( *iKsNAF ); |
|
1085 } |
|
1086 //Set KsNAF back to caller's buffer |
|
1087 iCallerKsNAFBuf->Copy(*iKsNAF); |
|
1088 } |
|
1089 else |
|
1090 { |
|
1091 GBA_TRACE_DEBUG(("Error no keys")); |
|
1092 result = EFalse; |
|
1093 } |
|
1094 } |
|
1095 GBA_TRACE_DEBUG(("Calu test11")); |
|
1096 } |
|
1097 return result; |
|
1098 } |
|
1099 |
|
1100 |
|
1101 |
|
1102 // ----------------------------------------------------------------------------- |
|
1103 // C3GPPBootstrap::StoreCredentialsL() |
|
1104 // Store bootstrapping credentails into the store |
|
1105 // GBA_ME: IMPI, Ks, Rand, B-TID, key lifetime |
|
1106 // GBA_U: IMPI, B-TID, key lifetime |
|
1107 // ----------------------------------------------------------------------------- |
|
1108 void C3GPPBootstrap::StoreCredentialsL() |
|
1109 { |
|
1110 GBA_TRACE_DEBUG(("Save credentials into dictionary store")); |
|
1111 |
|
1112 RFs fs; |
|
1113 User::LeaveIfError(fs.Connect()); |
|
1114 CleanupClosePushL(fs); |
|
1115 TFindFile folder( fs ); |
|
1116 |
|
1117 TFileName fullPath; |
|
1118 |
|
1119 MakePrivateFilenameL(fs, KGbaCredentialsFileName, fullPath); |
|
1120 EnsurePathL(fs, fullPath ); |
|
1121 |
|
1122 GBA_TRACE_DEBUG(fullPath); |
|
1123 TInt err = folder.FindByDir( fullPath, KNullDesC ); |
|
1124 |
|
1125 if ( err == KErrNotFound || err == KErrNone || err == KErrPathNotFound ) |
|
1126 { |
|
1127 |
|
1128 CDictionaryFileStore* pStore = CDictionaryFileStore::OpenLC(fs,fullPath,KUidGBACredRoot); |
|
1129 |
|
1130 //Save IMPI |
|
1131 RDictionaryWriteStream writer; |
|
1132 CleanupClosePushL(writer); |
|
1133 writer.AssignL(*pStore, KUidIMPI); |
|
1134 writer.WriteInt32L(iIdentity->Size()); |
|
1135 writer.WriteL(*iIdentity); |
|
1136 writer.CommitL(); |
|
1137 CleanupStack::PopAndDestroy( &writer ); |
|
1138 |
|
1139 //GBA_U doesn't need to save ks and rand. |
|
1140 if ( !iGBAUAvailable ) |
|
1141 { |
|
1142 GBA_TRACE_DEBUG(("It is GBA_ME, save Ks and Rand")); |
|
1143 //Save ks |
|
1144 RDictionaryWriteStream writer1; |
|
1145 CleanupClosePushL(writer1); |
|
1146 writer1.AssignL( *pStore, KUidKs ); |
|
1147 writer1.WriteInt32L(iMasterKey->Size()); |
|
1148 writer1.WriteL(*iMasterKey); |
|
1149 writer1.CommitL(); |
|
1150 CleanupStack::PopAndDestroy( &writer1 ); |
|
1151 |
|
1152 //Save Rand |
|
1153 RDictionaryWriteStream writer2; |
|
1154 CleanupClosePushL(writer2); |
|
1155 writer2.AssignL(*pStore,KUidRand ); |
|
1156 writer2.WriteInt32L(iRand->Size()); |
|
1157 writer2.WriteL(*iRand); |
|
1158 writer2.CommitL(); |
|
1159 CleanupStack::PopAndDestroy( &writer2 ); |
|
1160 } |
|
1161 else |
|
1162 { |
|
1163 GBA_TRACE_DEBUG(("It is GBA_U, remove Ks and Rand if there are")); |
|
1164 pStore->RemoveL(KUidKs); |
|
1165 pStore->RemoveL(KUidRand); |
|
1166 } |
|
1167 //Save B-TID |
|
1168 RDictionaryWriteStream writer3; |
|
1169 CleanupClosePushL(writer3); |
|
1170 writer3.AssignL(*pStore,KUidBTID ); |
|
1171 writer3.WriteInt32L(iBTID->Size()); |
|
1172 writer3.WriteL(*iBTID); |
|
1173 writer3.CommitL(); |
|
1174 CleanupStack::PopAndDestroy( &writer3 ); |
|
1175 |
|
1176 //Save key lifetime |
|
1177 RDictionaryWriteStream writer4; |
|
1178 CleanupClosePushL(writer4); |
|
1179 writer4.AssignL(*pStore,KUidkeylifetime ); |
|
1180 TPtrC8 ptrkeylifetime((TUint8*)&iLifetime,sizeof(TTime)); |
|
1181 writer4.WriteL(ptrkeylifetime); |
|
1182 writer4.CommitL(); |
|
1183 CleanupStack::PopAndDestroy( &writer4 ); |
|
1184 |
|
1185 //Save gba run type |
|
1186 RDictionaryWriteStream writer5; |
|
1187 CleanupClosePushL(writer5); |
|
1188 writer5.AssignL(*pStore,KUidGBARunType); |
|
1189 writer5.WriteInt8L(iGBARunType); |
|
1190 writer5.CommitL(); |
|
1191 CleanupStack::PopAndDestroy( &writer5 ); |
|
1192 |
|
1193 pStore->CommitL(); |
|
1194 CleanupStack::PopAndDestroy( pStore ); |
|
1195 CleanupStack::PopAndDestroy( &fs ); |
|
1196 } |
|
1197 else |
|
1198 { |
|
1199 CleanupStack::PopAndDestroy( &fs ); |
|
1200 User::LeaveIfError( err ); |
|
1201 } |
|
1202 } |
|
1203 |
|
1204 // ----------------------------------------------------------------------------- |
|
1205 // C3GPPBootstrap::CheckGBAUAvailability() |
|
1206 // Check the GBA availability from store, if no record there, check from |
|
1207 // smart card directly. |
|
1208 // ----------------------------------------------------------------------------- |
|
1209 TBool C3GPPBootstrap::CheckGBAUAvailabilityL( TBool aIsfromGBAClient ) |
|
1210 { |
|
1211 TBool GBAUAvailability = EFalse; |
|
1212 //Read the record from store |
|
1213 TInt result = LoadGBAUAvailabililtyFromStoreL( aIsfromGBAClient, GBAUAvailability ); |
|
1214 |
|
1215 //The store GBA type is GBA_U or GBA_ME |
|
1216 if ( result != KErrNotFound && result != KErrGeneral ) |
|
1217 { |
|
1218 //return the cached GBAU availabilty, since smart card is not changed |
|
1219 return GBAUAvailability; |
|
1220 } |
|
1221 else if ( result == KErrGeneral ) |
|
1222 { |
|
1223 //impi is different |
|
1224 //delete the whole store |
|
1225 RFs fs; |
|
1226 User::LeaveIfError( fs.Connect() ); |
|
1227 CleanupClosePushL(fs); |
|
1228 TFileName fullPath; |
|
1229 MakePrivateFilenameL(fs, KGbaCredentialsFileName, fullPath); |
|
1230 fs.Delete( fullPath ); |
|
1231 CleanupStack::PopAndDestroy( &fs ); |
|
1232 } |
|
1233 else |
|
1234 { |
|
1235 //The first time query |
|
1236 } |
|
1237 // There is no record on GBA_U availability or impis are different |
|
1238 // It only happens on the first time when GBA server starts |
|
1239 // or after smart card is removed. |
|
1240 |
|
1241 //retrieve the GBA availability from smart card |
|
1242 iSmartCardInterface->QueryGBAUAvailabilityL( GBAUAvailability ); |
|
1243 |
|
1244 SaveGBAUAvailabilityToStoreL( GBAUAvailability ); |
|
1245 return GBAUAvailability; |
|
1246 } |
|
1247 |
|
1248 |
|
1249 // ----------------------------------------------------------------------------- |
|
1250 // C3GPPBootstrap::LoadGBAUAvailabililtyFromStoreL() |
|
1251 // ----------------------------------------------------------------------------- |
|
1252 TInt C3GPPBootstrap::LoadGBAUAvailabililtyFromStoreL( TBool& aIsfromGBAClient, TBool& aGBAUAvail ) |
|
1253 { |
|
1254 GBA_TRACE_DEBUG(("Loading the GBA-U avail from store")); |
|
1255 TInt cleanupstack = 0; |
|
1256 RFs fs; |
|
1257 User::LeaveIfError( fs.Connect() ); |
|
1258 CleanupClosePushL(fs); |
|
1259 cleanupstack++; |
|
1260 TFindFile folder( fs ); |
|
1261 |
|
1262 |
|
1263 TFileName fullPath; |
|
1264 MakePrivateFilenameL(fs, KGbaCredentialsFileName, fullPath); |
|
1265 GBA_TRACE_DEBUG(fullPath); |
|
1266 TInt err = folder.FindByDir( fullPath, KNullDesC ); |
|
1267 |
|
1268 // the store file is not available |
|
1269 if ( err != KErrNone ) |
|
1270 { |
|
1271 GBA_TRACE_DEBUG(("No store available")); |
|
1272 CleanupStack::PopAndDestroy(cleanupstack); |
|
1273 |
|
1274 //get impi here, save to store later |
|
1275 if ( aIsfromGBAClient ) |
|
1276 { |
|
1277 //retrieve the impi from smart card |
|
1278 TPtr8 idPtr = iIdentity->Des(); |
|
1279 idPtr.Zero(); |
|
1280 TRAPD(error,iSmartCardInterface->QueryIdentityL(idPtr)); |
|
1281 |
|
1282 if( error != KErrNone ) |
|
1283 { |
|
1284 GBA_TRACE_DEBUG((" Can't get IMPI from smart card")); |
|
1285 User::LeaveIfError( error ); |
|
1286 } |
|
1287 |
|
1288 GBA_TRACE_DEBUG((" got IMPI")); |
|
1289 } |
|
1290 return KErrNotFound; |
|
1291 } |
|
1292 else |
|
1293 { |
|
1294 GBA_TRACE_DEBUG(("Found store ")); |
|
1295 CDictionaryFileStore* pStore = CDictionaryFileStore::OpenLC(fs,KGbaCredentialsFileName,KUidGBACredRoot); |
|
1296 cleanupstack++; |
|
1297 TInt impiLength = 0; |
|
1298 HBufC8* cachedimpi = NULL; |
|
1299 TInt8 GBAUAvail = 0; |
|
1300 |
|
1301 //Read GBA-U avail |
|
1302 if ( pStore->IsPresentL( KUidGBAUAvail ) ) |
|
1303 { |
|
1304 GBA_TRACE_DEBUG(("GBAU Avail is present ")); |
|
1305 RDictionaryReadStream reader; |
|
1306 CleanupClosePushL(reader); |
|
1307 reader.OpenL(*pStore,KUidGBAUAvail); |
|
1308 GBAUAvail = reader.ReadInt8L(); |
|
1309 CleanupStack::PopAndDestroy( &reader ); |
|
1310 } |
|
1311 |
|
1312 //Read IMPI |
|
1313 if ( pStore->IsPresentL( KUidIMPI ) ) |
|
1314 { |
|
1315 GBA_TRACE_DEBUG(("IMPI is present ")); |
|
1316 RDictionaryReadStream reader1; |
|
1317 CleanupClosePushL(reader1); |
|
1318 cleanupstack++; |
|
1319 reader1.OpenL(*pStore,KUidIMPI); |
|
1320 impiLength = reader1.ReadInt32L(); |
|
1321 |
|
1322 cachedimpi = HBufC8::NewLC(impiLength); |
|
1323 cleanupstack++; |
|
1324 TPtr8 ptrcachedimpi = cachedimpi->Des(); |
|
1325 |
|
1326 reader1.ReadL(ptrcachedimpi,impiLength); |
|
1327 ptrcachedimpi.SetLength(impiLength); |
|
1328 GBA_TRACE_DEBUG(("IMPI = ")); |
|
1329 GBA_TRACE_DEBUG(ptrcachedimpi); |
|
1330 |
|
1331 if ( aIsfromGBAClient ) |
|
1332 { |
|
1333 //retrieve the impi from smart card |
|
1334 TPtr8 idPtr = iIdentity->Des(); |
|
1335 idPtr.Zero(); |
|
1336 TRAPD(error,iSmartCardInterface->QueryIdentityL(idPtr)); |
|
1337 |
|
1338 if( error != KErrNone ) |
|
1339 { |
|
1340 GBA_TRACE_DEBUG((" Can't get IMPI from smart card")); |
|
1341 User::LeaveIfError( error ); |
|
1342 } |
|
1343 |
|
1344 GBA_TRACE_DEBUG((" got IMPI")); |
|
1345 } |
|
1346 |
|
1347 |
|
1348 if( *iIdentity == *cachedimpi ) |
|
1349 { |
|
1350 GBA_TRACE_DEBUG(("IMPI are the same")); |
|
1351 //the impi are the same, return the cached gbau availability |
|
1352 CleanupStack::PopAndDestroy(cleanupstack); |
|
1353 aGBAUAvail = (TBool)GBAUAvail; |
|
1354 return KErrNone; |
|
1355 } |
|
1356 else |
|
1357 { |
|
1358 GBA_TRACE_DEBUG(("IMPIs are different")); |
|
1359 //the impi are different, return KErrGeneral |
|
1360 iSmartCardInterface->NotifyCardChangeL(); |
|
1361 CleanupStack::PopAndDestroy(cleanupstack); |
|
1362 return KErrGeneral; |
|
1363 } |
|
1364 } |
|
1365 else |
|
1366 { |
|
1367 GBA_TRACE_DEBUG(("no impi present")); |
|
1368 return KErrGeneral; |
|
1369 } |
|
1370 } |
|
1371 } |
|
1372 |
|
1373 // ----------------------------------------------------------------------------- |
|
1374 // C3GPPBootstrap::SaveGBAUAvailabilityToStoreL() |
|
1375 // ----------------------------------------------------------------------------- |
|
1376 // |
|
1377 void C3GPPBootstrap::SaveGBAUAvailabilityToStoreL( TBool& aGBAUAvail ) |
|
1378 { |
|
1379 GBA_TRACE_DEBUG(("Save GBA-U avail into dictionary store")); |
|
1380 |
|
1381 RFs fs; |
|
1382 User::LeaveIfError(fs.Connect()); |
|
1383 CleanupClosePushL(fs); |
|
1384 TFindFile folder( fs ); |
|
1385 |
|
1386 TFileName fullPath; |
|
1387 MakePrivateFilenameL(fs, KGbaCredentialsFileName, fullPath); |
|
1388 EnsurePathL(fs, fullPath ); |
|
1389 GBA_TRACE_DEBUG(fullPath); |
|
1390 TInt err = folder.FindByDir( fullPath, KNullDesC ); |
|
1391 |
|
1392 if ( err == KErrNotFound || err == KErrNone || err == KErrPathNotFound ) |
|
1393 { |
|
1394 |
|
1395 CDictionaryFileStore* pStore = CDictionaryFileStore::OpenLC(fs,fullPath,KUidGBACredRoot); |
|
1396 |
|
1397 //Save IMPI |
|
1398 RDictionaryWriteStream writer; |
|
1399 CleanupClosePushL(writer); |
|
1400 writer.AssignL(*pStore, KUidIMPI); |
|
1401 writer.WriteInt32L(iIdentity->Size()); |
|
1402 writer.WriteL(*iIdentity); |
|
1403 writer.CommitL(); |
|
1404 CleanupStack::PopAndDestroy( &writer ); |
|
1405 //Save GBA-U avail |
|
1406 RDictionaryWriteStream writer1; |
|
1407 CleanupClosePushL(writer1); |
|
1408 writer1.AssignL(*pStore,KUidGBAUAvail ); |
|
1409 writer1.WriteInt8L((TInt8)aGBAUAvail); |
|
1410 writer1.CommitL(); |
|
1411 CleanupStack::PopAndDestroy( &writer1 ); |
|
1412 |
|
1413 pStore->CommitL(); |
|
1414 CleanupStack::PopAndDestroy(pStore); |
|
1415 CleanupStack::PopAndDestroy(&fs); |
|
1416 GBA_TRACE_DEBUG(("Save GBA-U avail successfully")); |
|
1417 } |
|
1418 else |
|
1419 { |
|
1420 GBA_TRACE_DEBUG(("Save GBA-U avail failed")); |
|
1421 CleanupStack::PopAndDestroy(&fs); |
|
1422 User::LeaveIfError( err ); |
|
1423 } |
|
1424 } |
|
1425 |
|
1426 // ----------------------------------------------------------------------------- |
|
1427 // C3GPPBootstrap::IsStillValid() |
|
1428 // ----------------------------------------------------------------------------- |
|
1429 // |
|
1430 TBool C3GPPBootstrap::IsStillValid( TTime* aLifetime ) |
|
1431 { |
|
1432 TTime nowTime; |
|
1433 nowTime.UniversalTime(); |
|
1434 GBA_TRACE_DEBUG(("Current Time:")); |
|
1435 GBA_TRACE_TIME( nowTime ); |
|
1436 |
|
1437 GBA_TRACE_DEBUG(("Expiry Time:")); |
|
1438 GBA_TRACE_TIME( *aLifetime ); |
|
1439 |
|
1440 if( *aLifetime > nowTime ) |
|
1441 { |
|
1442 GBA_TRACE_DEBUG(("key still valid")); |
|
1443 return ETrue; |
|
1444 } |
|
1445 else |
|
1446 { |
|
1447 GBA_TRACE_DEBUG(("key expired")); |
|
1448 return EFalse; |
|
1449 } |
|
1450 } |
|
1451 |
|
1452 // ----------------------------------------------------------------------------- |
|
1453 // C3GPPBootstrap::ConvertStringToTTime() |
|
1454 // ----------------------------------------------------------------------------- |
|
1455 // |
|
1456 TBool C3GPPBootstrap::ConvertStringToTTime(TDesC8& aLifetimeBuf, TTime* aLifetime) |
|
1457 { |
|
1458 GBA_TRACE_BEGIN(); |
|
1459 TInt aTimeVariable[KVariableIndex6] = |
|
1460 { |
|
1461 0,0,0,0,0,0 |
|
1462 }; // { year,month,day,hour,minute,second } |
|
1463 |
|
1464 // assuming the lifetime is given in ISO 8601 format |
|
1465 // YYYY-MM-DD or YYYYMMDD (we don't allow YYYYMM or YYYY format, although this isn't specified in the standard) |
|
1466 // (year could have a + before it if key is valid beyond year 9999, but we hope that someone will rewrite this within next 8000 years) |
|
1467 // there might be a T between date and time we just ignore it |
|
1468 // hours |
|
1469 // hh:mm:ss or hhmmss |
|
1470 // hh:mm or hhmm |
|
1471 // hh |
|
1472 |
|
1473 TInt pos = 0; |
|
1474 TInt len = KVariableIndex4; |
|
1475 for(TInt variableIndex = 0; variableIndex < KVariableIndex6; variableIndex++) |
|
1476 { |
|
1477 // if next value isn't a digit we're done |
|
1478 if(!TChar(aLifetimeBuf[pos]).IsDigit()) |
|
1479 break; |
|
1480 |
|
1481 if(pos + len < aLifetimeBuf.Length()) |
|
1482 { |
|
1483 |
|
1484 TLex8 lex(aLifetimeBuf.Mid(pos,len)); |
|
1485 if(KErrNone != lex.Val(aTimeVariable[variableIndex])) |
|
1486 { |
|
1487 GBA_TRACE_DEBUG(("failed")); |
|
1488 GBA_TRACE_DEBUG(aLifetimeBuf.Mid(pos,len)); |
|
1489 return EFalse; |
|
1490 } |
|
1491 pos += len; |
|
1492 |
|
1493 |
|
1494 // remove possible separators |
|
1495 if(aLifetimeBuf[pos] == '-' || aLifetimeBuf[pos] == ':') |
|
1496 pos += 1; |
|
1497 // there can be spaces after month |
|
1498 if( variableIndex == KVariableIndex2 ) |
|
1499 while(pos < aLifetimeBuf.Length() && |
|
1500 (TChar(aLifetimeBuf[pos]).IsSpace() || aLifetimeBuf[pos] == 'T')) |
|
1501 pos++; |
|
1502 |
|
1503 } |
|
1504 else |
|
1505 { |
|
1506 // if we don't get second it doesn't matter |
|
1507 if(variableIndex >= KVariableIndex5) |
|
1508 break; |
|
1509 return EFalse; |
|
1510 } |
|
1511 len = KVariableIndex2; // year is the exception |
|
1512 } |
|
1513 // Symbian months and days start from 0, UTC months from 1 |
|
1514 aTimeVariable[1] = aTimeVariable[1] - 1; |
|
1515 aTimeVariable[2] = aTimeVariable[2] - 1; |
|
1516 |
|
1517 TBuf<KBufferSize255> aDBBuf; |
|
1518 aDBBuf.Format(KTimeFormat, aTimeVariable[KVariableIndex0],aTimeVariable[KVariableIndex1],aTimeVariable[KVariableIndex2], |
|
1519 aTimeVariable[KVariableIndex3],aTimeVariable[KVariableIndex4],aTimeVariable[KVariableIndex5]); |
|
1520 GBA_TRACE_DEBUG(aDBBuf); |
|
1521 |
|
1522 // time should always be in UTC so no need to check the timezone |
|
1523 TDateTime dt; |
|
1524 |
|
1525 TRAPD(error,dt.Set( |
|
1526 aTimeVariable[KVariableIndex0], |
|
1527 (TMonth)(aTimeVariable[KVariableIndex1]), |
|
1528 aTimeVariable[KVariableIndex2], |
|
1529 aTimeVariable[KVariableIndex3], |
|
1530 aTimeVariable[KVariableIndex4], |
|
1531 aTimeVariable[KVariableIndex5], |
|
1532 0 |
|
1533 )); |
|
1534 |
|
1535 if(error != KErrNone) |
|
1536 { |
|
1537 aDBBuf.Format(KErrorMessage,error); |
|
1538 GBA_TRACE_DEBUG(aDBBuf); |
|
1539 return EFalse; |
|
1540 } |
|
1541 |
|
1542 *aLifetime = dt; |
|
1543 |
|
1544 GBA_TRACE_END(); |
|
1545 return ETrue; |
|
1546 } |
|
1547 |
|
1548 |
|
1549 // --------------------------------------------------------------------------- |
|
1550 // C3GPPBootstrap::CreateImplementationL() |
|
1551 // --------------------------------------------------------------------------- |
|
1552 // |
|
1553 MUICCInterface* C3GPPBootstrap::RequestUICCInterfaceL() |
|
1554 { |
|
1555 GBA_TRACE_BEGIN(); |
|
1556 TAny* ptr = REComSession::CreateImplementationL(iImplementationUID, iDtorIDKey); |
|
1557 MUICCInterface* ptyped = static_cast<MUICCInterface*>(ptr); |
|
1558 GBA_TRACE_END(); |
|
1559 return ptyped; |
|
1560 } |
|
1561 |
|
1562 |
|
1563 // --------------------------------------------------------------------------- |
|
1564 // C3GPPBootstrap::IsPluginExistL() |
|
1565 // --------------------------------------------------------------------------- |
|
1566 // |
|
1567 TBool C3GPPBootstrap::IsPluginExistL() |
|
1568 { |
|
1569 GBA_TRACE_BEGIN(); |
|
1570 RImplInfoPtrArray array; |
|
1571 // Note that a special cleanup function is required to reset and destroy |
|
1572 // all items in the array, and then close it. |
|
1573 TCleanupItem cleanup(ResetAndDestroyArray, &array); |
|
1574 CleanupStack::PushL(cleanup); |
|
1575 |
|
1576 REComSession::ListImplementationsL( KGBAUICCInterfaceUID, array ); |
|
1577 |
|
1578 if( array.Count()) |
|
1579 { |
|
1580 CleanupStack::PopAndDestroy(&array); //array, results in a call to ResetAndDestroyArray |
|
1581 GBA_TRACE_END(); |
|
1582 return ETrue; |
|
1583 } |
|
1584 else |
|
1585 { |
|
1586 GBA_TRACE_END(); |
|
1587 CleanupStack::PopAndDestroy(&array); //array, results in a call to ResetAndDestroyArray |
|
1588 return EFalse; |
|
1589 } |
|
1590 } |
|
1591 |
|
1592 |
|
1593 // CleanupEComArray function is used for cleanup support of locally declared arrays |
|
1594 void ResetAndDestroyArray(TAny* aArray) |
|
1595 { |
|
1596 GBA_TRACE_BEGIN(); |
|
1597 (static_cast<RImplInfoPtrArray*> (aArray))->ResetAndDestroy(); |
|
1598 (static_cast<RImplInfoPtrArray*> (aArray))->Close(); |
|
1599 GBA_TRACE_END(); |
|
1600 } |
|
1601 |
|
1602 |
|
1603 // --------------------------------------------------------------------------- |
|
1604 // C3GPPBootstrap::InterfaceIs2G() |
|
1605 // --------------------------------------------------------------------------- |
|
1606 // |
|
1607 TBool C3GPPBootstrap::InterfaceIs2G() |
|
1608 { |
|
1609 return iSmartCardInterface->InterfaceIs2G(); |
|
1610 } |
|
1611 |
|
1612 |
|
1613 // --------------------------------------------------------------------------- |
|
1614 // C3GPPBootstrap::MakePrivateFilenameL() |
|
1615 // --------------------------------------------------------------------------- |
|
1616 // |
|
1617 void C3GPPBootstrap::MakePrivateFilenameL(RFs& aFs, const TDesC& aLeafName, |
|
1618 TDes& aNameOut) |
|
1619 { |
|
1620 aNameOut.Copy(KGBAStoreStandardDrive); |
|
1621 // Get private path |
|
1622 TBuf<KStringLength> privatePath; |
|
1623 aFs.PrivatePath(privatePath); |
|
1624 aNameOut.Append(privatePath); |
|
1625 aNameOut.Append(aLeafName); |
|
1626 } |
|
1627 |
|
1628 |
|
1629 // --------------------------------------------------------------------------- |
|
1630 // C3GPPBootstrap::EnsurePathL() |
|
1631 // --------------------------------------------------------------------------- |
|
1632 // |
|
1633 void C3GPPBootstrap::EnsurePathL( RFs& aFs, const TDesC& aFile ) |
|
1634 { |
|
1635 TInt err = aFs.MkDirAll(aFile); |
|
1636 if (err != KErrNone && err != KErrAlreadyExists) |
|
1637 { |
|
1638 User::Leave(err); |
|
1639 } |
|
1640 } |
|
1641 |
|
1642 //EOF |
|
1643 |
|
1644 |