How to encrypt calls with RTP encryption?
Download: | rtp-encryption.zip |
This article is a brief introduction about RTP call encryption in relation with Ozeki VoIP SIP SDK. After reading through this page you will be fully familiar with all the essential terms concerning RTP encryption and what you will need for creating your own solution using Ozeki VoIP SIP SDK.
What is RTP encryption?
The Secure Real-time Transport Protocol (or SRTP) defines a
profile of RTP (Real-time Transport Protocol), intended to
provide encryption, message authentication and integrity, and
replay protection to the RTP data in both unicast and multicast applications.
For encryption and decryption of the data flow (and hence for providing confidentiality
of the data flow), SRTP utilizes AES (Advanced Encryption Standard) as the default cipher.
AES is a symmetric-key algorithm, meaning the same key is used for both encrypting and decrypting the data.
Transport Layer Security (TLS) and its predecessor, Secure Sockets
Layer (SSL), are cryptographic protocols that provide communication
security over the Internet. TLS and SSL encrypt the segments of network
connections above the Transport Layer, using asymmetric cryptography for key
exchange, symmetric encryption for privacy, and message authentication codes for message integrity.
Please note that, the security keys will be sent via SIP messages, so it's highly recommended
to encrypt the SIP messages as well, when you are using RTP encryption.
How to implement RTP encryption using C#?
Ozeki VoIP SIP SDK supports SRTP encryption for the phone line objects. You can set the SRTPMode property of the phone line. The SRTPMode is an enum defined in the Ozeki.Network namespace. It defines three SRTP modes: None, Prefer and Force.
Ozeki VoIP SIP SDK provides three types of SRTP modes:
- SRTPMode.None: The None SRTPMode is the default value for the encryption. If you do not set the SRTP mode in your program, there will be no RTP encryption for the calls.
- SRTPMode.Prefer: If you set the SRTP mode to Prefer, the system will try to encrypt the RTP connection, but there will be no encryption if one of the clients does not support it.
- SRTPMode.Force: If the SRTP mode is set to Force, the RTP connection will be encrypted no matter what.
When using UDP for message transmission, you need to select some of the codecs to disable as the maximum length of 1500 bytes of the UDP packet will be exceeded if all the codecs are enabled when using SRTP mode.
The RTP encryption can be used in the case of an Ozeki VoIP SIP SDK supported softphone application by setting it's phone line object's SRTPMode property with the preferred SRTP mode, as the following example introduces.
RTP encryption example in C#
using System; using Ozeki.VoIP; namespace RTP_Encryption { class Program { static ISoftPhone softphone; // softphone object static IPhoneLine phoneLine; // phoneline object private static void Main(string[] args) { // Create a softphone object with RTP port range 5000-10000 softphone = SoftPhoneFactory.CreateSoftPhone(5000, 10000); // SIP account registration data, (supplied by your VoIP service provider) var registrationRequired = true; var userName = "sipusername"; var displayName = "sipdisplayname"; var authenticationId = "authenticationid"; var registerPassword = "Password"; var domainHost = "pbxip.voipprovider.com"; var domainPort = 5060; var account = new SIPAccount(registrationRequired, displayName, userName, authenticationId, registerPassword, domainHost, domainPort); // Send SIP regitration request RegisterAccount(account); // Prevents the termination of the application Console.ReadLine(); } static void RegisterAccount(SIPAccount account) { try { phoneLine = softphone.CreatePhoneLine(account); phoneLine.Config.SRTPMode = SRTPMode.Force; phoneLine.RegistrationStateChanged += sipAccount_RegStateChanged; softphone.RegisterPhoneLine(phoneLine); } catch (Exception ex) { Console.WriteLine("Error during SIP registration: " + ex); } } static void sipAccount_RegStateChanged(object sender, RegistrationStateChangedArgs e) { if (e.State == RegState.Error || e.State == RegState.NotRegistered) Console.WriteLine("Registration failed!"); if (e.State == RegState.RegistrationSucceeded) Console.WriteLine("Registration succeeded - Online!"); } } }
Related Pages
More information
- How to build a softphone voip sip client
- Register to SIP PBX
- Voip softphone development
- How to encrypt voip sip calls with sip encryption
- How to encrypt voip sip calls with rtp encryption
- How to ring a sip extension csharp example for sip invite
- How to make a sip voice call using csharp
- Voip multiple phone lines
- How to send stream of voice data into call using csharp microphone
- How to receive voice from SIP voice call using csharp speaker
- How to make conference voice call using voip sip
- How to play an mp3 file into a voice call using csharp
- How to convert text to speech and play that into a call using csharp
- How to use Microsoft Speech Platform 11 for TTS and STT
- How to record voip sip voice call
- How to accept incoming call using csharp
- How to reject incoming call using csharp
- How to read Headset buttons using Bluetooth
- How to implement auto answer using csharp
- How to recognize incoming voice using speech to text conversion
- Voip forward call
- Voip blind transfer
- Voip attended transfer
- Voip do not disturb
- Voip call hold
- SIP Message Waiting Indication
- Voip DTMF signaling
- How to work with sip and sdp in voip sip calls
- How to work with rtp in voip sip calls
- How to make voip video calls in csharp
- Voip video codec
- Shows how to use SpeechToText Google API
- How to convert Text to Speech using C# and Google
- Azure Text-to-Speech