aboutsummaryrefslogtreecommitdiff
path: root/src/core/gnunet-service-core_kx.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-06 11:01:23 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-06 11:01:23 +0000
commit60e84bc16ecf431bd6f7aa22b3adb48df70bf8cf (patch)
tree8feca79fc98294639d7927613cdb20f08efd5373 /src/core/gnunet-service-core_kx.h
parente788f53d58b5a4d46f86f5508b70bbede9e010b3 (diff)
downloadgnunet-60e84bc16ecf431bd6f7aa22b3adb48df70bf8cf.tar.gz
gnunet-60e84bc16ecf431bd6f7aa22b3adb48df70bf8cf.zip
hxing
Diffstat (limited to 'src/core/gnunet-service-core_kx.h')
-rw-r--r--src/core/gnunet-service-core_kx.h148
1 files changed, 148 insertions, 0 deletions
diff --git a/src/core/gnunet-service-core_kx.h b/src/core/gnunet-service-core_kx.h
index f4f1daaeb..b5b9b712e 100644
--- a/src/core/gnunet-service-core_kx.h
+++ b/src/core/gnunet-service-core_kx.h
@@ -1,3 +1,37 @@
1/*
2 This file is part of GNUnet.
3 (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file core/gnunet-service-core_kx.h
23 * @brief code for managing the key exchange (SET_KEY, PING, PONG) with other peers
24 * @author Christian Grothoff
25 */
26#ifndef GNUNET_SERVICE_CORE_KX_H
27#define GNUNET_SERVICE_CORE_KX_H
28
29#include "gnunet_util_lib.h"
30
31
32/**
33 * Information about the status of a key exchange with another peer.
34 */
1struct GSC_KeyExchangeInfo 35struct GSC_KeyExchangeInfo
2{ 36{
3 37
@@ -75,3 +109,117 @@ struct GSC_KeyExchangeInfo
75 enum PeerStateMachine status; 109 enum PeerStateMachine status;
76 110
77}; 111};
112
113
114/**
115 * We received a SET_KEY message. Validate and update
116 * our key material and status.
117 *
118 * @param kx key exchange status for the corresponding peer
119 * @param msg the set key message we received
120 * @param ats performance data
121 * @param ats_count number of entries in ats (excluding 0-termination)
122 */
123void
124GSC_KX_handle_set_key (struct GSC_KeyExchangeInfo *n,
125 const struct GNUNET_MessageHandler *msg,
126 const struct GNUNET_TRANSPORT_ATS_Information *ats,
127 uint32_t ats_count);
128
129
130/**
131 * We received a PING message. Validate and transmit
132 * a PONG message.
133 *
134 * @param kx key exchange status for the corresponding peer
135 * @param msg the encrypted PING message itself
136 * @param ats performance data
137 * @param ats_count number of entries in ats (excluding 0-termination)
138 */
139void
140GSC_KX_handle_ping (struct GSC_KeyExchangeInfo *kx,
141 const struct GNUNET_MessageHeader *msg,
142 const struct GNUNET_TRANSPORT_ATS_Information *ats,
143 uint32_t ats_count);
144
145
146/**
147 * We received a PONG message. Validate and update our status.
148 *
149 * @param kx key exchange status for the corresponding peer
150 * @param msg the encrypted PONG message itself
151 * @param ats performance data
152 * @param ats_count number of entries in ats (excluding 0-termination)
153 */
154void
155GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx,
156 const struct GNUNET_MessageHeader *msg,
157 const struct GNUNET_TRANSPORT_ATS_Information *ats,
158 uint32_t ats_count);
159
160
161/**
162 * Encrypt and transmit a message with the given payload.
163 *
164 * @param kx key exchange context
165 * @param payload payload of the message
166 * @param payload_size number of bytes in 'payload'
167 */
168void
169GSC_KX_encrypt_and_transmit (struct GSC_KeyExchangeInfo *kx,
170 const void *payload,
171 size_t payload_size);
172
173
174/**
175 * We received an encrypted message. Decrypt, validate and
176 * pass on to the appropriate clients.
177 *
178 * @param kx key exchange information context
179 * @param msg encrypted message
180 * @param ats performance data
181 * @param ats_count number of entries in ats (excluding 0-termination)
182 */
183void
184GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
185 const struct GNUNET_MessageHeader *msg,
186 const struct GNUNET_TRANSPORT_ATS_Information *ats,
187 uint32_t ats_count);
188
189
190/**
191 * Start the key exchange with the given peer.
192 *
193 * @param pid identity of the peer to do a key exchange with
194 * @return key exchange information context
195 */
196struct GSC_KeyExchangeInfo *
197GSC_KX_start (const struct GNUNET_PeerIdentity *pid);
198
199
200/**
201 * Stop key exchange with the given peer. Clean up key material.
202 *
203 * @param kx key exchange to stop
204 */
205void
206GSC_KX_stop (struct GSC_KeyExchangeInfo *kx);
207
208
209/**
210 * Initialize KX subsystem.
211 *
212 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
213 */
214int
215GSC_KX_init (void);
216
217
218/**
219 * Shutdown KX subsystem.
220 */
221void
222GSC_KX_done (void);
223
224#endif
225/* end of gnunet-service-core_kx.h */