|
1 // Copyright (c) 2005-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 "tlsoomkeyexchangestep.h" |
|
21 |
|
22 #include <x509cert.h> |
|
23 |
|
24 |
|
25 CTlsOOMKeyExchangeStep* CTlsOOMKeyExchangeStep::NewL(const TDesC& aConfigPath, const TDesC& aServerName, |
|
26 const TDesC& aSessionID, CTestExecuteLogger& aLogger) |
|
27 { |
|
28 |
|
29 CTlsOOMKeyExchangeStep* self = new (ELeave) CTlsOOMKeyExchangeStep(aConfigPath, aServerName, aSessionID, aLogger); |
|
30 return self; |
|
31 |
|
32 } |
|
33 |
|
34 CTlsOOMKeyExchangeStep::CTlsOOMKeyExchangeStep(const TDesC& aConfigPath, const TDesC& aServerName, |
|
35 const TDesC& aSessionID, CTestExecuteLogger& aLogger) |
|
36 : CTlsOOMStepBase(aLogger, aConfigPath), |
|
37 iSessionID(aSessionID), |
|
38 iServerName(aServerName) |
|
39 { |
|
40 } |
|
41 |
|
42 void CTlsOOMKeyExchangeStep::DoTestStepL() |
|
43 { |
|
44 |
|
45 CTLSProvider* tlsProvider; |
|
46 CTLSSession* tlsSession; |
|
47 CTlsCryptoAttributes* tlsAttributes; |
|
48 HBufC8* serverCert; |
|
49 |
|
50 InitTlsProviderLC(tlsProvider, tlsAttributes, serverCert); |
|
51 |
|
52 TTLSCipherSuite cipherSuite; |
|
53 cipherSuite.iHiByte = 0; |
|
54 cipherSuite.iLoByte = 3; |
|
55 |
|
56 tlsAttributes->iClientAuthenticate = EFalse; |
|
57 tlsAttributes->iDialogNonAttendedMode = ETrue; |
|
58 tlsAttributes->iCurrentCipherSuite = cipherSuite; |
|
59 |
|
60 tlsAttributes->iSessionNameAndID.iServerName.iAddress.Copy(iServerName); |
|
61 tlsAttributes->iSessionNameAndID.iServerName.iPort = 10; |
|
62 tlsAttributes->iSessionNameAndID.iSessionId.Append(iSessionID); |
|
63 |
|
64 tlsAttributes->iCompressionMethod = ENullCompression; |
|
65 |
|
66 tlsAttributes->iNegotiatedProtocol.iMajor = 3; |
|
67 tlsAttributes->iNegotiatedProtocol.iMinor = 1; |
|
68 tlsAttributes->iProposedProtocol.iMajor = 3; |
|
69 tlsAttributes->iProposedProtocol.iMinor = 1; |
|
70 |
|
71 tlsAttributes->iPublicKeyParams->iKeyType = ERsa; |
|
72 |
|
73 CX509Certificate* serverCertObj; |
|
74 iStatus = KRequestPending; |
|
75 tlsProvider->VerifyServerCertificate(*serverCert, serverCertObj, iStatus); |
|
76 CleanupStack::PushL(serverCertObj); |
|
77 SetActive(); |
|
78 CActiveScheduler::Start(); |
|
79 |
|
80 if (iStatus != KErrNone) |
|
81 { |
|
82 User::Leave(iStatus.Int()); |
|
83 } |
|
84 |
|
85 iStatus = KRequestPending; |
|
86 tlsProvider->CreateL(tlsSession, iStatus); |
|
87 CleanupStack::PushL(tlsSession); |
|
88 SetActive(); |
|
89 CActiveScheduler::Start(); |
|
90 |
|
91 // leave if the status is failure |
|
92 if (iStatus != KErrNone) |
|
93 { |
|
94 User::Leave(iStatus.Int()); |
|
95 } |
|
96 |
|
97 HBufC8* clientKeyExch; |
|
98 |
|
99 iStatus = KRequestPending; |
|
100 tlsSession->ClientKeyExchange(clientKeyExch, iStatus); |
|
101 CleanupStack::PushL(clientKeyExch); |
|
102 SetActive(); |
|
103 CActiveScheduler::Start(); |
|
104 |
|
105 CleanupStack::PopAndDestroy(5, tlsProvider); //serverCert, tlsSession, clientKeyExchange, serverCertObj |
|
106 |
|
107 } |