OPAL Version 3.10.4

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

srtp.h
Go to the documentation of this file.
1 /*
2 * srtp.h
3 *
4 * SRTP protocol handler
5 *
6 * OPAL Library
7 *
8 * Copyright (C) 2006 Post Increment
9 *
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
14 *
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * The Original Code is OPAL Library.
21 *
22 * The Initial Developer of the Original Code is Post Increment
23 * Portions of this code were written with the assistance of funding from
24 * US Joint Forces Command Joint Concept Development & Experimentation (J9)
25 * http://www.jfcom.mil/about/abt_j9.htm
26 *
27 * Contributor(s): ______________________________________.
28 *
29 * $Revision: 22444 $
30 * $Author: rjongbloed $
31 * $Date: 2009-04-20 18:49:06 -0500 (Mon, 20 Apr 2009) $
32 */
33
34 #ifndef OPAL_RTP_SRTP_H
35 #define OPAL_RTP_SRTP_H
36
37 #ifdef P_USE_PRAGMA
38 #pragma interface
39 #endif
40
41 #ifndef _PTLIB_H
42 #include <ptlib.h>
43 #endif
44
45 #include <opal/buildopts.h>
46
47 #include <rtp/rtp.h>
48 #include <opal/rtpconn.h>
49
50 #if OPAL_SRTP
51
52
54 //
55 // this class holds the parameters required for an SRTP session
56 //
57 // Crypto modes are identified by key strings that are contained in PFactory<OpalSRTPParms>
58 // The following strings should be implemented:
59 //
60 // AES_CM_128_HMAC_SHA1_80,
61 // AES_CM_128_HMAC_SHA1_32,
62 // AES_CM_128_NULL_AUTH,
63 // NULL_CIPHER_HMAC_SHA1_80
64 // STRONGHOLD
65 //
66
67 class OpalSRTPSecurityMode : public OpalSecurityMode
68 {
69 PCLASSINFO(OpalSRTPSecurityMode, OpalSecurityMode);
70 public:
71 struct KeySalt {
72 KeySalt() { }
73 KeySalt(const PBYTEArray & data) : key(data) { }
74 KeySalt(const BYTE * data, PINDEX dataLen) : key(data, dataLen) { }
75 PBYTEArray key;
76 PBYTEArray salt;
77 };
78 virtual PBoolean SetOutgoingKey(const KeySalt & key) = 0;
79 virtual PBoolean GetOutgoingKey(KeySalt & key) const = 0;
80 virtual PBoolean SetOutgoingSSRC(DWORD ssrc) = 0;
81 virtual PBoolean GetOutgoingSSRC(DWORD & ssrc) const = 0;
82
83 virtual PBoolean SetIncomingKey(const KeySalt & key) = 0;
84 virtual PBoolean GetIncomingKey(KeySalt & key) const = 0;
85 virtual PBoolean SetIncomingSSRC(DWORD ssrc) = 0;
86 virtual PBoolean GetIncomingSSRC(DWORD & ssrc) const = 0;
87 };
88
90 //
91 // this class implements SRTP over UDP
92 //
93
94 class OpalSRTP_UDP : public SecureRTP_UDP
95 {
96 PCLASSINFO(OpalSRTP_UDP, SecureRTP_UDP);
97 public:
98 OpalSRTP_UDP(
99 const Params & options
100 );
101
102 virtual SendReceiveStatus OnSendData (RTP_DataFrame & frame) = 0;
103 virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame) = 0;
104 virtual SendReceiveStatus OnSendControl(RTP_ControlFrame & frame, PINDEX & len) = 0;
105 virtual SendReceiveStatus OnReceiveControl(RTP_ControlFrame & frame) = 0;
106 };
107
108
110 //
111 // this class implements SRTP using libSRTP
112 //
113
114 class LibSRTP_UDP : public OpalSRTP_UDP
115 {
116 PCLASSINFO(LibSRTP_UDP, OpalSRTP_UDP);
117 public:
118 LibSRTP_UDP(
119 const Params & options
120 );
121
122 ~LibSRTP_UDP();
123
124 PBoolean Open(
125 PIPSocket::Address localAddress,
126 WORD portBase,
127 WORD portMax,
128 BYTE ipTypeOfService,
129 PNatMethod * natMethod = NULL,
130 RTP_QOS * rtpqos = NULL
131 );
132
133 virtual SendReceiveStatus OnSendData (RTP_DataFrame & frame);
134 virtual SendReceiveStatus OnReceiveData(RTP_DataFrame & frame);
135 virtual SendReceiveStatus OnSendControl(RTP_ControlFrame & frame, PINDEX & len);
136 virtual SendReceiveStatus OnReceiveControl(RTP_ControlFrame & frame);
137 };
138
139 PFACTORY_LOAD(LibSRTPSecurityMode_STRONGHOLD);
140
141
142 #endif // OPAL_SRTP
143
144 #endif // OPAL_RTP_SRTP_H