blob: abbb3cf295557f379666ecf342add8aee22aa634 [file] [log] [blame]
Alexandre Lision51140e12013-12-02 10:54:09 -05001/*
2 This class maps the ZRTP C calls to ZRTP C++ methods.
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#include <libzrtpcpp/ZrtpCWrapper.h>
21
22#include <stdio.h>
23#include <stdint.h>
24
25#ifdef __cplusplus
26extern "C"
27{
28#endif
29
30/* Forward declaration of thethe ZRTP specific callback functions that this
31 adapter must implement */
32static int32_t zrtp_sendDataZRTP (ZrtpContext* ctx, const uint8_t* data, int32_t length ) ;
33static int32_t zrtp_activateTimer (ZrtpContext* ctx, int32_t time ) ;
34static int32_t zrtp_cancelTimer(ZrtpContext* ctx) ;
35static void zrtp_sendInfo (ZrtpContext* ctx, int32_t severity, int32_t subCode ) ;
36static int32_t zrtp_srtpSecretsReady (ZrtpContext* ctx, C_SrtpSecret_t* secrets, int32_t part ) ;
37static void zrtp_srtpSecretsOff (ZrtpContext* ctx, int32_t part ) ;
38static void zrtp_rtpSecretsOn (ZrtpContext* ctx, char* c, char* s, int32_t verified ) ;
39static void zrtp_handleGoClear(ZrtpContext* ctx) ;
40static void zrtp_zrtpNegotiationFailed(ZrtpContext* ctx, int32_t severity, int32_t subCode ) ;
41static void zrtp_zrtpNotSuppOther(ZrtpContext* ctx) ;
42static void zrtp_synchEnter(ZrtpContext* ctx) ;
43static void zrtp_synchLeave(ZrtpContext* ctx) ;
44static void zrtp_zrtpAskEnrollment (ZrtpContext* ctx, char* info ) ;
45static void zrtp_zrtpInformEnrollment(ZrtpContext* ctx, char* info ) ;
46static void zrtp_signSAS(ZrtpContext* ctx, char* sas) ;
47static int32_t zrtp_checkSASSignature (ZrtpContext* ctx, char* sas ) ;
48
49/* The callback function structure for ZRTP */
50static zrtp_Callbacks c_callbacks = {
51 &zrtp_sendDataZRTP,
52 &zrtp_activateTimer,
53 &zrtp_cancelTimer,
54 &zrtp_sendInfo,
55 &zrtp_srtpSecretsReady,
56 &zrtp_srtpSecretsOff,
57 &zrtp_rtpSecretsOn,
58 &zrtp_handleGoClear,
59 &zrtp_zrtpNegotiationFailed,
60 &zrtp_zrtpNotSuppOther,
61 &zrtp_synchEnter,
62 &zrtp_synchLeave,
63 &zrtp_zrtpAskEnrollment,
64 &zrtp_zrtpInformEnrollment,
65 &zrtp_signSAS,
66 &zrtp_checkSASSignature
67};
68
69/*
70 * Here start with callback functions that support the ZRTP core
71 */
72static int32_t zrtp_sendDataZRTP (ZrtpContext* ctx, const uint8_t* data, int32_t length )
73{
74 return 0;
75}
76
77static int32_t zrtp_activateTimer (ZrtpContext* ctx, int32_t time)
78{
79 return 0;
80}
81
82static int32_t zrtp_cancelTimer(ZrtpContext* ctx)
83{
84 return 0;
85}
86
87static void zrtp_sendInfo (ZrtpContext* ctx, int32_t severity, int32_t subCode )
88{
89}
90
91static int32_t zrtp_srtpSecretsReady (ZrtpContext* ctx, C_SrtpSecret_t* secrets, int32_t part )
92{
93 return 0;
94}
95
96static void zrtp_srtpSecretsOff (ZrtpContext* ctx, int32_t part )
97{
98}
99
100static void zrtp_rtpSecretsOn (ZrtpContext* ctx, char* c, char* s, int32_t verified )
101{
102}
103
104static void zrtp_handleGoClear(ZrtpContext* ctx)
105{
106}
107
108static void zrtp_zrtpNegotiationFailed (ZrtpContext* ctx, int32_t severity, int32_t subCode )
109{
110}
111
112static void zrtp_zrtpNotSuppOther(ZrtpContext* ctx)
113{
114}
115
116static void zrtp_synchEnter(ZrtpContext* ctx)
117{
118}
119
120static void zrtp_synchLeave(ZrtpContext* ctx)
121{
122}
123
124static void zrtp_zrtpAskEnrollment(ZrtpContext* ctx, char* info )
125{
126
127}
128static void zrtp_zrtpInformEnrollment(ZrtpContext* ctx, char* info )
129{
130}
131
132static void zrtp_signSAS(ZrtpContext* ctx, char* sas)
133{
134}
135
136static int32_t zrtp_checkSASSignature(ZrtpContext* ctx, char* sas )
137{
138 return 0;
139}
140
141int main(int argc, char *argv[])
142{
143 ZrtpContext* zrtpCtx;
144 char* hh;
145 char** names;
146
147 zrtpCtx = zrtp_CreateWrapper ();
148 zrtp_initializeZrtpEngine(zrtpCtx, &c_callbacks, "test", "test.zid", NULL);
149
150 hh = zrtp_getHelloHash(zrtpCtx);
151 if (hh != 0)
152 {
153 printf("hh: %s\n", hh);
154 }
155 else
156 printf("no hh");
157
158 zrtp_InitializeConfig(zrtpCtx);
159 names = zrtp_getAlgorithmNames(zrtpCtx, zrtp_HashAlgorithm);
160
161 for (; *names; names++) {
162 printf("name: %s\n", *names);
163 }
164
165 return 0;
166}
167#ifdef __cplusplus
168}
169#endif