00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef CRYPTOCONTEXTCTRL_H
00023 #define CRYPTOCONTEXTCTRL_H
00024
00025 #include <commoncpp/config.h>
00026
00027 #define REPLAY_WINDOW_SIZE 64
00028
00029 #ifdef SRTP_SUPPORT
00030 #include <ccrtp/crypto/SrtpSymCrypto.h>
00031 #endif
00032
00033 NAMESPACE_COMMONCPP
00034
00062 class __EXPORT CryptoContextCtrl {
00063 public:
00073 CryptoContextCtrl( uint32 ssrc );
00074
00140 CryptoContextCtrl( uint32 ssrc,
00141 const int32 ealg,
00142 const int32 aalg,
00143 uint8* masterKey,
00144 int32 masterKeyLength,
00145 uint8* masterSalt,
00146 int32 masterSaltLength,
00147 int32 ekeyl,
00148 int32 akeyl,
00149 int32 skeyl,
00150 int32 tagLength );
00156 ~CryptoContextCtrl();
00157
00174 void srtcpEncrypt( uint8* rtp, size_t len, uint64 index, uint32 ssrc );
00175
00192 void srtcpAuthenticate(uint8* rtp, size_t len, uint32 roc, uint8* tag );
00193
00205 void deriveSrtcpKeys();
00206
00222 bool checkReplay(uint32 newSeqNumber);
00223
00233 void update( uint32 newSeqNumber );
00234
00240 inline int32
00241 getTagLength() const
00242 {return tagLength;}
00243
00244
00250 inline int32
00251 getMkiLength() const
00252 {return mkiLength;}
00253
00259 inline uint32
00260 getSsrc() const
00261 {return ssrcCtx;}
00262
00284 CryptoContextCtrl* newCryptoContextForSSRC(uint32 ssrc);
00285
00286 private:
00287
00288 uint32 ssrcCtx;
00289 bool using_mki;
00290 uint32 mkiLength;
00291 uint8* mki;
00292
00293 uint32 s_l;
00294
00295
00296 uint64 replay_window;
00297
00298 uint8* master_key;
00299 uint32 master_key_length;
00300 uint8* master_salt;
00301 uint32 master_salt_length;
00302
00303
00304 int32 n_e;
00305 uint8* k_e;
00306 int32 n_a;
00307 uint8* k_a;
00308 int32 n_s;
00309 uint8* k_s;
00310
00311 int32 ealg;
00312 int32 aalg;
00313 int32 ekeyl;
00314 int32 akeyl;
00315 int32 skeyl;
00316 int32 tagLength;
00317
00318 void* macCtx;
00319
00320 #ifdef SRTP_SUPPORT
00321 SrtpSymCrypto* cipher;
00322 SrtpSymCrypto* f8Cipher;
00323 #else
00324 void* cipher;
00325 void* f8Cipher;
00326 #endif
00327
00328 };
00329
00330 END_NAMESPACE
00331
00332 #endif
00333