blob: d3c9f9db616b77d4fe91fc14655695885878d7df [file] [log] [blame]
Alexandre Lision51140e12013-12-02 10:54:09 -05001/*
Alexandre Lision7fd5d3d2013-12-04 13:06:40 -05002 Copyright (C) 2006-2013 Werner Dittmann
Alexandre Lision51140e12013-12-02 10:54:09 -05003
4 This program is free software: you can redistribute it and/or modify
Alexandre Lision7fd5d3d2013-12-04 13:06:40 -05005 it under the terms of the GNU Lesser General Public License as published by
Alexandre Lision51140e12013-12-02 10:54:09 -05006 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program 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
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef _ZRTPUSERCALLBACK_H_
19#define _ZRTPUSERCALLBACK_H_
20
21/**
22 * @file ZrtpUserCallback.h
23 * @brief The ZRTP UserCallback class
24 *
25 * @ingroup GNU_ZRTP
26 * @{
27 */
28
29#include <stdint.h>
30#include <string>
31
32#include <libzrtpcpp/ZrtpCodes.h>
33
34/**
35 * Application callback methods.
36 *
37 * The ccRTP specific part of GNU ZRTP uses these callback methods
38 * to report ZRTP events to the application. This class implements a
39 * default behaviour for each callback method, usually just a return.
40 *
41 * An application may extend this class and overload methods
42 * to implement its own behaviour. The application must register its
43 * callback class using ZrtpQueue#setUserCallback().
44 *
45 * <b>CAVEAT</b><br/>
46 * All methods of the user callback class and classes that
47 * extend this class run in the context of the RTP thread. Thus it is
48 * of paramount importance to keep the execution time of the methods
49 * as short as possible.
50 *
51 * @author Werner Dittmann <Werner.Dittmann@t-online.de>
52 */
53
54class __EXPORT ZrtpUserCallback {
55
56 public:
57
58 /// Create the stadard user callback class.
59 ZrtpUserCallback() {}
60
61 virtual ~ZrtpUserCallback() {};
62
63 /**
64 * Inform user interface that security is active now.
65 *
66 * ZRTP calls this method if the sender and the receiver are
67 * in secure mode now.
68 *
69 * @param cipher
70 * Name and mode of cipher used to encrypt the SRTP stream
71 */
72 virtual void secureOn(std::string cipher) {
73 return;
74 }
75 /**
76 * Inform user interface that security is not active any more.
77 *
78 * ZRTP calls this method if either the sender or the receiver
79 * left secure mode.
80 *
81 */
82 virtual void secureOff() {
83 return;
84 }
85
86 /**
87 * Show the Short Authentication String (SAS) on user interface.
88 *
89 * ZRTP calls this method to display the SAS and inform about the SAS
90 * verification status. The user interface shall enable a SAS verfication
91 * button (or similar UI element). The user shall click on this UI
92 * element after he/she confirmed the SAS code with the partner.
93 *
94 * @param sas
95 * The string containing the SAS.
96 * @param verified
97 * If <code>verified</code> is true then SAS was verified by both
98 * parties during a previous call, otherwise it is set to false.
99 */
100 virtual void showSAS(std::string sas, bool verified) {
101 return;
102 }
103
104 /**
105 * Inform the user that ZRTP received "go clear" message from its peer.
106 *
107 * On receipt of a go clear message the user is requested to confirm
108 * a switch to unsecure (clear) modus. Until the user confirms ZRTP
109 * (and the underlying RTP) does not send any data.
110 */
111 virtual void confirmGoClear() {
112 return;
113 }
114
115 /**
116 * Show some information to user.
117 *
118 * ZRTP calls this method to display some information to the user.
119 * Along with the message ZRTP provides a severity indicator that
120 * defines: Info, Warning, Error, and Alert. Refer to the <code>
121 * MessageSeverity</code> enum in <code>ZrtpCodes.h</code>. The
122 * UI may use this indicator to highlight messages or alike.
123 *
124 * @param sev
125 * Severity of the message.
126 * @param subCode
127 * The subcode identifying the reason.
128 */
129 virtual void showMessage(GnuZrtpCodes::MessageSeverity sev, int32_t subCode) {
130 return;
131 }
132
133 /**
134 * ZRTPQueue calls this if the negotiation failed.
135 *
136 * ZRTPQueue calls this method in case ZRTP negotiation failed. The
137 * parameters show the severity as well as some explanatory text.
138 * Refer to the <code>MessageSeverity</code> enum above.
139 *
140 * @param severity
141 * This defines the message's severity
142 * @param subCode
143 * The subcode identifying the reason.
144 */
145 virtual void zrtpNegotiationFailed(GnuZrtpCodes::MessageSeverity severity,
146 int32_t subCode) {
147 return;
148 }
149
150 /**
151 * ZRTPQueue calls this method if the other side does not support ZRTP.
152 *
153 * If the other side does not answer the ZRTP <em>Hello</em> packets then
154 * ZRTP calls this method.
155 *
156 */
157 virtual void zrtpNotSuppOther() {
158 return;
159 }
160
161 /**
162 * ZRTPQueue calls this method to inform about a PBX enrollment request.
163 *
164 * Please refer to chapter 8.3 ff to get more details about PBX enrollment
165 * and SAS relay.
166 *
167 * @param info
168 * Give some information to the user about the PBX requesting an
169 * enrollment.
170 *
171 */
172 virtual void zrtpAskEnrollment(GnuZrtpCodes::InfoEnrollment info) {
173 return;
174 }
175
176 /**
177 * ZRTPQueue calls this method to inform about PBX enrollment result.
178 *
179 * Informs the use about the acceptance or denial of an PBX enrollment
180 * request
181 *
182 * @param info
183 * Give some information to the user about the result of an
184 * enrollment.
185 *
186 */
187 virtual void zrtpInformEnrollment(GnuZrtpCodes::InfoEnrollment info) {
188 return;
189 }
190
191 /**
192 * ZRTPQueue calls this method to request a SAS signature.
193 *
194 * After ZRTP core was able to compute the Short Authentication String
195 * (SAS) it calls this method. The client may now use an approriate
196 * method to sign the SAS. The client may use
197 * setSignatureData() of ZrtpQueue to store the signature
198 * data an enable signature transmission to the other peer. Refer
199 * to chapter 8.2 of ZRTP specification.
200 *
201 * @param sasHash
202 * Pointer to the 32 byte SAS hash to be signed.
203 * @see ZrtpQueue#setSignatureData
204 *
205 */
206 virtual void signSAS(uint8_t* sasHash) {
207 return;
208 }
209
210 /**
211 * ZRTPQueue calls this method to request a SAS signature check.
212 *
213 * After ZRTP received a SAS signature in one of the Confirm packets it
214 * call this method. The client may use <code>getSignatureLength()</code>
215 * and <code>getSignatureData()</code>of ZrtpQueue to get the signature
216 * data and perform the signature check. Refer to chapter 8.2 of ZRTP
217 * specification.
218 *
219 * If the signature check fails the client may return false to ZRTP. In
220 * this case ZRTP signals an error to the other peer and terminates
221 * the ZRTP handshake.
222 *
223 * @param sasHash
224 * Pointer to the 32 byte SAS hash that was signed by the other peer.
225 * @return
226 * true if the signature was ok, false otherwise.
227 *
228 */
229 virtual bool checkSASSignature(uint8_t* sasHash) {
230 return true;
231 }
232};
233
234#endif