blob: 01265459b695a4fe09adc74c46e60d22bb16455d [file] [log] [blame]
Alexandre Lision51140e12013-12-02 10:54:09 -05001/*
2 This file defines the GNU ZRTP C-to-C++ wrapper.
3 Copyright (C) 2010 Werner Dittmann
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program 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
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18*/
19
20#ifndef ZRTPCWRAPPER_H
21#define ZRTPCWRAPPER_H
22
23/**
24 *
25 * @file ZrtpCWrapper.h
26 * @brief The GNU ZRTP C-to-C++ wrapper.
27 *
28 * To avoid any include of C++ header files some structure, defines, and
29 * enumerations are repeated in this file. Refer to the inline comments if
30 * you modify the file.
31 *
32 * @ingroup GNU_ZRTP
33 * @{
34 *
35 * @see ZRtp
36 */
37
38#include <stdint.h>
39
40/**
41 * Defines to specify the role a ZRTP peer has.
42 *
43 * According to the ZRTP specification the role determines which keys to
44 * use to encrypt or decrypt SRTP data.
45 *
46 * <ul>
47 * <li> The Initiator encrypts SRTP data using the <em>keyInitiator</em> and the
48 * <em>saltInitiator</em> data, the Responder uses these data to decrypt.
49 * </li>
50 * <li> The Responder encrypts SRTP data using the <em>keyResponder</em> and the
51 * <em>saltResponder</em> data, the Initiator uses these data to decrypt.
52 * </li>
53 * </ul>
54 */
55/*
56 * Keep the following defines in sync with Role enumeration in ZrtpCallback.h
57 */
58#define Responder 1 /*!< This client is in ZRTP Responder mode */
59#define Initiator 2 /*!< This client is in ZRTP Initiator mode */
60
61#define CRC_SIZE 4 /*!< Size of CRC code of a ZRTP packet */
62#define ZRTP_MAGIC 0x5a525450 /*!< The magic code that identifies a ZRTP packet */
63#define MAX_ZRTP_SIZE 3072 /*!< The biggest ZRTP packet ever possible */
64
65/*
66 * IMPORTANT: keep the following enums in synch with ZrtpCodes. We copy them here
67 * to avoid any C++ header includes and defines. The protocol states are located
68 * ZrtpStateClass.h .
69 */
70/**
71 * This enum defines the information message severity.
72 *
73 * The ZRTP implementation issues information messages to inform the user
74 * about ongoing processing, unusual behavior, or alerts in case of severe
75 * problems. Each main severity code a number of sub-codes exist that
76 * specify the exact nature of the problem.
77 *
78 * An application gets message severity codes and the associated sub-codes
79 * via the ZrtpUserCallback#showMessage method.
80 *
81 * The severity levels and their meaning are:
82 *
83 * <dl>
84 * <dt>Info</dt> <dd>keeps the user informed about ongoing processing and
85 * security setup. The enumeration InfoCodes defines the subcodes.
86 * </dd>
87 * <dt>Warning</dt> <dd>is an information about some security issues, e.g. if
88 * an AES 256 encryption is request but only DH 3072 as public key scheme
89 * is supported. ZRTP will establish a secure session (SRTP). The
90 * enumeration WarningCodes defines the sub-codes.
91 * </dd>
92 * <dt>Severe</dt> <dd>is used if an error occured during ZRTP protocol usage.
93 * In case of <em>Severe</em> ZRTP will <b>not</b> establish a secure session.
94 * The enumeration SevereCodes defines the sub-codes.
95 * </dd>
96 * <dt>Zrtp</dt> <dd>shows a ZRTP security problem. Refer to the enumeration
97 * ZrtpErrorCodes for sub-codes. GNU ZRTP of course will <b>not</b>
98 * establish a secure session.
99 * </dd>
100 * </dl>
101 *
102 */
103enum zrtp_MessageSeverity {
104 zrtp_Info = 1, /*!< Just an info message */
105 zrtp_Warning, /*!< A Warning message - security can be established */
106 zrtp_Severe, /*!< Severe error, security will not be established */
107 zrtp_ZrtpError /*!< ZRTP error, security will not be established */
108};
109
110/**
111 * Sub-codes for Info
112 */
113enum zrtp_InfoCodes {
114 zrtp_InfoHelloReceived = 1, /*!< Hello received, preparing a Commit */
115 zrtp_InfoCommitDHGenerated, /*!< Commit: Generated a public DH key */
116 zrtp_InfoRespCommitReceived, /*!< Responder: Commit received, preparing DHPart1 */
117 zrtp_InfoDH1DHGenerated, /*!< DH1Part: Generated a public DH key */
118 zrtp_InfoInitDH1Received, /*!< Initiator: DHPart1 received, preparing DHPart2 */
119 zrtp_InfoRespDH2Received, /*!< Responder: DHPart2 received, preparing Confirm1 */
120 zrtp_InfoInitConf1Received, /*!< Initiator: Confirm1 received, preparing Confirm2 */
121 zrtp_InfoRespConf2Received, /*!< Responder: Confirm2 received, preparing Conf2Ack */
122 zrtp_InfoRSMatchFound, /*!< At least one retained secrets matches - security OK */
123 zrtp_InfoSecureStateOn, /*!< Entered secure state */
124 zrtp_InfoSecureStateOff /*!< No more security for this session */
125};
126
127/**
128 * Sub-codes for Warning
129 */
130enum zrtp_WarningCodes {
131 zrtp_WarningDHAESmismatch = 1, /*!< Commit contains an AES256 cipher but does not offer a Diffie-Helman 4096 */
132 zrtp_WarningGoClearReceived, /*!< Received a GoClear message */
133 zrtp_WarningDHShort, /*!< Hello offers an AES256 cipher but does not offer a Diffie-Helman 4096 */
134 zrtp_WarningNoRSMatch, /*!< No retained shared secrets available - must verify SAS */
135 zrtp_WarningCRCmismatch, /*!< Internal ZRTP packet checksum mismatch - packet dropped */
136 zrtp_WarningSRTPauthError, /*!< Dropping packet because SRTP authentication failed! */
137 zrtp_WarningSRTPreplayError, /*!< Dropping packet because SRTP replay check failed! */
138 zrtp_WarningNoExpectedRSMatch /*!< Valid retained shared secrets availabe but no matches found - must verify SAS */
139};
140
141/**
142 * Sub-codes for Severe
143 */
144enum zrtp_SevereCodes {
145 zrtp_SevereHelloHMACFailed = 1, /*!< Hash HMAC check of Hello failed! */
146 zrtp_SevereCommitHMACFailed, /*!< Hash HMAC check of Commit failed! */
147 zrtp_SevereDH1HMACFailed, /*!< Hash HMAC check of DHPart1 failed! */
148 zrtp_SevereDH2HMACFailed, /*!< Hash HMAC check of DHPart2 failed! */
149 zrtp_SevereCannotSend, /*!< Cannot send data - connection or peer down? */
150 zrtp_SevereProtocolError, /*!< Internal protocol error occured! */
151 zrtp_SevereNoTimer, /*!< Cannot start a timer - internal resources exhausted? */
152 zrtp_SevereTooMuchRetries /*!< Too much retries during ZRTP negotiation - connection or peer down? */
153};
154
155/**
156 * Error codes according to the ZRTP specification chapter 6.9
157 *
158 * GNU ZRTP uses these error codes in two ways: to fill the appropriate
159 * field ing the ZRTP Error packet and as sub-code in
160 * ZrtpUserCallback#showMessage(). GNU ZRTP uses thes error codes also
161 * to report received Error packts, in this case the sub-codes are their
162 * negative values.
163 *
164 * The enumeration member comments are copied from the ZRTP specification.
165 */
166enum zrtp_ZrtpErrorCodes {
167 zrtp_MalformedPacket = 0x10, /*!< Malformed packet (CRC OK, but wrong structure) */
168 zrtp_CriticalSWError = 0x20, /*!< Critical software error */
169 zrtp_UnsuppZRTPVersion = 0x30, /*!< Unsupported ZRTP version */
170 zrtp_HelloCompMismatch = 0x40, /*!< Hello components mismatch */
171 zrtp_UnsuppHashType = 0x51, /*!< Hash type not supported */
172 zrtp_UnsuppCiphertype = 0x52, /*!< Cipher type not supported */
173 zrtp_UnsuppPKExchange = 0x53, /*!< Public key exchange not supported */
174 zrtp_UnsuppSRTPAuthTag = 0x54, /*!< SRTP auth. tag not supported */
175 zrtp_UnsuppSASScheme = 0x55, /*!< SAS scheme not supported */
176 zrtp_NoSharedSecret = 0x56, /*!< No shared secret available, DH mode required */
177 zrtp_DHErrorWrongPV = 0x61, /*!< DH Error: bad pvi or pvr ( == 1, 0, or p-1) */
178 zrtp_DHErrorWrongHVI = 0x62, /*!< DH Error: hvi != hashed data */
179 zrtp_SASuntrustedMiTM = 0x63, /*!< Received relayed SAS from untrusted MiTM */
180 zrtp_ConfirmHMACWrong = 0x70, /*!< Auth. Error: Bad Confirm pkt HMAC */
181 zrtp_NonceReused = 0x80, /*!< Nonce reuse */
182 zrtp_EqualZIDHello = 0x90, /*!< Equal ZIDs in Hello */
183 zrtp_GoCleatNotAllowed = 0x100, /*!< GoClear packet received, but not allowed */
184 zrtp_IgnorePacket = 0x7fffffff /*!< Internal state, not reported */
185};
186
187/**
188 * Information codes for the Enrollment user callbacks.
189 */
190enum zrtp_InfoEnrollment {
191 zrtp_EnrollmentRequest, //!< Aks user to confirm or deny an Enrollemnt request
192 zrtp_EnrollmentCanceled, //!< User did not confirm the PBX enrollement
193 zrtp_EnrollmentFailed, //!< Enrollment process failed, no PBX secret available
194 zrtp_EnrollmentOk //!< Enrollment process for this PBX was ok
195};
196
197/* The ZRTP protocol states */
198enum zrtpStates {
199 Initial, /*!< Initial state after starting the state engine */
200 Detect, /*!< State sending Hello, try to detect answer message */
201 AckDetected, /*!< HelloAck received */
202 AckSent, /*!< HelloAck sent after Hello received */
203 WaitCommit, /*!< Wait for a Commit message */
204 CommitSent, /*!< Commit message sent */
205 WaitDHPart2, /*!< Wait for a DHPart2 message */
206 WaitConfirm1, /*!< Wait for a Confirm1 message */
207 WaitConfirm2, /*!< Wait for a confirm2 message */
208 WaitConfAck, /*!< Wait for Conf2Ack */
209 WaitClearAck, /*!< Wait for clearAck - not used */
210 SecureState, /*!< This is the secure state - SRTP active */
211 WaitErrorAck, /*!< Wait for ErrorAck message */
212 numberOfStates /*!< Gives total number of protocol states */
213};
214
215/*! The algorihms that we support in SRTP and that ZRTP can negotiate. */
216typedef enum {
217 zrtp_Aes = 1, /*!< Use AES as symmetrical cipher algorithm */
218 zrtp_TwoFish, /*!< Use TwoFish as symmetrical cipher algorithm */
219 zrtp_Sha1, /*!< Use Sha1 as authentication algorithm */
220 zrtp_Skein /*!< Use Skein as authentication algorithm */
221} zrtp_SrtpAlgorithms;
222
223/**
224 * This structure contains pointers to the SRTP secrets and the role info.
225 *
226 * About the role and what the meaning of the role is refer to the
227 * of the enum Role. The pointers to the secrets are valid as long as
228 * the ZRtp object is active. To use these data after the ZRtp object's
229 * lifetime you may copy the data into a save place.
230 */
231typedef struct c_srtpSecrets
232{
233 zrtp_SrtpAlgorithms symEncAlgorithm;/*!< symmetrical cipher algorithm */
234 const uint8_t* keyInitiator; /*!< Initiator's key */
235 int32_t initKeyLen; /*!< Initiator's key length */
236 const uint8_t* saltInitiator; /*!< Initiator's salt */
237 int32_t initSaltLen; /*!< Initiator's salt length */
238 const uint8_t* keyResponder; /*!< Responder's key */
239 int32_t respKeyLen; /*!< Responder's key length */
240 const uint8_t* saltResponder; /*!< Responder's salt */
241 int32_t respSaltLen; /*!< Responder's salt length */
242 zrtp_SrtpAlgorithms authAlgorithm; /*!< SRTP authentication algorithm */
243 int32_t srtpAuthTagLen; /*!< SRTP authentication length */
244 char* sas; /*!< The SAS string */
245 int32_t role; /*!< ZRTP role of this client */
246} C_SrtpSecret_t;
247
248/*
249 * Keep the following defines in sync with enum EnableSecurity in ZrtpCallback.h
250 */
251#define ForReceiver 1 /*!< Enable security for SRTP receiver */
252#define ForSender 2 /*!< Enable security for SRTP sender */
253
254#ifdef __cplusplus
255#pragma GCC visibility push(default)
256extern "C"
257{
258#endif
259
260 typedef struct ZRtp ZRtp;
261 typedef struct ZrtpCallbackWrapper ZrtpCallbackWrapper;
262 typedef struct ZrtpConfigure ZrtpConfigure;
263
264
265 typedef struct zrtpContext
266 {
267 ZRtp* zrtpEngine; /*!< Holds the real ZRTP engine */
268 ZrtpCallbackWrapper* zrtpCallback; /*!< Help class Callback wrapper */
269 ZrtpConfigure* configure; /*!< Optional configuration data */
270 void* userData; /*!< User data, set by application */
271 } ZrtpContext;
272
273 /**
274 * This structure defines the callback functions required by GNU ZRTP.
275 *
276 * The RTP stack specific part must implement the callback methods.
277 * The generic part of GNU ZRTP uses these mehtods
278 * to communicate with the specific part, for example to send data
279 * via the RTP/SRTP stack, to set timers and cancel timer and so on.
280 *
281 * The generiy part of GNU ZRTP needs only a few callback methods to
282 * be implemented by the specific part.
283 *
284 * @author Werner Dittmann <Werner.Dittmann@t-online.de>
285 */
286
287 /**
288 * The following methods define the GNU ZRTP callback interface.
289 * For detailed documentation refer to file ZrtpCallback.h, each C
290 * method has "zrtp_" prepended to the C++ name.
291 *
292 * @see ZrtpCallback
293 */
294 typedef struct zrtp_Callbacks
295 {
296 /**
297 * Send a ZRTP packet via RTP.
298 *
299 * ZRTP calls this method to send a ZRTP packet via the RTP session.
300 * The ZRTP packet will have to be created using the provided ZRTP message.
301 *
302 * @param ctx
303 * Pointer to the opaque ZrtpContext structure.
304 * @param data
305 * Points to ZRTP message to send.
306 * @param length
307 * The length in bytes of the data
308 * @return
309 * zero if sending failed, one if packet was sent
310 */
311 int32_t (*zrtp_sendDataZRTP) (ZrtpContext* ctx, const uint8_t* data, int32_t length ) ;
312
313 /**
314 * Activate timer.
315 *
316 * @param ctx
317 * Pointer to the opaque ZrtpContext structure.
318 * @param time
319 * The time in ms for the timer
320 * @return
321 * zero if activation failed, one if timer was activated
322 */
323 int32_t (*zrtp_activateTimer) (ZrtpContext* ctx, int32_t time ) ;
324
325 /**
326 * Cancel the active timer.
327 *
328 * @param ctx
329 * Pointer to the opaque ZrtpContext structure.
330 * @return
331 * zero if cancel action failed, one if timer was canceled
332 */
333 int32_t (*zrtp_cancelTimer)(ZrtpContext* ctx) ;
334
335 /**
336 * Send information messages to the hosting environment.
337 *
338 * The ZRTP implementation uses this method to send information
339 * messages to the host. Along with the message ZRTP provides a
340 * severity indicator that defines: Info, Warning, Error,
341 * Alert. Refer to the <code>MessageSeverity</code> enum above.
342 *
343 * @param ctx
344 * Pointer to the opaque ZrtpContext structure.
345 * @param severity
346 * This defines the message's severity
347 * @param subCode
348 * The subcode identifying the reason.
349 * @see ZrtpCodes#MessageSeverity
350 */
351 void (*zrtp_sendInfo) (ZrtpContext* ctx, int32_t severity, int32_t subCode ) ;
352
353 /**
354 * SRTP crypto data ready for the sender or receiver.
355 *
356 * The ZRTP implementation calls this method right after all SRTP
357 * secrets are computed and ready to be used. The parameter points
358 * to a structure that contains pointers to the SRTP secrets and a
359 * <code>enum Role</code>. The called method (the implementation
360 * of this abstract method) must either copy the pointers to the SRTP
361 * data or the SRTP data itself to a save place. The SrtpSecret_t
362 * structure is destroyed after the callback method returns to the
363 * ZRTP implementation.
364 *
365 * The SRTP data themselves are obtained in the ZRtp object and are
366 * valid as long as the ZRtp object is active. TheZRtp's
367 * destructor clears the secrets. Thus the called method needs to
368 * save the pointers only, ZRtp takes care of the data.
369 *
370 * The implementing class may enable SRTP processing in this
371 * method or delay it to srtpSecertsOn().
372 *
373 * @param ctx
374 * Pointer to the opaque ZrtpContext structure.
375 * @param secrets A pointer to a SrtpSecret_t structure that
376 * contains all necessary data.
377 *
378 * @param part for which part (Sender or Receiver) this data is
379 * valid.
380 *
381 * @return Returns false if something went wrong during
382 * initialization of SRTP context, for example memory shortage.
383 */
384 int32_t (*zrtp_srtpSecretsReady) (ZrtpContext* ctx, C_SrtpSecret_t* secrets, int32_t part ) ;
385
386 /**
387 * Switch off the security for the defined part.
388 *
389 * @param ctx
390 * Pointer to the opaque ZrtpContext structure.
391 * @param part Defines for which part (sender or receiver) to
392 * switch on security
393 */
394 void (*zrtp_srtpSecretsOff) (ZrtpContext* ctx, int32_t part ) ;
395
396 /**
397 * Switch on the security.
398 *
399 * ZRTP calls this method after it has computed the SAS and check
400 * if it is verified or not. In addition ZRTP provides information
401 * about the cipher algorithm and key length for the SRTP session.
402 *
403 * This method must enable SRTP processing if it was not enabled
404 * during sertSecretsReady().
405 *
406 * @param ctx
407 * Pointer to the opaque ZrtpContext structure.
408 * @param c The name of the used cipher algorithm and mode, or
409 * NULL
410 *
411 * @param s The SAS string
412 *
413 * @param verified if <code>verified</code> is true then SAS was
414 * verified by both parties during a previous call.
415 */
416 void (*zrtp_rtpSecretsOn) (ZrtpContext* ctx, char* c, char* s, int32_t verified ) ;
417
418 /**
419 * This method handles GoClear requests.
420 *
421 * According to the ZRTP specification the user must be informed about
422 * a GoClear request because the ZRTP implementation switches off security
423 * if it could authenticate the GoClear packet.
424 *
425 * <b>Note:</b> GoClear is not yet implemented in GNU ZRTP.
426 *
427 * @param ctx
428 * Pointer to the opaque ZrtpContext structure.
429 */
430 void (*zrtp_handleGoClear)(ZrtpContext* ctx) ;
431
432 /**
433 * Handle ZRTP negotiation failed.
434 *
435 * ZRTP calls this method in case ZRTP negotiation failed. The
436 * parameters show the severity as well as the reason.
437 *
438 * @param ctx
439 * Pointer to the opaque ZrtpContext structure.
440 * @param severity
441 * This defines the message's severity
442 * @param subCode
443 * The subcode identifying the reason.
444 * @see ZrtpCodes#MessageSeverity
445 */
446 void (*zrtp_zrtpNegotiationFailed) (ZrtpContext* ctx, int32_t severity, int32_t subCode ) ;
447
448 /**
449 * ZRTP calls this method if the other side does not support ZRTP.
450 *
451 * @param ctx
452 * Pointer to the opaque ZrtpContext structure.
453 * If the other side does not answer the ZRTP <em>Hello</em> packets then
454 * ZRTP calls this method,
455 *
456 */
457 void (*zrtp_zrtpNotSuppOther)(ZrtpContext* ctx) ;
458
459 /**
460 * Enter synchronization mutex.
461 *
462 * GNU ZRTP requires one mutex to synchronize its
463 * processing. Because mutex implementations depend on the
464 * underlying infrastructure, for example operating system or
465 * thread implementation, GNU ZRTP delegates mutex handling to the
466 * specific part of its implementation.
467 *
468 * @param ctx
469 * Pointer to the opaque ZrtpContext structure.
470 */
471 void (*zrtp_synchEnter)(ZrtpContext* ctx) ;
472
473 /**
474 * Leave synchronization mutex.
475 *
476 * @param ctx
477 * Pointer to the opaque ZrtpContext structure.
478 */
479 void (*zrtp_synchLeave)(ZrtpContext* ctx) ;
480
481 /**
482 * Inform about a PBX enrollment request.
483 *
484 * Please refer to chapter 8.3 ff to get more details about PBX
485 * enrollment and SAS relay.
486 *
487 * <b>Note:</b> PBX enrollement is not yet fully supported by GNU
488 * ZRTP.
489 *
490 * @param ctx
491 * Pointer to the opaque ZrtpContext structure.
492 * @param info Give some information to the user about the PBX
493 * requesting an enrollment.
494 */
495 void (*zrtp_zrtpAskEnrollment) (ZrtpContext* ctx, int32_t info) ;
496
497 /**
498 * Inform about PBX enrollment result.
499 *
500 * Informs the use about the acceptance or denial of an PBX enrollment
501 * request
502 *
503 * <b>Note:</b> PBX enrollement is not yet fully supported by GNU
504 * ZRTP.
505 *
506 * @param ctx
507 * Pointer to the opaque ZrtpContext structure.
508 * @param info Give some information to the user about the result
509 * of an enrollment.
510 */
511 void (*zrtp_zrtpInformEnrollment) (ZrtpContext* ctx, int32_t info ) ;
512
513 /**
514 * Request a SAS signature.
515 *
516 * After ZRTP was able to compute the Short Authentication String
517 * (SAS) it calls this method. The client may now use an
518 * approriate method to sign the SAS. The client may use
519 * ZrtpQueue#setSignatureData() to store the signature data and
520 * enable signature transmission to the other peer. Refer to
521 * chapter 8.2 of ZRTP specification.
522 *
523 * <b>Note:</b> SAS signing is not yet fully supported by GNU
524 * ZRTP.
525 *
526 * @param ctx
527 * Pointer to the opaque ZrtpContext structure.
528 * @param sas
529 * Pointer to the 32 byte SAS hash to sign.
530 *
531 */
532 void (*zrtp_signSAS)(ZrtpContext* ctx, uint8_t* sas) ;
533
534 /**
535 * ZRTPQueue calls this method to request a SAS signature check.
536 *
537 * After ZRTP received a SAS signature in one of the Confirm packets it
538 * call this method. The client may use <code>getSignatureLength()</code>
539 * and <code>getSignatureData()</code>of ZrtpQueue to get the signature
540 * data and perform the signature check. Refer to chapter 8.2 of ZRTP
541 * specification.
542 *
543 * If the signature check fails the client may return false to ZRTP. In
544 * this case ZRTP signals an error to the other peer and terminates
545 * the ZRTP handshake.
546 *
547 * <b>Note:</b> SAS signing is not yet fully supported by GNU
548 * ZRTP.
549 *
550 * @param ctx
551 * Pointer to the opaque ZrtpContext structure.
552 * @param sas
553 * Pointer to the 32 byte SAS hash that was signed by the other peer.
554 * @return
555 * true if the signature was ok, false otherwise.
556 *
557 */
558 int32_t (*zrtp_checkSASSignature) (ZrtpContext* ctx, uint8_t* sas ) ;
559 } zrtp_Callbacks;
560
561 /**
562 * Create the GNU ZRTP C wrapper.
563 *
564 * This wrapper implements the C interface to the C++ based GNU ZRTP.
565 * @returns
566 * Pointer to the ZrtpContext
567 */
568 ZrtpContext* zrtp_CreateWrapper();
569
570 /**
571 * Initialize the ZRTP protocol engine.
572 *
573 * This method initialized the GNU ZRTP protocol engine. An application
574 * calls this method to actually create the ZRTP protocol engine and
575 * initialize its configuration data. This method does not start the
576 * protocol engine.
577 *
578 * If an application requires a specific algorithm configuration then it
579 * must set the algorithm configuration data before it initializes the
580 * ZRTP protocol engine.
581 *
582 * @param zrtpContext
583 * Pointer to the opaque ZrtpContext structure.
584 * @param cb
585 * The callback structure that holds the addresses of the callback
586 * methods.
587 * @param id
588 * A C string that holds the ZRTP client id, only the first 16 chars
589 * are used.
590 * @param zidFilename
591 * The name of the ZID file. This file holds some parameters and
592 * other data like additional shared secrets.
593 * @param userData
594 * A pointer to user data. The wrapper just stores this pointer in
595 * the ZrtpContext and the application may use it for its purposes.
596 * @param mitmMode
597 * A trusted Mitm (PBX) must set this to true. The ZRTP engine sets
598 * the M Flag in the Hello packet to announce a trusted MitM.
599 * @returns
600 * Pointer to the ZrtpContext
601 *
602 * @see zrtp_InitializeConfig
603 */
604 void zrtp_initializeZrtpEngine(ZrtpContext* zrtpContext,
605 zrtp_Callbacks *cb,
606 const char* id,
607 const char* zidFilename,
608 void* userData,
609 int32_t mitmMode);
610
611 /**
612 * Destroy the ZRTP wrapper and its underlying objects.
613 */
614 void zrtp_DestroyWrapper (ZrtpContext* zrtpContext);
615
616 /**
617 * Computes the ZRTP checksum over a received ZRTP packet buffer and
618 * compares the result with received checksum.
619 *
620 * @param buffer
621 * Pointer to ZRTP packet buffer
622 * @param length
623 * Length of the packet buffer excluding received CRC data
624 * @param crc
625 * The received CRC data.
626 * @returns
627 * True if CRC matches, false otherwise.
628 */
629 int32_t zrtp_CheckCksum(uint8_t* buffer, uint16_t length, uint32_t crc);
630
631 /**
632 * Computes the ZRTP checksum over a newly created ZRTP packet buffer.
633 *
634 * @param buffer
635 * Pointer to the created ZRTP packet buffer
636 * @param length
637 * Length of the packet buffer
638 * @returns
639 * The computed CRC.
640 */
641 uint32_t zrtp_GenerateCksum(uint8_t* buffer, uint16_t length);
642
643 /**
644 * Prepares the ZRTP checksum for appending to ZRTP packet.
645 * @param crc
646 * The computed CRC data.
647 * @returns
648 * Prepared CRC data in host order
649 */
650 uint32_t zrtp_EndCksum(uint32_t crc);
651
652 /**
653 * Kick off the ZRTP protocol engine.
654 *
655 * This method calls the ZrtpStateClass#evInitial() state of the state
656 * engine. After this call we are able to process ZRTP packets
657 * from our peer and to process them.
658 *
659 * <b>NOTE: application shall never call this method directly but use the
660 * appropriate method provided by the RTP implementation. </b>
661 *
662 * @param zrtpContext
663 * Pointer to the opaque ZrtpContext structure.
664 */
665 void zrtp_startZrtpEngine(ZrtpContext* zrtpContext);
666
667 /**
668 * Stop ZRTP security.
669 *
670 * <b>NOTE: An application shall never call this method directly but use the
671 * appropriate method provided by the RTP implementation. </b>
672 *
673 * @param zrtpContext
674 * Pointer to the opaque ZrtpContext structure.
675 */
676 void zrtp_stopZrtpEngine(ZrtpContext* zrtpContext);
677
678 /**
679 * Process RTP extension header.
680 *
681 * This method expects to get a pointer to the message part of
682 * a ZRTP packet.
683 *
684 * <b>NOTE: An application shall never call this method directly. Only
685 * the module that implements the RTP binding shall use this method</b>
686 *
687 * @param zrtpContext
688 * Pointer to the opaque ZrtpContext structure.
689 * @param extHeader
690 * A pointer to the first byte of the ZRTP message part.
691 * @param peerSSRC
692 * The peer's SSRC.
693 * @return
694 * Code indicating further packet handling, see description above.
695 */
696 void zrtp_processZrtpMessage(ZrtpContext* zrtpContext, uint8_t *extHeader, uint32_t peerSSRC);
697
698 /**
699 * Process a timeout event.
700 *
701 * We got a timeout from the timeout provider. Forward it to the
702 * protocol state engine.
703 *
704 * <b>NOTE: application shall never call this method directly. Only
705 * the module that implements the RTP binding shall use this method</b>
706 *
707 * @param zrtpContext
708 * Pointer to the opaque ZrtpContext structure.
709 */
710 void zrtp_processTimeout(ZrtpContext* zrtpContext);
711
712 /*
713 * Check for and handle GoClear ZRTP packet header.
714 *
715 * This method checks if this is a GoClear packet. If not, just return
716 * false. Otherwise handle it according to the specification.
717 *
718 * @param zrtpContext
719 * Pointer to the opaque ZrtpContext structure.
720 * @param extHeader
721 * A pointer to the first byte of the extension header. Refer to
722 * RFC3550.
723 * @return
724 * False if not a GoClear, true otherwise.
725 *
726 int32_t zrtp_handleGoClear(ZrtpContext* zrtpContext, uint8_t *extHeader);
727 */
728
729 /**
730 * Set the auxilliary secret.
731 *
732 * Use this method to set the auxilliary secret data. Refer to ZRTP
733 * specification, chapter 4.3 ff
734 *
735 * @param zrtpContext
736 * Pointer to the opaque ZrtpContext structure.
737 * @param data
738 * Points to the secret data.
739 * @param length
740 * Length of the auxilliary secrect in bytes
741 */
742 void zrtp_setAuxSecret(ZrtpContext* zrtpContext, uint8_t* data, int32_t length);
743
744 /**
745 * Check current state of the ZRTP state engine
746 *
747 * <b>NOTE: application usually don't call this method. Only
748 * the m-odule that implements the RTP binding shall use this method</b>
749 *
750 * @param zrtpContext
751 * Pointer to the opaque ZrtpContext structure.
752 * @param state
753 * The state to check.
754 * @return
755 * Returns true if ZRTP engine is in the given state, false otherwise.
756 */
757 int32_t zrtp_inState(ZrtpContext* zrtpContext, int32_t state);
758
759 /**
760 * Set SAS as verified.
761 *
762 * Call this method if the user confirmed (verfied) the SAS. ZRTP
763 * remembers this together with the retained secrets data.
764 *
765 * @param zrtpContext
766 * Pointer to the opaque ZrtpContext structure.
767 */
768 void zrtp_SASVerified(ZrtpContext* zrtpContext);
769
770 /**
771 * Reset the SAS verfied flag for the current active user's retained secrets.
772 *
773 * @param zrtpContext
774 * Pointer to the opaque ZrtpContext structure.
775 */
776 void zrtp_resetSASVerified(ZrtpContext* zrtpContext);
777
778 /**
779 * Get the ZRTP Hello Hash data.
780 *
781 * Use this method to get the ZRTP Hello Hash data. The method
782 * returns the data as a string containing the ZRTP protocol version and
783 * hex-digits. Refer to ZRTP specification, chapter 8.
784 *
785 * <b>NOTE: An application may call this method if it needs this information.
786 * Usually it is not necessary.</b>
787 *
788 * @param zrtpContext
789 * Pointer to the opaque ZrtpContext structure.
790 * @return
791 * a pointer to a C-string that contains the Hello hash value as
792 * hex-digits. The hello hash is available immediately after
793 * @c zrtp_CreateWrapper .
794 * The caller must @c free() if it does not use the
795 * hello hash C-string anymore.
796 */
797 char* zrtp_getHelloHash(ZrtpContext* zrtpContext);
798
799 /**
800 * Get the peer's ZRTP Hello Hash data.
801 *
802 * Use this method to get the peer's ZRTP Hello Hash data. The method
803 * returns the data as a string containing the ZRTP protocol version and
804 * hex-digits.
805 *
806 * The peer's hello hash is available only after ZRTP received a hello. If
807 * no data is available the function returns an empty string.
808 *
809 * Refer to ZRTP specification, chapter 8.
810 *
811 * @return
812 * a std:string containing the Hello version and the hello hash as hex digits.
813 */
814 char* zrtp_getPeerHelloHash(ZrtpContext* zrtpContext);
815
816 /**
817 * Get Multi-stream parameters.
818 *
819 * Use this method to get the Multi-stream parameters that were computed
820 * during the ZRTP handshake. An application may use these parameters to
821 * enable multi-stream processing for an associated SRTP session.
822 *
823 * The application must not modify the contents of returned char array, it
824 * is opaque data. The application may hand over this string to a new ZRTP
825 * instance to enable multi-stream processing for this new session.
826 *
827 * Refer to chapter 4.4.2 in the ZRTP specification for further details
828 * and restriction how and when to use multi-stream mode.
829 *
830 * @param zrtpContext
831 * Pointer to the opaque ZrtpContext structure.
832 * @param length
833 * Pointer to an integer that receives the length of the char array
834 * @return
835 * a char array that contains the multi-stream parameters.
836 * If ZRTP was not started or ZRTP is not yet in secure state the method
837 * returns NULL and a length of 0.
838 */
839 char* zrtp_getMultiStrParams(ZrtpContext* zrtpContext, int32_t *length);
840
841 /**
842 * Set Multi-stream parameters.
843 *
844 * Use this method to set the parameters required to enable Multi-stream
845 * processing of ZRTP. The multi-stream parameters must be set before the
846 * application starts the ZRTP protocol engine.
847 *
848 * Refer to chapter 4.4.2 in the ZRTP specification for further details
849 * of multi-stream mode.
850 *
851 * @param zrtpContext
852 * Pointer to the opaque ZrtpContext structure.
853 * @param length
854 * The integer that contains the length of the char array
855 * @param parameters
856 * A char array that contains the multi-stream parameters that this
857 * new ZRTP instance shall use. See also
858 * <code>getMultiStrParams()</code>
859 */
860 void zrtp_setMultiStrParams(ZrtpContext* zrtpContext, char* parameters, int32_t length);
861
862 /**
863 * Check if this ZRTP session is a Multi-stream session.
864 *
865 * Use this method to check if this ZRTP instance uses multi-stream.
866 * Refer to chapters 4.2 and 4.4.2 in the ZRTP.
867 *
868 * @param zrtpContext
869 * Pointer to the opaque ZrtpContext structure.
870 * @return
871 * True if multi-stream is used, false otherwise.
872 */
873 int32_t zrtp_isMultiStream(ZrtpContext* zrtpContext);
874
875 /**
876 * Check if the other ZRTP client supports Multi-stream.
877 *
878 * Use this method to check if the other ZRTP client supports
879 * Multi-stream mode.
880 *
881 * @param zrtpContext
882 * Pointer to the opaque ZrtpContext structure.
883 * @return
884 * True if multi-stream is available, false otherwise.
885 */
886 int32_t zrtp_isMultiStreamAvailable(ZrtpContext* zrtpContext);
887
888 /**
889 * Accept a PBX enrollment request.
890 *
891 * If a PBX service asks to enroll the PBX trusted MitM key and the user
892 * accepts this request, for example by pressing an OK button, the client
893 * application shall call this method and set the parameter
894 * <code>accepted</code> to true. If the user does not accept the request
895 * set the parameter to false.
896 *
897 * @param zrtpContext
898 * Pointer to the opaque ZrtpContext structure.
899 * @param accepted
900 * True if the enrollment request is accepted, false otherwise.
901 */
902 void zrtp_acceptEnrollment(ZrtpContext* zrtpContext, int32_t accepted);
903
904 /**
905 * Check the state of the enrollment mode.
906 *
907 * If true then we will set the enrollment flag (E) in the confirm
908 * packets and performs the enrollment actions. A MitM (PBX) enrollment service
909 * started this ZRTP session. Can be set to true only if mitmMode is also true.
910 *
911 * @param zrtpContext
912 * Pointer to the opaque ZrtpContext structure.
913 * @return status of the enrollmentMode flag.
914 */
915 int32_t zrtp_isEnrollmentMode(ZrtpContext* zrtpContext);
916
917 /**
918 * Check the state of the enrollment mode.
919 *
920 * If true then we will set the enrollment flag (E) in the confirm
921 * packets and perform the enrollment actions. A MitM (PBX) enrollment
922 * service must sets this mode to true.
923 *
924 * Can be set to true only if mitmMode is also true.
925 *
926 * @param zrtpContext
927 * Pointer to the opaque ZrtpContext structure.
928 * @param enrollmentMode defines the new state of the enrollmentMode flag
929 */
930 void zrtp_setEnrollmentMode(ZrtpContext* zrtpContext, int32_t enrollmentMode);
931
932 /**
933 * Check if a peer's cache entry has a vaild MitM key.
934 *
935 * If true then the other peer ha a valid MtiM key, i.e. the peer has performed
936 * the enrollment procedure. A PBX ZRTP Back-2-Back application can use this function
937 * to check which of the peers is enrolled.
938 *
939 * @return True if the other peer has a valid Mitm key (is enrolled).
940 */
941 int32_t isPeerEnrolled(ZrtpContext* zrtpContext);
942
943 /**
944 * Send the SAS relay packet.
945 *
946 * The method creates and sends a SAS relay packet according to the ZRTP
947 * specifications. Usually only a MitM capable user agent (PBX) uses this
948 * function.
949 *
950 * @param zrtpContext
951 * Pointer to the opaque ZrtpContext structure.
952 * @param sh the full SAS hash value
953 * @param render the SAS rendering algorithm
954 */
955 int32_t zrtp_sendSASRelayPacket(ZrtpContext* zrtpContext, uint8_t* sh, char* render);
956
957 /**
958 * Get the commited SAS rendering algorithm for this ZRTP session.
959 *
960 * @param zrtpContext
961 * Pointer to the opaque ZrtpContext structure.
962 * @return the commited SAS rendering algorithm
963 */
964 const char* zrtp_getSasType(ZrtpContext* zrtpContext);
965
966 /**
967 * Get the computed SAS hash for this ZRTP session.
968 *
969 * A PBX ZRTP back-to-Back function uses this function to get the SAS
970 * hash of an enrolled client to construct the SAS relay packet for
971 * the other client.
972 *
973 * @param zrtpContext
974 * Pointer to the opaque ZrtpContext structure.
975 * @return a pointer to the byte array that contains the full
976 * SAS hash.
977 */
978 uint8_t* zrtp_getSasHash(ZrtpContext* zrtpContext);
979
980 /**
981 * Set signature data
982 *
983 * This functions stores signature data and transmitts it during ZRTP
984 * processing to the other party as part of the Confirm packets. Refer to
985 * chapters 5.7 and 7.2.
986 *
987 * The signature data must be set before ZRTP the application calls
988 * <code>start()</code>.
989 *
990 * @param zrtpContext
991 * Pointer to the opaque ZrtpContext structure.
992 * @param data
993 * The signature data including the signature type block. The method
994 * copies this data into the Confirm packet at signature type block.
995 * @param length
996 * The length of the signature data in bytes. This length must be
997 * multiple of 4.
998 * @return
999 * True if the method stored the data, false otherwise.
1000 */
1001 int32_t zrtp_setSignatureData(ZrtpContext* zrtpContext, uint8_t* data, int32_t length);
1002
1003 /**
1004 * Get signature data
1005 *
1006 * This functions returns signature data that was receivied during ZRTP
1007 * processing. Refer to chapters 5.7 and 7.2.
1008 *
1009 * The signature data can be retrieved after ZRTP enters secure state.
1010 * <code>start()</code>.
1011 *
1012 * @param zrtpContext
1013 * Pointer to the opaque ZrtpContext structure.
1014 * @return
1015 * Number of bytes copied into the data buffer
1016 */
1017 const uint8_t* zrtp_getSignatureData(ZrtpContext* zrtpContext);
1018
1019 /**
1020 * Get length of signature data
1021 *
1022 * This functions returns the length of signature data that was receivied
1023 * during ZRTP processing. Refer to chapters 5.7 and 7.2.
1024 *
1025 * @param zrtpContext
1026 * Pointer to the opaque ZrtpContext structure.
1027 * @return
1028 * Length in bytes of the received signature data. The method returns
1029 * zero if no signature data avilable.
1030 */
1031 int32_t zrtp_getSignatureLength(ZrtpContext* zrtpContext);
1032
1033 /**
1034 * Emulate a Conf2Ack packet.
1035 *
1036 * This method emulates a Conf2Ack packet. According to ZRTP specification
1037 * the first valid SRTP packet that the Initiator receives must switch
1038 * on secure mode. Refer to chapter 4 in the specificaton
1039 *
1040 * <b>NOTE: application shall never call this method directly. Only
1041 * the module that implements the RTP binding shall use this method</b>
1042 *
1043 * @param zrtpContext
1044 * Pointer to the opaque ZrtpContext structure.
1045 */
1046 void zrtp_conf2AckSecure(ZrtpContext* zrtpContext);
1047
1048 /**
1049 * Get other party's ZID (ZRTP Identifier) data
1050 *
1051 * This functions returns the other party's ZID that was receivied
1052 * during ZRTP processing.
1053 *
1054 * The ZID data can be retrieved after ZRTP receive the first Hello
1055 * packet from the other party. The application may call this method
1056 * for example during SAS processing in showSAS(...) user callback
1057 * method.
1058 *
1059 * @param zrtpContext
1060 * Pointer to the opaque ZrtpContext structure.
1061 * @param data
1062 * Pointer to a data buffer. This buffer must have a size of
1063 * at least 12 bytes (96 bit) (ZRTP Identifier, see chap. 4.9)
1064 * @return
1065 * Number of bytes copied into the data buffer - must be equivalent
1066 * to 12 bytes.
1067 */
1068 int32_t zrtp_getPeerZid(ZrtpContext* zrtpContext, uint8_t* data);
1069
1070
1071 /**
1072 * This enumerations list all configurable algorithm types.
1073 */
1074
1075 /* Keep in synch with enumeration in ZrtpConfigure.h */
1076
1077 typedef enum zrtp_AlgoTypes {
1078 zrtp_HashAlgorithm = 1, zrtp_CipherAlgorithm, zrtp_PubKeyAlgorithm, zrtp_SasType, zrtp_AuthLength
1079 } Zrtp_AlgoTypes;
1080
1081 /**
1082 * Initialize the GNU ZRTP Configure data.
1083 *
1084 * Initializing and setting a ZRTP configuration is optional. GNU ZRTP
1085 * uses a sensible default if an application does not define its own
1086 * ZRTP configuration.
1087 *
1088 * If an application initialize th configure data it must set the
1089 * configuration data.
1090 *
1091 * The ZRTP specification, chapters 5.1.2 through 5.1.6 defines the
1092 * algorithm names and their meaning.
1093 *
1094 * The current ZRTP implementation implements all mandatory algorithms
1095 * plus a set of the optional algorithms. An application shall use
1096 * @c zrtp_getAlgorithmNames to get the names of the available algorithms.
1097 *
1098 * @param zrtpContext
1099 * Pointer to the opaque ZrtpContext structure.
1100 * @returns
1101 * Pointer to the ZrtpConfCtx
1102 *
1103 * @see zrtp_getAlgorithmNames
1104 */
1105 int32_t zrtp_InitializeConfig (ZrtpContext* zrtpContext);
1106
1107 /**
1108 * Get names of all available algorithmes of a given algorithm type.
1109 *
1110 * The algorithm names are as specified in the ZRTP specification, chapters
1111 * 5.1.2 through 5.1.6 .
1112 *
1113 * @param zrtpContext
1114 * Pointer to the opaque ZrtpContext structure.
1115 * @param type
1116 * The algorithm type.
1117 * @returns
1118 * A NULL terminated array of character pointers.
1119 */
1120 char** zrtp_getAlgorithmNames(ZrtpContext* zrtpContext, Zrtp_AlgoTypes type);
1121
1122 /**
1123 * Free storage used to store the algorithm names.
1124 *
1125 * If an application does not longer require the algoritm names it should
1126 * free the space.
1127 *
1128 * @param names
1129 * The NULL terminated array of character pointers.
1130 */
1131 void zrtp_freeAlgorithmNames(char** names);
1132
1133 /**
1134 * Convenience function that sets a pre-defined standard configuration.
1135 *
1136 * The standard configuration consists of the following algorithms:
1137 * <ul>
1138 * <li> Hash: SHA256 </li>
1139 * <li> Symmetric Cipher: AES 128, AES 256 </li>
1140 * <li> Public Key Algorithm: DH2048, DH3027, MultiStream </li>
1141 * <li> SAS type: libase 32 </li>
1142 * <li> SRTP Authentication lengths: 32, 80 </li>
1143 *</ul>
1144 *
1145 * @param zrtpContext
1146 * Pointer to the opaque ZrtpContext structure.
1147 */
1148 void zrtp_setStandardConfig(ZrtpContext* zrtpContext);
1149
1150 /**
1151 * Convenience function that sets the mandatory algorithms only.
1152 *
1153 * Mandatory algorithms are:
1154 * <ul>
1155 * <li> Hash: SHA256 </li>
1156 * <li> Symmetric Cipher: AES 128 </li>
1157 * <li> Public Key Algorithm: DH3027, MultiStream </li>
1158 * <li> SAS type: libase 32 </li>
1159 * <li> SRTP Authentication lengths: 32, 80 </li>
1160 *</ul>
1161 *
1162 * @param zrtpContext
1163 * Pointer to the opaque ZrtpContext structure.
1164 */
1165 void zrtp_setMandatoryOnly(ZrtpContext* zrtpContext);
1166
1167 /**
1168 * Clear all configuration data.
1169 *
1170 * The functions clears all configuration data.
1171 *
1172 * @param zrtpContext
1173 * Pointer to the opaque ZrtpContext structure.
1174 */
1175 void zrtp_confClear(ZrtpContext* zrtpContext);
1176
1177 /**
1178 * Add an algorithm to configuration data.
1179 *
1180 * Adds the specified algorithm to the configuration data.
1181 * If no free configuration data slot is available the
1182 * function does not add the algorithm and returns -1. The
1183 * methods appends the algorithm to the existing algorithms.
1184 *
1185 * @param zrtpContext
1186 * Pointer to the opaque ZrtpContext structure.
1187 * @param algoType
1188 * Specifies which algorithm type to select
1189 * @param algo
1190 * The name of the algorithm to add.
1191 * @return
1192 * Number of free configuration data slots or -1 on error
1193 */
1194 int32_t zrtp_addAlgo(ZrtpContext* zrtpContext, Zrtp_AlgoTypes algoType, const char* algo);
1195
1196 /**
1197 * Add an algorithm to configuration data at given index
1198 *
1199 * Adds the specified algorithm to the configuration data vector
1200 * at a given index. If the index is larger than the actual size
1201 * of the configuration vector the method just appends the algorithm.
1202 *
1203 * @param zrtpContext
1204 * Pointer to the opaque ZrtpContext structure.
1205 * @param algoType
1206 * Specifies which algorithm type to select
1207 * @param algo
1208 * The name of the algorithm to add.
1209 * @param index
1210 * The index where to add the algorihm
1211 * @return
1212 * Number of free configuration data slots or -1 on error
1213 */
1214 int32_t zrtp_addAlgoAt(ZrtpContext* zrtpContext, Zrtp_AlgoTypes algoType, const char* algo, int32_t index);
1215
1216 /**
1217 * Remove a algorithm from configuration data.
1218 *
1219 * Removes the specified algorithm from configuration data. If
1220 * the algorithm was not configured previously the function does
1221 * not modify the configuration data and returns the number of
1222 * free configuration data slots.
1223 *
1224 * If an application removes all algorithms then ZRTP does not
1225 * include any algorithm into the hello message and falls back
1226 * to a predefined mandatory algorithm.
1227 *
1228 * @param zrtpContext
1229 * Pointer to the opaque ZrtpContext structure.
1230 * @param algoType
1231 * Specifies which algorithm type to select
1232 * @param algo
1233 * The name of the algorithm to remove.
1234 * @return
1235 * Number of free configuration slots.
1236 */
1237 int32_t zrtp_removeAlgo(ZrtpContext* zrtpContext, Zrtp_AlgoTypes algoType, const char* algo);
1238
1239 /**
1240 * Returns the number of configured algorithms.
1241 *
1242 * @param zrtpContext
1243 * Pointer to the opaque ZrtpContext structure.
1244 * @param algoType
1245 * Specifies which algorithm type to select
1246 * @return
1247 * The number of configured algorithms (used configuration
1248 * data slots)
1249 */
1250 int32_t zrtp_getNumConfiguredAlgos(ZrtpContext* zrtpContext, Zrtp_AlgoTypes algoType);
1251
1252 /**
1253 * Returns the identifier of the algorithm at index.
1254 *
1255 * @param zrtpContext
1256 * Pointer to the opaque ZrtpContext structure.
1257 * @param algoType
1258 * Specifies which algorithm type to select
1259 * @param index
1260 * The index in the list of the algorihm type
1261 * @return
1262 * A pointer to the algorithm name. If the index
1263 * does not point to a configured slot then the function
1264 * returns NULL.
1265 *
1266 */
1267 const char* zrtp_getAlgoAt(ZrtpContext* zrtpContext, Zrtp_AlgoTypes algoType, int32_t index);
1268
1269 /**
1270 * Checks if the configuration data of the algorihm type already contains
1271 * a specific algorithms.
1272 *
1273 * @param zrtpContext
1274 * Pointer to the opaque ZrtpContext structure.
1275 * @param algoType
1276 * Specifies which algorithm type to select
1277 * @param algo
1278 * The name of the algorithm to check
1279 * @return
1280 * True if the algorithm was found, false otherwise.
1281 *
1282 */
1283 int32_t zrtp_containsAlgo(ZrtpContext* zrtpContext, Zrtp_AlgoTypes algoType, const char* algo);
1284
1285 /**
1286 * Enables or disables trusted MitM processing.
1287 *
1288 * For further details of trusted MitM processing refer to ZRTP
1289 * specification, chapter 7.3
1290 *
1291 * @param zrtpContext
1292 * Pointer to the opaque ZrtpContext structure.
1293 * @param yesNo
1294 * If set to true then trusted MitM processing is enabled.
1295 */
1296 void zrtp_setTrustedMitM(ZrtpContext* zrtpContext, int32_t yesNo);
1297
1298 /**
1299 * Check status of trusted MitM processing.
1300 *
1301 * @param zrtpContext
1302 * Pointer to the opaque ZrtpContext structure.
1303 * @return
1304 * Returns true if trusted MitM processing is enabled.
1305 */
1306 int32_t zrtp_isTrustedMitM(ZrtpContext* zrtpContext);
1307
1308 /**
1309 * Enables or disables SAS signature processing.
1310 *
1311 * For further details of trusted MitM processing refer to ZRTP
1312 * specification, chapter 7.2
1313 *
1314 * @param zrtpContext
1315 * Pointer to the opaque ZrtpContext structure.
1316 * @param yesNo
1317 * If true then certificate processing is enabled.
1318 */
1319 void zrtp_setSasSignature(ZrtpContext* zrtpContext, int32_t yesNo);
1320
1321 /**
1322 * Check status of SAS signature processing.
1323 *
1324 * @param zrtpContext
1325 * Pointer to the opaque ZrtpContext structure.
1326 * @return
1327 * Returns true if certificate processing is enabled.
1328 */
1329 int32_t zrtp_isSasSignature(ZrtpContext* zrtpContext);
1330
1331#ifdef __cplusplus
1332}
1333#pragma GCC visibility pop
1334#endif
1335
1336/**
1337 * @}
1338 */
1339#endif