1 /*
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
38 #include <stdint.h>
39
55 /*
56 * Keep the following defines in sync with Role enumeration in ZrtpCallback.h
57 */
62 #define ZRTP_MAGIC 0x5a525450
63 #define MAX_ZRTP_SIZE 3072
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
108 };
109
125 };
126
139 };
140
153 };
154
185 };
186
195 };
196
197 /* The ZRTP protocol states */
213 };
214
222
232 {
247
248 /*
249 * Keep the following defines in sync with enum EnableSecurity in ZrtpCallback.h
250 */
251 #define ForReceiver 1
254 #ifdef __cplusplus
255 #pragma GCC visibility push(default)
256 extern "C"
257 {
258 #endif
259
263
264
266 {
272
295 {
312
324
334
352
385
395
417
431
447
458
472
480
496
512
533
560
569
606 const char* id,
607 const char* zidFilename,
608 void* userData,
609 int32_t mitmMode);
610
615
629 int32_t
zrtp_CheckCksum(uint8_t* buffer, uint16_t length, uint32_t crc);
630
642
651
666
677
697
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
743
758
769
777
798
815
840
861
874
887
903
916
931
942
956
965
979
1002
1018
1032
1047
1069
1070
1075 /* Keep in synch with enumeration in ZrtpConfigure.h */
1076
1080
1106
1121
1132
1149
1166
1176
1195
1215
1238
1251
1268
1284
1297
1307
1320
1330
1331 #ifdef __cplusplus
1332 }
1333 #pragma GCC visibility pop
1334 #endif
1335
1339 #endif
void zrtp_conf2AckSecure(ZrtpContext *zrtpContext)
Emulate a Conf2Ack packet.
int32_t zrtp_addAlgo(ZrtpContext *zrtpContext, Zrtp_AlgoTypes algoType, const char *algo)
Add an algorithm to configuration data.
zrtp_SevereCodes
Sub-codes for Severe.
Enrollment process failed, no PBX secret available.
void(* zrtp_srtpSecretsOff)(ZrtpContext *ctx, int32_t part)
Switch off the security for the defined part.
const uint8_t * saltInitiator
void zrtp_setSasSignature(ZrtpContext *zrtpContext, int32_t yesNo)
Enables or disables SAS signature processing.
int32_t zrtp_inState(ZrtpContext *zrtpContext, int32_t state)
Check current state of the ZRTP state engine.
const char * zrtp_getSasType(ZrtpContext *zrtpContext)
Get the commited SAS rendering algorithm for this ZRTP session.
void(* zrtp_zrtpNotSuppOther)(ZrtpContext *ctx)
ZRTP calls this method if the other side does not support ZRTP.
char * zrtp_getHelloHash(ZrtpContext *zrtpContext)
Get the ZRTP Hello Hash data.
void zrtp_processTimeout(ZrtpContext *zrtpContext)
Process a timeout event.
int32_t zrtp_CheckCksum(uint8_t *buffer, uint16_t length, uint32_t crc)
Computes the ZRTP checksum over a received ZRTP packet buffer and compares the result with received c...
void zrtp_stopZrtpEngine(ZrtpContext *zrtpContext)
Stop ZRTP security.
void zrtp_setMandatoryOnly(ZrtpContext *zrtpContext)
Convenience function that sets the mandatory algorithms only.
int32_t zrtp_isMultiStream(ZrtpContext *zrtpContext)
Check if this ZRTP session is a Multi-stream session.
const uint8_t * saltResponder
struct c_srtpSecrets C_SrtpSecret_t
This structure contains pointers to the SRTP secrets and the role info.
Enrollment process for this PBX was ok.
zrtp_ZrtpErrorCodes
Error codes according to the ZRTP specification chapter 6.9.
__EXPORT AppLog & info(AppLog &sl)
Manipulator for info level.
Aks user to confirm or deny an Enrollemnt request.
int32_t zrtp_getSignatureLength(ZrtpContext *zrtpContext)
Get length of signature data.
int32_t zrtp_getNumConfiguredAlgos(ZrtpContext *zrtpContext, Zrtp_AlgoTypes algoType)
Returns the number of configured algorithms.
void zrtp_initializeZrtpEngine(ZrtpContext *zrtpContext, zrtp_Callbacks *cb, const char *id, const char *zidFilename, void *userData, int32_t mitmMode)
Initialize the ZRTP protocol engine.
void(* zrtp_zrtpInformEnrollment)(ZrtpContext *ctx, int32_t info)
Inform about PBX enrollment result.
const uint8_t * zrtp_getSignatureData(ZrtpContext *zrtpContext)
Get signature data.
char * zrtp_getPeerHelloHash(ZrtpContext *zrtpContext)
Get the peer's ZRTP Hello Hash data.
int32_t zrtp_removeAlgo(ZrtpContext *zrtpContext, Zrtp_AlgoTypes algoType, const char *algo)
Remove a algorithm from configuration data.
zrtp_AlgoTypes
This enumerations list all configurable algorithm types.
This structure contains pointers to the SRTP secrets and the role info.
int32_t(* zrtp_cancelTimer)(ZrtpContext *ctx)
Cancel the active timer.
User did not confirm the PBX enrollement.
int32_t zrtp_getPeerZid(ZrtpContext *zrtpContext, uint8_t *data)
Get other party's ZID (ZRTP Identifier) data.
ZrtpCallbackWrapper * zrtpCallback
enum zrtp_AlgoTypes Zrtp_AlgoTypes
This enumerations list all configurable algorithm types.
const uint8_t * keyResponder
void(* zrtp_signSAS)(ZrtpContext *ctx, uint8_t *sas)
Request a SAS signature.
uint32_t zrtp_GenerateCksum(uint8_t *buffer, uint16_t length)
Computes the ZRTP checksum over a newly created ZRTP packet buffer.
void(* zrtp_sendInfo)(ZrtpContext *ctx, int32_t severity, int32_t subCode)
Send information messages to the hosting environment.
int32_t(* zrtp_srtpSecretsReady)(ZrtpContext *ctx, C_SrtpSecret_t *secrets, int32_t part)
SRTP crypto data ready for the sender or receiver.
zrtp_SrtpAlgorithms symEncAlgorithm
void zrtp_setMultiStrParams(ZrtpContext *zrtpContext, char *parameters, int32_t length)
Set Multi-stream parameters.
void zrtp_processZrtpMessage(ZrtpContext *zrtpContext, uint8_t *extHeader, uint32_t peerSSRC)
Process RTP extension header.
uint8_t * zrtp_getSasHash(ZrtpContext *zrtpContext)
Get the computed SAS hash for this ZRTP session.
void zrtp_SASVerified(ZrtpContext *zrtpContext)
Set SAS as verified.
ZrtpContext * zrtp_CreateWrapper()
Create the GNU ZRTP C wrapper.
void zrtp_setTrustedMitM(ZrtpContext *zrtpContext, int32_t yesNo)
Enables or disables trusted MitM processing.
int32_t isPeerEnrolled(ZrtpContext *zrtpContext)
Check if a peer's cache entry has a vaild MitM key.
void zrtp_setAuxSecret(ZrtpContext *zrtpContext, uint8_t *data, int32_t length)
Set the auxilliary secret.
void zrtp_startZrtpEngine(ZrtpContext *zrtpContext)
Kick off the ZRTP protocol engine.
void(* zrtp_rtpSecretsOn)(ZrtpContext *ctx, char *c, char *s, int32_t verified)
Switch on the security.
int32_t zrtp_isMultiStreamAvailable(ZrtpContext *zrtpContext)
Check if the other ZRTP client supports Multi-stream.
void zrtp_freeAlgorithmNames(char **names)
Free storage used to store the algorithm names.
void zrtp_setStandardConfig(ZrtpContext *zrtpContext)
Convenience function that sets a pre-defined standard configuration.
uint32_t zrtp_EndCksum(uint32_t crc)
Prepares the ZRTP checksum for appending to ZRTP packet.
void zrtp_resetSASVerified(ZrtpContext *zrtpContext)
Reset the SAS verfied flag for the current active user's retained secrets.
int32_t zrtp_isEnrollmentMode(ZrtpContext *zrtpContext)
Check the state of the enrollment mode.
void zrtp_DestroyWrapper(ZrtpContext *zrtpContext)
Destroy the ZRTP wrapper and its underlying objects.
zrtp_InfoEnrollment
Information codes for the Enrollment user callbacks.
int32_t zrtp_isTrustedMitM(ZrtpContext *zrtpContext)
Check status of trusted MitM processing.
void(* zrtp_zrtpNegotiationFailed)(ZrtpContext *ctx, int32_t severity, int32_t subCode)
Handle ZRTP negotiation failed.
void zrtp_confClear(ZrtpContext *zrtpContext)
Clear all configuration data.
struct zrtp_Callbacks zrtp_Callbacks
This structure defines the callback functions required by GNU ZRTP.
void zrtp_setEnrollmentMode(ZrtpContext *zrtpContext, int32_t enrollmentMode)
Check the state of the enrollment mode.
zrtp_SrtpAlgorithms authAlgorithm
zrtp_WarningCodes
Sub-codes for Warning.
int32_t(* zrtp_checkSASSignature)(ZrtpContext *ctx, uint8_t *sas)
ZRTPQueue calls this method to request a SAS signature check.
void(* zrtp_handleGoClear)(ZrtpContext *ctx)
This method handles GoClear requests.
void zrtp_acceptEnrollment(ZrtpContext *zrtpContext, int32_t accepted)
Accept a PBX enrollment request.
struct zrtpContext ZrtpContext
int32_t zrtp_setSignatureData(ZrtpContext *zrtpContext, uint8_t *data, int32_t length)
Set signature data.
int32_t zrtp_isSasSignature(ZrtpContext *zrtpContext)
Check status of SAS signature processing.
This structure defines the callback functions required by GNU ZRTP.
int32_t(* zrtp_activateTimer)(ZrtpContext *ctx, int32_t time)
Activate timer.
void(* zrtp_zrtpAskEnrollment)(ZrtpContext *ctx, int32_t info)
Inform about a PBX enrollment request.
struct ZrtpCallbackWrapper ZrtpCallbackWrapper
void(* zrtp_synchLeave)(ZrtpContext *ctx)
Leave synchronization mutex.
void(* zrtp_synchEnter)(ZrtpContext *ctx)
Enter synchronization mutex.
int32_t zrtp_InitializeConfig(ZrtpContext *zrtpContext)
Initialize the GNU ZRTP Configure data.
ZrtpConfigure * configure
zrtp_InfoCodes
Sub-codes for Info.
const uint8_t * keyInitiator
zrtp_MessageSeverity
This enum defines the information message severity.
char * zrtp_getMultiStrParams(ZrtpContext *zrtpContext, int32_t *length)
Get Multi-stream parameters.
char ** zrtp_getAlgorithmNames(ZrtpContext *zrtpContext, Zrtp_AlgoTypes type)
Get names of all available algorithmes of a given algorithm type.
const char * zrtp_getAlgoAt(ZrtpContext *zrtpContext, Zrtp_AlgoTypes algoType, int32_t index)
Returns the identifier of the algorithm at index.
int32_t zrtp_sendSASRelayPacket(ZrtpContext *zrtpContext, uint8_t *sh, char *render)
Send the SAS relay packet.
int32_t zrtp_addAlgoAt(ZrtpContext *zrtpContext, Zrtp_AlgoTypes algoType, const char *algo, int32_t index)
Add an algorithm to configuration data at given index.
int32_t(* zrtp_sendDataZRTP)(ZrtpContext *ctx, const uint8_t *data, int32_t length)
Send a ZRTP packet via RTP.
int32_t zrtp_containsAlgo(ZrtpContext *zrtpContext, Zrtp_AlgoTypes algoType, const char *algo)
Checks if the configuration data of the algorihm type already contains a specific algorithms...