|
1 /* |
|
2 * Copyright (c) 2006 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDES |
|
22 |
|
23 #include "test_secure.h" |
|
24 #include "mmcccodecinformation.h" |
|
25 #include "mccteststubs.h" |
|
26 #include "mmccinterface.h" |
|
27 #include "testdefinitions.hrh" |
|
28 #include "mmccsecureinterface.h" |
|
29 |
|
30 |
|
31 _LIT8(KTestKey128bits, "1122334455667788"); |
|
32 _LIT8(KTestMKI128Bits, "AAAAAAAAAAAAAAAA"); |
|
33 _LIT8(KRFCTestSalt112bits, "0EC675AD498AFE"); |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ================================================= |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CTestInterfaceInterface::CTestInterfaceInterface |
|
39 // C++ default constructor can NOT contain any code, that |
|
40 // might leave. |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 CTestSecure::CTestSecure( CConsoleBase& aConsole, |
|
44 const TMccNetSettings& aSettings, CMccInterface& aIF, CMccInterfaceStub& aIFStub ) |
|
45 : |
|
46 iConsole( aConsole ), iNetsettings( aSettings ), iInterface( aIF ), |
|
47 iInterfaceStub( aIFStub ) |
|
48 { |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // CTestInterface::ConstructL |
|
53 // Symbian 2nd phase constructor can leave. |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 void CTestSecure::ConstructL() |
|
57 { |
|
58 |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // CTestInterface::NewL |
|
63 // Static constructor. |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CTestSecure* CTestSecure::NewL( CConsoleBase& aConsole, |
|
67 const TMccNetSettings& aSettings, CMccInterface& aIF, CMccInterfaceStub& aIFStub ) |
|
68 { |
|
69 CTestSecure* self |
|
70 = new ( ELeave ) CTestSecure( aConsole, aSettings, aIF, aIFStub ); |
|
71 |
|
72 CleanupStack::PushL( self ); |
|
73 self->ConstructL(); |
|
74 CleanupStack::Pop( self ); |
|
75 return self; |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CTestInterface::~CTestInterface |
|
80 // Destructor. |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 CTestSecure::~CTestSecure() |
|
84 { |
|
85 //delete iSecureInterface; |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // CTestInterface::DoRunInterfaceTestsL |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 void CTestSecure::DoRunSecureTestsL() |
|
93 { |
|
94 iConsole.ClearScreen(); |
|
95 iConsole.Printf( _L("\n*** INTERFACE TESTS ***\n") ); |
|
96 |
|
97 iConsole.Printf( _L("DUMMY SECURE INTERFACE\n") ); |
|
98 RDebug::Print( _L("Mcc_COM_TEST_START: DummyMethodL") ); |
|
99 //__UHEAP_MARK; |
|
100 DummyMethodL(); |
|
101 //__UHEAP_MARKEND; |
|
102 RDebug::Print( _L("Mcc_COM_TEST_STOP: DummyMethodL") ); |
|
103 |
|
104 iConsole.Printf( _L("CREATE SECURE INTERFACE\n") ); |
|
105 RDebug::Print( _L("Mcc_COM_TEST_START: TestCreateSecureInterfaceL") ); |
|
106 __UHEAP_MARK; |
|
107 TestCreateSecureInterfaceL(); |
|
108 __UHEAP_MARKEND; |
|
109 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestCreateSecureInterfaceL") ); |
|
110 |
|
111 iConsole.Printf( _L("CREATE CRYPTO CONTEXT\n") ); |
|
112 RDebug::Print( _L("Mcc_COM_TEST_START: TestCreateCryptoContextL") ); |
|
113 __UHEAP_MARK; |
|
114 TestCreateCryptoContextL(); |
|
115 __UHEAP_MARKEND; |
|
116 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestCreateCryptoContextL") ); |
|
117 |
|
118 iConsole.Printf( _L("CREATE INVALID CRYPTO CONTEXT\n") ); |
|
119 RDebug::Print( _L("Mcc_COM_TEST_START: TestCreateInvalidCryptoContextL") ); |
|
120 __UHEAP_MARK; |
|
121 TestCreateInvalidCryptoContextL(); |
|
122 __UHEAP_MARKEND; |
|
123 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestCreateInvalidCryptoContextL") ); |
|
124 |
|
125 iConsole.Printf( _L("UPDATE CRYPTO CONTEXT\n") ); |
|
126 RDebug::Print( _L("Mcc_COM_TEST_START: TestUpdateCryptoContextL") ); |
|
127 __UHEAP_MARK; |
|
128 TestUpdateCryptoContextL(); |
|
129 __UHEAP_MARKEND; |
|
130 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestUpdateCryptoContextL") ); |
|
131 |
|
132 iConsole.Printf( _L("BIND CRYPTO CONTEXT\n") ); |
|
133 RDebug::Print( _L("Mcc_COM_TEST_START: TestBindCryptoContextL") ); |
|
134 __UHEAP_MARK; |
|
135 TestBindCryptoContextL(); |
|
136 __UHEAP_MARKEND; |
|
137 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestBindCryptoContextL") ); |
|
138 |
|
139 iConsole.Printf( _L("BIND CRYPTO CONTEXT & REFRESH IT \n") ); |
|
140 RDebug::Print( _L("Mcc_COM_TEST_START: TestBindCryptoContextAndRefreshContextL") ); |
|
141 __UHEAP_MARK; |
|
142 TestBindCryptoContextAndRefreshContextL(); |
|
143 __UHEAP_MARKEND; |
|
144 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestBindCryptoContextAndRefreshContextL") ); |
|
145 |
|
146 iConsole.Printf( _L("BIND CRYPTO CONTEXT & PREPARE STREAM \n") ); |
|
147 RDebug::Print( _L("Mcc_COM_TEST_START: TestBindCryptoContextAndPrepareStreamL") ); |
|
148 __UHEAP_MARK; |
|
149 TestBindCryptoContextAndPrepareStreamL(); |
|
150 __UHEAP_MARKEND; |
|
151 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestBindCryptoContextAndPrepareStreamL") ); |
|
152 |
|
153 iConsole.Printf( _L("BIND CRYPTO CONTEXT & PREPARE MULTIPLE STREAMS \n") ); |
|
154 RDebug::Print( _L("Mcc_COM_TEST_START: TestBindCryptoContextAndPrepareMultipleStreamsL") ); |
|
155 __UHEAP_MARK; |
|
156 TestBindCryptoContextAndPrepareMultipleStreamsL(); |
|
157 __UHEAP_MARKEND; |
|
158 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestBindCryptoContextAndPrepareMultipleStreamsL") ); |
|
159 |
|
160 iConsole.Printf( _L("REMOVE CRYPTO CONTEXT\n") ); |
|
161 RDebug::Print( _L("Mcc_COM_TEST_START: TestRemoveCryptoContextL") ); |
|
162 __UHEAP_MARK; |
|
163 TestRemoveCryptoContextL(); |
|
164 __UHEAP_MARKEND; |
|
165 RDebug::Print( _L("Mcc_COM_TEST_STOP: TestRemoveCryptoContextL") ); |
|
166 |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // CTestSecure::TestCreateSecureInterface |
|
171 // --------------------------------------------------------------------------- |
|
172 // |
|
173 void CTestSecure::TestCreateSecureInterfaceL() |
|
174 { |
|
175 RDebug::Print( _L("CTestSecure::TestCreateSecureInterfaceL") ); |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // CTestSecure::DummyMethodL |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 void CTestSecure::DummyMethodL() |
|
183 { |
|
184 iSecureInterface = CMccSecureInterface::NewL( iInterface ); |
|
185 |
|
186 this->CreateSecureSessioLinkAddDlUlSinkSourceCreateStreamsL(); |
|
187 |
|
188 User::LeaveIfError( iInterface.DeleteStream( iSessionId, iLinkId, iDlStreamId ) ); |
|
189 User::LeaveIfError( iInterface.DeleteStream( iSessionId, iLinkId, iUlStreamId ) ); |
|
190 |
|
191 this->CloseSecureSessioL(); |
|
192 delete iSecureInterface; |
|
193 } |
|
194 |
|
195 |
|
196 // --------------------------------------------------------------------------- |
|
197 // CTestSecure::TestCreateCryptoContextL |
|
198 // --------------------------------------------------------------------------- |
|
199 // |
|
200 void CTestSecure::TestCreateCryptoContextL() |
|
201 { |
|
202 |
|
203 // Creates new master key |
|
204 HBufC8* masterKey = KTestKey128bits().AllocLC(); |
|
205 TMccSrtpMasterKey mccMasterKey( *masterKey, KNullDesC8() ); |
|
206 TMccSrtpMasterKeyPckg mccMasterKeyPckg = mccMasterKey; |
|
207 CleanupStack::PopAndDestroy( masterKey ); |
|
208 |
|
209 |
|
210 // Creates new master salt |
|
211 HBufC8* masterSalt = KRFCTestSalt112bits().AllocLC(); |
|
212 TMccSrtpMasterSalt salt( *masterSalt ); |
|
213 TMccSrtpMasterSaltPckg saltPckg = salt; |
|
214 CleanupStack::PopAndDestroy( masterSalt ); |
|
215 |
|
216 // Creates new crypto params |
|
217 TMccSrtpCryptoParams cryptoParams; |
|
218 TMccSrtpCryptoParamsPckg cryptoParamsPckg = cryptoParams; |
|
219 |
|
220 |
|
221 iSecureInterface = CMccSecureInterface::NewL( iInterface ); |
|
222 |
|
223 |
|
224 |
|
225 TInt error = iSecureInterface->CreateContext( mccMasterKeyPckg, |
|
226 saltPckg, |
|
227 iContextId, |
|
228 cryptoParamsPckg ); |
|
229 |
|
230 RDebug::Print( _L("TestCreateCryptoContextL context id: %u\n"), iContextId ); |
|
231 |
|
232 error = iSecureInterface->CreateContext( mccMasterKeyPckg, |
|
233 saltPckg, |
|
234 iContextId2, |
|
235 cryptoParamsPckg ); |
|
236 |
|
237 RDebug::Print( _L("TestCreateCryptoContextL context id: %u\n"), iContextId2 ); |
|
238 delete iSecureInterface; |
|
239 } |
|
240 |
|
241 // --------------------------------------------------------------------------- |
|
242 // CTestSecure::TestCreateInvalidCryptoContextL() |
|
243 // --------------------------------------------------------------------------- |
|
244 // |
|
245 void CTestSecure::TestCreateInvalidCryptoContextL() |
|
246 { |
|
247 iSecureInterface = CMccSecureInterface::NewL( iInterface ); |
|
248 |
|
249 _LIT8(KTestInvalidKey128bits, "11223344"); |
|
250 |
|
251 // Creates invalid master key |
|
252 HBufC8* masterKey2 = KTestInvalidKey128bits().AllocLC(); |
|
253 TMccSrtpMasterKey master( *masterKey2, KNullDesC8() ); |
|
254 TMccSrtpMasterKeyPckg masterKeyPckg( master ); |
|
255 CleanupStack::PopAndDestroy( masterKey2 ); |
|
256 |
|
257 |
|
258 // Creates new master key |
|
259 HBufC8* masterKey = KTestKey128bits().AllocLC(); |
|
260 TMccSrtpMasterKey mccMasterKey( *masterKey, KNullDesC8() ); |
|
261 TMccSrtpMasterKeyPckg mccMasterKeyPckg = mccMasterKey; |
|
262 CleanupStack::PopAndDestroy( masterKey ); |
|
263 |
|
264 |
|
265 // Creates new master salt |
|
266 HBufC8* masterSalt = KRFCTestSalt112bits().AllocLC(); |
|
267 TMccSrtpMasterSalt salt( *masterSalt ); |
|
268 TMccSrtpMasterSaltPckg saltPckg = salt; |
|
269 CleanupStack::PopAndDestroy( masterSalt ); |
|
270 |
|
271 // Creates new crypto params |
|
272 TMccSrtpCryptoParams cryptoParams; |
|
273 TMccSrtpCryptoParamsPckg cryptoParamsPckg = cryptoParams; |
|
274 |
|
275 |
|
276 TInt error = iSecureInterface->CreateContext( masterKeyPckg, |
|
277 saltPckg, |
|
278 iContextId, |
|
279 cryptoParamsPckg ); |
|
280 |
|
281 |
|
282 delete iSecureInterface; |
|
283 RDebug::Print( _L("TestCreateInvalidCryptoContextL context id: %d\n"), iContextId ); |
|
284 RDebug::Print( _L("CTestSecure::TestCreateInvalidCryptoContextL KErrArgument[-6] OK - %d"), error ); |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------------------------- |
|
288 // CTestSecure::TestUpdateCryptoContextL() |
|
289 // --------------------------------------------------------------------------- |
|
290 // |
|
291 void CTestSecure::TestUpdateCryptoContextL() |
|
292 { |
|
293 iSecureInterface = CMccSecureInterface::NewL( iInterface ); |
|
294 |
|
295 _LIT8(KUpdateTestKey128bits,"9922334455667711"); |
|
296 |
|
297 // Creates new master key |
|
298 HBufC8* masterKey = KTestKey128bits().AllocLC(); |
|
299 TMccSrtpMasterKey mccMasterKey( *masterKey, KNullDesC8() ); |
|
300 TMccSrtpMasterKeyPckg mccMasterKeyPckg = mccMasterKey; |
|
301 CleanupStack::PopAndDestroy( masterKey ); |
|
302 |
|
303 |
|
304 // Creates new master salt |
|
305 HBufC8* masterSalt = KRFCTestSalt112bits().AllocLC(); |
|
306 TMccSrtpMasterSalt salt( *masterSalt ); |
|
307 TMccSrtpMasterSaltPckg saltPckg = salt; |
|
308 CleanupStack::PopAndDestroy( masterSalt ); |
|
309 |
|
310 // Creates new crypto params |
|
311 TMccSrtpCryptoParams cryptoParams; |
|
312 TMccSrtpCryptoParamsPckg cryptoParamsPckg = cryptoParams; |
|
313 |
|
314 User::LeaveIfError( iSecureInterface->CreateContext( mccMasterKeyPckg, |
|
315 saltPckg, |
|
316 iContextId, |
|
317 cryptoParamsPckg ) ); |
|
318 |
|
319 HBufC8* masterKey2 = KUpdateTestKey128bits().AllocLC(); |
|
320 TMccSrtpMasterKey master2( *masterKey2, KNullDesC8() ); |
|
321 TMccSrtpMasterKeyPckg masterKeyPckg2( master2 ); |
|
322 CleanupStack::PopAndDestroy( masterKey2 ); |
|
323 |
|
324 User::LeaveIfError( iSecureInterface->UpdateContext( masterKeyPckg2, |
|
325 saltPckg, |
|
326 iContextId, |
|
327 cryptoParamsPckg ) ); |
|
328 |
|
329 delete iSecureInterface; |
|
330 } |
|
331 |
|
332 // --------------------------------------------------------------------------- |
|
333 // CTestSecure::TestBindCryptoContextL() |
|
334 // --------------------------------------------------------------------------- |
|
335 // |
|
336 void CTestSecure::TestBindCryptoContextL() |
|
337 { |
|
338 iSecureInterface = CMccSecureInterface::NewL( iInterface ); |
|
339 |
|
340 this->CreateSecureSessioLinkAddDlUlSinkSourceCreateStreamsL(); |
|
341 |
|
342 // Creates new master key |
|
343 HBufC8* masterKey = KTestKey128bits().AllocLC(); |
|
344 TMccSrtpMasterKey mccMasterKey( *masterKey, KNullDesC8() ); |
|
345 TMccSrtpMasterKeyPckg mccMasterKeyPckg = mccMasterKey; |
|
346 CleanupStack::PopAndDestroy( masterKey ); |
|
347 |
|
348 |
|
349 // Creates new master salt |
|
350 HBufC8* masterSalt = KRFCTestSalt112bits().AllocLC(); |
|
351 TMccSrtpMasterSalt salt( *masterSalt ); |
|
352 TMccSrtpMasterSaltPckg saltPckg = salt; |
|
353 CleanupStack::PopAndDestroy( masterSalt ); |
|
354 |
|
355 // Creates new crypto params |
|
356 TMccSrtpCryptoParams cryptoParams; |
|
357 TMccSrtpCryptoParamsPckg cryptoParamsPckg = cryptoParams; |
|
358 |
|
359 User::LeaveIfError( iSecureInterface->CreateContext( mccMasterKeyPckg, |
|
360 saltPckg, |
|
361 iContextId, |
|
362 cryptoParamsPckg ) ); |
|
363 |
|
364 RDebug::Print( _L("TestBindCryptoContextL context id: %d\n"), iContextId ); |
|
365 |
|
366 User::LeaveIfError( iSecureInterface->CreateContext( mccMasterKeyPckg, |
|
367 saltPckg, |
|
368 iContextId2, |
|
369 cryptoParamsPckg ) ); |
|
370 |
|
371 RDebug::Print( _L("TestBindCryptoContextL context id: %d\n"), iContextId2 ); |
|
372 |
|
373 User::LeaveIfError( iSecureInterface->Bind( iSessionId, |
|
374 iLinkId, |
|
375 iDlStreamId, |
|
376 iRtpSourceId, |
|
377 iContextId ) ); |
|
378 |
|
379 User::LeaveIfError( iSecureInterface->Bind( iSessionId, |
|
380 iLinkId, |
|
381 iUlStreamId, |
|
382 iRtpSinkId, |
|
383 iContextId2 ) ); |
|
384 // Context is already binded |
|
385 TInt error( KErrNone ); |
|
386 |
|
387 error = iSecureInterface->Bind( iSessionId, |
|
388 iLinkId, |
|
389 iUlStreamId, |
|
390 iRtpSinkId, |
|
391 iContextId ); |
|
392 |
|
393 RDebug::Print( _L("TestBindCryptoContextL context error OK - error: %d\n"), error ); |
|
394 |
|
395 error = iSecureInterface->Bind( iSessionId, |
|
396 iLinkId, |
|
397 iDlStreamId, |
|
398 iRtpSinkId, |
|
399 iContextId2 ); |
|
400 |
|
401 RDebug::Print( _L("TestBindCryptoContextL context error OK - error: %d\n"), error ); |
|
402 |
|
403 User::LeaveIfError( iInterface.DeleteStream( iSessionId, iLinkId, iDlStreamId ) ); |
|
404 User::LeaveIfError( iInterface.DeleteStream( iSessionId, iLinkId, iUlStreamId ) ); |
|
405 |
|
406 this->CloseSecureSessioL(); |
|
407 |
|
408 delete iSecureInterface; |
|
409 } |
|
410 |
|
411 // --------------------------------------------------------------------------- |
|
412 // CTestSecure::TestBindCryptoContextAndRefreshContextL() |
|
413 // --------------------------------------------------------------------------- |
|
414 // |
|
415 void CTestSecure::TestBindCryptoContextAndRefreshContextL() |
|
416 { |
|
417 iSecureInterface = CMccSecureInterface::NewL( iInterface ); |
|
418 |
|
419 this->CreateSecureSessioLinkAddDlUlSinkSourceCreateStreamsL(); |
|
420 |
|
421 // Creates new master key |
|
422 HBufC8* masterKey = KTestKey128bits().AllocLC(); |
|
423 TMccSrtpMasterKey mccMasterKey( *masterKey, KNullDesC8() ); |
|
424 TMccSrtpMasterKeyPckg mccMasterKeyPckg = mccMasterKey; |
|
425 CleanupStack::PopAndDestroy( masterKey ); |
|
426 |
|
427 |
|
428 // Creates new master salt |
|
429 HBufC8* masterSalt = KRFCTestSalt112bits().AllocLC(); |
|
430 TMccSrtpMasterSalt salt( *masterSalt ); |
|
431 TMccSrtpMasterSaltPckg saltPckg = salt; |
|
432 CleanupStack::PopAndDestroy( masterSalt ); |
|
433 |
|
434 // Creates new crypto params |
|
435 TMccSrtpCryptoParams cryptoParams; |
|
436 TMccSrtpCryptoParamsPckg cryptoParamsPckg = cryptoParams; |
|
437 |
|
438 /******* Make new context ***********/ |
|
439 _LIT8(KUpdateTestKey128bits,"9922334455667711"); |
|
440 |
|
441 HBufC8* masterKey2 = KUpdateTestKey128bits().AllocLC(); |
|
442 TMccSrtpMasterKey master2( *masterKey2, KNullDesC8() ); |
|
443 TMccSrtpMasterKeyPckg masterKeyPckg2( master2 ); |
|
444 CleanupStack::PopAndDestroy( masterKey2 ); |
|
445 /******** End ********/ |
|
446 |
|
447 User::LeaveIfError( iSecureInterface->CreateContext( mccMasterKeyPckg, |
|
448 saltPckg, |
|
449 iContextId, |
|
450 cryptoParamsPckg ) ); |
|
451 |
|
452 User::LeaveIfError( iSecureInterface->CreateContext( mccMasterKeyPckg, |
|
453 saltPckg, |
|
454 iContextId2, |
|
455 cryptoParamsPckg ) ); |
|
456 |
|
457 |
|
458 User::LeaveIfError( iSecureInterface->Bind( iSessionId, |
|
459 iLinkId, |
|
460 iDlStreamId, |
|
461 iRtpSourceId, |
|
462 iContextId) ); |
|
463 |
|
464 User::LeaveIfError( iSecureInterface->Bind( iSessionId, |
|
465 iLinkId, |
|
466 iUlStreamId, |
|
467 iRtpSinkId, |
|
468 iContextId2 ) ); |
|
469 |
|
470 |
|
471 User::LeaveIfError( iSecureInterface->UpdateContext( masterKeyPckg2, |
|
472 saltPckg, |
|
473 iContextId, |
|
474 cryptoParamsPckg ) ); |
|
475 |
|
476 User::LeaveIfError( iSecureInterface->UpdateContext( masterKeyPckg2, |
|
477 saltPckg, |
|
478 iContextId2, |
|
479 cryptoParamsPckg ) ); |
|
480 |
|
481 |
|
482 User::LeaveIfError( iSecureInterface->RemoveContext( iContextId ) ); |
|
483 User::LeaveIfError( iSecureInterface->RemoveContext( iContextId2 ) ); |
|
484 |
|
485 |
|
486 this->CloseSecureSessioL(); |
|
487 |
|
488 delete iSecureInterface; |
|
489 } |
|
490 |
|
491 // --------------------------------------------------------------------------- |
|
492 // CTestSecure::TestBindCryptoContextAndPrepareStreamL() |
|
493 // --------------------------------------------------------------------------- |
|
494 // |
|
495 void CTestSecure::TestBindCryptoContextAndPrepareStreamL() |
|
496 { |
|
497 iSecureInterface = CMccSecureInterface::NewL( iInterface ); |
|
498 |
|
499 this->CreateSecureSessioLinkAddDlUlSinkSourceCreateStreamsL(); |
|
500 |
|
501 /******* Make new context ***********/ |
|
502 _LIT8(KUpdateTestKey128bits,"9922334455667711"); |
|
503 |
|
504 HBufC8* masterKey2 = KUpdateTestKey128bits().AllocLC(); |
|
505 TMccSrtpMasterKey master2( *masterKey2, KNullDesC8() ); |
|
506 TMccSrtpMasterKeyPckg masterKeyPckg2( master2 ); |
|
507 CleanupStack::PopAndDestroy( masterKey2 ); |
|
508 /******** End ********/ |
|
509 |
|
510 // Creates new master key |
|
511 HBufC8* masterKey = KTestKey128bits().AllocLC(); |
|
512 TMccSrtpMasterKey mccMasterKey( *masterKey, KNullDesC8() ); |
|
513 TMccSrtpMasterKeyPckg mccMasterKeyPckg = mccMasterKey; |
|
514 CleanupStack::PopAndDestroy( masterKey ); |
|
515 |
|
516 |
|
517 // Creates new master salt |
|
518 HBufC8* masterSalt = KRFCTestSalt112bits().AllocLC(); |
|
519 TMccSrtpMasterSalt salt( *masterSalt ); |
|
520 TMccSrtpMasterSaltPckg saltPckg = salt; |
|
521 CleanupStack::PopAndDestroy( masterSalt ); |
|
522 |
|
523 // Creates new crypto params |
|
524 TMccSrtpCryptoParams cryptoParams; |
|
525 TMccSrtpCryptoParamsPckg cryptoParamsPckg = cryptoParams; |
|
526 |
|
527 User::LeaveIfError( iSecureInterface->CreateContext( mccMasterKeyPckg, |
|
528 saltPckg, |
|
529 iContextId, |
|
530 cryptoParamsPckg ) ); |
|
531 |
|
532 User::LeaveIfError( iSecureInterface->CreateContext( mccMasterKeyPckg, |
|
533 saltPckg, |
|
534 iContextId2, |
|
535 cryptoParamsPckg ) ); |
|
536 |
|
537 |
|
538 User::LeaveIfError( iSecureInterface->Bind( iSessionId, |
|
539 iLinkId, |
|
540 iDlStreamId, |
|
541 iRtpSourceId, |
|
542 iContextId) ); |
|
543 |
|
544 User::LeaveIfError( iSecureInterface->Bind( iSessionId, |
|
545 iLinkId, |
|
546 iUlStreamId, |
|
547 iRtpSinkId, |
|
548 iContextId2 ) ); |
|
549 |
|
550 |
|
551 User::LeaveIfError( iInterface.PrepareStream( iSessionId, iLinkId, iDlStreamId ) ); |
|
552 iInterfaceStub.WaitForEvent( iSessionId, iLinkId, iDlStreamId, KMccStreamPrepared ); |
|
553 |
|
554 User::LeaveIfError( iInterface.PrepareStream( iSessionId, iLinkId, iUlStreamId ) ); |
|
555 iInterfaceStub.WaitForEvent( iSessionId, iLinkId, iUlStreamId, KMccStreamPrepared ); |
|
556 |
|
557 User::LeaveIfError( iSecureInterface->UpdateContext( masterKeyPckg2, |
|
558 saltPckg, |
|
559 iContextId, |
|
560 cryptoParamsPckg ) ); |
|
561 |
|
562 User::LeaveIfError( iSecureInterface->UpdateContext( masterKeyPckg2, |
|
563 saltPckg, |
|
564 iContextId2, |
|
565 cryptoParamsPckg ) ); |
|
566 |
|
567 |
|
568 iInterface.RemoveDataSource( iSessionId, iLinkId, iDlStreamId, iRtpSourceId ); |
|
569 iInterface.RemoveDataSink( iSessionId, iLinkId, iUlStreamId, iRtpSinkId ); |
|
570 |
|
571 User::LeaveIfError( iSecureInterface->RemoveContext( iContextId ) ); |
|
572 User::LeaveIfError( iSecureInterface->RemoveContext( iContextId2 ) ); |
|
573 |
|
574 this->CloseSecureSessioL(); |
|
575 |
|
576 delete iSecureInterface; |
|
577 } |
|
578 |
|
579 // --------------------------------------------------------------------------- |
|
580 // CTestSecure::TestBindCryptoContextAndPrepareMultipleStreamL() |
|
581 // --------------------------------------------------------------------------- |
|
582 // |
|
583 void CTestSecure::TestBindCryptoContextAndPrepareMultipleStreamsL() |
|
584 { |
|
585 iSecureInterface = CMccSecureInterface::NewL( iInterface ); |
|
586 |
|
587 // Get codecs |
|
588 RPointerArray<CMccCodecInformation> codecArray; |
|
589 CleanupResetAndDestroy< RPointerArray<CMccCodecInformation> >::PushL( codecArray ); |
|
590 User::LeaveIfError( iInterface.GetCapabilities( codecArray ) ); |
|
591 |
|
592 |
|
593 this->CreateSecureSessioLinkAddDlUlSinkSourceCreateStreamsL(); |
|
594 |
|
595 /******* Make new context ***********/ |
|
596 _LIT8(KUpdateTestKey128bits,"9922334455667711"); |
|
597 |
|
598 HBufC8* masterKey2 = KUpdateTestKey128bits().AllocLC(); |
|
599 TMccSrtpMasterKey master2( *masterKey2, KNullDesC8() ); |
|
600 TMccSrtpMasterKeyPckg masterKeyPckg2( master2 ); |
|
601 CleanupStack::PopAndDestroy( masterKey2 ); |
|
602 /******** End ********/ |
|
603 |
|
604 // Creates new master key |
|
605 HBufC8* masterKey = KTestKey128bits().AllocLC(); |
|
606 TMccSrtpMasterKey mccMasterKey( *masterKey, KNullDesC8() ); |
|
607 TMccSrtpMasterKeyPckg mccMasterKeyPckg = mccMasterKey; |
|
608 CleanupStack::PopAndDestroy( masterKey ); |
|
609 |
|
610 |
|
611 // Creates new master salt |
|
612 HBufC8* masterSalt = KRFCTestSalt112bits().AllocLC(); |
|
613 TMccSrtpMasterSalt salt( *masterSalt ); |
|
614 TMccSrtpMasterSaltPckg saltPckg = salt; |
|
615 CleanupStack::PopAndDestroy( masterSalt ); |
|
616 |
|
617 // Creates new crypto params |
|
618 TMccSrtpCryptoParams cryptoParams; |
|
619 TMccSrtpCryptoParamsPckg cryptoParamsPckg = cryptoParams; |
|
620 |
|
621 // Reuse datasource/sink |
|
622 TUint32 ulStreamId2; |
|
623 TUint32 micSourceId2; |
|
624 User::LeaveIfError( |
|
625 iInterface.Reuse( iSessionId, iLinkId, iUlStreamId, iRtpSinkId ) ); |
|
626 User::LeaveIfError( |
|
627 iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, micSourceId2 ) ); |
|
628 User::LeaveIfError( iInterface.CreateStream( iSessionId, iLinkId, ulStreamId2, |
|
629 KMccAudioUplinkStream, *codecArray[0] ) ); |
|
630 |
|
631 |
|
632 User::LeaveIfError( iSecureInterface->CreateContext( mccMasterKeyPckg, |
|
633 saltPckg, |
|
634 iContextId, |
|
635 cryptoParamsPckg ) ); |
|
636 |
|
637 User::LeaveIfError( iSecureInterface->CreateContext( mccMasterKeyPckg, |
|
638 saltPckg, |
|
639 iContextId2, |
|
640 cryptoParamsPckg ) ); |
|
641 |
|
642 |
|
643 User::LeaveIfError( iSecureInterface->Bind( iSessionId, |
|
644 iLinkId, |
|
645 iDlStreamId, |
|
646 iRtpSourceId, |
|
647 iContextId) ); |
|
648 |
|
649 User::LeaveIfError( iSecureInterface->Bind( iSessionId, |
|
650 iLinkId, |
|
651 iUlStreamId, |
|
652 iRtpSinkId, |
|
653 iContextId2 ) ); |
|
654 |
|
655 |
|
656 User::LeaveIfError( iInterface.PrepareStream( iSessionId, iLinkId, iDlStreamId ) ); |
|
657 iInterfaceStub.WaitForEvent( iSessionId, iLinkId, iDlStreamId, KMccStreamPrepared ); |
|
658 |
|
659 User::LeaveIfError( iInterface.PrepareStream( iSessionId, iLinkId, ulStreamId2 ) ); |
|
660 iInterfaceStub.WaitForEvent( iSessionId, iLinkId, ulStreamId2, KMccStreamPrepared ); |
|
661 |
|
662 User::LeaveIfError( iSecureInterface->UpdateContext( masterKeyPckg2, |
|
663 saltPckg, |
|
664 iContextId, |
|
665 cryptoParamsPckg ) ); |
|
666 |
|
667 User::LeaveIfError( iSecureInterface->UpdateContext( masterKeyPckg2, |
|
668 saltPckg, |
|
669 iContextId2, |
|
670 cryptoParamsPckg ) ); |
|
671 |
|
672 |
|
673 User::LeaveIfError( iInterface.DeleteStream( iSessionId, iLinkId, ulStreamId2 ) ); |
|
674 |
|
675 CleanupStack::PopAndDestroy( &codecArray ); |
|
676 this->CloseSecureSessioL(); |
|
677 |
|
678 delete iSecureInterface; |
|
679 } |
|
680 |
|
681 // --------------------------------------------------------------------------- |
|
682 // CTestSecure::TestRemoveCryptoContextL() |
|
683 // --------------------------------------------------------------------------- |
|
684 // |
|
685 void CTestSecure::TestRemoveCryptoContextL() |
|
686 { |
|
687 iSecureInterface = CMccSecureInterface::NewL( iInterface ); |
|
688 |
|
689 // Creates new master key |
|
690 HBufC8* masterKey = KTestKey128bits().AllocLC(); |
|
691 TMccSrtpMasterKey mccMasterKey( *masterKey, KNullDesC8() ); |
|
692 TMccSrtpMasterKeyPckg mccMasterKeyPckg = mccMasterKey; |
|
693 CleanupStack::PopAndDestroy( masterKey ); |
|
694 |
|
695 |
|
696 // Creates new master salt |
|
697 HBufC8* masterSalt = KRFCTestSalt112bits().AllocLC(); |
|
698 TMccSrtpMasterSalt salt( *masterSalt ); |
|
699 TMccSrtpMasterSaltPckg saltPckg = salt; |
|
700 CleanupStack::PopAndDestroy( masterSalt ); |
|
701 |
|
702 // Creates new crypto params |
|
703 TMccSrtpCryptoParams cryptoParams; |
|
704 TMccSrtpCryptoParamsPckg cryptoParamsPckg = cryptoParams; |
|
705 |
|
706 User::LeaveIfError( iSecureInterface->CreateContext( mccMasterKeyPckg, |
|
707 saltPckg, |
|
708 iContextId, |
|
709 cryptoParamsPckg ) ); |
|
710 |
|
711 RDebug::Print( _L("TestRemoveCryptoContextL context id: %d\n"), iContextId ); |
|
712 |
|
713 |
|
714 |
|
715 User::LeaveIfError( iSecureInterface->CreateContext( mccMasterKeyPckg, |
|
716 saltPckg, |
|
717 iContextId2, |
|
718 cryptoParamsPckg ) ); |
|
719 |
|
720 RDebug::Print( _L("TestRemoveCryptoContextL context id: %d\n"), iContextId2 ); |
|
721 |
|
722 //User::LeaveIfError( iSecureInterface->RemoveContext( iContextId ) ); |
|
723 //User::LeaveIfError( iSecureInterface->RemoveContext( iContextId2 ) ); |
|
724 |
|
725 delete iSecureInterface; |
|
726 } |
|
727 |
|
728 |
|
729 |
|
730 // --------------------------------------------------------------------------- |
|
731 // CTestSecure::CreateSecureSessioLinkAddDlUlSinkSourceCreateStreamsL() |
|
732 // --------------------------------------------------------------------------- |
|
733 // |
|
734 void CTestSecure::CreateSecureSessioLinkAddDlUlSinkSourceCreateStreamsL() |
|
735 { |
|
736 // Creates secure session |
|
737 RPointerArray<CMccCodecInformation> codecArray; |
|
738 CleanupResetAndDestroy< RPointerArray<CMccCodecInformation> >::PushL( codecArray ); |
|
739 User::LeaveIfError( iInterface.GetCapabilities( codecArray ) ); |
|
740 |
|
741 User::LeaveIfError( iInterface.CreateSession( iSessionId ) ); |
|
742 User::LeaveIfError( |
|
743 iInterface.CreateLink( iSessionId, KMccLinkSecure, iLinkId, |
|
744 iNetsettings ) ); |
|
745 |
|
746 iInterfaceStub.WaitForEvent( iSessionId, iLinkId, 0, KMccLinkCreated ); |
|
747 |
|
748 // DL |
|
749 User::LeaveIfError( |
|
750 iInterface.AddDataSink( KUidMmfAudioOutput, KNullDesC8, iAudioSinkId ) ); |
|
751 User::LeaveIfError( |
|
752 iInterface.AddDataSource( KMccRtpSourceUid, KNullDesC8, iRtpSourceId ) ); |
|
753 |
|
754 |
|
755 User::LeaveIfError( iInterface.CreateStream( iSessionId, iLinkId, iDlStreamId, |
|
756 KMccAudioDownlinkStream, *codecArray[0] ) ); |
|
757 |
|
758 // UL |
|
759 User::LeaveIfError( |
|
760 iInterface.AddDataSink( KMccRtpSinkUid, KNullDesC8, iRtpSinkId ) ); |
|
761 User::LeaveIfError( |
|
762 iInterface.AddDataSource( KUidMmfAudioInput, KNullDesC8, iMicSourceId ) ); |
|
763 |
|
764 |
|
765 User::LeaveIfError( iInterface.CreateStream( iSessionId, iLinkId, iUlStreamId, |
|
766 KMccAudioUplinkStream, *codecArray[0] ) ); |
|
767 |
|
768 CleanupStack::PopAndDestroy( &codecArray ); |
|
769 } |
|
770 |
|
771 // --------------------------------------------------------------------------- |
|
772 // CTestSecure::CloseSecureSessioL() |
|
773 // --------------------------------------------------------------------------- |
|
774 // |
|
775 void CTestSecure::CloseSecureSessioL() |
|
776 { |
|
777 User::LeaveIfError( iInterface.CloseLink( iSessionId, iLinkId ) ); |
|
778 User::LeaveIfError( iInterface.CloseSession( iSessionId ) ); |
|
779 } |