|
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 ciphersuitestep.h |
|
18 @internalTechnology |
|
19 */ |
|
20 #ifndef __TLSHANDSHAKESTEP_H__ |
|
21 #define __TLSHANDSHAKESTEP_H__ |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <tlstypedef.h> |
|
25 #include <securesocket.h> |
|
26 #include <es_sock.h> |
|
27 #include <in_sock.h> |
|
28 #include <testexecutestepbase.h> |
|
29 #include "ciphersuitesstep.h" |
|
30 #include <ssl.h> |
|
31 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
32 #include <ssl_internal.h> |
|
33 #endif |
|
34 |
|
35 _LIT(KHandShakeTestStep, "HandShakeStep"); |
|
36 _LIT(KClientCert, "ClientCert"); |
|
37 |
|
38 /** Number of chars allowed for address & page settings */ |
|
39 const TInt KSettingFieldWidth = 128; |
|
40 |
|
41 // Send buffer size |
|
42 const TInt KSendBufferSize = 256; |
|
43 // Receive buffer size |
|
44 const TInt KReceiveBufferSize = 512; |
|
45 // Max server name size, limited by test server |
|
46 const TInt KMaxServerNameLength = 255; |
|
47 |
|
48 // forward declarations: |
|
49 class CHandShakeStep; |
|
50 |
|
51 /** Connection settings to access a server */ |
|
52 struct TConnectSettings |
|
53 { |
|
54 /** Server address (as text) */ |
|
55 TBuf<KSettingFieldWidth> iAddress; |
|
56 /** Server port */ |
|
57 TInt iPortNum; |
|
58 /** Web page to get from the server */ |
|
59 TBuf8<KSettingFieldWidth> iPage; |
|
60 }; |
|
61 |
|
62 class CHandShakeTesterActive : public CActive |
|
63 { |
|
64 public: |
|
65 CHandShakeTesterActive( CTestExecuteLogger& aLogger ); |
|
66 ~CHandShakeTesterActive(); |
|
67 |
|
68 //Active |
|
69 void DoCancel() {return; }; |
|
70 TVerdict DoSecureConnectionTestL(CHandShakeStep* aStep); |
|
71 TInt HandShakeL(); |
|
72 TInt MakePageRequest(); |
|
73 void GetPageReceivedL(); |
|
74 TInt VerifyPageReceived(); |
|
75 TInt VerifyFinalCipherUsed(); |
|
76 void OutputPageToFileL(const TDesC8& aPageReceived); |
|
77 void RunL(); |
|
78 virtual TInt RunError(TInt aError); |
|
79 // Generic |
|
80 |
|
81 public: |
|
82 |
|
83 CTestExecuteLogger& Logger(){return iLogger;} |
|
84 CTestExecuteLogger& iLogger; |
|
85 |
|
86 CHandShakeStep* iStepPointer; |
|
87 TVerdict iTestSuccess; |
|
88 TInt iRunError; |
|
89 |
|
90 enum EState |
|
91 { |
|
92 EIdle, |
|
93 // Main test |
|
94 ESecureConnected, |
|
95 EGetRequestSent, |
|
96 EGetPageReceived |
|
97 }; |
|
98 EState iState; |
|
99 |
|
100 } ; |
|
101 |
|
102 class CHandShakeStep : public CTestStep, public MSoPskKeyHandler |
|
103 { |
|
104 public: |
|
105 CHandShakeStep(); |
|
106 |
|
107 TVerdict doTestStepPreambleL(); |
|
108 TVerdict doTestStepL(); |
|
109 TVerdict doTestL(); |
|
110 void ConnectL(); |
|
111 HBufC8* ReadCipherSuitesL(); |
|
112 CDesC8ArrayFlat* ReadServerNamesL(); |
|
113 void SetPskL(); |
|
114 void SetNullCipherL(); |
|
115 void CloseConnection(); |
|
116 |
|
117 virtual void GetPskL(const HBufC8 *aPskIdentityHint, HBufC8 *&aPskIdentity, HBufC8 *&aPskKey); |
|
118 |
|
119 ~CHandShakeStep(); |
|
120 |
|
121 CHandShakeTesterActive* iActiveObjTest; |
|
122 CActiveScheduler* iSched; |
|
123 |
|
124 // Connection parameters |
|
125 TConnectSettings iConnectSettings; |
|
126 // The Secure socket |
|
127 CSecureSocket* iTlsSocket; |
|
128 // Socket to make connection on |
|
129 RSocket iSocket; |
|
130 // Data sent buffer |
|
131 RBuf8 iSndBuffer; |
|
132 // #bytes sent |
|
133 TSockXfrLength iBytesSent; |
|
134 // Data received buffer (single packet) |
|
135 RBuf8 iRcvBuffer; |
|
136 // Page received (made by appending packets) |
|
137 RBuf8 iRcvPage; |
|
138 // Server address |
|
139 TInetAddr iInetAddr; |
|
140 // The socket server |
|
141 RSocketServ iSocketServ; |
|
142 // What is the cipher suit that is expected to be selected by web server |
|
143 TInt iExpectedFinalCipher; |
|
144 // The cipher suits to be included in hello client message read from INI file |
|
145 HBufC8 *iBufCipherSuitesFromIni; |
|
146 // PSK optional. |
|
147 TBool iUsePsk; |
|
148 // Null cipher optional. |
|
149 TBool iUseNullCipher; |
|
150 // Expected set suit error is optional. |
|
151 TInt iExpectedSetSuitesError; |
|
152 // Server names are optional. |
|
153 TBool iUseServerNames; |
|
154 // Array with server names. |
|
155 CDesC8ArrayFlat *iServerNamesArray; |
|
156 // Expected handshake error is optional. |
|
157 TInt iExpectedHandshakeError; |
|
158 |
|
159 }; |
|
160 |
|
161 #endif /* __TLSHANDSHAKESTEP_H__ */ |