|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Represents an SRTP stream. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __SRTP_STREAM_H__ |
|
22 #define __SRTP_STREAM_H__ |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32def.h> |
|
26 #include <e32base.h> |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class CSRTPSession; |
|
30 class CSRTPCryptoContext; |
|
31 class MSRTPReKeyingObserver; |
|
32 class CSRTPCryptoHandlerSRTP; |
|
33 class CSRTPCryptoHandlerSRTCP; |
|
34 |
|
35 /** |
|
36 * Represents an SRTP stream. |
|
37 */ |
|
38 class CSRTPStream : public CBase |
|
39 { |
|
40 public: |
|
41 |
|
42 /** |
|
43 * iStreamOffset, List offset. |
|
44 */ |
|
45 static const TInt iStreamOffset; |
|
46 |
|
47 /** |
|
48 * iStreamLink, Link to list. |
|
49 */ |
|
50 TSglQueLink iStreamLink; |
|
51 |
|
52 public: |
|
53 |
|
54 /** |
|
55 * Set roll-over counter value. |
|
56 * RFC 3711 3.3.1 ROC() can not be reset to 0 after Re-Key |
|
57 * @param aROC The new ROC value. |
|
58 * @return void |
|
59 */ |
|
60 IMPORT_C void SetROC( TUint32 aROC ); |
|
61 |
|
62 /** |
|
63 * Get roll-over counter value. |
|
64 * @return current ROC value. |
|
65 */ |
|
66 IMPORT_C TUint32 ROC( ) const; |
|
67 |
|
68 /** |
|
69 * Get SSRC |
|
70 * @return SSRC. |
|
71 */ |
|
72 IMPORT_C TUint SSRC( ) const; |
|
73 |
|
74 /** |
|
75 * Set SSRC value if the stream's SSRC is 0 as late binding |
|
76 * @param aSSRC The new SSRC value. |
|
77 * @return void |
|
78 */ |
|
79 void SetSSRC( const TUint aSSRC ); |
|
80 |
|
81 /** |
|
82 * Get cryptographic context associated for this stream |
|
83 * or the one associated for the session |
|
84 * @return CSRTPCryptoContext |
|
85 */ |
|
86 CSRTPCryptoContext& GetCryptoContext(); |
|
87 |
|
88 /** |
|
89 * Call for Rekey |
|
90 * @return void |
|
91 */ |
|
92 void ReKeyNeeded(); |
|
93 |
|
94 |
|
95 /** |
|
96 * Call for KeyExpired |
|
97 * @return void |
|
98 */ |
|
99 void KeyExpired(); |
|
100 |
|
101 /** |
|
102 * Destructor |
|
103 */ |
|
104 ~CSRTPStream(); |
|
105 |
|
106 /** |
|
107 * Tell stream type is InStream or OutStream |
|
108 * @return TBool |
|
109 */ |
|
110 IMPORT_C TBool StreamType(); |
|
111 |
|
112 /** |
|
113 * Check if crypto context has been set |
|
114 * @return ETrue if crypto context is existed, otherwise EFalse |
|
115 */ |
|
116 TBool IsContextSet(); |
|
117 |
|
118 /** |
|
119 * Delete the existed crypto context and re-initial the states |
|
120 * @param None |
|
121 * @leave KErrNone if success, system-wide error code otherwise |
|
122 * @return void |
|
123 */ |
|
124 virtual void UpdateCryptoAndStatesL()=0; |
|
125 |
|
126 protected: //methods |
|
127 CSRTPStream (CSRTPSession& aSession, |
|
128 const TUint aSSRC, |
|
129 TBool aStreamType ); |
|
130 |
|
131 CSRTPStream (CSRTPSession& aSession, |
|
132 TUint aSSRC, |
|
133 CSRTPCryptoContext* aCon, |
|
134 MSRTPReKeyingObserver& aObs, |
|
135 TBool aStreamType ); |
|
136 |
|
137 CSRTPStream (CSRTPSession& aSession, |
|
138 TBool aStreamType); |
|
139 |
|
140 CSRTPStream (CSRTPSession& aSession, |
|
141 CSRTPCryptoContext* aCon, |
|
142 MSRTPReKeyingObserver& aObs, |
|
143 TBool aStreamType ); |
|
144 |
|
145 CSRTPStream (CSRTPSession& aSession, |
|
146 TUint aSSRC, |
|
147 MSRTPReKeyingObserver& aObs, |
|
148 TBool aStreamType ); |
|
149 CSRTPStream (CSRTPSession& aSession, |
|
150 MSRTPReKeyingObserver& aObs, |
|
151 TBool aStreamType ); |
|
152 |
|
153 /** |
|
154 * Create RTP crypto handler |
|
155 * @return void |
|
156 */ |
|
157 void CreateCryptoHandlerSRTPL(); |
|
158 |
|
159 /** |
|
160 * Create RTCP crypto handler |
|
161 * @return void |
|
162 */ |
|
163 void CreateCryptoHandlerSRTCPL(); |
|
164 |
|
165 |
|
166 /** |
|
167 * Delete the existed crypto handler and create a new one |
|
168 * @return void |
|
169 */ |
|
170 void UpdateCryptoHandlerL(); |
|
171 |
|
172 |
|
173 protected: //data |
|
174 CSRTPSession& iSession; // access to session |
|
175 CSRTPCryptoContext* iContext; // crypto context |
|
176 MSRTPReKeyingObserver* iObserver; // observer (application) |
|
177 TBool iStrmSpecificCrypto; // do we have stream or session- |
|
178 // spesific context |
|
179 CSRTPCryptoHandlerSRTP* iHandlerRTP; // crypto handling class for RTP |
|
180 CSRTPCryptoHandlerSRTCP* iHandlerRTCP; // crypto handling class for RTCP |
|
181 TUint32 iROC; // unsigned 32 bit ROC |
|
182 TUint iSSRC; // SSRC |
|
183 TBool iIsStreamInType; |
|
184 TBool iRekey; |
|
185 |
|
186 private: |
|
187 #ifdef EUNIT_TESTING |
|
188 friend class UT_CSRTPCryptoHandlerSRTP; |
|
189 friend class UT_CSRTPCryptoHandlerSRTCP; |
|
190 friend class UT_CSRTPCryptoHandler; |
|
191 friend class UT_CSRTPStreamIn; |
|
192 friend class UT_CSRTPStreamOut; |
|
193 friend class UT_CSRTPStream; |
|
194 friend class UT_CSRTPCryptoContext; |
|
195 #endif |
|
196 }; |
|
197 |
|
198 #endif // __SRTP_STREAM_H__ |