2

I am implementing a java gateway for the compatibility between webrtc and sip. I have done sdp exchange part. But now i am stuck in media part. So far i assume that i need to implement dtls-srtp handshake and then the encryption, decryption part. So can anyone please suggest any java library for

  1. DTLS handshake
  2. SRTP <--> RTP conversion

Or specific way to do this.
Edit: I am using JsSIP for webrtc to sip end. And Pangolin for sip client.

Rashed
  • 87
  • 1
  • 12
  • Before you get into DTLS / SRTP, you will first need to implement (or find a library) Interactive Connectivity Establishment, the mechanism by which both parties try to find a pair of (host, port) candidates which they can use to communicate. – Jeremy Mar 08 '18 at 12:34
  • @jeremy: Thank you. Can you please suggest any library. – Rashed Mar 10 '18 at 10:09
  • I found jstun library and used it. but it can not parse all the attribute and throw exception. Now i am trying to use pjnath stun library using jna( java native access). Can you please give any advice? – Rashed Mar 11 '18 at 10:30

1 Answers1

3

I've done this before. Check out my project jPhoneLite. It uses BouncyCastle for the DTLS part.

https://github.com/pquiring/javaforce/blob/master/src/javaforce/voip/SRTPChannel.java

But I want to convert it to Java9 which now includes DTLS but I'm not sure if it will work.

The DTLS is NOT actually used to transmit any data. The client/server connect, negotiate keys and then use the keys to encode data in the normal RTP channel. The DTLS connection is dropped as soon as keys are exchanged.

See RFC 5705 where DTLS is used only to get a key which is what my code supports.

See RFC 5764 where DTLS "is" used to send/receive the actual data. My code currently does NOT support this method.

Peter Quiring
  • 1,648
  • 1
  • 16
  • 21
  • Thank you for your answer. I am confused about one thing. Befor DTLS I need to handle P2P STUN request/response. What is the reason and process to do this? Can you help me out plz? – Rashed Apr 01 '18 at 07:33
  • 1
    Done that too. https://github.com/pquiring/javaforce/blob/master/src/javaforce/STUN.java – Peter Quiring Apr 01 '18 at 11:51
  • FYI - STUN is used to work around firewalls that make it nearly impossible for internet users to directly connect to each other – Peter Quiring Apr 03 '18 at 00:51
  • Hi. I have gone through the DTLS part from the SRTPChannel used in jPhoneLite.I have implemented DTLS-SRTP handshake part. But i can not figure out the encryption and decryption part using the exchanged key. I just found encrypt and decrypt function in the SRTPChannel. Which is not using DTLS key. Can you help me, where did you implemented the SRTP<-->RTP( encryption and decryption ). – Rashed Apr 24 '18 at 05:46
  • 1
    Note : There are two different RFCs related to DTLS and SRTP. I've updated my post to reflect that. – Peter Quiring Apr 27 '18 at 15:56
  • Ok. I understand. You did a great work. It helped me lot. – Rashed Apr 28 '18 at 06:06