live
SRTPCryptographicContext Class Reference

#include <SRTPCryptographicContext.hh>

Collaboration diagram for SRTPCryptographicContext:

Data Structures

struct  derivedKeys
struct  allDerivedKeys

Public Member Functions

 SRTPCryptographicContext (MIKEYState const &mikeyState)
virtual ~SRTPCryptographicContext ()
Boolean processIncomingSRTPPacket (u_int8_t *buffer, unsigned inPacketSize, unsigned &outPacketSize)
Boolean processIncomingSRTCPPacket (u_int8_t *buffer, unsigned inPacketSize, unsigned &outPacketSize)
Boolean processOutgoingSRTPPacket (u_int8_t *buffer, unsigned inPacketSize, unsigned &outPacketSize)
Boolean processOutgoingSRTCPPacket (u_int8_t *buffer, unsigned inPacketSize, unsigned &outPacketSize)
u_int32_t sendingROC () const

Private Types

enum  SRTPKeyDerivationLabel {
  label_srtp_encryption = 0x00 , label_srtp_msg_auth = 0x01 , label_srtp_salt = 0x02 , label_srtcp_encryption = 0x03 ,
  label_srtcp_msg_auth = 0x04 , label_srtcp_salt = 0x05
}

Private Member Functions

unsigned generateSRTPAuthenticationTag (u_int8_t const *dataToAuthenticate, unsigned numBytesToAuthenticate, u_int8_t *resultAuthenticationTag)
unsigned generateSRTCPAuthenticationTag (u_int8_t const *dataToAuthenticate, unsigned numBytesToAuthenticate, u_int8_t *resultAuthenticationTag)
Boolean verifySRTPAuthenticationTag (u_int8_t *dataToAuthenticate, unsigned numBytesToAuthenticate, u_int32_t roc, u_int8_t const *authenticationTag)
Boolean verifySRTCPAuthenticationTag (u_int8_t const *dataToAuthenticate, unsigned numBytesToAuthenticate, u_int8_t const *authenticationTag)
void decryptSRTPPacket (u_int64_t index, u_int32_t ssrc, u_int8_t *data, unsigned numDataBytes)
void decryptSRTCPPacket (u_int32_t index, u_int32_t ssrc, u_int8_t *data, unsigned numDataBytes)
void encryptSRTPPacket (u_int64_t index, u_int32_t ssrc, u_int8_t *data, unsigned numDataBytes)
void encryptSRTCPPacket (u_int32_t index, u_int32_t ssrc, u_int8_t *data, unsigned numDataBytes)
unsigned generateAuthenticationTag (derivedKeys &keysToUse, u_int8_t const *dataToAuthenticate, unsigned numBytesToAuthenticate, u_int8_t *resultAuthenticationTag)
Boolean verifyAuthenticationTag (derivedKeys &keysToUse, u_int8_t const *dataToAuthenticate, unsigned numBytesToAuthenticate, u_int8_t const *authenticationTag)
void cryptData (derivedKeys &keys, u_int64_t index, u_int32_t ssrc, u_int8_t *data, unsigned numDataBytes)
void performKeyDerivation ()
void deriveKeysFromMaster (u_int8_t const *masterKey, u_int8_t const *salt, allDerivedKeys &allKeysResult)
void deriveSingleKey (u_int8_t const *masterKey, u_int8_t const *salt, SRTPKeyDerivationLabel label, unsigned resultKeyLength, u_int8_t *resultKey)
u_int8_t const * masterKeyPlusSalt () const
u_int8_t const * masterKey () const
u_int8_t const * masterSalt () const
Boolean weEncryptSRTP () const
Boolean weEncryptSRTCP () const
Boolean weAuthenticate () const
u_int32_t MKI () const

Private Attributes

MIKEYState const & fMIKEYState
allDerivedKeys fDerivedKeys
Boolean fHaveReceivedSRTPPackets
u_int16_t fPreviousHighRTPSeqNum
u_int32_t fReceptionROC
Boolean fHaveSentSRTPPackets
u_int32_t fSendingROC
u_int32_t fSRTCPIndex

Detailed Description

Definition at line 27 of file SRTPCryptographicContext.hh.

Member Enumeration Documentation

◆ SRTPKeyDerivationLabel

Enumerator
label_srtp_encryption 
label_srtp_msg_auth 
label_srtp_salt 
label_srtcp_encryption 
label_srtcp_msg_auth 
label_srtcp_salt 

