2 This file is part of GNUnet.
3 (C) 2009, 2010, 2011 Christian Grothoff (and other contributing authors)
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.
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.
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.
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
26 #ifndef GNUNET_SERVICE_CORE_KX_H
27 #define GNUNET_SERVICE_CORE_KX_H
29 #include "gnunet_util_lib.h"
33 * Information about the status of a key exchange with another peer.
35 struct GSC_KeyExchangeInfo;
39 * We received a SET_KEY message. Validate and update
40 * our key material and status.
42 * @param kx key exchange status for the corresponding peer
43 * @param msg the set key message we received
46 GSC_KX_handle_set_key (struct GSC_KeyExchangeInfo *kx,
47 const struct GNUNET_MessageHandler *msg);
51 * We received a PING message. Validate and transmit
54 * @param kx key exchange status for the corresponding peer
55 * @param msg the encrypted PING message itself
58 GSC_KX_handle_ping (struct GSC_KeyExchangeInfo *kx,
59 const struct GNUNET_MessageHeader *msg);
63 * We received a PONG message. Validate and update our status.
65 * @param kx key exchange status for the corresponding peer
66 * @param msg the encrypted PONG message itself
69 GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx,
70 const struct GNUNET_MessageHeader *msg);
74 * Encrypt and transmit a message with the given payload.
76 * @param kx key exchange context
77 * @param bw_in bandwidth limit to transmit to the other peer;
78 * the other peer shall not send us more than the
80 * @param payload payload of the message
81 * @param payload_size number of bytes in 'payload'
84 GSC_KX_encrypt_and_transmit (struct GSC_KeyExchangeInfo *kx,
85 struct GNUNET_BANDWIDTH_Value32NBO bw_in,
91 * We received an encrypted message. Decrypt, validate and
92 * pass on to the appropriate clients.
94 * @param kx key exchange information context
95 * @param msg encrypted message
96 * @param atsi performance data
97 * @param atsi_count number of entries in ats (excluding 0-termination)
100 GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
101 const struct GNUNET_MessageHeader *msg,
102 const struct GNUNET_TRANSPORT_ATS_Information *atsi,
103 uint32_t atsi_count);
107 * Start the key exchange with the given peer.
109 * @param pid identity of the peer to do a key exchange with
110 * @return key exchange information context
112 struct GSC_KeyExchangeInfo *
113 GSC_KX_start (const struct GNUNET_PeerIdentity *pid);
117 * Stop key exchange with the given peer. Clean up key material.
119 * @param kx key exchange to stop
122 GSC_KX_stop (struct GSC_KeyExchangeInfo *kx);
126 * Initialize KX subsystem.
128 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
135 * Shutdown KX subsystem.
141 /* end of gnunet-service-core_kx.h */