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
27
28 #ifdef SRTP_SUPPORT
29 #include <ccrtp/crypto/AesSrtp.h>
30 #endif
31
32 #define REPLAY_WINDOW_SIZE 64
33
34
37
41
42 #ifdef CCXX_NAMESPACES
43 namespace ost {
44 #endif
45
47
77 public:
88
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 );
181
191 inline void
193 {roc = r;}
194
203 inline uint32
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
305 {return tagLength;}
306
307
313 inline int32
315 {return mkiLength;}
316
322 inline uint32
324 {return ssrc;}
325
348 CryptoContext* newCryptoContextForSSRC(uint32 ssrc,
int roc, int64 keyDerivRate);
349
350 private:
351
356
361
362 /* bitmask for replay check */
364
371
372 /* Session Encryption, Authentication keys, Salt */
379
387
388 #ifdef SRTP_SUPPORT
389 AesSrtp* aesCipher;
390 AesSrtp* f8AesCipher;
391 #else
394 #endif
395
396 };
397 #ifdef CCXX_NAMESPACES
398 }
399 #endif
400
401 #endif
402
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.
uint32 master_salt_length
const int SrtpEncryptionNull
int32 getTagLength() const
Get the length of the SRTP authentication tag in bytes.
const int SrtpAuthenticationSha1Hmac
uint32 getSsrc() const
Get the SSRC of this SRTP Cryptograhic context.
const int SrtpAuthenticationNull
uint32 master_key_srtp_use_nb
const int SrtpEncryptionAESCM