Definition at line 73 of file SRTPCryptographicContext.hh.

Constructor & Destructor Documentation

◆ SRTPCryptographicContext()

SRTPCryptographicContext::SRTPCryptographicContext ( MIKEYState const & mikeyState)

◆ ~SRTPCryptographicContext()

virtual SRTPCryptographicContext::~SRTPCryptographicContext ( )
virtual

Member Function Documentation

◆ cryptData()

void SRTPCryptographicContext::cryptData ( derivedKeys & keys,
u_int64_t index,
u_int32_t ssrc,
u_int8_t * data,
unsigned numDataBytes )
private

◆ decryptSRTCPPacket()

void SRTPCryptographicContext::decryptSRTCPPacket ( u_int32_t index,
u_int32_t ssrc,
u_int8_t * data,
unsigned numDataBytes )
private

◆ decryptSRTPPacket()

void SRTPCryptographicContext::decryptSRTPPacket ( u_int64_t index,
u_int32_t ssrc,
u_int8_t * data,
unsigned numDataBytes )
private

◆ deriveKeysFromMaster()

void SRTPCryptographicContext::deriveKeysFromMaster ( u_int8_t const * masterKey,
u_int8_t const * salt,
allDerivedKeys & allKeysResult )
private

References masterKey().

◆ deriveSingleKey()

void SRTPCryptographicContext::deriveSingleKey ( u_int8_t const * masterKey,
u_int8_t const * salt,
SRTPKeyDerivationLabel label,
unsigned resultKeyLength,
u_int8_t * resultKey )
private

References masterKey().

◆ encryptSRTCPPacket()

void SRTPCryptographicContext::encryptSRTCPPacket ( u_int32_t index,
u_int32_t ssrc,
u_int8_t * data,
unsigned numDataBytes )
private

◆ encryptSRTPPacket()

void SRTPCryptographicContext::encryptSRTPPacket ( u_int64_t index,
u_int32_t ssrc,
u_int8_t * data,
unsigned numDataBytes )
private

◆ generateAuthenticationTag()

unsigned SRTPCryptographicContext::generateAuthenticationTag ( derivedKeys & keysToUse,
u_int8_t const * dataToAuthenticate,
unsigned numBytesToAuthenticate,
u_int8_t * resultAuthenticationTag )
private

◆ generateSRTCPAuthenticationTag()

unsigned SRTPCryptographicContext::generateSRTCPAuthenticationTag ( u_int8_t const * dataToAuthenticate,
unsigned numBytesToAuthenticate,
u_int8_t * resultAuthenticationTag )
private

◆ generateSRTPAuthenticationTag()

unsigned SRTPCryptographicContext::generateSRTPAuthenticationTag ( u_int8_t const * dataToAuthenticate,
unsigned numBytesToAuthenticate,
u_int8_t * resultAuthenticationTag )
private

◆ masterKey()

u_int8_t const * SRTPCryptographicContext::masterKey ( ) const
inlineprivate

Definition at line 129 of file SRTPCryptographicContext.hh.

129{ return &masterKeyPlusSalt()[0]; }
u_int8_t const * masterKeyPlusSalt() const

References masterKeyPlusSalt().

Referenced by deriveKeysFromMaster(), and deriveSingleKey().

◆ masterKeyPlusSalt()

u_int8_t const * SRTPCryptographicContext::masterKeyPlusSalt ( ) const
inlineprivate

Definition at line 127 of file SRTPCryptographicContext.hh.

127{ return fMIKEYState.keyData(); }
u_int8_t const * keyData() const
Definition MIKEY.hh:50

References fMIKEYState, and MIKEYState::keyData().

Referenced by masterKey(), and masterSalt().

◆ masterSalt()

u_int8_t const * SRTPCryptographicContext::masterSalt ( ) const
inlineprivate

Definition at line 130 of file SRTPCryptographicContext.hh.

#define SRTP_CIPHER_KEY_LENGTH

References masterKeyPlusSalt(), and SRTP_CIPHER_KEY_LENGTH.

◆ MKI()

u_int32_t SRTPCryptographicContext::MKI ( ) const
inlineprivate

Definition at line 135 of file SRTPCryptographicContext.hh.

135{ return fMIKEYState.MKI(); }
u_int32_t MKI() const
Definition MIKEY.hh:51

References fMIKEYState, and MIKEYState::MKI().

◆ performKeyDerivation()

void SRTPCryptographicContext::performKeyDerivation ( )
private

