Creating an SRTP Session

The SRTP library generates SRTP packets from the RTP or RTCP stream and forwards the packets to the receiver. SRTP transforms incoming SRTP packets to RTP/RTCP packets and passes them up the stack. The cryptographic state information associated with each SRTP stream is termed the cryptographic context. The state information is maintained by both the sender and receiver of SRTP streams. If multiple SRTP streams exist within a given RTP session, then separate cryptographic contexts must be maintained for each stream. Each stream is identified by a Synchronisation Source (SSRC).

All actions on the RTP and RTCP streams require a valid SRTP session. Creation and initialization of a SRTP session is a pre-requirement for all consequent actions.

Required background

Prior to initiation of a create session request, an application or a RTP stack must ensure:

  • Values to populate the cryptographic context for the session to be created must be available

  • Destination Address must be identified.

Procedure

  1. Create a SRTP session by invoking the NewL() or NewLC() API's of the class CSRTPSession.

    The functions NewL() and NewLC() both have two variants each. Each of the variants are explained below.

    1. 
                           IMPORT_C static CSRTPSession* NewL(const TInetAddr&
                           aDestination )

      This API is appropriate when each stream will have its own cryptographic context.

      aDestination is the input parameter that contains the destination address, including the port.

      The API leaves with KErrNone if successfully executed, else returns a valid system-wide error code.

    2. IMPORT_C static CSRTPSession* NewL( const TInetAddr&
                           aDestination, CSRTPCryptoContext* aCon,
                           MSRTPReKeyingObserver& aObs );

      This API is appropraite when all streams will use the same cryptographic context configured in the SRTP session.

      aDestination is the input parameter that contains the destination address, including the port.

      aCon is the input parameter that contains the default cryptographic context for the session.

      aObs is the input parameter that contains the callback object.

      The API leaves with KErrNone if successfully executed, else returns a valid system-wide error code.

    3. IMPORT_C static CSRTPSession* NewLC(const TInetAddr&
                           aDestination ); 
                        

      This function creates a new SRTP session and pushes it to CleanupStack.

      aDestination is the input parameter that contains the destination address, including the port.

      The API leaves with KErrNone if successfully executed, else returns a valid system-wide error code.

    4. IMPORT_C static CSRTPSession* NewLC(const TInetAddr&
                           aDestination, CSRTPCryptoContext* aCon,
                           MSRTPReKeyingObserver& aObs); 
                        

      This function creates a new SRTP session and pushes it to CleanupStack.

      This API is invoked if all streams will use the same cryptographic context.

      aDestination is the input parameter that contains the destination address, including the port.

      aCon is the input parameter that contains the default cryptographic context for the session.

      aObs is the input parameter that contains the callback object.

      The API leaves with KErrNone if successfully executed, else returns a valid system-wide error code.

Results

On successful execution of the API, a SRTP session is created and initialized.

On creation of a valid SRTP session, the application can request for encrypting and decrypting of RTP and RTCP streams, Updating SRTP Master Key or Notification of Key Expiry.

The stream(s) associated with the session are always owned by the session.

The cryptographic context of the session may be owned by the stream or the session.

The master keys and the master salt are owned by the cryptographic context.

When an SRTP session is deleted, the Cryptographic context, the stream, the master key and the mastersalt key associated with the session are deleted.

The steps below describe the stream management techniques of a SRTP session:

  1. Attach a stream to session of by invoking the API AddStreamToList()of the class CSRTPSession.

    void AddStreamToList(CSRTPStream *aStream);

    This API attaches the given stream to the session.

    aStream is the input parameter that contains the stream to be added to session.

  2. Remove a stream to the session by invoking the API RemoveStreamFromList()of the class CSRTPSession.

    void RemoveStreamFromList(CSRTPStream *aStream);

    This API removes the given stream from the session.

    aStream is the input parameter that contains the stream to be removed from the session.