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 License
15 along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18
19
20 #ifndef CRYPTOCONTEXT_H
21 #define CRYPTOCONTEXT_H
22
23 #include <commoncpp/config.h>
24
26
27
28 #define REPLAY_WINDOW_SIZE 64
29
33
39
40 #ifndef CRYPTOCONTEXTCTRL_H
41
42 #include <stdint.h>
43
44 #ifdef SRTP_SUPPORT
46 #endif
47
49
50 NAMESPACE_COMMONCPP
51
53
83 public:
94
170 int64 keyDerivRate,
171 const int32 ealg,
172 const int32 aalg,
174 int32 masterKeyLength,
176 int32 masterSaltLength,
177 int32 ekeyl,
178 int32 akeyl,
179 int32 skeyl,
180 int32 tagLength );
187
197 inline void
199 {roc = r;}
200
209 inline uint32
211 {return roc;}
212
229 void srtpEncrypt(
RTPPacket*
rtp, uint64 index, uint32 ssrc );
230
247 void srtpAuthenticate(
RTPPacket*
rtp, uint32 roc, uint8* tag );
248
260 void deriveSrtpKeys(uint64 index);
261
274 uint64 guessIndex(uint16 newSeqNumber);
275
291 bool checkReplay(uint16 newSeqNumber);
292
302 void update( uint16 newSeqNumber );
303
309 inline int32
311 {return tagLength;}
312
313
319 inline int32
321 {return mkiLength;}
322
328 inline uint32
330 {return ssrcCtx;}
331
353 CryptoContext* newCryptoContextForSSRC(uint32 ssrc,
int roc, int64 keyDerivRate);
354
355 private:
356
361
366
367 /* bitmask for replay check */
369
376
377 /* Session Encryption, Authentication keys, Salt */
384
392
394
395 #ifdef SRTP_SUPPORT
398 #else
401 #endif
402
403 };
404
405 END_NAMESPACE
406
407 #endif
408
409 #endif
410
Implments the SRTP encryption modes as defined in RFC3711.
A base class for both IncomingRTPPkt and OutgoingRTPPkt.
int32 getMkiLength() const
Get the length of the MKI in bytes.
The implementation for a SRTP cryptographic context.
void setRoc(uint32 r)
Set the Roll-Over-Counter.
uint32 master_key_srtcp_use_nb
const int SrtpEncryptionAESF8
uint32 getRoc() const
Get the Roll-Over-Counter.
const int SrtpEncryptionTWOF8
uint32 master_salt_length
const int SrtpEncryptionTWOCM
const int SrtpAuthenticationSkeinHmac
const int SrtpEncryptionNull
int32 getTagLength() const
Get the length of the SRTP authentication tag in bytes.
const int SrtpAuthenticationSha1Hmac
Class which implements SRTP AES cryptographic functions.
uint32 getSsrc() const
Get the SSRC of this SRTP Cryptograhic context.
const int SrtpAuthenticationNull
uint32 master_key_srtp_use_nb
const int SrtpEncryptionAESCM