Bayonne2 / Common C++ 2 Framework: CryptoContextCtrl.h Source File

Bayonne2 / Common C++ 2 Framework
CryptoContextCtrl.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2004-2006 the Minisip Team
3  Copyright (C) 2011 Werner Dittmann for the SRTCP support
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with GNU ccRTP. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 
20 
21 #ifndef CRYPTOCONTEXTCTRL_H
22 #define CRYPTOCONTEXTCTRL_H
23 
24 #include <commoncpp/config.h>
25 
26  #define REPLAY_WINDOW_SIZE 64
27 
28 #ifdef SRTP_SUPPORT
29 #include <ccrtp/crypto/SrtpSymCrypto.h>
30 #endif
31 
32 NAMESPACE_COMMONCPP
33 
61   class __EXPORT CryptoContextCtrl {
62  public:
72  CryptoContextCtrl( uint32 ssrc );
73 
139  CryptoContextCtrl( uint32 ssrc,
140  const int32 ealg,
141  const int32 aalg,
142  uint8* masterKey,
143  int32 masterKeyLength,
144  uint8* masterSalt,
145  int32 masterSaltLength,
146  int32 ekeyl,
147  int32 akeyl,
148  int32 skeyl,
149  int32 tagLength );
155  ~CryptoContextCtrl();
156 
173  void srtcpEncrypt( uint8* rtp, size_t len, uint64 index, uint32 ssrc );
174 
191  void srtcpAuthenticate(uint8* rtp, size_t len, uint32 roc, uint8* tag );
192 
204  void deriveSrtcpKeys();
205 
221  bool checkReplay(uint32 newSeqNumber);
222 
232  void update( uint32 newSeqNumber );
233 
239  inline int32
240   getTagLength() const
241 {return tagLength;}
242 
243 
249  inline int32
250   getMkiLength() const
251 {return mkiLength;}
252 
258  inline uint32
259   getSsrc() const
260 {return ssrcCtx;}
261 
283  CryptoContextCtrl* newCryptoContextForSSRC(uint32 ssrc);
284 
285  private:
286 
287   uint32 ssrcCtx;
288   bool using_mki;
289   uint32 mkiLength;
290   uint8* mki;
291 
292   uint32 s_l;
293 
294  /* bitmask for replay check */
295   uint64 replay_window;
296 
297   uint8* master_key;
298   uint32 master_key_length;
299   uint8* master_salt;
300   uint32 master_salt_length;
301 
302  /* Session Encryption, Authentication keys, Salt */
303   int32 n_e;
304   uint8* k_e;
305   int32 n_a;
306   uint8* k_a;
307   int32 n_s;
308   uint8* k_s;
309 
310   int32 ealg;
311   int32 aalg;
312   int32 ekeyl;
313   int32 akeyl;
314   int32 skeyl;
315   int32 tagLength;
316 
317   void* macCtx;
318 
319 #ifdef SRTP_SUPPORT
320  SrtpSymCrypto* cipher;
321  SrtpSymCrypto* f8Cipher;
322 #else
323   void* cipher;
324   void* f8Cipher;
325 #endif
326 
327  };
328 
329 END_NAMESPACE
330 
331 #endif
332 
CryptoContextCtrl
The implementation for a SRTCP cryptographic context.
Definition: CryptoContextCtrl.h:61
CryptoContextCtrl::getTagLength
int32 getTagLength() const
Get the length of the SRTP authentication tag in bytes.
Definition: CryptoContextCtrl.h:240
CryptoContextCtrl::getSsrc
uint32 getSsrc() const
Get the SSRC of this SRTP Cryptograhic context.
Definition: CryptoContextCtrl.h:259
__EXPORT
#define __EXPORT
Definition: audio2.h:51
CryptoContextCtrl::getMkiLength
int32 getMkiLength() const
Get the length of the MKI in bytes.
Definition: CryptoContextCtrl.h:250

Generated on Dec 21, 2017 for commoncpp2-1.8.1, ccrtp-1.7.2, libzrtpcpp-2.3.4, ccscript3-1.1.7, ccaudio2-1.0.0 and bayonne2-2.3.2 (after installation in /usr/local/) by   doxygen 1.8.6

AltStyle によって変換されたページ (->オリジナル) /