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