summaryrefslogtreecommitdiff
path: root/demo/wrappertest.c
blob: abbb3cf295557f379666ecf342add8aee22aa634 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
    This class maps the ZRTP C calls to ZRTP C++ methods.
    Copyright (C) 2010  Werner Dittmann

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

#include <libzrtpcpp/ZrtpCWrapper.h>

#include <stdio.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C"
{
#endif

/* Forward declaration of thethe ZRTP specific callback functions that this
  adapter must implement */
static int32_t zrtp_sendDataZRTP (ZrtpContext* ctx, const uint8_t* data, int32_t length ) ;
static int32_t zrtp_activateTimer (ZrtpContext* ctx, int32_t time ) ;
static int32_t zrtp_cancelTimer(ZrtpContext* ctx) ;
static void zrtp_sendInfo (ZrtpContext* ctx, int32_t severity, int32_t subCode ) ;
static int32_t zrtp_srtpSecretsReady (ZrtpContext* ctx, C_SrtpSecret_t* secrets, int32_t part ) ;
static void zrtp_srtpSecretsOff (ZrtpContext* ctx, int32_t part ) ;
static void zrtp_rtpSecretsOn (ZrtpContext* ctx, char* c, char* s, int32_t verified ) ;
static void zrtp_handleGoClear(ZrtpContext* ctx) ;
static void zrtp_zrtpNegotiationFailed(ZrtpContext* ctx, int32_t severity, int32_t subCode ) ;
static void zrtp_zrtpNotSuppOther(ZrtpContext* ctx) ;
static void zrtp_synchEnter(ZrtpContext* ctx) ;
static void zrtp_synchLeave(ZrtpContext* ctx) ;
static void zrtp_zrtpAskEnrollment (ZrtpContext* ctx, char* info ) ;
static void zrtp_zrtpInformEnrollment(ZrtpContext* ctx, char* info ) ;
static void zrtp_signSAS(ZrtpContext* ctx, char* sas) ;
static int32_t zrtp_checkSASSignature (ZrtpContext* ctx, char* sas ) ;

/* The callback function structure for ZRTP */
static zrtp_Callbacks c_callbacks = {
    &zrtp_sendDataZRTP,
    &zrtp_activateTimer,
    &zrtp_cancelTimer,
    &zrtp_sendInfo,
    &zrtp_srtpSecretsReady,
    &zrtp_srtpSecretsOff,
    &zrtp_rtpSecretsOn,
    &zrtp_handleGoClear,
    &zrtp_zrtpNegotiationFailed,
    &zrtp_zrtpNotSuppOther,
    &zrtp_synchEnter,
    &zrtp_synchLeave,
    &zrtp_zrtpAskEnrollment,
    &zrtp_zrtpInformEnrollment,
    &zrtp_signSAS,
    &zrtp_checkSASSignature
};

/*
 * Here start with callback functions that support the ZRTP core
 */
static int32_t zrtp_sendDataZRTP (ZrtpContext* ctx, const uint8_t* data, int32_t length )
{
    return 0;
}

static int32_t zrtp_activateTimer (ZrtpContext* ctx, int32_t time)
{
    return 0;
}

static int32_t zrtp_cancelTimer(ZrtpContext* ctx)
{
    return 0;
}

static void zrtp_sendInfo (ZrtpContext* ctx, int32_t severity, int32_t subCode )
{
}

static int32_t zrtp_srtpSecretsReady (ZrtpContext* ctx, C_SrtpSecret_t* secrets, int32_t part )
{
    return 0;
}

static void zrtp_srtpSecretsOff (ZrtpContext* ctx, int32_t part )
{
}

static void zrtp_rtpSecretsOn (ZrtpContext* ctx, char* c, char* s, int32_t verified )
{
}

static void zrtp_handleGoClear(ZrtpContext* ctx)
{
}

static void zrtp_zrtpNegotiationFailed (ZrtpContext* ctx, int32_t severity, int32_t subCode )
{
}

static void zrtp_zrtpNotSuppOther(ZrtpContext* ctx)
{
}

static void zrtp_synchEnter(ZrtpContext* ctx)
{
}

static void zrtp_synchLeave(ZrtpContext* ctx)
{
}

static void zrtp_zrtpAskEnrollment(ZrtpContext* ctx, char* info )
{

}
static void zrtp_zrtpInformEnrollment(ZrtpContext* ctx, char* info )
{
}

static void zrtp_signSAS(ZrtpContext* ctx, char* sas)
{
}

static int32_t zrtp_checkSASSignature(ZrtpContext* ctx, char* sas )
{
    return 0;
}

int main(int argc, char *argv[])
{
    ZrtpContext* zrtpCtx;
    char* hh;
    char** names;
    
    zrtpCtx = zrtp_CreateWrapper ();
    zrtp_initializeZrtpEngine(zrtpCtx, &c_callbacks, "test", "test.zid", NULL);
    
    hh = zrtp_getHelloHash(zrtpCtx);
    if (hh != 0) 
    {
        printf("hh: %s\n", hh);
    }
    else
        printf("no hh");

    zrtp_InitializeConfig(zrtpCtx);
    names = zrtp_getAlgorithmNames(zrtpCtx, zrtp_HashAlgorithm);
    
    for (; *names; names++) {
        printf("name: %s\n", *names);
    }
    
    return 0;
}
#ifdef __cplusplus
}
#endif