◆ processIncomingSRTCPPacket()

Boolean SRTPCryptographicContext::processIncomingSRTCPPacket ( u_int8_t * buffer,
unsigned inPacketSize,
unsigned & outPacketSize )

◆ processIncomingSRTPPacket()

Boolean SRTPCryptographicContext::processIncomingSRTPPacket ( u_int8_t * buffer,
unsigned inPacketSize,
unsigned & outPacketSize )

◆ processOutgoingSRTCPPacket()

Boolean SRTPCryptographicContext::processOutgoingSRTCPPacket ( u_int8_t * buffer,
unsigned inPacketSize,
unsigned & outPacketSize )

◆ processOutgoingSRTPPacket()

Boolean SRTPCryptographicContext::processOutgoingSRTPPacket ( u_int8_t * buffer,
unsigned inPacketSize,
unsigned & outPacketSize )

◆ sendingROC()

u_int32_t SRTPCryptographicContext::sendingROC ( ) const

◆ verifyAuthenticationTag()

Boolean SRTPCryptographicContext::verifyAuthenticationTag ( derivedKeys & keysToUse,
u_int8_t const * dataToAuthenticate,
unsigned numBytesToAuthenticate,
u_int8_t const * authenticationTag )
private

◆ verifySRTCPAuthenticationTag()

Boolean SRTPCryptographicContext::verifySRTCPAuthenticationTag ( u_int8_t const * dataToAuthenticate,
unsigned numBytesToAuthenticate,
u_int8_t const * authenticationTag )
private

◆ verifySRTPAuthenticationTag()

Boolean SRTPCryptographicContext::verifySRTPAuthenticationTag ( u_int8_t * dataToAuthenticate,
unsigned numBytesToAuthenticate,
u_int32_t roc,
u_int8_t const * authenticationTag )
private

◆ weAuthenticate()

Boolean SRTPCryptographicContext::weAuthenticate ( ) const
inlineprivate

Definition at line 134 of file SRTPCryptographicContext.hh.

134{ return fMIKEYState.useAuthentication(); }
Boolean useAuthentication() const
Definition MIKEY.hh:53

References fMIKEYState, and MIKEYState::useAuthentication().

◆ weEncryptSRTCP()

Boolean SRTPCryptographicContext::weEncryptSRTCP ( ) const
inlineprivate

Definition at line 133 of file SRTPCryptographicContext.hh.

133{ return fMIKEYState.encryptSRTCP(); }
Boolean encryptSRTCP() const
Definition MIKEY.hh:49

References MIKEYState::encryptSRTCP(), and fMIKEYState.

◆ weEncryptSRTP()

Boolean SRTPCryptographicContext::weEncryptSRTP ( ) const
inlineprivate

Definition at line 132 of file SRTPCryptographicContext.hh.

132{ return fMIKEYState.encryptSRTP(); }
Boolean encryptSRTP() const
Definition MIKEY.hh:48

References MIKEYState::encryptSRTP(), and fMIKEYState.

Field Documentation

◆ fDerivedKeys

allDerivedKeys SRTPCryptographicContext::fDerivedKeys
private

Definition at line 138 of file SRTPCryptographicContext.hh.

◆ fHaveReceivedSRTPPackets

Boolean SRTPCryptographicContext::fHaveReceivedSRTPPackets
private

Definition at line 141 of file SRTPCryptographicContext.hh.

◆ fHaveSentSRTPPackets

Boolean SRTPCryptographicContext::fHaveSentSRTPPackets
private

Definition at line 146 of file SRTPCryptographicContext.hh.

◆ fMIKEYState

MIKEYState const& SRTPCryptographicContext::fMIKEYState
private

◆ fPreviousHighRTPSeqNum

u_int16_t SRTPCryptographicContext::fPreviousHighRTPSeqNum
private

Definition at line 142 of file SRTPCryptographicContext.hh.

◆ fReceptionROC

u_int32_t SRTPCryptographicContext::fReceptionROC
private

Definition at line 143 of file SRTPCryptographicContext.hh.

◆ fSendingROC

u_int32_t SRTPCryptographicContext::fSendingROC
private

Definition at line 147 of file SRTPCryptographicContext.hh.

◆ fSRTCPIndex

u_int32_t SRTPCryptographicContext::fSRTCPIndex
private

Definition at line 150 of file SRTPCryptographicContext.hh.


The documentation for this class was generated from the following file: