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
62 public:
73
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 );
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
241 {return tagLength;}
242
243
249 inline int32
251 {return mkiLength;}
252
258 inline uint32
260 {return ssrcCtx;}
261
284
285 private:
286
291
293
294 /* bitmask for replay check */
296
301
302 /* Session Encryption, Authentication keys, Salt */
309
316
318
319 #ifdef SRTP_SUPPORT
320 SrtpSymCrypto* cipher;
321 SrtpSymCrypto* f8Cipher;
322 #else
325 #endif
326
327 };
328
329 END_NAMESPACE
330
331 #endif
332
The implementation for a SRTCP cryptographic context.
int32 getTagLength() const
Get the length of the SRTP authentication tag in bytes.
uint32 master_salt_length
uint32 getSsrc() const
Get the SSRC of this SRTP Cryptograhic context.
int32 getMkiLength() const
Get the length of the MKI in bytes.