[sip-comm-dev] [GSoC] Useful SRTP code


#1

Hi Emanuel,

I read your post on your blog today and that made me think that I still have some code relative to SRTP to provide you. This is actually an example on how to instantiate and use the SRTP implementation (with hardcoded keys), this may be useful to you later in this project.

You'll find a patch enclosed that:
- add the necessary code to the build.xml to support bouncycastle
- add the code to CallSessionImpl.java to instantiate SRTP

(Note: this patch was made against a version of SC from last summer, so it might not apply without errors).

I also remember that Su Bing reported last year some errors at compilation time with the bouncycastle jar. He provided me a modified bouncycastle version, but it would be great if you could make it work with the original one. Let me know if you need the one Su provided me.

Cheers,

srtp-impl-v0.6.patch (5.99 KB)

···

--
Romain KUNTZ
kuntz@lsiit.u-strasbg.fr
Louis Pasteur University - Networks and Protocols Team


#2

Hello Romain,

First, thank you for the piece of code. I've already had figured that the activation of SRTP should be done in the CallSessionImpl class but the provided code makes it 100% clear now.

Indeed I've encountered some problems with the patch, and I applied it "manually" in the end (fortunately it's not that long), so this part is solved.

The part that isn't solved yet is the one related to the bouncycastle jar. More exactly adding the line to include it in the build xml triggers a pretty strange behaviour, as it follows:

- in case I have an account already registered (I'm using a SIP account), SC launches anyway the Account Registration Wizard (behaving as no account is currently registered) and none appears in the accounts list in the GUI; more - if I try adding an account I'm getting the following error:

java.lang.NullPointerException
   at net.java.sip.communicator.plugin.sipaccregwizz.SIPAccRegWizzActivator.getSIPProtocolProviderFactory(SIPAccRegWizzActivator.java:82)
   at net.java.sip.communicator.plugin.sipaccregwizz.FirstWizardPage.isExistingAccount(FirstWizardPage.java:654)
   at net.java.sip.communicator.plugin.sipaccregwizz.FirstWizardPage.pageNext(FirstWizardPage.java:399)
   at net.java.sip.communicator.impl.gui.customcontrols.wizard.WizardController.nextButtonPressed(WizardController.java:77)
   at net.java.sip.communicator.impl.gui.customcontrols.wizard.WizardController.actionPerformed(WizardController.java:52)
   at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
   at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
   at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
   at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
   at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
   at java.awt.Component.processMouseEvent(Unknown Source)
   at javax.swing.JComponent.processMouseEvent(Unknown Source)
   at java.awt.Component.processEvent(Unknown Source)
   at java.awt.Container.processEvent(Unknown Source)
   at java.awt.Component.dispatchEventImpl(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Window.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.EventQueue.dispatchEvent(Unknown Source)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
   at java.awt.Dialog$1.run(Unknown Source)
   at java.awt.Dialog$3.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.awt.Dialog.show(Unknown Source)
   at java.awt.Component.show(Unknown Source)
   at java.awt.Component.setVisible(Unknown Source)
   at java.awt.Window.setVisible(Unknown Source)
   at java.awt.Dialog.setVisible(Unknown Source)
   at net.java.sip.communicator.impl.gui.customcontrols.SIPCommDialog.setVisible(SIPCommDialog.java:231)
   at net.java.sip.communicator.impl.gui.customcontrols.wizard.Wizard.showDialog(Wizard.java:180)
   at net.java.sip.communicator.impl.gui.main.configforms.AccountsConfigurationForm.actionPerformed(AccountsConfigurationForm.java:255)
   at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
   at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
   at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
   at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
   at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
   at java.awt.Component.processMouseEvent(Unknown Source)
   at javax.swing.JComponent.processMouseEvent(Unknown Source)
   at java.awt.Component.processEvent(Unknown Source)
   at java.awt.Container.processEvent(Unknown Source)
   at java.awt.Component.dispatchEventImpl(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Window.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.EventQueue.dispatchEvent(Unknown Source)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.run(Unknown Source)

It's actually pretty similar with what I've found here after a Google search:

http://osdir.com/ml/voip.sip-communicator.user/2007-01/msg00003.html

The reply from Emil for that entry states that it's quite unusual that the bundleContext to be null, when the wizard is shown, and I personally think the same way (even if I'm not very experienced with OSGi architecture).

Deleting the line that adds the bouncycastle.jar in build.xml solves the problem and all comes back to normal.

Anyway, I've tried also a different approach:

- in case I delete my SIP account, add the bouncycastle jar, and try to run again, I can go one step further; more exactly after I'm presented with the registration summary, on clicking Finish I get:

[java] Exception occurred during event dispatching:
      [java] java.lang.NoClassDefFoundError: net/java/sip/communicator/service/media/MediaException
      [java] at net.java.sip.communicator.impl.protocol.sip.ProtocolProviderServiceSipImpl.initialize(ProtocolProviderServiceSipImpl.java:774)
      [java] at net.java.sip.communicator.impl.protocol.sip.ProtocolProviderFactorySipImpl.loadAccount(ProtocolProviderFactorySipImpl.java:196)
      [java] at net.java.sip.communicator.impl.protocol.sip.ProtocolProviderFactorySipImpl.installAccount(ProtocolProviderFactorySipImpl.java:131)
      [java] at net.java.sip.communicator.plugin.sipaccregwizz.SIPAccountRegistrationWizard.installAccount(SIPAccountRegistrationWizard.java:243)
      [java] at net.java.sip.communicator.plugin.sipaccregwizz.SIPAccountRegistrationWizard.finish(SIPAccountRegistrationWizard.java:175)
      [java] at net.java.sip.communicator.impl.gui.main.account.AccountRegSummaryPage.pageNext(AccountRegSummaryPage.java:153)
      [java] at net.java.sip.communicator.impl.gui.customcontrols.wizard.WizardController.nextButtonPressed(WizardController.java:77)
      [java] at net.java.sip.communicator.impl.gui.customcontrols.wizard.WizardController.actionPerformed(WizardController.java:52)
      [java] at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
      [java] at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
      [java] at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
      [java] at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
      [java] at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
      [java] at java.awt.Component.processMouseEvent(Unknown Source)
      [java] at javax.swing.JComponent.processMouseEvent(Unknown Source)
      [java] at java.awt.Component.processEvent(Unknown Source)
      [java] at java.awt.Container.processEvent(Unknown Source)
      [java] at java.awt.Component.dispatchEventImpl(Unknown Source)
      [java] at java.awt.Container.dispatchEventImpl(Unknown Source)
      [java] at java.awt.Component.dispatchEvent(Unknown Source)
      [java] at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
      [java] at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
      [java] at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
      [java] at java.awt.Container.dispatchEventImpl(Unknown Source)
      [java] at java.awt.Window.dispatchEventImpl(Unknown Source)
      [java] at java.awt.Component.dispatchEvent(Unknown Source)
      [java] at java.awt.EventQueue.dispatchEvent(Unknown Source)
      [java] at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
      [java] at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
      [java] at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
      [java] at java.awt.Dialog$1.run(Unknown Source)
      [java] at java.awt.Dialog$3.run(Unknown Source)
      [java] at java.security.AccessController.doPrivileged(Native Method)
      [java] at java.awt.Dialog.show(Unknown Source)
      [java] at java.awt.Component.show(Unknown Source)
      [java] at java.awt.Component.setVisible(Unknown Source)
      [java] at java.awt.Window.setVisible(Unknown Source)
      [java] at java.awt.Dialog.setVisible(Unknown Source)
      [java] at net.java.sip.communicator.impl.gui.customcontrols.SIPCommDialog.setVisible(SIPCommDialog.java:231)
      [java] at net.java.sip.communicator.impl.gui.customcontrols.wizard.Wizard.showDialog(Wizard.java:180)
      [java] at net.java.sip.communicator.impl.gui.main.login.LoginManager.showAccountRegistrationWizard(LoginManager.java:185)
      [java] at net.java.sip.communicator.impl.gui.main.login.LoginManager.runLogin(LoginManager.java:150)
      [java] at net.java.sip.communicator.impl.gui.UIServiceImpl$RunLoginGui.run(UIServiceImpl.java:797)
      [java] at java.awt.event.InvocationEvent.dispatch(Unknown Source)
      [java] at java.awt.EventQueue.dispatchEvent(Unknown Source)
      [java] at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
      [java] at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
      [java] at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
      [java] at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      [java] at java.awt.EventDispatchThread.run(Unknown Source)

which is again really weird because the class is obviously right there...

What's interesting in this case is the fact that the account is actually added, and if I remove the bouncycastle library from media.jar and rebuild I can run SC without a problem - with the added account. Otherwise we fall back at the next run to the first problem - getting the Account Reg Wizard even if the account is there.

I've tried these steps with 3 versions of the latest bouncycastle release (.139) for jdk 1.6, 1.5 and 1.4 and with an older one (.130) which is jdk 1.4 compliant. The behaviour was the same in all cases.

I can't see what's the connection between adding the crypto library at building and the issues presented above, but this is only at a first sight. I may get eventually a bit deep into the problem and try tracing the code at execution to see if I can find out where these are related. Anyway, I'd like the version of bouncycastle about you said that Su Bing modified last year, if you can send it to me, in order to see if it works, which could tell at least if the issues that appear now are the same or related with the ones encountered last year.

Cheers,
Emanuel

PS: Sorry if I answered a bit late.. I'm still quite caught with faculty related activities in the first part of the week (until June when the semester ends)

···

On Tue, 6 May 2008, Romain KUNTZ wrote:

Hi Emanuel,

I read your post on your blog today and that made me think that I still have some code relative to SRTP to provide you. This is actually an example on how to instantiate and use the SRTP implementation (with hardcoded keys), this may be useful to you later in this project.

You'll find a patch enclosed that:
- add the necessary code to the build.xml to support bouncycastle
- add the code to CallSessionImpl.java to instantiate SRTP

(Note: this patch was made against a version of SC from last summer, so it might not apply without errors).

I also remember that Su Bing reported last year some errors at compilation time with the bouncycastle jar. He provided me a modified bouncycastle version, but it would be great if you could make it work with the original one. Let me know if you need the one Su provided me.

Cheers,

--
--------------------------------------------------------------------

"Life is full of unexpected but nothing happens without a reason..."

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#3

Hi! I encountered following: when the MediaServiceImpl starts, a new thread
is created and started using the "run"-method. But this does not start a
Thread but directly (blocking) executes the method. Is this really intended,
or should the start method be called? In my case using "start" works and
improves the startup time a lot, when a webcam is attached.

    public void start()
    {
        new DeviceConfigurationThread().start();
    }

The thread was invented by emcho. The checkin comment was: "started
implementing threaded device detection. i am explicitly not calling the
.start() method of the initialization thread (and only run) cause i think
there are still some sync problems"

Do you still think, that there are some sync issues? Or could they be
resolved in the meantime?

Cheers
Thomas

···

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net


#4

Hi Emanuel,

I can't see what's the connection between adding the crypto library at building and the issues presented above, but this is only at a first sight. I may get eventually a bit deep into the problem and try tracing the code at execution to see if I can find out where these are related. Anyway, I'd like the version of bouncycastle about you said that Su Bing modified last year, if you can send it to me, in order to see if it works, which could tell at least if the issues that appear now are the same or related with the ones encountered last year.

Thanks for investigating further the problem! I have put the modified bouncycastle here: http://clarinet.u-strasbg.fr/~kuntz/sc/bcprov-jdk14-137.zip

Tell us if this version works fine for you. You may have a look a it and check what's the difference with the original one, this probably would help to track the problem.

PS: Sorry if I answered a bit late.. I'm still quite caught with faculty related activities in the first part of the week (until June when the semester ends)

Don't worry about that. Now is the community bounding period so we do not expect students to be 100% on the project, and we understand that your studies takes precedence over it.

Cheers,
romain

···

On 2008/05/08, at 18:09, Onica S. Emanuel wrote:

Hi Emanuel,

I read your post on your blog today and that made me think that I still have some code relative to SRTP to provide you. This is actually an example on how to instantiate and use the SRTP implementation (with hardcoded keys), this may be useful to you later in this project.

You'll find a patch enclosed that:
- add the necessary code to the build.xml to support bouncycastle
- add the code to CallSessionImpl.java to instantiate SRTP

(Note: this patch was made against a version of SC from last summer, so it might not apply without errors).

I also remember that Su Bing reported last year some errors at compilation time with the bouncycastle jar. He provided me a modified bouncycastle version, but it would be great if you could make it work with the original one. Let me know if you need the one Su provided me.

Cheers,

--
--------------------------------------------------------------------

"Life is full of unexpected but nothing happens without a reason..."

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@sip-communicator.dev.java.net
For additional commands, e-mail: dev-help@sip-communicator.dev.java.net