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

Bayonne2 / Common C++ 2 Framework
CryptoContext.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2004-2006 the Minisip Team
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 
19 
20 
21 #ifndef CRYPTOCONTEXT_H
22 #define CRYPTOCONTEXT_H
23 
24 #include <cc++/config.h>
25 
26 #include <ccrtp/rtppkt.h>
27 
28 #ifdef SRTP_SUPPORT
29 #include <ccrtp/crypto/AesSrtp.h>
30 #endif
31 
32  #define REPLAY_WINDOW_SIZE 64
33 
34 
35  const int SrtpAuthenticationNull = 0;
36  const int SrtpAuthenticationSha1Hmac = 1;
37 
38  const int SrtpEncryptionNull = 0;
39  const int SrtpEncryptionAESCM = 1;
40  const int SrtpEncryptionAESF8 = 2;
41 
42 #ifdef CCXX_NAMESPACES
43 namespace ost {
44 #endif
45 
46  class RTPPacket;
47 
76   class __EXPORT CryptoContext {
77  public:
87  CryptoContext( uint32 ssrc );
88 
163  CryptoContext( uint32 ssrc, int32 roc,
164  int64 keyDerivRate,
165  const int32 ealg,
166  const int32 aalg,
167  uint8* masterKey,
168  int32 masterKeyLength,
169  uint8* masterSalt,
170  int32 masterSaltLength,
171  int32 ekeyl,
172  int32 akeyl,
173  int32 skeyl,
174  int32 tagLength );
180  ~CryptoContext();
181 
191  inline void
192   setRoc(uint32 r)
193  {roc = r;}
194 
203  inline uint32
204   getRoc() const
205 {return roc;}
206 
223  void srtpEncrypt( RTPPacket* rtp, uint64 index, uint32 ssrc );
224 
241  void srtpAuthenticate(RTPPacket* rtp, uint32 roc, uint8* tag );
242 
254  void deriveSrtpKeys(uint64 index);
255 
268  uint64 guessIndex(uint16 newSeqNumber);
269 
285  bool checkReplay(uint16 newSeqNumber);
286 
296  void update( uint16 newSeqNumber );
297 
303  inline int32
304   getTagLength() const
305 {return tagLength;}
306 
307 
313  inline int32
314   getMkiLength() const
315 {return mkiLength;}
316 
322  inline uint32
323   getSsrc() const
324 {return ssrc;}
325 
348  CryptoContext* newCryptoContextForSSRC(uint32 ssrc, int roc, int64 keyDerivRate);
349 
350  private:
351 
352   uint32 ssrc;
353   bool using_mki;
354   uint32 mkiLength;
355   uint8* mki;
356 
357   uint32 roc;
358   uint32 guessed_roc;
359   uint16 s_l;
360   int64 key_deriv_rate;
361 
362  /* bitmask for replay check */
363   uint64 replay_window;
364 
365   uint8* master_key;
366   uint32 master_key_length;
367   uint32 master_key_srtp_use_nb;
368   uint32 master_key_srtcp_use_nb;
369   uint8* master_salt;
370   uint32 master_salt_length;
371 
372  /* Session Encryption, Authentication keys, Salt */
373   int32 n_e;
374   uint8* k_e;
375   int32 n_a;
376   uint8* k_a;
377   int32 n_s;
378   uint8* k_s;
379 
380   uint8 ealg;
381   uint8 aalg;
382   uint8 ekeyl;
383   uint8 akeyl;
384   uint8 skeyl;
385   uint8 tagLength;
386   bool seqNumSet;
387 
388 #ifdef SRTP_SUPPORT
389  AesSrtp* aesCipher;
390  AesSrtp* f8AesCipher;
391 #else
392   void* aesCipher;
393   void* f8AesCipher;
394 #endif
395 
396  };
397 #ifdef CCXX_NAMESPACES
398 }
399 #endif
400 
401 #endif
402 
CryptoContext::replay_window
uint64 replay_window
Definition: CryptoContext.h:363
RTPPacket
A base class for both IncomingRTPPkt and OutgoingRTPPkt.
Definition: rtppkt.h:75
CryptoContext::getMkiLength
int32 getMkiLength() const
Get the length of the MKI in bytes.
Definition: CryptoContext.h:314
CryptoContext
The implementation for a SRTP cryptographic context.
Definition: CryptoContext.h:76
CryptoContext::setRoc
void setRoc(uint32 r)
Set the Roll-Over-Counter.
Definition: CryptoContext.h:192
CryptoContext::master_key_srtcp_use_nb
uint32 master_key_srtcp_use_nb
Definition: CryptoContext.h:368
SrtpEncryptionAESF8
const int SrtpEncryptionAESF8
Definition: CryptoContext.h:40
CryptoContext::k_s
uint8 * k_s
Definition: CryptoContext.h:378
CryptoContext::aesCipher
void * aesCipher
Definition: CryptoContext.h:392
CryptoContext::getRoc
uint32 getRoc() const
Get the Roll-Over-Counter.
Definition: CryptoContext.h:204
CryptoContext::tagLength
uint8 tagLength
Definition: CryptoContext.h:385
CryptoContext::master_key_length
uint32 master_key_length
Definition: CryptoContext.h:366
CryptoContext::k_a
uint8 * k_a
Definition: CryptoContext.h:376
CryptoContext::master_salt_length
uint32 master_salt_length
Definition: CryptoContext.h:370
CryptoContext::guessed_roc
uint32 guessed_roc
Definition: CryptoContext.h:358
CryptoContext::key_deriv_rate
int64 key_deriv_rate
Definition: CryptoContext.h:360
CryptoContext::mkiLength
uint32 mkiLength
Definition: CryptoContext.h:354
__EXPORT
#define __EXPORT
Definition: audio2.h:51
CryptoContext::master_key
uint8 * master_key
Definition: CryptoContext.h:365
SrtpEncryptionNull
const int SrtpEncryptionNull
Definition: CryptoContext.h:38
CryptoContext::getTagLength
int32 getTagLength() const
Get the length of the SRTP authentication tag in bytes.
Definition: CryptoContext.h:304
SrtpAuthenticationSha1Hmac
const int SrtpAuthenticationSha1Hmac
Definition: CryptoContext.h:36
CryptoContext::f8AesCipher
void * f8AesCipher
Definition: CryptoContext.h:393
CryptoContext::k_e
uint8 * k_e
Definition: CryptoContext.h:374
CryptoContext::mki
uint8 * mki
Definition: CryptoContext.h:355
CryptoContext::getSsrc
uint32 getSsrc() const
Get the SSRC of this SRTP Cryptograhic context.
Definition: CryptoContext.h:323
CryptoContext::master_salt
uint8 * master_salt
Definition: CryptoContext.h:369
SrtpAuthenticationNull
const int SrtpAuthenticationNull
Definition: CryptoContext.h:35
CryptoContext::master_key_srtp_use_nb
uint32 master_key_srtp_use_nb
Definition: CryptoContext.h:367
SrtpEncryptionAESCM
const int SrtpEncryptionAESCM
Definition: CryptoContext.h:39
rtppkt.h
RTP packets handling.

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 によって変換されたページ (->オリジナル) /