public void deriveSrtcpKeys ( ) { // compute the session encryption key byte label = 3 ; computeIv ( label ) ; KeyParameter encryptionKey = new KeyParameter ( masterKey ) ; cipher . init ( true , encryptionKey ) ; Arrays . fill ( masterKey , ( byte ) 0 ) ; cipherCtr . getCipherStream ( cipher , encKey , policy . getEncKeyLength ( ) , ivStore ) ; if ( authKey != null ) { label = 4 ; computeIv ( label ) ; cipherCtr . getCipherStream ( cipher , authKey , policy . getAuthKeyLength ( ) , ivStore ) ; switch ( ( policy . getAuthType ( ) ) ) { case SRTPPolicy . HMACSHA1_AUTHENTICATION : KeyParameter key = new KeyParameter ( authKey ) ; mac . init ( key ) ; break ; default : break ; } } Arrays . fill ( authKey , ( byte ) 0 ) ; // compute the session salt label = 5 ; computeIv ( label ) ; cipherCtr . getCipherStream ( cipher , saltKey , policy . getSaltKeyLength ( ) , ivStore ) ; Arrays . fill ( masterSalt , ( byte ) 0 ) ; // As last step: initialize cipher with derived encryption key. if ( cipherF8 != null ) { SRTPCipherF8 . deriveForIV ( cipherF8 , encKey , saltKey ) ; } encryptionKey = new KeyParameter ( encKey ) ; cipher . init ( true , encryptionKey ) ; Arrays . fill ( encKey , ( byte ) 0 ) ; }
Derives the srtcp session keys from the master key .