254 Hex(*mki3); |
248 Hex(*mki3); |
255 |
249 |
256 |
250 |
257 TSrtpCryptoParams params; |
251 TSrtpCryptoParams params; |
258 //test constructL |
252 //test constructL |
259 iMasterKey3 = CSRTPMasterKey::NewL( *masterKey3, *mki3, |
253 iMasterKey3 = CSRTPMasterKey::NewLC( *masterKey3, *mki3, |
260 KSRTPDefSessionEncryptionKeyLength, |
254 KSRTPDefSessionEncryptionKeyLength, |
261 KSRTPDefSessionAuthenticationKeyLength ); |
255 KSRTPDefSessionAuthenticationKeyLength ); |
262 iMasterSalt3 = CSRTPMasterSalt::NewL( *masterSalt3, 1100 ); |
256 iMasterSalt3 = CSRTPMasterSalt::NewL( *masterSalt3, 1100 ); |
263 |
257 CleanupStack::Pop( iMasterKey3 ); |
264 CleanupStack::PopAndDestroy( mki3 ); |
258 CleanupStack::PopAndDestroy( mki3 ); |
265 |
259 |
266 CleanupStack::PopAndDestroy( masterSalt3 ); |
260 CleanupStack::PopAndDestroy( masterSalt3 ); |
267 CleanupStack::PopAndDestroy( masterKey3 ); |
261 CleanupStack::PopAndDestroy( masterKey3 ); |
268 |
262 CleanupStack::PushL( iMasterKey3 ); |
269 |
263 CleanupStack::PushL( iMasterSalt3 ); |
270 params.iSrtcpAuthTagLen=80; |
264 params.iSrtcpAuthTagLen=80; |
271 RTP_EUNIT_ASSERT_SPECIFIC_LEAVE( iContext3= CSRTPCryptoContext::NewL(iMasterKey3,iMasterSalt3, params ), |
265 RTP_EUNIT_ASSERT_SPECIFIC_LEAVE( iContext3= CSRTPCryptoContext::NewL(iMasterKey3,iMasterSalt3, params ), |
272 KErrArgument ); |
266 KErrArgument ); |
273 |
267 CleanupStack::Pop( iMasterSalt3 ); |
274 |
268 CleanupStack::Pop( iMasterKey3 ); |
275 delete iContext3; |
269 delete iContext3; |
276 |
270 |
277 } |
271 } |
278 |
272 |
279 void UT_CSRTPCryptoContext::UT_CSRTPCryptoContext_Test2L( ) |
273 void UT_CSRTPCryptoContext::UT_CSRTPCryptoContext_Test2L( ) |
292 *mki3 = K128bitMKITest3; |
286 *mki3 = K128bitMKITest3; |
293 Hex(*mki3); |
287 Hex(*mki3); |
294 |
288 |
295 |
289 |
296 TSrtpCryptoParams params; |
290 TSrtpCryptoParams params; |
297 iMasterKey3 = CSRTPMasterKey::NewL( *masterKey3, *mki3, |
291 iMasterKey3 = CSRTPMasterKey::NewLC( *masterKey3, *mki3, |
298 KSRTPDefSessionEncryptionKeyLength, |
292 KSRTPDefSessionEncryptionKeyLength, |
299 KSRTPDefSessionAuthenticationKeyLength ); |
293 KSRTPDefSessionAuthenticationKeyLength ); |
300 iMasterSalt3 = CSRTPMasterSalt::NewL( *masterSalt3, 1100 ); |
294 iMasterSalt3 = CSRTPMasterSalt::NewL( *masterSalt3, 1100 ); |
301 |
295 CleanupStack::Pop( iMasterKey3 ); |
302 CleanupStack::PopAndDestroy( mki3 ); |
296 CleanupStack::PopAndDestroy( mki3 ); |
303 CleanupStack::PopAndDestroy( masterSalt3 ); |
297 CleanupStack::PopAndDestroy( masterSalt3 ); |
304 CleanupStack::PopAndDestroy( masterKey3 ); |
298 CleanupStack::PopAndDestroy( masterKey3 ); |
305 |
299 |
306 params.iSrtcpAuthTagLen=80; |
300 params.iSrtcpAuthTagLen=80; |
307 RTP_EUNIT_ASSERT_SPECIFIC_LEAVE( iContext3= CSRTPCryptoContext::NewL(iMasterKey3,iMasterSalt3, params ), |
301 |
|
302 CleanupStack::PushL( iMasterKey3 ); |
|
303 CleanupStack::PushL( iMasterSalt3 ); |
|
304 RTP_EUNIT_ASSERT_SPECIFIC_LEAVE( iContext3= CSRTPCryptoContext::NewL(iMasterKey3,iMasterSalt3, params ), |
308 KErrArgument ); |
305 KErrArgument ); |
309 |
306 |
310 delete iContext3; |
307 CleanupStack::Pop( iMasterSalt3 ); |
|
308 CleanupStack::Pop( iMasterKey3 ); |
|
309 delete iContext3; |
311 |
310 |
312 } |
311 } |
313 |
312 |
314 void UT_CSRTPCryptoContext::UT_CSRTPCryptoContext_Test3L( ) |
313 void UT_CSRTPCryptoContext::UT_CSRTPCryptoContext_Test3L( ) |
315 { |
314 { |
323 HBufC8* mki =HBufC8::NewL(K128bitMKITest1().Length()); |
322 HBufC8* mki =HBufC8::NewL(K128bitMKITest1().Length()); |
324 CleanupStack::PushL( mki); |
323 CleanupStack::PushL( mki); |
325 *mki = K128bitMKITest1; |
324 *mki = K128bitMKITest1; |
326 Hex(*mki); |
325 Hex(*mki); |
327 |
326 |
328 iMasterKey4 = CSRTPMasterKey::NewL( *masterKey, *mki, |
327 iMasterKey4 = CSRTPMasterKey::NewLC( *masterKey, *mki, |
329 KSRTPDefSessionEncryptionKeyLength, |
328 KSRTPDefSessionEncryptionKeyLength, |
330 KSRTPDefSessionAuthenticationKeyLength ); |
329 KSRTPDefSessionAuthenticationKeyLength ); |
331 iMasterSalt4 = CSRTPMasterSalt::NewL( *masterSalt,KSRTPDefSessionSaltingKeyLength ); |
330 iMasterSalt4 = CSRTPMasterSalt::NewL( *masterSalt,KSRTPDefSessionSaltingKeyLength ); |
332 |
331 CleanupStack::Pop( iMasterKey4 ); |
333 CleanupStack::PopAndDestroy( mki ); |
332 CleanupStack::PopAndDestroy( mki ); |
334 |
333 |
335 CleanupStack::PopAndDestroy( masterSalt ); |
334 CleanupStack::PopAndDestroy( masterSalt ); |
336 CleanupStack::PopAndDestroy( masterKey ); |
335 CleanupStack::PopAndDestroy( masterKey ); |
337 |
336 |
338 |
337 CleanupStack::PushL( iMasterKey4 ); |
339 |
338 CleanupStack::PushL( iMasterSalt4 ); |
340 |
339 |
341 //invalid authalg |
340 //invalid authalg |
342 TSrtpCryptoParams params; |
341 TSrtpCryptoParams params; |
343 params.iSrtpAuthAlg=TSRTPAuthAlg(10); |
342 params.iSrtpAuthAlg=TSRTPAuthAlg(10); |
344 RTP_EUNIT_ASSERT_SPECIFIC_LEAVE(iContext4=CSRTPCryptoContext::NewL(iMasterKey4,iMasterSalt4, params), |
343 RTP_EUNIT_ASSERT_SPECIFIC_LEAVE(iContext4=CSRTPCryptoContext::NewL(iMasterKey4,iMasterSalt4, params), |
345 KErrArgument ); |
344 KErrArgument ); |
346 |
345 |
347 |
346 CleanupStack::Pop( iMasterSalt4 ); |
348 |
347 CleanupStack::Pop( iMasterKey4 ); |
349 } |
348 } |
350 |
349 |
351 void UT_CSRTPCryptoContext::UT_CSRTPCryptoContext_Test4L( ) |
350 void UT_CSRTPCryptoContext::UT_CSRTPCryptoContext_Test4L( ) |
352 { |
351 { |
353 HBufC8* masterKey = HBufC8::NewL(K128bitMasterKey1().Length()); |
352 HBufC8* masterKey = HBufC8::NewL(K128bitMasterKey1().Length()); |
360 HBufC8* mki =HBufC8::NewL(K128bitMKITest1().Length()); |
359 HBufC8* mki =HBufC8::NewL(K128bitMKITest1().Length()); |
361 CleanupStack::PushL( mki); |
360 CleanupStack::PushL( mki); |
362 *mki = K128bitMKITest1; |
361 *mki = K128bitMKITest1; |
363 Hex(*mki); |
362 Hex(*mki); |
364 |
363 |
365 iMasterKey5 = CSRTPMasterKey::NewL( *masterKey, *mki, |
364 iMasterKey5 = CSRTPMasterKey::NewLC( *masterKey, *mki, |
366 KSRTPDefSessionEncryptionKeyLength, |
365 KSRTPDefSessionEncryptionKeyLength, |
367 KSRTPDefSessionAuthenticationKeyLength); |
366 KSRTPDefSessionAuthenticationKeyLength); |
368 iMasterSalt5 = CSRTPMasterSalt::NewL( *masterSalt,KSRTPDefSessionSaltingKeyLength ); |
367 iMasterSalt5 = CSRTPMasterSalt::NewL( *masterSalt,KSRTPDefSessionSaltingKeyLength ); |
369 |
368 CleanupStack::Pop( iMasterKey5 ); |
370 CleanupStack::PopAndDestroy( mki ); |
369 CleanupStack::PopAndDestroy( mki ); |
371 CleanupStack::PopAndDestroy( masterSalt ); |
370 CleanupStack::PopAndDestroy( masterSalt ); |
372 CleanupStack::PopAndDestroy( masterKey ); |
371 CleanupStack::PopAndDestroy( masterKey ); |
373 |
372 |
374 |
373 CleanupStack::PushL( iMasterKey5 ); |
375 |
374 CleanupStack::PushL( iMasterSalt5 ); |
376 |
375 |
377 TSrtpCryptoParams params; |
376 TSrtpCryptoParams params; |
378 //invalid auth tag length in context5 |
377 //invalid auth tag length in context5 |
379 params.iSrtpAuthTagLen=20; |
378 params.iSrtpAuthTagLen=20; |
380 RTP_EUNIT_ASSERT_SPECIFIC_LEAVE( iContext5=CSRTPCryptoContext::NewL(iMasterKey5,iMasterSalt5,params ), |
379 RTP_EUNIT_ASSERT_SPECIFIC_LEAVE( iContext5=CSRTPCryptoContext::NewL(iMasterKey5,iMasterSalt5,params ), |
381 KErrArgument ); |
380 KErrArgument ); |
382 |
381 |
383 |
382 CleanupStack::Pop( iMasterSalt5 ); |
|
383 CleanupStack::Pop( iMasterKey5 ); |
384 } |
384 } |
385 |
385 |
386 void UT_CSRTPCryptoContext::UT_CSRTPCryptoContext_Test5L( ) |
386 void UT_CSRTPCryptoContext::UT_CSRTPCryptoContext_Test5L( ) |
387 { |
387 { |
388 HBufC8* masterKey = HBufC8::NewL(K128bitMasterKey1().Length()); |
388 HBufC8* masterKey = HBufC8::NewL(K128bitMasterKey1().Length()); |
394 *masterSalt = K112bitMasterSalt1; |
394 *masterSalt = K112bitMasterSalt1; |
395 HBufC8* mki =HBufC8::NewL(K128bitMKITest1().Length()); |
395 HBufC8* mki =HBufC8::NewL(K128bitMKITest1().Length()); |
396 CleanupStack::PushL( mki); |
396 CleanupStack::PushL( mki); |
397 *mki = K128bitMKITest1; |
397 *mki = K128bitMKITest1; |
398 Hex(*mki); |
398 Hex(*mki); |
399 iMasterKey6 = CSRTPMasterKey::NewL( *masterKey, *mki, |
399 iMasterKey6 = CSRTPMasterKey::NewLC( *masterKey, *mki, |
400 KSRTPDefSessionEncryptionKeyLength, |
400 KSRTPDefSessionEncryptionKeyLength, |
401 KSRTPDefSessionAuthenticationKeyLength ); |
401 KSRTPDefSessionAuthenticationKeyLength ); |
402 iMasterSalt6 = CSRTPMasterSalt::NewL( *masterSalt,KSRTPDefSessionSaltingKeyLength ); |
402 iMasterSalt6 = CSRTPMasterSalt::NewL( *masterSalt,KSRTPDefSessionSaltingKeyLength ); |
403 |
403 CleanupStack::Pop( iMasterKey6 ); |
404 TSrtpCryptoParams params; |
404 TSrtpCryptoParams params; |
405 CleanupStack::PopAndDestroy( mki ); |
405 CleanupStack::PopAndDestroy( mki ); |
406 CleanupStack::PopAndDestroy( masterSalt ); |
406 CleanupStack::PopAndDestroy( masterSalt ); |
407 CleanupStack::PopAndDestroy( masterKey ); |
407 CleanupStack::PopAndDestroy( masterKey ); |
408 |
408 |
409 |
409 CleanupStack::PushL( iMasterKey6 ); |
|
410 CleanupStack::PushL( iMasterSalt6 ); |
410 |
411 |
411 //invalid prefix length in context6 |
412 //invalid prefix length in context6 |
412 params.iPrefixLen=10; |
413 params.iPrefixLen=10; |
413 RTP_EUNIT_ASSERT_SPECIFIC_LEAVE( iContext6=CSRTPCryptoContext::NewL(iMasterKey6,iMasterSalt6, params ) , |
414 RTP_EUNIT_ASSERT_SPECIFIC_LEAVE( iContext6=CSRTPCryptoContext::NewL(iMasterKey6,iMasterSalt6, params ) , |
414 KErrArgument ); |
415 KErrArgument ); |
415 |
416 |
416 |
417 CleanupStack::Pop( iMasterSalt6 ); |
|
418 CleanupStack::Pop( iMasterKey6 ); |
417 |
419 |
418 } |
420 } |
419 void UT_CSRTPCryptoContext::UT_MasterKey_Test1L( ) |
421 void UT_CSRTPCryptoContext::UT_MasterKey_Test1L( ) |
420 { |
422 { |
421 |
423 |
532 Hex(*mki3); |
534 Hex(*mki3); |
533 |
535 |
534 |
536 |
535 TSrtpCryptoParams params; |
537 TSrtpCryptoParams params; |
536 //test constructL |
538 //test constructL |
537 iMasterKey3 = CSRTPMasterKey::NewL( *masterKey3, *mki3 ); |
539 iMasterKey3 = CSRTPMasterKey::NewLC( *masterKey3, *mki3 ); |
538 iMasterSalt3 = CSRTPMasterSalt::NewL( *masterSalt3); |
540 iMasterSalt3 = CSRTPMasterSalt::NewL( *masterSalt3); |
539 |
541 CleanupStack::Pop( iMasterKey3 ); |
540 CleanupStack::PopAndDestroy( mki3 ); |
542 CleanupStack::PopAndDestroy( mki3 ); |
541 |
543 |
542 CleanupStack::PopAndDestroy( masterSalt3 ); |
544 CleanupStack::PopAndDestroy( masterSalt3 ); |
543 CleanupStack::PopAndDestroy( masterKey3 ); |
545 CleanupStack::PopAndDestroy( masterKey3 ); |
544 |
546 |
545 |
547 CleanupStack::PushL( iMasterKey3 ); |
|
548 CleanupStack::PushL( iMasterSalt3 ); |
546 |
549 |
547 iContext3= CSRTPCryptoContext::NewL(iMasterKey3,iMasterSalt3, params ); |
550 iContext3= CSRTPCryptoContext::NewL(iMasterKey3,iMasterSalt3, params ); |
548 |
551 CleanupStack::Pop( iMasterSalt3 ); |
549 |
552 CleanupStack::Pop( iMasterKey3 ); |
550 |
553 |
551 params.iSrtpAuthTagLen=112; |
554 params.iSrtpAuthTagLen=112; |
552 iContext3->UpdateCryptoParams(params ); |
555 iContext3->UpdateCryptoParams(params ); |
553 EUNIT_ASSERT(iContext->IsEqual(*iContext3)==EFalse); |
556 EUNIT_ASSERT(iContext->IsEqual(*iContext3)==EFalse); |
554 |
557 |
555 delete iContext3; |
558 delete iContext3; |
556 iContext3 = NULL; |
|
557 //test only param is different |
559 //test only param is different |
558 HBufC8* masterKey1 = HBufC8::NewL(K128bitMasterKey1().Length()); |
560 HBufC8* masterKey1 = HBufC8::NewL(K128bitMasterKey1().Length()); |
559 CleanupStack::PushL( masterKey1 ); |
561 CleanupStack::PushL( masterKey1 ); |
560 *masterKey1 = K128bitMasterKey1; |
562 *masterKey1 = K128bitMasterKey1; |
561 |
563 |
567 HBufC8* mki =HBufC8::NewL(K128bitMKITest1().Length()); |
569 HBufC8* mki =HBufC8::NewL(K128bitMKITest1().Length()); |
568 CleanupStack::PushL( mki); |
570 CleanupStack::PushL( mki); |
569 *mki = K128bitMKITest1; |
571 *mki = K128bitMKITest1; |
570 Hex(*mki); |
572 Hex(*mki); |
571 |
573 |
572 iMasterKey = CSRTPMasterKey::NewL( *masterKey1, *mki, |
574 iMasterKey = CSRTPMasterKey::NewLC( *masterKey1, *mki, |
573 KSRTPDefSessionEncryptionKeyLength, |
575 KSRTPDefSessionEncryptionKeyLength, |
574 KSRTPDefSessionAuthenticationKeyLength ); |
576 KSRTPDefSessionAuthenticationKeyLength ); |
575 iMasterSalt = CSRTPMasterSalt::NewL( *masterSalt1,KSRTPDefSessionSaltingKeyLength ); |
577 iMasterSalt = CSRTPMasterSalt::NewL( *masterSalt1,KSRTPDefSessionSaltingKeyLength ); |
576 |
578 CleanupStack::Pop( iMasterKey ); |
577 CleanupStack::PopAndDestroy( mki ); |
579 CleanupStack::PopAndDestroy( mki ); |
578 CleanupStack::PopAndDestroy( masterSalt1 ); |
580 CleanupStack::PopAndDestroy( masterSalt1 ); |
579 CleanupStack::PopAndDestroy( masterKey1 ); |
581 CleanupStack::PopAndDestroy( masterKey1 ); |
580 TSrtpCryptoParams params2; |
582 TSrtpCryptoParams params2; |
581 params2.iSrtpAuthTagLen=32; |
583 params2.iSrtpAuthTagLen=32; |
582 |
584 CleanupStack::PushL( iMasterKey ); |
583 |
585 CleanupStack::PushL( iMasterSalt ); |
584 CSRTPCryptoContext* context = CSRTPCryptoContext::NewL(iMasterKey, iMasterSalt,params2 ); |
586 CSRTPCryptoContext* context = CSRTPCryptoContext::NewL(iMasterKey, iMasterSalt,params2 ); |
585 EUNIT_ASSERT(!iContext->IsEqual(*context)); |
587 EUNIT_ASSERT(!iContext->IsEqual(*context)); |
586 |
588 CleanupStack::Pop( iMasterSalt ); |
587 |
589 CleanupStack::Pop( iMasterKey ); |
588 params2.iSrtpAuthTagLen=80; |
590 params2.iSrtpAuthTagLen=80; |
589 params2.iMasterKeysLifeTime = 0; |
591 params2.iMasterKeysLifeTime = 0; |
590 context->UpdateCryptoParams(params2 ); |
592 context->UpdateCryptoParams(params2 ); |
591 |
593 |
592 EUNIT_ASSERT(iContext->IsEqual(*context)); |
594 EUNIT_ASSERT(iContext->IsEqual(*context)); |
598 TBool sync= ETrue; |
600 TBool sync= ETrue; |
599 iContext->SetRCCm3Sync(sync); |
601 iContext->SetRCCm3Sync(sync); |
600 EUNIT_ASSERT(iContext->CryptoParams().iIsRCCm3Sync); |
602 EUNIT_ASSERT(iContext->CryptoParams().iIsRCCm3Sync); |
601 } |
603 } |
602 |
604 |
603 void UT_CSRTPCryptoContext::TestIsValidL() |
605 void UT_CSRTPCryptoContext::TestIsValid() |
604 { |
606 { |
605 TSrtpCryptoParams params; |
607 TSrtpCryptoParams params; |
606 //TEst cases 1 about Encryption method |
608 //TEst cases 1 about Encryption method |
607 params.iSrtpEncAlg=TSRTPEncAlg(10); |
609 params.iSrtpEncAlg=TSRTPEncAlg(10); |
608 iContext->UpdateCryptoParams(params ); |
610 iContext->UpdateCryptoParams(params ); |
661 HBufC8* mki3 =HBufC8::NewL(K128bitMKITest3().Length()); |
663 HBufC8* mki3 =HBufC8::NewL(K128bitMKITest3().Length()); |
662 CleanupStack::PushL( mki3); |
664 CleanupStack::PushL( mki3); |
663 *mki3 = K128bitMKITest3; |
665 *mki3 = K128bitMKITest3; |
664 Hex(*mki3); |
666 Hex(*mki3); |
665 |
667 |
666 iMasterKey3 = CSRTPMasterKey::NewL( *masterKey3, *mki3, |
668 iMasterKey3 = CSRTPMasterKey::NewLC( *masterKey3, *mki3, |
667 KSRTPDefSessionAuthenticationKeyLength, |
669 KSRTPDefSessionAuthenticationKeyLength, |
668 KSRTPDefSessionEncryptionKeyLength |
670 KSRTPDefSessionEncryptionKeyLength |
669 ); |
671 ); |
670 iMasterSalt3 = CSRTPMasterSalt::NewL( *masterSalt3, 1100 ); |
672 iMasterSalt3 = CSRTPMasterSalt::NewL( *masterSalt3, 1100 ); |
671 |
673 CleanupStack::Pop( iMasterKey3 ); |
672 CleanupStack::PopAndDestroy( mki3 ); |
674 CleanupStack::PopAndDestroy( mki3 ); |
673 |
675 |
674 CleanupStack::PopAndDestroy( masterSalt3 ); |
676 CleanupStack::PopAndDestroy( masterSalt3 ); |
675 CleanupStack::PopAndDestroy( masterKey3 ); |
677 CleanupStack::PopAndDestroy( masterKey3 ); |
676 |
678 CleanupStack::PushL( iMasterKey3 ); |
|
679 CleanupStack::PushL( iMasterSalt3 ); |
677 RTP_EUNIT_ASSERT_SPECIFIC_LEAVE( iContext3= CSRTPCryptoContext::NewL(iMasterKey3,iMasterSalt3, params ), |
680 RTP_EUNIT_ASSERT_SPECIFIC_LEAVE( iContext3= CSRTPCryptoContext::NewL(iMasterKey3,iMasterSalt3, params ), |
678 KErrArgument ); |
681 KErrArgument ); |
679 |
682 |
|
683 CleanupStack::Pop( iMasterSalt3 ); |
|
684 CleanupStack::Pop( iMasterKey3 ); |
680 } |
685 } |
681 |
686 |
682 void UT_CSRTPCryptoContext::SRTPMasterKeyStaleEvent(const CSRTPStream& /*aStream*/) |
687 void UT_CSRTPCryptoContext::SRTPMasterKeyStaleEvent(const CSRTPStream& /*aStream*/) |
683 { |
688 { |
684 |
689 |