|
1 |
|
2 |
|
3 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 // All rights reserved. |
|
5 // This component and the accompanying materials are made available |
|
6 // under the terms of "Eclipse Public License v1.0" |
|
7 // which accompanies this distribution, and is available |
|
8 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 // |
|
10 // Initial Contributors: |
|
11 // Nokia Corporation - initial contribution. |
|
12 // |
|
13 // Contributors: |
|
14 // |
|
15 // Description: |
|
16 // |
|
17 |
|
18 #include "TlsProvTestStep.h" |
|
19 #include <test/testexecutelog.h> |
|
20 #include <hash.h> |
|
21 |
|
22 |
|
23 |
|
24 TVerdict CTlsProvTestActive::doTest7_0L( CTlsProvStep* aStep ) |
|
25 { |
|
26 CTlsTestRandom rnd; |
|
27 |
|
28 SetThreadRandomL( &rnd ); |
|
29 |
|
30 RArray<TTLSCipherSuite> userCipherSuiteList; |
|
31 CTLSProvider* tlsProvider = CTLSProvider::ConnectL(); |
|
32 |
|
33 iStatus = KRequestPending; |
|
34 tlsProvider->CipherSuitesL( userCipherSuiteList ,iStatus); |
|
35 SetActive(); |
|
36 CActiveScheduler::Start(); |
|
37 |
|
38 |
|
39 CTLSSession* sessionObj; |
|
40 |
|
41 CTlsCryptoAttributes* tlsCryptoAttributes = tlsProvider->Attributes(); |
|
42 |
|
43 HBufC8* encServerCert = NULL; |
|
44 |
|
45 TInt res = StandardTestInitL(aStep, tlsCryptoAttributes, encServerCert); |
|
46 |
|
47 if( res < 0 ) |
|
48 { |
|
49 iLogInfo.Copy( _L(" 7.0: problems with test data files") ); |
|
50 return EFail; |
|
51 } |
|
52 tlsCryptoAttributes->iSessionNameAndID.iServerName.iAddress.Copy( KServer2 ); |
|
53 |
|
54 |
|
55 |
|
56 CX509Certificate* serverCert = NULL; |
|
57 iStatus = KRequestPending; |
|
58 tlsProvider->VerifyServerCertificate( encServerCert->Des(), serverCert, iStatus); |
|
59 SetActive(); |
|
60 CActiveScheduler::Start(); |
|
61 |
|
62 |
|
63 tlsCryptoAttributes->iClientAuthenticate = EFalse; |
|
64 tlsCryptoAttributes->iDialogNonAttendedMode = ETrue; |
|
65 |
|
66 |
|
67 HBufC8* clientKeyExch = NULL; |
|
68 |
|
69 iStatus = KRequestPending; |
|
70 tlsProvider->CreateL( sessionObj, |
|
71 iStatus); |
|
72 SetActive(); |
|
73 CActiveScheduler::Start(); |
|
74 |
|
75 // check that ClientKeyExch is not NULL |
|
76 if ( (iStatus.Int() != KErrNone ) || (NULL == sessionObj) ) |
|
77 { |
|
78 iLogInfo.Copy( _L(" 7.0: CTLSProvider::Create failed") ); |
|
79 return EInconclusive; |
|
80 } |
|
81 |
|
82 |
|
83 iStatus = KRequestPending; |
|
84 sessionObj->ClientKeyExchange(clientKeyExch, iStatus); |
|
85 SetActive(); |
|
86 CActiveScheduler::Start(); |
|
87 |
|
88 // check that ClientKeyExch is not NULL |
|
89 if ( (NULL == clientKeyExch) || ( 0 == clientKeyExch->Length()) ) |
|
90 { |
|
91 iLogInfo.Copy( _L(" 7.0: CTLSSession::ClientKeyExchange failed") ); |
|
92 return EInconclusive; |
|
93 } |
|
94 |
|
95 HBufC8* verifySrvFinInput = NULL; |
|
96 HBufC8* finshedMsg = NULL; |
|
97 |
|
98 res = aStep->ReadDataForSrvFinishedL(verifySrvFinInput, finshedMsg); |
|
99 if( res < 0 ) |
|
100 { |
|
101 iLogInfo.Copy( _L(" problems with test data files (for server finished check)") ); |
|
102 return EInconclusive; |
|
103 } |
|
104 |
|
105 CMessageDigest* md5Dig = NULL; |
|
106 CMessageDigest* shaDig = NULL; |
|
107 |
|
108 md5Dig = CMD5::NewL(); |
|
109 CleanupStack::PushL( md5Dig ); |
|
110 shaDig = CSHA1::NewL(); |
|
111 CleanupStack::PushL( shaDig ); |
|
112 |
|
113 md5Dig->Reset(); |
|
114 md5Dig->Update( verifySrvFinInput->Des() ); |
|
115 |
|
116 shaDig->Reset(); |
|
117 shaDig->Update( verifySrvFinInput->Des() ); |
|
118 |
|
119 iStatus = KRequestPending; |
|
120 sessionObj->VerifyServerFinishedMsgL( |
|
121 md5Dig, |
|
122 shaDig, |
|
123 finshedMsg->Des(), |
|
124 iStatus) ; |
|
125 |
|
126 SetActive(); |
|
127 CActiveScheduler::Start(); |
|
128 |
|
129 CleanupStack::PopAndDestroy( 2, md5Dig ); |
|
130 |
|
131 if ( iStatus.Int() != KErrNone ) |
|
132 { |
|
133 iLogInfo.Copy( _L(" 7.0 CTLSSession::VerifyServerFinishedMsgL failed") ); |
|
134 return EFail; |
|
135 } |
|
136 |
|
137 |
|
138 iLogInfo.Copy( _L(" 7.0: OK") ); |
|
139 |
|
140 |
|
141 return EPass; |
|
142 } |
|
143 |
|
144 |
|
145 TVerdict CTlsProvTestActive::doTest7_1L( CTlsProvStep* aStep ) |
|
146 { |
|
147 CTlsTestRandom rnd; |
|
148 |
|
149 SetThreadRandomL( &rnd ); |
|
150 |
|
151 RArray<TTLSCipherSuite> userCipherSuiteList; |
|
152 CTLSProvider* tlsProvider = CTLSProvider::ConnectL(); |
|
153 |
|
154 iStatus = KRequestPending; |
|
155 tlsProvider->CipherSuitesL( userCipherSuiteList ,iStatus); |
|
156 SetActive(); |
|
157 CActiveScheduler::Start(); |
|
158 |
|
159 |
|
160 CTLSSession* sessionObj; |
|
161 |
|
162 CTlsCryptoAttributes* tlsCryptoAttributes = tlsProvider->Attributes(); |
|
163 |
|
164 HBufC8* encServerCert = NULL; |
|
165 |
|
166 TInt res = StandardTestInitL(aStep, tlsCryptoAttributes, encServerCert); |
|
167 |
|
168 if( res < 0 ) |
|
169 { |
|
170 iLogInfo.Copy( _L(" 7.1: problems with test data files") ); |
|
171 return EFail; |
|
172 } |
|
173 tlsCryptoAttributes->iSessionNameAndID.iServerName.iAddress.Copy( KServer2 ); |
|
174 tlsCryptoAttributes->iNegotiatedProtocol.iMajor = 3; |
|
175 tlsCryptoAttributes->iNegotiatedProtocol.iMinor = 0; |
|
176 |
|
177 tlsCryptoAttributes->iProposedProtocol.iMajor = 3; |
|
178 tlsCryptoAttributes->iProposedProtocol.iMinor = 0; |
|
179 |
|
180 |
|
181 CX509Certificate* serverCert = NULL; |
|
182 iStatus = KRequestPending; |
|
183 tlsProvider->VerifyServerCertificate( encServerCert->Des(), serverCert, iStatus); |
|
184 SetActive(); |
|
185 CActiveScheduler::Start(); |
|
186 |
|
187 |
|
188 tlsCryptoAttributes->iClientAuthenticate = EFalse; |
|
189 tlsCryptoAttributes->iDialogNonAttendedMode = ETrue; |
|
190 |
|
191 |
|
192 HBufC8* clientKeyExch = NULL; |
|
193 |
|
194 iStatus = KRequestPending; |
|
195 tlsProvider->CreateL( sessionObj, |
|
196 iStatus); |
|
197 SetActive(); |
|
198 CActiveScheduler::Start(); |
|
199 |
|
200 // check that ClientKeyExch is not NULL |
|
201 if ( (iStatus.Int() != KErrNone ) || (NULL == sessionObj) ) |
|
202 { |
|
203 iLogInfo.Copy( _L(" 7.1: CTLSProvider::Create failed") ); |
|
204 return EInconclusive; |
|
205 } |
|
206 |
|
207 |
|
208 iStatus = KRequestPending; |
|
209 sessionObj->ClientKeyExchange(clientKeyExch, iStatus); |
|
210 SetActive(); |
|
211 CActiveScheduler::Start(); |
|
212 |
|
213 // check that ClientKeyExch is not NULL |
|
214 if ( (NULL == clientKeyExch) || ( 0 == clientKeyExch->Length()) ) |
|
215 { |
|
216 iLogInfo.Copy( _L(" 7.1: CTLSSession::ClientKeyExchange failed") ); |
|
217 return EInconclusive; |
|
218 } |
|
219 |
|
220 HBufC8* verifySrvFinInput = NULL; |
|
221 HBufC8* finshedMsg = NULL; |
|
222 |
|
223 res = aStep->ReadDataForSrvFinishedL(verifySrvFinInput, finshedMsg); |
|
224 if( res < 0 ) |
|
225 { |
|
226 iLogInfo.Copy( _L(" problems with test data files (for server finished check)") ); |
|
227 return EInconclusive; |
|
228 } |
|
229 |
|
230 CMessageDigest* md5Dig = NULL; |
|
231 CMessageDigest* shaDig = NULL; |
|
232 |
|
233 md5Dig = CMD5::NewL(); |
|
234 CleanupStack::PushL( md5Dig ); |
|
235 shaDig = CSHA1::NewL(); |
|
236 CleanupStack::PushL( shaDig ); |
|
237 |
|
238 md5Dig->Reset(); |
|
239 md5Dig->Update( verifySrvFinInput->Des() ); |
|
240 |
|
241 shaDig->Reset(); |
|
242 shaDig->Update( verifySrvFinInput->Des() ); |
|
243 |
|
244 iStatus = KRequestPending; |
|
245 sessionObj->VerifyServerFinishedMsgL( |
|
246 md5Dig, |
|
247 shaDig, |
|
248 finshedMsg->Des(), |
|
249 iStatus) ; |
|
250 |
|
251 SetActive(); |
|
252 CActiveScheduler::Start(); |
|
253 |
|
254 CleanupStack::PopAndDestroy( 2, md5Dig ); |
|
255 |
|
256 if ( iStatus.Int() != KErrNone ) |
|
257 { |
|
258 iLogInfo.Copy( _L(" 7.1 CTLSSession::VerifyServerFinishedMsgL failed") ); |
|
259 return EFail; |
|
260 } |
|
261 |
|
262 |
|
263 iLogInfo.Copy( _L(" 7.1: OK") ); |
|
264 |
|
265 |
|
266 return EPass; |
|
267 |
|
268 } |
|
269 |
|
270 |
|
271 |
|
272 TVerdict CTlsProvTestActive::doTest7_2L( CTlsProvStep* aStep ) |
|
273 { |
|
274 CTlsTestRandom rnd; |
|
275 |
|
276 SetThreadRandomL( &rnd ); |
|
277 |
|
278 RArray<TTLSCipherSuite> userCipherSuiteList; |
|
279 CTLSProvider* tlsProvider = CTLSProvider::ConnectL(); |
|
280 |
|
281 iStatus = KRequestPending; |
|
282 tlsProvider->CipherSuitesL( userCipherSuiteList ,iStatus); |
|
283 SetActive(); |
|
284 CActiveScheduler::Start(); |
|
285 |
|
286 |
|
287 CTLSSession* sessionObj; |
|
288 |
|
289 CTlsCryptoAttributes* tlsCryptoAttributes = tlsProvider->Attributes(); |
|
290 |
|
291 HBufC8* encServerCert = NULL; |
|
292 |
|
293 TInt res = StandardTestInitL(aStep, tlsCryptoAttributes, encServerCert); |
|
294 |
|
295 if( res < 0 ) |
|
296 { |
|
297 iLogInfo.Copy( _L(" 7.2: problems with test data files") ); |
|
298 return EFail; |
|
299 } |
|
300 |
|
301 aStep->GetStringFromConfig(aStep->ConfigSection(),_L("HandshakeMsgsClient"),aStep->iHandshakeMsgsClient); |
|
302 aStep->GetStringFromConfig(aStep->ConfigSection(),_L("ClntFinishedCheckOutput"),aStep->iClntFinishedCheckOutput); |
|
303 |
|
304 tlsCryptoAttributes->iSessionNameAndID.iServerName.iAddress.Copy( KServer2 ); |
|
305 |
|
306 |
|
307 |
|
308 CX509Certificate* serverCert = NULL; |
|
309 iStatus = KRequestPending; |
|
310 tlsProvider->VerifyServerCertificate( encServerCert->Des(), serverCert, iStatus); |
|
311 SetActive(); |
|
312 CActiveScheduler::Start(); |
|
313 |
|
314 |
|
315 tlsCryptoAttributes->iClientAuthenticate = EFalse; |
|
316 tlsCryptoAttributes->iDialogNonAttendedMode = ETrue; |
|
317 |
|
318 |
|
319 HBufC8* clientKeyExch = NULL; |
|
320 |
|
321 iStatus = KRequestPending; |
|
322 tlsProvider->CreateL( sessionObj, |
|
323 iStatus); |
|
324 SetActive(); |
|
325 CActiveScheduler::Start(); |
|
326 |
|
327 // check that ClientKeyExch is not NULL |
|
328 if ( (iStatus.Int() != KErrNone ) || (NULL == sessionObj) ) |
|
329 { |
|
330 iLogInfo.Copy( _L(" 7.2: CTLSProvider::Create failed") ); |
|
331 return EInconclusive; |
|
332 } |
|
333 |
|
334 |
|
335 iStatus = KRequestPending; |
|
336 sessionObj->ClientKeyExchange(clientKeyExch, iStatus); |
|
337 SetActive(); |
|
338 CActiveScheduler::Start(); |
|
339 |
|
340 // check that ClientKeyExch is not NULL |
|
341 if ( (NULL == clientKeyExch) || ( 0 == clientKeyExch->Length()) ) |
|
342 { |
|
343 iLogInfo.Copy( _L(" 7.2: CTLSSession::ClientKeyExchange failed") ); |
|
344 return EInconclusive; |
|
345 } |
|
346 |
|
347 HBufC8* clntFinInput = NULL; |
|
348 HBufC8* finshedMsg = NULL; |
|
349 |
|
350 res = aStep->ReadDataForClntFinishedL(clntFinInput, finshedMsg); |
|
351 if( res < 0 ) |
|
352 { |
|
353 iLogInfo.Copy( _L(" problems with test data files (for client finished check)") ); |
|
354 return EInconclusive; |
|
355 } |
|
356 |
|
357 CMessageDigest* md5Dig = NULL; |
|
358 CMessageDigest* shaDig = NULL; |
|
359 |
|
360 md5Dig = CMD5::NewL(); |
|
361 CleanupStack::PushL( md5Dig ); |
|
362 shaDig = CSHA1::NewL(); |
|
363 CleanupStack::PushL( shaDig ); |
|
364 |
|
365 md5Dig->Reset(); |
|
366 md5Dig->Update( clntFinInput->Des() ); |
|
367 |
|
368 shaDig->Reset(); |
|
369 shaDig->Update( clntFinInput->Des() ); |
|
370 |
|
371 HBufC8* output = NULL; |
|
372 iStatus = KRequestPending; |
|
373 sessionObj->ClientFinishedMsgL( |
|
374 md5Dig, |
|
375 shaDig, |
|
376 output, |
|
377 iStatus) ; |
|
378 |
|
379 SetActive(); |
|
380 CActiveScheduler::Start(); |
|
381 |
|
382 CleanupStack::PopAndDestroy( 2, md5Dig ); |
|
383 |
|
384 if ( iStatus.Int() != KErrNone || (0 != output->Compare(finshedMsg->Des()) ) ) |
|
385 { |
|
386 iLogInfo.Copy( _L(" 7.2 CTLSSession::ClientFinishedMsgL failed") ); |
|
387 return EFail; |
|
388 } |
|
389 |
|
390 |
|
391 iLogInfo.Copy( _L(" 7.2: OK") ); |
|
392 |
|
393 return EPass; |
|
394 |
|
395 } |
|
396 |
|
397 |
|
398 |
|
399 TVerdict CTlsProvTestActive::doTest7_3L( CTlsProvStep* aStep ) |
|
400 { |
|
401 CTlsTestRandom rnd; |
|
402 |
|
403 SetThreadRandomL( &rnd ); |
|
404 |
|
405 RArray<TTLSCipherSuite> userCipherSuiteList; |
|
406 CTLSProvider* tlsProvider = CTLSProvider::ConnectL(); |
|
407 |
|
408 iStatus = KRequestPending; |
|
409 tlsProvider->CipherSuitesL( userCipherSuiteList ,iStatus); |
|
410 SetActive(); |
|
411 CActiveScheduler::Start(); |
|
412 |
|
413 |
|
414 CTLSSession* sessionObj; |
|
415 |
|
416 CTlsCryptoAttributes* tlsCryptoAttributes = tlsProvider->Attributes(); |
|
417 |
|
418 HBufC8* encServerCert = NULL; |
|
419 |
|
420 TInt res = StandardTestInitL(aStep, tlsCryptoAttributes, encServerCert); |
|
421 |
|
422 if( res < 0 ) |
|
423 { |
|
424 iLogInfo.Copy( _L(" 7.3: problems with test data files") ); |
|
425 return EFail; |
|
426 } |
|
427 |
|
428 aStep->GetStringFromConfig(aStep->ConfigSection(),_L("HandshakeMsgsClient"),aStep->iHandshakeMsgsClient); |
|
429 aStep->GetStringFromConfig(aStep->ConfigSection(),_L("ClntFinishedCheckOutput"),aStep->iClntFinishedCheckOutput); |
|
430 |
|
431 tlsCryptoAttributes->iSessionNameAndID.iServerName.iAddress.Copy( KServer2 ); |
|
432 |
|
433 tlsCryptoAttributes->iNegotiatedProtocol.iMajor = 3; |
|
434 tlsCryptoAttributes->iNegotiatedProtocol.iMinor = 0; |
|
435 |
|
436 tlsCryptoAttributes->iProposedProtocol.iMajor = 3; |
|
437 tlsCryptoAttributes->iProposedProtocol.iMinor = 0; |
|
438 |
|
439 |
|
440 |
|
441 CX509Certificate* serverCert = NULL; |
|
442 iStatus = KRequestPending; |
|
443 tlsProvider->VerifyServerCertificate( encServerCert->Des(), serverCert, iStatus); |
|
444 SetActive(); |
|
445 CActiveScheduler::Start(); |
|
446 |
|
447 |
|
448 tlsCryptoAttributes->iClientAuthenticate = EFalse; |
|
449 tlsCryptoAttributes->iDialogNonAttendedMode = ETrue; |
|
450 |
|
451 |
|
452 HBufC8* clientKeyExch = NULL; |
|
453 |
|
454 iStatus = KRequestPending; |
|
455 tlsProvider->CreateL( sessionObj, |
|
456 iStatus); |
|
457 SetActive(); |
|
458 CActiveScheduler::Start(); |
|
459 |
|
460 // check that ClientKeyExch is not NULL |
|
461 if ( (iStatus.Int() != KErrNone ) || (NULL == sessionObj) ) |
|
462 { |
|
463 iLogInfo.Copy( _L(" 7.3: CTLSProvider::Create failed") ); |
|
464 return EInconclusive; |
|
465 } |
|
466 |
|
467 |
|
468 iStatus = KRequestPending; |
|
469 sessionObj->ClientKeyExchange(clientKeyExch, iStatus); |
|
470 SetActive(); |
|
471 CActiveScheduler::Start(); |
|
472 |
|
473 // check that ClientKeyExch is not NULL |
|
474 if ( (NULL == clientKeyExch) || ( 0 == clientKeyExch->Length()) ) |
|
475 { |
|
476 iLogInfo.Copy( _L(" 7.3: CTLSSession::ClientKeyExchange failed") ); |
|
477 return EInconclusive; |
|
478 } |
|
479 |
|
480 HBufC8* clntFinInput = NULL; |
|
481 HBufC8* finshedMsg = NULL; |
|
482 |
|
483 res = aStep->ReadDataForClntFinishedL(clntFinInput, finshedMsg); |
|
484 if( res < 0 ) |
|
485 { |
|
486 iLogInfo.Copy( _L(" problems with test data files (for client finished check)") ); |
|
487 return EInconclusive; |
|
488 } |
|
489 |
|
490 CMessageDigest* md5Dig = NULL; |
|
491 CMessageDigest* shaDig = NULL; |
|
492 |
|
493 md5Dig = CMD5::NewL(); |
|
494 CleanupStack::PushL( md5Dig ); |
|
495 shaDig = CSHA1::NewL(); |
|
496 CleanupStack::PushL( shaDig ); |
|
497 |
|
498 md5Dig->Reset(); |
|
499 md5Dig->Update( clntFinInput->Des() ); |
|
500 |
|
501 shaDig->Reset(); |
|
502 shaDig->Update( clntFinInput->Des() ); |
|
503 |
|
504 HBufC8* output = NULL; |
|
505 iStatus = KRequestPending; |
|
506 sessionObj->ClientFinishedMsgL( |
|
507 md5Dig, |
|
508 shaDig, |
|
509 output, |
|
510 iStatus) ; |
|
511 |
|
512 SetActive(); |
|
513 CActiveScheduler::Start(); |
|
514 |
|
515 CleanupStack::PopAndDestroy( 2, md5Dig ); |
|
516 |
|
517 if ( iStatus.Int() != KErrNone || (0 != output->Compare(finshedMsg->Des()) ) ) |
|
518 { |
|
519 iLogInfo.Copy( _L(" 7.3 CTLSSession::ClientFinishedMsgL failed") ); |
|
520 return EFail; |
|
521 } |
|
522 |
|
523 |
|
524 iLogInfo.Copy( _L(" 7.3: OK") ); |
|
525 |
|
526 return EPass; |
|
527 |
|
528 } |
|
529 |
|
530 |