24
|
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 "te_simeap.h"
|
|
21 |
|
|
22 |
|
|
23 |
_LIT8(KConfigScAuthAIDAscii, "AID1");
|
|
24 |
_LIT8(KConfigScAuthAUTN, "AUTN_IN");
|
|
25 |
_LIT8(KConfigScAuthRAND, "RAND_IN");
|
|
26 |
_LIT8(KConfigScAuthRES, "123456789");
|
|
27 |
_LIT8(KConfigScAuthIK, "1234567890");
|
|
28 |
_LIT8(KConfigScAuthCK, "1234567899");
|
|
29 |
_LIT8(KConfigScAuthKC, "12345678");
|
|
30 |
_LIT8(KConfigScAuthAUTS, "1234567897");
|
|
31 |
_LIT8(KConfigScAuthAUTNbin, "\x00\x01\x02\x03\x04\x05");
|
|
32 |
_LIT8(KConfigScAuthRANDbin, "\x00\x01\x02\x03\x06\x07");
|
|
33 |
_LIT8(KConfigScAuthRESbin, "\x00\x00\x00\x11\x11\x11");
|
|
34 |
_LIT8(KConfigScAuthIKbin, "\x00\x00\x00\x11\x11\x22");
|
|
35 |
_LIT8(KConfigScAuthCKbin, "\x00\x00\x00\x11\x22\x33");
|
|
36 |
_LIT8(KConfigScAuthKCbin, "\x00\x01\x00\x02\x03\x04\x05\x06");
|
|
37 |
_LIT8(KConfigScAuthAIDBin, "\x00\x01\x00\x02");
|
|
38 |
|
|
39 |
_LIT8(KConfigEapListAID, "AID00");
|
|
40 |
_LIT8(KConfigEapListLabel, "EAPAID");
|
|
41 |
_LIT8(KConfigEapListEapList, "1723");
|
|
42 |
|
|
43 |
_LIT8(KConfigScEapAID1, "\x00\x01\x00\x00\x02");
|
|
44 |
_LIT8(KConfigScEapType1, "17");
|
|
45 |
_LIT8(KConfigScEapId1, "EAP_ID1");
|
|
46 |
_LIT8(KConfigScEapPsId1, "EAP_PseudonymID1");
|
|
47 |
_LIT8(KConfigScEapKey1, "EAP_KEY1");
|
|
48 |
_LIT8(KConfigScEapKey1EMSK, "EAP_KEY1EXT");
|
|
49 |
_LIT8(KConfigScEapChal11, "CHALLENGE_DATA1");
|
|
50 |
_LIT8(KConfigScEapResp11, "RESPONSE_DATA1");
|
|
51 |
const RMobileSmartCardEap::TEapAuthStatus KEapAuthStatus1_1 = RMobileSmartCardEap::EAuthenticating;
|
|
52 |
_LIT8(KConfigScEapChal12, "CHALLENGE_DATA2");
|
|
53 |
_LIT8(KConfigScEapResp12, "RESPONSE_DATA2");
|
|
54 |
const RMobileSmartCardEap::TEapAuthStatus KEapAuthStatus1_2 = RMobileSmartCardEap::EAuthenticating;
|
|
55 |
_LIT8(KConfigScEapChal13, "CHALLENGE_DATA3");
|
|
56 |
_LIT8(KConfigScEapResp13, "RESPONSE_DATA3");
|
|
57 |
const RMobileSmartCardEap::TEapAuthStatus KEapAuthStatus1_3 = RMobileSmartCardEap::EAuthenticated;
|
|
58 |
|
|
59 |
_LIT8(KConfigScEapAID2, "\x00\x02\x00\x00\x02");
|
|
60 |
_LIT8(KConfigScEapType2, "23");
|
|
61 |
_LIT8(KConfigScEapId2, "\x00\x01\x02\x03\x04\x05");
|
|
62 |
_LIT8(KConfigScEapKey2, "\x00\x01\x02\x03\x04\x66");
|
|
63 |
_LIT8(KConfigScEapChal21, "\x00\x00\x00\x11\x11\x11\x22\x22\x22");
|
|
64 |
_LIT8(KConfigScEapResp21, "\xAA\xBB\xCC\x00\xDD\xEE\xFF");
|
|
65 |
const RMobileSmartCardEap::TEapAuthStatus KEapAuthStatus2_1 = RMobileSmartCardEap::EAuthenticating;
|
|
66 |
_LIT8(KConfigScEapChal22, "\x00\x00\x00\x12\x12\x12\x22\x22\x22");
|
|
67 |
_LIT8(KConfigScEapResp22, "\xAB\xBB\xCC\x00\xDD\xEE\xFF");
|
|
68 |
const RMobileSmartCardEap::TEapAuthStatus KEapAuthStatus2_2 = RMobileSmartCardEap::EAuthenticated;
|
|
69 |
|
|
70 |
_LIT8(KConfigScReInitEapAID, "\x00\x00\x00\x00\xEE");
|
|
71 |
_LIT8(KConfigScReInitEapType1, "22");
|
|
72 |
_LIT8(KConfigScReInitEapType2, "11");
|
|
73 |
|
|
74 |
_LIT8(KConfigScEapAIDBadCli, "\x00\x03\x00\x00\x02");
|
|
75 |
_LIT8(KConfigScEapTypeBadCli, "25");
|
|
76 |
|
|
77 |
|
|
78 |
CTestSmartCardEap::CTestSmartCardEap()
|
|
79 |
{
|
|
80 |
// store the name of this test case
|
|
81 |
// this is the name that is used by the script file
|
|
82 |
SetTestStepName(_L("TestSmartCardEap"));
|
|
83 |
}
|
|
84 |
|
|
85 |
TVerdict CTestSmartCardEap::doTestStepL()
|
|
86 |
{
|
|
87 |
INFO_PRINTF1(_L("CTestSmartCardEap"));
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
// Vars to be used throughout test
|
|
92 |
TRequestStatus reqStatus = KErrNone;
|
|
93 |
RMobilePhone::TAID myAID = KConfigScEapAID1();
|
|
94 |
RMobileSmartCardEap::TEapType myEapType = KConfigScEapType1();
|
|
95 |
RMobileSmartCardEap simScEap, simScEap2;
|
|
96 |
// simScEap0 will be a handle to same sub-session as simScEap.
|
|
97 |
// simScEap0 is used for mainly testing the
|
|
98 |
// NotifyEapMethodAccessStatusChange() notification.
|
|
99 |
RMobileSmartCardEap simScEap0;
|
|
100 |
|
|
101 |
// A quick open/close
|
|
102 |
RMobileSmartCardEap simScEapQuick;
|
|
103 |
TInt ret = simScEapQuick.Open(iPhone, myAID, myEapType);
|
|
104 |
TESTL(ret == KErrNone);
|
|
105 |
simScEapQuick.Close();
|
|
106 |
|
|
107 |
// Test opening handle with bad params
|
|
108 |
INFO_PRINTF1(_L("Attempting to create handle to sub-session with non-existent <AID,EAPType>"));
|
|
109 |
_LIT8(badAID, "badAID");
|
|
110 |
_LIT8(badEAP, "badEAP");
|
|
111 |
myAID = badAID();
|
|
112 |
myEapType = badEAP();
|
|
113 |
ret = simScEap.Open(iPhone, myAID, myEapType);
|
|
114 |
TESTL(ret == KErrNotFound);
|
|
115 |
|
|
116 |
// Test opening 2 handles to the same sub-session using good params
|
|
117 |
// for a handle
|
|
118 |
INFO_PRINTF1(_L("Creating handle to sub-session"));
|
|
119 |
myAID = KConfigScEapAID1();
|
|
120 |
myEapType = KConfigScEapType1();
|
|
121 |
ret = simScEap0.Open(iPhone, myAID, myEapType);
|
|
122 |
CleanupClosePushL(simScEap0);
|
|
123 |
TESTL(ret == KErrNone);
|
|
124 |
TEST(!simScEap0.IsEapMethodOwner());
|
|
125 |
|
|
126 |
ret = simScEap.Open(iPhone, myAID, myEapType);
|
|
127 |
CleanupClosePushL(simScEap);
|
|
128 |
TESTL(ret == KErrNone);
|
|
129 |
TEST(!simScEap.IsEapMethodOwner());
|
|
130 |
|
|
131 |
// Test notification for only one of the handles; the one that does
|
|
132 |
// NOT initialise.
|
|
133 |
RMobileSmartCardEap::TEapMethodAccessStatus eapAccessStatNotif = RMobileSmartCardEap::EEapMethodInUseApplicationInactive;
|
|
134 |
TRequestStatus reqStatusNotif = KErrNone;
|
|
135 |
simScEap0.NotifyEapMethodAccessStatusChange(reqStatusNotif, eapAccessStatNotif);
|
|
136 |
|
|
137 |
// Test GetEapMethodAccessStatus()
|
|
138 |
INFO_PRINTF1(_L("RMobileSmartCardEap::GetEapMethodAccessStatus sync."));
|
|
139 |
RMobileSmartCardEap::TEapMethodAccessStatus eapAccessStat = RMobileSmartCardEap::EEapMethodInUseApplicationInactive;
|
|
140 |
simScEap0.GetEapMethodAccessStatus(eapAccessStat);
|
|
141 |
TEST(eapAccessStat == RMobileSmartCardEap::EEapMethodAvailable);
|
|
142 |
simScEap.GetEapMethodAccessStatus(eapAccessStat);
|
|
143 |
TEST(eapAccessStat == RMobileSmartCardEap::EEapMethodAvailable);
|
|
144 |
|
|
145 |
// Initialise only one of the handles
|
|
146 |
INFO_PRINTF1(_L("Initialising handle to sub-session"));
|
|
147 |
simScEap.InitialiseEapMethod(reqStatus);
|
|
148 |
User::WaitForRequest(reqStatus);
|
|
149 |
TESTL(reqStatus == KErrNone);
|
|
150 |
TESTL(simScEap.IsEapMethodOwner());
|
|
151 |
simScEap.InitialiseEapMethod(reqStatus); // second initialise should do nothing and succeed
|
|
152 |
User::WaitForRequest(reqStatus);
|
|
153 |
TESTL(reqStatus == KErrNone);
|
|
154 |
|
|
155 |
// new status should be achieved
|
|
156 |
simScEap0.GetEapMethodAccessStatus(eapAccessStat);
|
|
157 |
TEST(eapAccessStat == RMobileSmartCardEap::EEapMethodInUseApplicationActive);
|
|
158 |
simScEap.GetEapMethodAccessStatus(eapAccessStat);
|
|
159 |
TEST(eapAccessStat == RMobileSmartCardEap::EEapMethodInUseApplicationActive);
|
|
160 |
|
|
161 |
// Notification should have now completed.
|
|
162 |
User::WaitForRequest(reqStatusNotif);
|
|
163 |
TEST(reqStatusNotif == KErrNone);
|
|
164 |
TEST(eapAccessStatNotif == RMobileSmartCardEap::EEapMethodInUseApplicationActive);
|
|
165 |
|
|
166 |
// re-post notification for later!
|
|
167 |
simScEap0.NotifyEapMethodAccessStatusChange(reqStatusNotif, eapAccessStatNotif);
|
|
168 |
|
|
169 |
// Test GetUserIdentity
|
|
170 |
INFO_PRINTF1(_L("RMobileSmartCardEap::GetEapSimUserIdentity async."));
|
|
171 |
RMobileSmartCardEap::TEapUserIdentityV6 userId;
|
|
172 |
RMobileSmartCardEap::TEapUserIdentityV6Pckg userIdPckg(userId);
|
|
173 |
RMobileSmartCardEap::TEapUserIdType eapIdType = RMobileSmartCardEap::EPermanentIdentity;
|
|
174 |
RMobileSmartCardEap::TEapUserIdType eapPsIdType = RMobileSmartCardEap::EPseudonymIdentity;
|
|
175 |
|
|
176 |
// EPermanentIdentity
|
|
177 |
simScEap.GetUserIdentity(reqStatus, eapIdType, userIdPckg);
|
|
178 |
User::WaitForRequest(reqStatus);
|
|
179 |
TEST(reqStatus == KErrNone);
|
|
180 |
TEST(userId.iEapId == KConfigScEapId1());
|
|
181 |
// EPseudonymIdentity
|
|
182 |
simScEap.GetUserIdentity(reqStatus, eapPsIdType, userIdPckg);
|
|
183 |
User::WaitForRequest(reqStatus);
|
|
184 |
TEST(reqStatus == KErrNone);
|
|
185 |
TEST(userId.iEapId == KConfigScEapPsId1());
|
|
186 |
// bad id tag
|
|
187 |
simScEap.GetUserIdentity(reqStatus, static_cast<RMobileSmartCardEap::TEapUserIdType>(5), userIdPckg);
|
|
188 |
User::WaitForRequest(reqStatus);
|
|
189 |
TEST(reqStatus == KErrArgument);
|
|
190 |
|
|
191 |
// Test GetAuthenticationStatus
|
|
192 |
INFO_PRINTF1(_L("RMobileSmartCardEap::GetAuthenticationStatus async."));
|
|
193 |
RMobileSmartCardEap::TEapAuthStatus authStatus = RMobileSmartCardEap::EHeld;
|
|
194 |
|
|
195 |
simScEap.GetAuthenticationStatus(reqStatus, authStatus);
|
|
196 |
User::WaitForRequest(reqStatus);
|
|
197 |
TEST(reqStatus == KErrNone);
|
|
198 |
TEST(authStatus == RMobileSmartCardEap::ENoAuthStarted);
|
|
199 |
|
|
200 |
// Test GetEapKey
|
|
201 |
INFO_PRINTF1(_L("RMobileSmartCardEap::GetEapKey async."));
|
|
202 |
RMobileSmartCardEap::TEapKeyV6 eapKey;
|
|
203 |
RMobileSmartCardEap::TEapKeyV6Pckg eapKeyPckg(eapKey);
|
|
204 |
RMobileSmartCardEap::TEapKeyTag eapKeyTag = RMobileSmartCardEap::EEapKeyMSK;
|
|
205 |
RMobileSmartCardEap::TEapKeyTag eapExtKeyTag = RMobileSmartCardEap::EEapKeyEMSK;
|
|
206 |
|
|
207 |
// MSK
|
|
208 |
simScEap.GetEapKey(reqStatus, eapKeyTag, eapKeyPckg);
|
|
209 |
User::WaitForRequest(reqStatus);
|
|
210 |
TEST(reqStatus == KErrNone);
|
|
211 |
TEST(eapKey.iEapKey == KConfigScEapKey1());
|
|
212 |
// EMSK
|
|
213 |
simScEap.GetEapKey(reqStatus, eapExtKeyTag, eapKeyPckg);
|
|
214 |
User::WaitForRequest(reqStatus);
|
|
215 |
TEST(reqStatus == KErrNone);
|
|
216 |
TEST(eapKey.iEapKey == KConfigScEapKey1EMSK());
|
|
217 |
// bad key tag
|
|
218 |
simScEap.GetEapKey(reqStatus, static_cast<RMobileSmartCardEap::TEapKeyTag>(5), eapKeyPckg);
|
|
219 |
User::WaitForRequest(reqStatus);
|
|
220 |
TEST(reqStatus == KErrArgument);
|
|
221 |
|
|
222 |
CActiveScheduler* iSimEapTestScheduler = new(ELeave) CActiveScheduler;
|
|
223 |
CleanupStack::PushL(iSimEapTestScheduler);
|
|
224 |
CActiveScheduler::Install(iSimEapTestScheduler);
|
|
225 |
|
|
226 |
// Test CAsyncSmartCardEapAuthentication *3 as specified in config file
|
|
227 |
INFO_PRINTF1(_L("CAsyncSmartCardEapAuthentication async."));
|
|
228 |
// 1st
|
|
229 |
TPtrC8 reqPacketPtr(KConfigScEapChal11);
|
|
230 |
CTestSimEapAuthenticateData* eapAuth = CTestSimEapAuthenticateData::NewLC(simScEap, static_cast<TDesC8&>(reqPacketPtr));
|
|
231 |
eapAuth->Start();
|
|
232 |
CActiveScheduler::Start();
|
|
233 |
ret = eapAuth->ValidateEapResponse(KConfigScEapResp11());
|
|
234 |
TEST(ret == KErrNone);
|
|
235 |
CleanupStack::PopAndDestroy(eapAuth);
|
|
236 |
|
|
237 |
simScEap.GetAuthenticationStatus(reqStatus, authStatus);
|
|
238 |
User::WaitForRequest(reqStatus);
|
|
239 |
TEST(reqStatus == KErrNone);
|
|
240 |
TEST(authStatus == KEapAuthStatus1_1);
|
|
241 |
|
|
242 |
// bad authenticate creeps in!
|
|
243 |
_LIT8(badAuthChall, "what????");
|
|
244 |
reqPacketPtr.Set(badAuthChall);
|
|
245 |
eapAuth = CTestSimEapAuthenticateData::NewLC(simScEap, static_cast<TDesC8&>(reqPacketPtr));
|
|
246 |
eapAuth->Start();
|
|
247 |
CActiveScheduler::Start();
|
|
248 |
ret = eapAuth->ValidateEapResponse(badAuthChall());
|
|
249 |
TEST(ret == KErrCorrupt);
|
|
250 |
CleanupStack::PopAndDestroy(eapAuth);
|
|
251 |
|
|
252 |
// 2nd
|
|
253 |
reqPacketPtr.Set(KConfigScEapChal12);
|
|
254 |
eapAuth = CTestSimEapAuthenticateData::NewLC(simScEap, static_cast<TDesC8&>(reqPacketPtr));
|
|
255 |
eapAuth->Start();
|
|
256 |
CActiveScheduler::Start();
|
|
257 |
ret = eapAuth->ValidateEapResponse(KConfigScEapResp12());
|
|
258 |
TEST(ret == KErrNone);
|
|
259 |
CleanupStack::PopAndDestroy(eapAuth);
|
|
260 |
|
|
261 |
simScEap.GetAuthenticationStatus(reqStatus, authStatus);
|
|
262 |
User::WaitForRequest(reqStatus);
|
|
263 |
TEST(reqStatus == KErrNone);
|
|
264 |
TEST(authStatus == KEapAuthStatus1_2);
|
|
265 |
|
|
266 |
// third authenticate will be tested after running some requests on
|
|
267 |
// a second sub-session, simScEap2.
|
|
268 |
|
|
269 |
// run a second sub-session at the same time
|
|
270 |
INFO_PRINTF1(_L("Opening and submitting requests on a second sub-session"));
|
|
271 |
myAID = KConfigScEapAID2();
|
|
272 |
myEapType = KConfigScEapType2();
|
|
273 |
ret = simScEap2.Open(iPhone, myAID, myEapType);
|
|
274 |
CleanupClosePushL(simScEap2);
|
|
275 |
TESTL(ret == KErrNone);
|
|
276 |
TEST(!simScEap2.IsEapMethodOwner());
|
|
277 |
|
|
278 |
simScEap2.InitialiseEapMethod(reqStatus);
|
|
279 |
User::WaitForRequest(reqStatus);
|
|
280 |
TESTL(reqStatus == KErrNone);
|
|
281 |
TESTL(simScEap2.IsEapMethodOwner());
|
|
282 |
|
|
283 |
// EPermanentIdentity
|
|
284 |
simScEap2.GetUserIdentity(reqStatus, eapIdType, userIdPckg);
|
|
285 |
User::WaitForRequest(reqStatus);
|
|
286 |
TEST(reqStatus == KErrNone);
|
|
287 |
TEST(userId.iEapId == KConfigScEapId2());
|
|
288 |
|
|
289 |
// EPseudonymIdentity - which doesn't exist for this sub-session!
|
|
290 |
simScEap2.GetUserIdentity(reqStatus, eapPsIdType, userIdPckg);
|
|
291 |
User::WaitForRequest(reqStatus);
|
|
292 |
TEST(reqStatus == KErrNotFound);
|
|
293 |
|
|
294 |
simScEap2.GetAuthenticationStatus(reqStatus, authStatus);
|
|
295 |
User::WaitForRequest(reqStatus);
|
|
296 |
TEST(reqStatus == KErrNone);
|
|
297 |
TEST(authStatus == RMobileSmartCardEap::ENoAuthStarted);
|
|
298 |
|
|
299 |
// MSK
|
|
300 |
simScEap2.GetEapKey(reqStatus, eapKeyTag, eapKeyPckg);
|
|
301 |
User::WaitForRequest(reqStatus);
|
|
302 |
TEST(reqStatus == KErrNone);
|
|
303 |
TEST(eapKey.iEapKey == KConfigScEapKey2());
|
|
304 |
|
|
305 |
// EMSK - which doesn't exist for this sub-session!
|
|
306 |
simScEap2.GetEapKey(reqStatus, eapExtKeyTag, eapKeyPckg);
|
|
307 |
User::WaitForRequest(reqStatus);
|
|
308 |
TEST(reqStatus == KErrNotFound);
|
|
309 |
|
|
310 |
// 2* Authenticate as per config.txt
|
|
311 |
reqPacketPtr.Set(KConfigScEapChal21);
|
|
312 |
eapAuth = CTestSimEapAuthenticateData::NewLC(simScEap2, static_cast<TDesC8&>(reqPacketPtr));
|
|
313 |
eapAuth->Start();
|
|
314 |
CActiveScheduler::Start();
|
|
315 |
ret = eapAuth->ValidateEapResponse(KConfigScEapResp21());
|
|
316 |
TEST(ret == KErrNone);
|
|
317 |
CleanupStack::PopAndDestroy(eapAuth);
|
|
318 |
simScEap2.GetAuthenticationStatus(reqStatus, authStatus);
|
|
319 |
User::WaitForRequest(reqStatus);
|
|
320 |
TEST(reqStatus == KErrNone);
|
|
321 |
TEST(authStatus == KEapAuthStatus2_1);
|
|
322 |
|
|
323 |
reqPacketPtr.Set(KConfigScEapChal22);
|
|
324 |
eapAuth = CTestSimEapAuthenticateData::NewLC(simScEap2, static_cast<TDesC8&>(reqPacketPtr));
|
|
325 |
eapAuth->Start();
|
|
326 |
CActiveScheduler::Start();
|
|
327 |
ret = eapAuth->ValidateEapResponse(KConfigScEapResp22());
|
|
328 |
TEST(ret == KErrNone);
|
|
329 |
CleanupStack::PopAndDestroy(eapAuth);
|
|
330 |
simScEap2.GetAuthenticationStatus(reqStatus, authStatus);
|
|
331 |
User::WaitForRequest(reqStatus);
|
|
332 |
TEST(reqStatus == KErrNone);
|
|
333 |
TEST(authStatus == KEapAuthStatus2_2);
|
|
334 |
|
|
335 |
// see if first sub-session still works
|
|
336 |
reqPacketPtr.Set(KConfigScEapChal13);
|
|
337 |
eapAuth = CTestSimEapAuthenticateData::NewLC(simScEap, static_cast<TDesC8&>(reqPacketPtr));
|
|
338 |
eapAuth->Start();
|
|
339 |
CActiveScheduler::Start();
|
|
340 |
ret = eapAuth->ValidateEapResponse(KConfigScEapResp13());
|
|
341 |
TEST(ret == KErrNone);
|
|
342 |
CleanupStack::PopAndDestroy(eapAuth);
|
|
343 |
|
|
344 |
simScEap.GetAuthenticationStatus(reqStatus, authStatus);
|
|
345 |
User::WaitForRequest(reqStatus);
|
|
346 |
TEST(reqStatus == KErrNone);
|
|
347 |
TEST(authStatus == KEapAuthStatus1_3);
|
|
348 |
|
|
349 |
// one more attempt at authenticate on each sub-session for an
|
|
350 |
// error (i.e. no more entries in config.txt!)
|
|
351 |
INFO_PRINTF1(_L("Test one too many authenticates"));
|
|
352 |
reqPacketPtr.Set(KConfigScEapChal13);
|
|
353 |
eapAuth = CTestSimEapAuthenticateData::NewLC(simScEap, static_cast<TDesC8&>(reqPacketPtr));
|
|
354 |
eapAuth->Start();
|
|
355 |
CActiveScheduler::Start();
|
|
356 |
ret = eapAuth->ValidateEapResponse(KConfigScEapResp13());
|
|
357 |
TEST(ret == KErrAccessDenied); // it's just an error code that simtsy returns in such a use case
|
|
358 |
CleanupStack::PopAndDestroy(eapAuth);
|
|
359 |
reqPacketPtr.Set(KConfigScEapChal21);
|
|
360 |
eapAuth = CTestSimEapAuthenticateData::NewLC(simScEap2, static_cast<TDesC8&>(reqPacketPtr));
|
|
361 |
eapAuth->Start();
|
|
362 |
CActiveScheduler::Start();
|
|
363 |
ret = eapAuth->ValidateEapResponse(KConfigScEapResp21());
|
|
364 |
TEST(ret == KErrAccessDenied); // it's just an error code that simtsy returns in such a use case
|
|
365 |
CleanupStack::PopAndDestroy(eapAuth);
|
|
366 |
|
|
367 |
// Release simScEap handle and check completion of simScEap0's
|
|
368 |
// previously placed notification, and do a couple more get status.
|
|
369 |
INFO_PRINTF1(_L("Releasing first handle"));
|
|
370 |
ret = simScEap.ReleaseEapMethod();
|
|
371 |
TESTL(ret == KErrNone);
|
|
372 |
User::WaitForRequest(reqStatusNotif);
|
|
373 |
TEST(reqStatusNotif == KErrNone);
|
|
374 |
TEST(eapAccessStatNotif == RMobileSmartCardEap::EEapMethodAvailable);
|
|
375 |
simScEap0.GetEapMethodAccessStatus(eapAccessStat);
|
|
376 |
TEST(eapAccessStat == RMobileSmartCardEap::EEapMethodAvailable);
|
|
377 |
simScEap.GetEapMethodAccessStatus(eapAccessStat);
|
|
378 |
TEST(eapAccessStat == RMobileSmartCardEap::EEapMethodAvailable);
|
|
379 |
|
|
380 |
// Now that simScEap has released, simScEap0 should be able to
|
|
381 |
// initialise, but no more config data, so KErrNotFound should be
|
|
382 |
// returned. simScEap0 takes ownership anyway!
|
|
383 |
simScEap0.InitialiseEapMethod(reqStatus);
|
|
384 |
User::WaitForRequest(reqStatus);
|
|
385 |
TEST(reqStatus == KErrNotFound);
|
|
386 |
TEST(simScEap0.IsEapMethodOwner());
|
|
387 |
|
|
388 |
// kill both sub-sessions and active scheduler
|
|
389 |
CleanupStack::PopAndDestroy(&simScEap2);
|
|
390 |
CleanupStack::PopAndDestroy(iSimEapTestScheduler);
|
|
391 |
CleanupStack::PopAndDestroy(&simScEap);
|
|
392 |
CleanupStack::PopAndDestroy(&simScEap0);
|
|
393 |
|
|
394 |
|
|
395 |
// Initialise two further sub-sessions, for stress testing, and
|
|
396 |
// ensuring simulator's array indices do not get mangled.
|
|
397 |
|
|
398 |
// Open both sub-sessions
|
|
399 |
RMobileSmartCardEap simScEapReInit_1, simScEapReInit_2;
|
|
400 |
myAID = KConfigScReInitEapAID();
|
|
401 |
myEapType = KConfigScReInitEapType1();
|
|
402 |
ret = simScEapReInit_1.Open(iPhone, myAID, myEapType);
|
|
403 |
TESTL(ret == KErrNone);
|
|
404 |
CleanupClosePushL(simScEapReInit_1);
|
|
405 |
myEapType = KConfigScReInitEapType2();
|
|
406 |
ret = simScEapReInit_2.Open(iPhone, myAID, myEapType);
|
|
407 |
TESTL(ret == KErrNone);
|
|
408 |
CleanupClosePushL(simScEapReInit_2);
|
|
409 |
|
|
410 |
// Initialise both sub-sessions
|
|
411 |
simScEapReInit_1.InitialiseEapMethod(reqStatus);
|
|
412 |
User::WaitForRequest(reqStatus);
|
|
413 |
TEST(reqStatus == KErrNone);
|
|
414 |
simScEapReInit_2.InitialiseEapMethod(reqStatus);
|
|
415 |
User::WaitForRequest(reqStatus);
|
|
416 |
TEST(reqStatus == KErrNone);
|
|
417 |
|
|
418 |
// Neither sub-session contains any data, so any request will
|
|
419 |
// return an error. Plus, making the following two erroneous
|
|
420 |
// requests will give more branch coverage to them in simtsy! :-)
|
|
421 |
|
|
422 |
simScEapReInit_1.GetUserIdentity(reqStatus, eapIdType, userIdPckg);
|
|
423 |
User::WaitForRequest(reqStatus);
|
|
424 |
TEST(reqStatus == KErrNotFound);
|
|
425 |
|
|
426 |
simScEapReInit_2.GetEapKey(reqStatus, eapKeyTag, eapKeyPckg);
|
|
427 |
User::WaitForRequest(reqStatus);
|
|
428 |
TEST(reqStatus == KErrNotFound);
|
|
429 |
|
|
430 |
// now they are both in use
|
|
431 |
simScEapReInit_1.GetEapMethodAccessStatus(eapAccessStat);
|
|
432 |
TEST(eapAccessStat == RMobileSmartCardEap::EEapMethodInUseApplicationActive);
|
|
433 |
simScEapReInit_2.GetEapMethodAccessStatus(eapAccessStat);
|
|
434 |
TEST(eapAccessStat == RMobileSmartCardEap::EEapMethodInUseApplicationActive);
|
|
435 |
|
|
436 |
ret = simScEapReInit_1.ReleaseEapMethod();
|
|
437 |
TESTL(ret == KErrNone);
|
|
438 |
ret = simScEapReInit_2.ReleaseEapMethod();
|
|
439 |
TESTL(ret == KErrNone);
|
|
440 |
|
|
441 |
// kill 'em; I've had enough
|
|
442 |
CleanupStack::PopAndDestroy(&simScEapReInit_2);
|
|
443 |
CleanupStack::PopAndDestroy(&simScEapReInit_1);
|
|
444 |
|
|
445 |
return TestStepResult();
|
|
446 |
}
|
|
447 |
|
|
448 |
CTestSimEapAuthenticateData* CTestSimEapAuthenticateData::NewLC(RMobileSmartCardEap& aPhone, TDesC8& aDes)
|
|
449 |
{
|
|
450 |
CTestSimEapAuthenticateData* self = new(ELeave) CTestSimEapAuthenticateData(aPhone, aDes);
|
|
451 |
CleanupStack::PushL(self);
|
|
452 |
self->ConstructL(aDes);
|
|
453 |
return self;
|
|
454 |
}
|
|
455 |
|
|
456 |
CTestSimEapAuthenticateData::CTestSimEapAuthenticateData(RMobileSmartCardEap& aPhone, TDesC8& aDes)
|
|
457 |
: CActive(EPriorityStandard), iPhone(aPhone), iDes(aDes), iAuthResp(NULL)
|
|
458 |
{
|
|
459 |
}
|
|
460 |
|
|
461 |
CTestSimEapAuthenticateData::~CTestSimEapAuthenticateData()
|
|
462 |
{
|
|
463 |
delete iTwoPhaseRetrieve;
|
|
464 |
iTwoPhaseRetrieve = NULL;
|
|
465 |
}
|
|
466 |
|
|
467 |
void CTestSimEapAuthenticateData::ConstructL(TDesC8& aDes)
|
|
468 |
{
|
|
469 |
CActiveScheduler::Add(this);
|
|
470 |
iTwoPhaseRetrieve = CAsyncSmartCardEapAuthentication::NewL(iPhone, aDes);
|
|
471 |
}
|
|
472 |
|
|
473 |
void CTestSimEapAuthenticateData::Start()
|
|
474 |
{
|
|
475 |
iTwoPhaseRetrieve->Start(iStatus);
|
|
476 |
SetActive();
|
|
477 |
}
|
|
478 |
|
|
479 |
void CTestSimEapAuthenticateData::RunL()
|
|
480 |
{
|
|
481 |
if (iStatus == KErrNone)
|
|
482 |
{
|
|
483 |
iAuthResp = &(iTwoPhaseRetrieve->RetrieveEapResponse());
|
|
484 |
}
|
|
485 |
|
|
486 |
CActiveScheduler::Stop();
|
|
487 |
}
|
|
488 |
|
|
489 |
/**
|
|
490 |
Validates if the EAP authenticate response is the same as the
|
|
491 |
aExpectedResponse the user expects.
|
|
492 |
|
|
493 |
@param aExpectedResponse The response that this active object should
|
|
494 |
have retrieved from the TSY.
|
|
495 |
@return iStatus of this active object if it has not completed
|
|
496 |
successfully, KErrCorrupt if the data retrieved from TSY is not
|
|
497 |
the same as the aExpectedResponse, or KErrNone if all is well.
|
|
498 |
*/
|
|
499 |
TInt CTestSimEapAuthenticateData::ValidateEapResponse(const TDesC8& aExpectedResponse)
|
|
500 |
{
|
|
501 |
TInt ret = KErrNone;
|
|
502 |
|
|
503 |
// iStatus will be an error if the request data is invalid.
|
|
504 |
if (iStatus != KErrNone)
|
|
505 |
{
|
|
506 |
ret = iStatus.Int();
|
|
507 |
}
|
|
508 |
else if ((*iAuthResp) != aExpectedResponse)
|
|
509 |
{
|
|
510 |
ret = KErrCorrupt;
|
|
511 |
}
|
|
512 |
|
|
513 |
return ret;
|
|
514 |
}
|
|
515 |
|
|
516 |
void CTestSimEapAuthenticateData::DoCancel()
|
|
517 |
{
|
|
518 |
iTwoPhaseRetrieve->Cancel();
|
|
519 |
CActiveScheduler::Stop();
|
|
520 |
}
|
|
521 |
|
|
522 |
|
|
523 |
// Now test for bad clients who open but never close the phone //
|
|
524 |
|
|
525 |
/**
|
|
526 |
Each test step initialises its own name.
|
|
527 |
*/
|
|
528 |
CTestInitEapWithoutClosing::CTestInitEapWithoutClosing()
|
|
529 |
{
|
|
530 |
SetTestStepName(_L("TestSmartCardBasedEapBadClient"));
|
|
531 |
}
|
|
532 |
|
|
533 |
/**
|
|
534 |
Thread entry point, which initialises an RMobileSmartCardEap sub-
|
|
535 |
session, but dies without closing the handle.
|
|
536 |
*/
|
|
537 |
TInt InitialiseAndDie(TAny* /*aArg*/)
|
|
538 |
{
|
|
539 |
// New cleanup-trap for this thread
|
|
540 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
|
541 |
|
|
542 |
RTelServer telServer;
|
|
543 |
TInt ret = telServer.Connect();
|
|
544 |
|
|
545 |
ret = telServer.LoadPhoneModule(KSimtsyName);
|
|
546 |
|
|
547 |
RMobilePhone simPhone;
|
|
548 |
ret = simPhone.Open(telServer, KPhoneName);
|
|
549 |
|
|
550 |
RMobileSmartCardEap mmEap;
|
|
551 |
RMobilePhone::TAID myAID = KConfigScEapAIDBadCli();
|
|
552 |
RMobileSmartCardEap::TEapType myEapType = KConfigScEapTypeBadCli();
|
|
553 |
TRequestStatus reqStatus;
|
|
554 |
|
|
555 |
ret = mmEap.Open(simPhone, myAID, myEapType);
|
|
556 |
mmEap.InitialiseEapMethod(reqStatus);
|
|
557 |
User::WaitForRequest(reqStatus);
|
|
558 |
|
|
559 |
TInt kill;
|
|
560 |
// Return a different panic code depending on previous actions.
|
|
561 |
// 666 is success!
|
|
562 |
if (ret != KErrNone || reqStatus != KErrNone)
|
|
563 |
{
|
|
564 |
kill = 999;
|
|
565 |
}
|
|
566 |
else
|
|
567 |
{
|
|
568 |
kill = 666;
|
|
569 |
}
|
|
570 |
|
|
571 |
_LIT(paniced, "paniced");
|
|
572 |
TPtrC panicedPtr(paniced);
|
|
573 |
User::Panic(panicedPtr, kill);
|
|
574 |
|
|
575 |
// Cannot reach this point! Thread has died.
|
|
576 |
simPhone.Close();
|
|
577 |
telServer.Close();
|
|
578 |
|
|
579 |
delete cleanup;
|
|
580 |
|
|
581 |
return KErrNone;
|
|
582 |
}
|
|
583 |
|
|
584 |
const TUint KDefaultHeapSize = 0x1000;
|
|
585 |
|
|
586 |
/**
|
|
587 |
Test RMobileSmartCardEap initialisation after another client dies.
|
|
588 |
|
|
589 |
@see InitialiseAndDie()
|
|
590 |
*/
|
|
591 |
enum TVerdict CTestInitEapWithoutClosing::doTestStepL()
|
|
592 |
{
|
|
593 |
INFO_PRINTF1(_L("Test Bad Client with SmartCard Application based EAP Functionality"));
|
|
594 |
|
|
595 |
RThread badThread;
|
|
596 |
_LIT(badThreadName, "BadThread");
|
|
597 |
TInt ret = badThread.Create(badThreadName, InitialiseAndDie, KDefaultStackSize,
|
|
598 |
KDefaultHeapSize, KDefaultHeapSize, NULL);
|
|
599 |
TESTL(ret == KErrNone);
|
|
600 |
|
|
601 |
TRequestStatus tStatus;
|
|
602 |
badThread.Logon(tStatus);
|
|
603 |
badThread.Resume();
|
|
604 |
User::WaitForRequest(tStatus);
|
|
605 |
|
|
606 |
TInt exitReason = badThread.ExitReason();
|
|
607 |
TESTL(exitReason == 666);
|
|
608 |
TESTL(badThread.ExitType() == EExitPanic);
|
|
609 |
badThread.Close();
|
|
610 |
|
|
611 |
RMobileSmartCardEap simEap;
|
|
612 |
RMobilePhone::TAID myAID = KConfigScEapAIDBadCli();
|
|
613 |
RMobileSmartCardEap::TEapType myEapType = KConfigScEapTypeBadCli();
|
|
614 |
ret = simEap.Open(iPhone, myAID, myEapType);
|
|
615 |
CleanupClosePushL(simEap);
|
|
616 |
TESTL(ret == KErrNone);
|
|
617 |
|
|
618 |
RMobileSmartCardEap::TEapMethodAccessStatus accessStatus(RMobileSmartCardEap::EEapMethodAvailable);
|
|
619 |
ret = simEap.GetEapMethodAccessStatus(accessStatus);
|
|
620 |
TEST(ret == KErrNone);
|
|
621 |
TEST(accessStatus == RMobileSmartCardEap::EEapMethodAvailable);
|
|
622 |
|
|
623 |
simEap.InitialiseEapMethod(tStatus);
|
|
624 |
User::WaitForRequest(tStatus);
|
|
625 |
TEST(tStatus == KErrNone);
|
|
626 |
TEST(simEap.IsEapMethodOwner());
|
|
627 |
|
|
628 |
CleanupStack::PopAndDestroy(&simEap);
|
|
629 |
|
|
630 |
return TestStepResult();
|
|
631 |
}
|
|
632 |
|
|
633 |
// Test extended functionality of RMobilePhone //
|
|
634 |
|
|
635 |
CTestSmartCardAppAuthenticate::CTestSmartCardAppAuthenticate()
|
|
636 |
{
|
|
637 |
// store the name of this test case
|
|
638 |
// this is the name that is used by the script file
|
|
639 |
SetTestStepName(_L("TestSmartCardAppAuthenticate"));
|
|
640 |
}
|
|
641 |
|
|
642 |
TVerdict CTestSmartCardAppAuthenticate::doTestStepL()
|
|
643 |
{
|
|
644 |
TRequestStatus reqStatus;
|
|
645 |
|
|
646 |
RMobilePhone::TSmartCardAuthenticateDataV6 authenticateData;
|
|
647 |
|
|
648 |
authenticateData.iAUTN = KConfigScAuthAUTN();
|
|
649 |
authenticateData.iRAND = KConfigScAuthRAND();
|
|
650 |
|
|
651 |
RMobilePhone::TSmartCardAuthenticateDataV6Pckg authenticateDataPckg(authenticateData);
|
|
652 |
|
|
653 |
// Success
|
|
654 |
iPhone.SmartCardAuthenticate(reqStatus, authenticateDataPckg);
|
|
655 |
User::WaitForRequest(reqStatus);
|
|
656 |
TESTL(reqStatus == KErrNone);
|
|
657 |
|
|
658 |
TEST(authenticateData.iAUTN == KConfigScAuthAUTN());
|
|
659 |
TEST(authenticateData.iRAND == KConfigScAuthRAND());
|
|
660 |
TEST(authenticateData.iRES == KConfigScAuthRES());
|
|
661 |
TEST(authenticateData.iIK == KConfigScAuthIK());
|
|
662 |
TEST(authenticateData.iCK == KConfigScAuthCK());
|
|
663 |
TEST(authenticateData.iKc == KConfigScAuthKC());
|
|
664 |
|
|
665 |
// Failure
|
|
666 |
iPhone.SmartCardAuthenticate(reqStatus, authenticateDataPckg);
|
|
667 |
User::WaitForRequest(reqStatus);
|
|
668 |
TESTL(reqStatus == KErrGeneral);
|
|
669 |
|
|
670 |
TEST(authenticateData.iAUTN == KConfigScAuthAUTN());
|
|
671 |
TEST(authenticateData.iRAND == KConfigScAuthRAND());
|
|
672 |
TEST(authenticateData.iAUTS == KConfigScAuthAUTS());
|
|
673 |
|
|
674 |
// Now with specific AID
|
|
675 |
RMobilePhone::TAID scAID = KConfigScAuthAIDAscii();
|
|
676 |
|
|
677 |
iPhone.SmartCardAuthenticate(reqStatus, scAID, authenticateDataPckg);
|
|
678 |
User::WaitForRequest(reqStatus);
|
|
679 |
TESTL(reqStatus == KErrNone);
|
|
680 |
|
|
681 |
TEST(authenticateData.iAUTN == KConfigScAuthAUTN());
|
|
682 |
TEST(authenticateData.iRAND == KConfigScAuthRAND());
|
|
683 |
TEST(authenticateData.iRES == KConfigScAuthRES());
|
|
684 |
TEST(authenticateData.iIK == KConfigScAuthIK());
|
|
685 |
TEST(authenticateData.iCK == KConfigScAuthCK());
|
|
686 |
TEST(authenticateData.iKc == KConfigScAuthKC());
|
|
687 |
|
|
688 |
// Specific AID and fail
|
|
689 |
iPhone.SmartCardAuthenticate(reqStatus, scAID, authenticateDataPckg);
|
|
690 |
User::WaitForRequest(reqStatus);
|
|
691 |
TESTL(reqStatus == KErrTotalLossOfPrecision); // same error as in config.txt
|
|
692 |
// (there's nothing special about this returned error code.)
|
|
693 |
|
|
694 |
TEST(authenticateData.iAUTN == KConfigScAuthAUTN());
|
|
695 |
TEST(authenticateData.iRAND == KConfigScAuthRAND());
|
|
696 |
TEST(authenticateData.iAUTS == KConfigScAuthAUTS());
|
|
697 |
|
|
698 |
// All binary data
|
|
699 |
authenticateData.iAUTN = KConfigScAuthAUTNbin();
|
|
700 |
authenticateData.iRAND = KConfigScAuthRANDbin();
|
|
701 |
|
|
702 |
scAID = KConfigScAuthAIDBin();
|
|
703 |
|
|
704 |
iPhone.SmartCardAuthenticate(reqStatus, scAID, authenticateDataPckg);
|
|
705 |
User::WaitForRequest(reqStatus);
|
|
706 |
TESTL(reqStatus == KErrNone);
|
|
707 |
|
|
708 |
TEST(authenticateData.iAUTN == KConfigScAuthAUTNbin());
|
|
709 |
TEST(authenticateData.iRAND == KConfigScAuthRANDbin());
|
|
710 |
TEST(authenticateData.iRES == KConfigScAuthRESbin());
|
|
711 |
TEST(authenticateData.iIK == KConfigScAuthIKbin());
|
|
712 |
TEST(authenticateData.iCK == KConfigScAuthCKbin());
|
|
713 |
TEST(authenticateData.iKc == KConfigScAuthKCbin());
|
|
714 |
|
|
715 |
return TestStepResult();
|
|
716 |
}
|
|
717 |
|
|
718 |
CTestGetSmartCardAppEapList::CTestGetSmartCardAppEapList()
|
|
719 |
{
|
|
720 |
// store the name of this test case
|
|
721 |
// this is the name that is used by the script file
|
|
722 |
SetTestStepName(_L("TestGetSmartCardAppEapList"));
|
|
723 |
}
|
|
724 |
|
|
725 |
TVerdict CTestGetSmartCardAppEapList::doTestStepL()
|
|
726 |
{
|
|
727 |
TRequestStatus reqStatus;
|
|
728 |
RMobilePhone::TUiccApplicationEapInfoV6 scAppInfo;
|
|
729 |
|
|
730 |
RMobilePhone::TUiccApplicationEapInfoV6Pckg scAppInfoPckg(scAppInfo);
|
|
731 |
|
|
732 |
iPhone.GetSmartCardApplicationInfo(reqStatus, 0, scAppInfoPckg);
|
|
733 |
User::WaitForRequest(reqStatus);
|
|
734 |
TESTL(reqStatus == KErrNone);
|
|
735 |
|
|
736 |
TEST(scAppInfo.iAID == KConfigEapListAID());
|
|
737 |
TEST(scAppInfo.iLabel == KConfigEapListLabel());
|
|
738 |
TEST(scAppInfo.iEapTypeList == KConfigEapListEapList());
|
|
739 |
|
|
740 |
return TestStepResult();
|
|
741 |
}
|
|
742 |
|
|
743 |
CTestSmartCardAppAuthenticate2::CTestSmartCardAppAuthenticate2()
|
|
744 |
{
|
|
745 |
// store the name of this test case
|
|
746 |
// this is the name that is used by the script file
|
|
747 |
SetTestStepName(_L("TestSmartCardAppAuthenticate2"));
|
|
748 |
}
|
|
749 |
|
|
750 |
TVerdict CTestSmartCardAppAuthenticate2::doTestStepL()
|
|
751 |
{
|
|
752 |
// This is to test that the smart card authentication will work with EAP-SIM.
|
|
753 |
TRequestStatus reqStatus;
|
|
754 |
|
|
755 |
RMobilePhone::TSmartCardAuthenticateDataV6 authenticateData;
|
|
756 |
|
|
757 |
authenticateData.iAUTN = _L8("");
|
|
758 |
authenticateData.iRAND = KConfigScAuthRAND();
|
|
759 |
authenticateData.iRES = _L8("");
|
|
760 |
authenticateData.iIK = _L8("");
|
|
761 |
authenticateData.iCK = _L8("");
|
|
762 |
authenticateData.iKc = _L8("");
|
|
763 |
|
|
764 |
RMobilePhone::TSmartCardAuthenticateDataV6Pckg authenticateDataPckg(authenticateData);
|
|
765 |
|
|
766 |
// Success
|
|
767 |
iPhone.SmartCardAuthenticate(reqStatus, authenticateDataPckg);
|
|
768 |
User::WaitForRequest(reqStatus);
|
|
769 |
TESTL(reqStatus == KErrNone);
|
|
770 |
|
|
771 |
TEST(authenticateData.iAUTN == _L8(""));
|
|
772 |
TEST(authenticateData.iRAND == KConfigScAuthRAND());
|
|
773 |
TEST(authenticateData.iRES == KConfigScAuthRES());
|
|
774 |
TEST(authenticateData.iIK == _L8(""));
|
|
775 |
TEST(authenticateData.iCK == _L8(""));
|
|
776 |
TEST(authenticateData.iKc == KConfigScAuthKC());
|
|
777 |
|
|
778 |
return TestStepResult();
|
|
779 |
}
|