Creating Cryptographic Context

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.

A cryptographic context includes a session key used in encryption and message authentication. A cryptographic context also includes a securely exchanged random bit string used to derive session keys called the master key. In addition to the session and master key the cryptographic context includes other working session parameters.

Required background

Prior to cryptographic context creation:

  • The master key,master salt and parameters (ie. TSrtpCryptoParams) required to create the cryptographic context must be created and initalised.

Procedure

The following steps describe the steps involved in creating a cryptographic context:

  • Create a cryptographic context by invoking the API NewL() or NewLC() of the class CSRTPCryptoContext.

    1. 
                           IMPORT_C static CSRTPCryptoContext* NewL( const CSRTPMasterKey* aKey,
                                                  const CSRTPMasterSalt* aSalt, 
                                                  const TSrtpCryptoParams& aCryptoParams);

      aKey is the input parameter that contains the master key.

      aSalt is the input parameter that contains the master salt key.

      aCryptoParams is the input parameter that contains the Crypto Context parameters.

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

    2. 
                           IMPORT_C static CSRTPCryptoContext* NewLC( const CSRTPMasterKey* aKey,
                                                  const CSRTPMasterSalt* aSalt, 
                                                  const TSrtpCryptoParams& aCryptoParams );

      aKey is the input parameter that contains the master key.

      aSalt is the input parameter that contains the master salt key.

      aCryptoParams is the input parameter that contains the Crypto Context parameters.

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

Creating Master Key

The master key can be created using the following API's:

  • IMPORT_C static CSRTPMasterKey* NewL( const TDesC8& aKey,const TDesC8& aMKI,TUint aN_E = KSRTPDefSessionEncryptionKeyLength,Uint aN_A = KSRTPDefSessionAuthenticationKeyLength );
  • IMPORT_C static CSRTPMasterKey* NewLC( const TDesC8& aKey,const TDesC8& aMKI,TUint aN_E = KSRTPDefSessionEncryptionKeyLength,TUint aN_A = KSRTPDefSessionAuthenticationKeyLength);
  • IMPORT_C static CSRTPMasterSalt* NewLC( const TDesC8& aKey, TUint aN_S = KSRTPDefSessionSaltingKeyLength );

Creating Master Salt Key

The master salt key can be created using the following API's:

  • IMPORT_C static CSRTPMasterSalt* NewL( const TDesC8& aKey,TUint aN_S = KSRTPDefSessionSaltingKeyLength )

Results

On successful execution of the API, a cryptographic context is created.

The cryptographic context can be used by a SRTP session or Stream. In other words, the cryptographic context is owned by the session or stream.

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

Related concepts
Creating an SRTP Session