Class SrtcpCryptoContext
SRTPCryptoContext class is the core class of SRTP implementation. There can be multiple SRTP sources in one SRTP session. And each SRTP stream has a corresponding SRTPCryptoContext object, identified by SSRC. In this way, different sources can be protected independently.
Inherited Members
Namespace: SipLib.Dtls
Assembly: SipLib.dll
Syntax
public class SrtcpCryptoContext
Constructors
| Edit this page View SourceSrtcpCryptoContext(long)
Constructs an empty SRTPCryptoContext using the SSRC. The other parameters are set to default null value.
Declaration
public SrtcpCryptoContext(long ssrcIn)
Parameters
Type | Name | Description |
---|---|---|
long | ssrcIn | SSRC of this SRTPCryptoContext |
SrtcpCryptoContext(long, byte[], byte[], SrtpPolicy)
Construct a normal SRTPCryptoContext based on the given parameters.
Declaration
public SrtcpCryptoContext(long ssrcIn, byte[] masterK, byte[] masterS, SrtpPolicy policyIn)
Parameters
Type | Name | Description |
---|---|---|
long | ssrcIn | The RTP SSRC that this SRTP cryptographic context protects. |
byte[] | masterK | byte array holding the master key for this SRTP cryptographic context. Refer to Section 3.2.1 of the RFC about the role of the master key. |
byte[] | masterS | byte array holding the master salt for this SRTP cryptographic context.It is used to computer the initialization vector that in turn is input to compute the session key, session authentication key and the session salt. |
SrtpPolicy | policyIn | SRTP policy for this SRTP cryptographic context, defined the encryption algorithm, the authentication algorithm, etc |
Methods
| Edit this page View SourceClose()
Close the crypto context. The Close function deletes key data and performs a cleanup of the crypto context. Clean up key data, maybe this is the second time.However, sometimes we cannot know if the CryptoContext was used and the application called deriveSrtpKeys(...) that would have cleaned the key data.
Declaration
public void Close()
DeriveContext(long)
Derives a new SRTPCryptoContext for use with a new SSRC. This method returns a new SRTPCryptoContext initialized with the data of this SRTPCryptoContext. Replacing the SSRC, Roll-over-Counter, and the key derivation rate the application cab use this SRTPCryptoContext to encrypt / decrypt a new stream(Synchronization source) inside one RTP session.
Declaration
public SrtcpCryptoContext DeriveContext(long ssrc)
Parameters
Type | Name | Description |
---|---|---|
long | ssrc | The SSRC for this context |
Returns
Type | Description |
---|---|
SrtcpCryptoContext | Returns a new SRTPCryptoContext with all relevant data set. |
DeriveSrtcpKeys()
Derives the srtcp session keys from the master key.
Declaration
public void DeriveSrtcpKeys()
GetAuthTagLength()
Gets the authentication tag length of this SRTP cryptographic context
Declaration
public int GetAuthTagLength()
Returns
Type | Description |
---|---|
int |
GetMKILength()
Gets the MKI length of this SRTP cryptographic context
Declaration
public int GetMKILength()
Returns
Type | Description |
---|---|
int |
GetSSRC()
Gets the SSRC of this SRTP cryptographic context
Declaration
public long GetSSRC()
Returns
Type | Description |
---|---|
long |
ProcessPacketAESCM(RawPacket, int)
Performs Counter Mode AES encryption / decryption
Declaration
public void ProcessPacketAESCM(RawPacket pkt, int index)
Parameters
Type | Name | Description |
---|---|---|
RawPacket | pkt | The RTP packet to be encrypted / decrypted |
int | index |
ProcessPacketAESF8(RawPacket, int)
Performs F8 Mode AES encryption / decryption
Declaration
public void ProcessPacketAESF8(RawPacket pkt, int index)
Parameters
Type | Name | Description |
---|---|---|
RawPacket | pkt | The RTP packet to be encrypted / decrypted |
int | index |
ReverseTransformPacket(RawPacket)
Transform a SRTCP packet into a RTCP packet. This method is called when a SRTCP packet was received.
Declaration
public bool ReverseTransformPacket(RawPacket pkt)
Parameters
Type | Name | Description |
---|---|---|
RawPacket | pkt | The received RTCP packet |
Returns
Type | Description |
---|---|
bool | Returns true if the packet can be accepted false if authentication or replay check failed |
TransformPacket(RawPacket)
Transform a RTP packet into a SRTP packet. This method is called when a normal RTP packet ready to be sent.
Operations done by the transformation may include: encryption, using either Counter Mode encryption, or F8 Mode encryption, adding authentication tag, currently HMC SHA1 method.
Both encryption and authentication functionality can be turned off as long as the SRTPPolicy used in this SRTPCryptoContext is requires no encryption and no authentication. Then the packet will be sent out untouched. However this is not encouraged. If no SRTP feature is enabled, then we shall not use SRTP TransformConnector. We should use the original method (RTPManager managed transportation) instead.
Declaration
public void TransformPacket(RawPacket pkt)
Parameters
Type | Name | Description |
---|---|---|
RawPacket | pkt | The RTP packet that is going to be sent out |