[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: -remove signing from DHTU API: no longer
From: |
gnunet |
Subject: |
[gnunet] branch master updated: -remove signing from DHTU API: no longer needed |
Date: |
Mon, 10 Jan 2022 14:57:23 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new bfd4daf8a -remove signing from DHTU API: no longer needed
bfd4daf8a is described below
commit bfd4daf8ae1a3c6229ee3a8ca944adb2ef7e8677
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Jan 10 14:57:20 2022 +0100
-remove signing from DHTU API: no longer needed
---
src/dhtu/plugin_dhtu_gnunet.c | 182 +++++++--------------------------------
src/dhtu/plugin_dhtu_ip.c | 78 ++++-------------
src/include/gnunet_dhtu_plugin.h | 75 ++--------------
3 files changed, 51 insertions(+), 284 deletions(-)
diff --git a/src/dhtu/plugin_dhtu_gnunet.c b/src/dhtu/plugin_dhtu_gnunet.c
index ee78858c8..2163af941 100644
--- a/src/dhtu/plugin_dhtu_gnunet.c
+++ b/src/dhtu/plugin_dhtu_gnunet.c
@@ -34,42 +34,6 @@
#include "gnunet_nse_service.h"
-/**
- * Handle for a private key used by this underlay.
- */
-struct GNUNET_DHTU_PrivateKey
-{
- /**
- * GNUnet uses eddsa for peers.
- */
- struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv;
-
-};
-
-GNUNET_NETWORK_STRUCT_BEGIN
-
-/**
- * Handle for a public key used by this underlay.
- */
-struct PublicKey
-{
-
- /**
- * Header.
- */
- struct GNUNET_DHTU_PublicKey header;
-
- /**
- * GNUnet uses eddsa for peers.
- */
- struct GNUNET_PeerIdentity peer_pub;
-
-};
-
-
-GNUNET_NETWORK_STRUCT_END
-
-
/**
* Handle for a HELLO we're offering the transport.
*/
@@ -106,19 +70,14 @@ struct GNUNET_DHTU_Source
{
/**
- * Application context for this source.
- */
- void *app_ctx;
-
- /**
- * Hash position of this peer in the DHT.
+ * Hash of @e pid, position of this peer in the DHT overlay.
*/
- struct GNUNET_DHTU_Hash my_id;
+ struct GNUNET_DHTU_HashKey id;
/**
- * Private key of this peer.
+ * Application context for this source.
*/
- struct GNUNET_DHTU_PrivateKey pk;
+ void *app_ctx;
};
@@ -145,17 +104,6 @@ struct GNUNET_DHTU_Target
*/
struct GNUNET_MQ_Handle *mq;
- /**
- * Public key of the peer.
- */
- struct PublicKey pk;
-
- /**
- * Hash of the @a pk to identify position of the peer
- * in the DHT.
- */
- struct GNUNET_DHTU_Hash peer_id;
-
/**
* Head of preferences expressed for this target.
*/
@@ -171,6 +119,16 @@ struct GNUNET_DHTU_Target
*/
struct GNUNET_ATS_ConnectivitySuggestHandle *csh;
+ /**
+ * Identity of this peer.
+ */
+ struct GNUNET_PeerIdentity pid;
+
+ /**
+ * Hash of @e pid, position of this peer in the DHT overlay.
+ */
+ struct GNUNET_DHTU_HashKey id;
+
/**
* Preference counter, length of the @a ph_head DLL.
*/
@@ -214,11 +172,6 @@ struct Plugin
*/
struct GNUNET_DHTU_Source src;
- /**
- * My identity.
- */
- struct GNUNET_PeerIdentity my_identity;
-
/**
* Callbacks into the DHT.
*/
@@ -253,76 +206,13 @@ struct Plugin
* Hellos we are offering to transport.
*/
struct HelloHandle *hh_tail;
-};
-
-/**
- * Use our private key to sign a message.
- *
- * @param cls closure
- * @param pk our private key to sign with
- * @param purpose what to sign
- * @param[out] signature, allocated on heap and returned
- * @return -1 on error, otherwise number of bytes in @a sig
- */
-static ssize_t
-ip_sign (void *cls,
- const struct GNUNET_DHTU_PrivateKey *pk,
- const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
- void **sig)
-{
- struct GNUNET_CRYPTO_EddsaSignature *es;
-
- es = GNUNET_new (struct GNUNET_CRYPTO_EddsaSignature);
- GNUNET_CRYPTO_eddsa_sign_ (&pk->eddsa_priv,
- purpose,
- es);
- *sig = es;
- return sizeof (*es);
-}
-
-
-/**
- * Verify signature in @a sig over @a purpose.
- *
- * @param cls closure
- * @param pk public key to verify signature of
- * @param purpose what was being signed
- * @param sig signature data
- * @param sig_size number of bytes in @a sig
- * @return #GNUNET_OK if signature is valid
- * #GNUNET_NO if signatures are not supported
- * #GNUNET_SYSERR if signature is invalid
- */
-static enum GNUNET_GenericReturnValue
-ip_verify (void *cls,
- const struct GNUNET_DHTU_PublicKey *pk,
- const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
- const void *sig,
- size_t sig_size)
-{
- const struct GNUNET_CRYPTO_EddsaSignature *es = sig;
- const struct PublicKey *pub;
+ /**
+ * Identity of this peer.
+ */
+ struct GNUNET_PeerIdentity my_identity;
- GNUNET_assert (sizeof (struct PublicKey) ==
- ntohs (pk->size));
- pub = (const struct PublicKey *) pk;
- if (sizeof (*es) != sig_size)
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- if (GNUNET_OK !=
- GNUNET_CRYPTO_eddsa_verify_ (ntohl (purpose->purpose),
- purpose,
- es,
- &pub->peer_pub.public_key))
- {
- GNUNET_break_op (0);
- return GNUNET_SYSERR;
- }
- return GNUNET_OK;
-}
+};
/**
@@ -409,7 +299,7 @@ ip_hold (void *cls,
GNUNET_ATS_connectivity_suggest_cancel (target->csh);
target->csh
= GNUNET_ATS_connectivity_suggest (plugin->ats,
- &target->pk.peer_pub,
+ &target->pid,
target->ph_count);
return ph;
}
@@ -439,7 +329,7 @@ ip_drop (struct GNUNET_DHTU_PreferenceHandle *ph)
else
target->csh
= GNUNET_ATS_connectivity_suggest (plugin->ats,
- &target->pk.peer_pub,
+ &target->pid,
target->ph_count);
}
@@ -503,15 +393,13 @@ core_connect_cb (void *cls,
target = GNUNET_new (struct GNUNET_DHTU_Target);
target->plugin = plugin;
target->mq = mq;
- target->pk.header.size = htons (sizeof (struct PublicKey));
- target->pk.peer_pub = *peer;
+ target->pid = *peer;
GNUNET_CRYPTO_hash (peer,
- sizeof (struct GNUNET_PeerIdentity),
- &target->peer_id.hc);
+ sizeof (*peer),
+ &target->id.sha512);
plugin->env->connect_cb (plugin->env->cls,
- &target->pk.header,
- &target->peer_id,
target,
+ &target->id,
&target->app_ctx);
return target;
}
@@ -573,12 +461,11 @@ peerinfo_cb (void *cls,
&GPI_plugins_find);
if (NULL == addr)
return;
- GNUNET_CRYPTO_hash (&plugin->my_identity,
- sizeof (struct GNUNET_PeerIdentity),
- &plugin->src.my_id.hc);
+ GNUNET_CRYPTO_hash (peer,
+ sizeof (*peer),
+ &plugin->src.id.sha512);
plugin->env->address_add_cb (plugin->env->cls,
- &plugin->src.my_id,
- &plugin->src.pk,
+ &plugin->src.id,
addr,
&plugin->src,
&plugin->src.app_ctx);
@@ -729,22 +616,11 @@ libgnunet_plugin_dhtu_ip_init (void *cls)
NULL),
GNUNET_MQ_handler_end ()
};
- struct GNUNET_CRYPTO_EddsaPrivateKey *pk;
- pk = GNUNET_CRYPTO_eddsa_key_create_from_configuration (env->cfg);
- if (NULL == pk)
- {
- GNUNET_break (0);
- return NULL;
- }
plugin = GNUNET_new (struct Plugin);
plugin->env = env;
- plugin->src.pk.eddsa_priv = *pk;
- GNUNET_free (pk);
api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions);
api->cls = plugin;
- api->sign = &ip_sign;
- api->verify = &ip_verify;
api->try_connect = &ip_try_connect;
api->hold = &ip_hold;
api->drop = &ip_drop;
diff --git a/src/dhtu/plugin_dhtu_ip.c b/src/dhtu/plugin_dhtu_ip.c
index ae35adb37..8eec6294b 100644
--- a/src/dhtu/plugin_dhtu_ip.c
+++ b/src/dhtu/plugin_dhtu_ip.c
@@ -55,6 +55,11 @@ struct GNUNET_DHTU_Source
*/
struct GNUNET_DHTU_Source *prev;
+ /**
+ * Position of this peer in the DHT.
+ */
+ struct GNUNET_DHTU_HashKey id;
+
/**
* Application context for this source.
*/
@@ -65,11 +70,6 @@ struct GNUNET_DHTU_Source
*/
char *address;
- /**
- * Hash of the IP address.
- */
- struct GNUNET_DHTU_Hash id;
-
/**
* My actual address.
*/
@@ -110,11 +110,6 @@ struct GNUNET_DHTU_Target
*/
void *app_ctx;
- /**
- * Hash of the IP address.
- */
- struct GNUNET_DHTU_Hash id;
-
/**
* Head of preferences expressed for this target.
*/
@@ -125,6 +120,11 @@ struct GNUNET_DHTU_Target
*/
struct GNUNET_DHTU_PreferenceHandle *ph_tail;
+ /**
+ * Position of this peer in the DHT.
+ */
+ struct GNUNET_DHTU_HashKey id;
+
/**
* Target IP address.
*/
@@ -228,48 +228,6 @@ struct Plugin
};
-/**
- * Use our private key to sign a message.
- *
- * @param cls closure
- * @param pk our private key to sign with
- * @param purpose what to sign
- * @param[out] signature, allocated on heap and returned
- * @return -1 on error, otherwise number of bytes in @a sig
- */
-static ssize_t
-ip_sign (void *cls,
- const struct GNUNET_DHTU_PrivateKey *pk,
- const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
- void **sig)
-{
- return 0;
-}
-
-
-/**
- * Verify signature in @a sig over @a purpose.
- *
- * @param cls closure
- * @param pk public key to verify signature of
- * @param purpose what was being signed
- * @param sig signature data
- * @param sig_size number of bytes in @a sig
- * @return #GNUNET_OK if signature is valid
- * #GNUNET_NO if signatures are not supported
- * #GNUNET_SYSERR if signature is invalid
- */
-static enum GNUNET_GenericReturnValue
-ip_verify (void *cls,
- const struct GNUNET_DHTU_PublicKey *pk,
- const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
- const void *sig,
- size_t sig_size)
-{
- return GNUNET_NO;
-}
-
-
/**
* Create a target to which we may send traffic.
*
@@ -283,7 +241,6 @@ create_target (struct Plugin *plugin,
const struct sockaddr *addr,
socklen_t addrlen)
{
- static struct GNUNET_DHTU_PublicKey pk;
struct GNUNET_DHTU_Target *dst;
if (MAX_DESTS >
@@ -316,7 +273,6 @@ create_target (struct Plugin *plugin,
GNUNET_assert (NULL == dst->ph_head);
GNUNET_free (dst);
}
- pk.size = htons (sizeof (pk));
dst = GNUNET_new (struct GNUNET_DHTU_Target);
dst->addrlen = addrlen;
memcpy (&dst->addr,
@@ -331,7 +287,7 @@ create_target (struct Plugin *plugin,
GNUNET_assert (sizeof (struct sockaddr_in) == addrlen);
GNUNET_CRYPTO_hash (&s4->sin_addr,
sizeof (struct in_addr),
- &dst->id.hc);
+ &dst->id.sha512);
}
break;
case AF_INET6:
@@ -341,7 +297,7 @@ create_target (struct Plugin *plugin,
GNUNET_assert (sizeof (struct sockaddr_in6) == addrlen);
GNUNET_CRYPTO_hash (&s6->sin6_addr,
sizeof (struct in6_addr),
- &dst->id.hc);
+ &dst->id.sha512);
}
break;
default:
@@ -353,9 +309,8 @@ create_target (struct Plugin *plugin,
plugin->dst_tail,
dst);
plugin->env->connect_cb (plugin->env->cls,
- &pk,
- &dst->id,
dst,
+ &dst->id,
&dst->app_ctx);
return dst;
}
@@ -585,7 +540,7 @@ create_source (struct Plugin *plugin,
GNUNET_assert (sizeof (struct sockaddr_in) == addrlen);
GNUNET_CRYPTO_hash (&s4->sin_addr,
sizeof (struct in_addr),
- &src->id.hc);
+ &src->id.sha512);
GNUNET_asprintf (&src->address,
"ip+udp://%s:%u",
inet_ntop (AF_INET,
@@ -603,7 +558,7 @@ create_source (struct Plugin *plugin,
GNUNET_assert (sizeof (struct sockaddr_in6) == addrlen);
GNUNET_CRYPTO_hash (&s6->sin6_addr,
sizeof (struct in6_addr),
- &src->id.hc);
+ &src->id.sha512);
GNUNET_asprintf (&src->address,
"ip+udp://[%s]:%u",
inet_ntop (AF_INET6,
@@ -623,7 +578,6 @@ create_source (struct Plugin *plugin,
src);
plugin->env->address_add_cb (plugin->env->cls,
&src->id,
- NULL, /* no key */
src->address,
src,
&src->app_ctx);
@@ -1023,8 +977,6 @@ libgnunet_plugin_dhtu_ip_init (void *cls)
plugin);
api = GNUNET_new (struct GNUNET_DHTU_PluginFunctions);
api->cls = plugin;
- api->sign = &ip_sign;
- api->verify = &ip_verify;
api->try_connect = &ip_try_connect;
api->hold = &ip_hold;
api->drop = &ip_drop;
diff --git a/src/include/gnunet_dhtu_plugin.h b/src/include/gnunet_dhtu_plugin.h
index e65318fb5..2c97d5848 100644
--- a/src/include/gnunet_dhtu_plugin.h
+++ b/src/include/gnunet_dhtu_plugin.h
@@ -57,36 +57,13 @@ struct GNUNET_DHTU_Target;
*/
struct GNUNET_DHTU_PreferenceHandle;
-/**
- * Opaque handle for a private key used by this underlay.
- */
-struct GNUNET_DHTU_PrivateKey;
/**
- * Handle for a public key used by another peer. Note that
- * the underlay used must be communicated separately.
+ * Key used to identify peer's position in the DHT.
*/
-struct GNUNET_DHTU_PublicKey
+struct GNUNET_DHTU_HashKey
{
- /**
- * How long is the public key, in network byte order.
- */
- uint16_t size;
-
- /* followed by size-2 bytes of the actual public key */
-};
-
-
-/**
- * Hash used by the DHT for keys and peers.
- */
-struct GNUNET_DHTU_Hash
-{
-
- /**
- * For now, use a 512 bit hash. (To be discussed).
- */
- struct GNUNET_HashCode hc;
+ struct GNUNET_HashCode sha512;
};
@@ -111,9 +88,7 @@ struct GNUNET_DHTU_PluginEnvironment
* Function to call with new addresses of this peer.
*
* @param cls the closure
- * @param my_id hash position of this address in the DHT
- * @param pk private key of this peer used at @a address,
- * pointer will remain valid until @e address_del_cb is called
+ * @param key hash position of this address in the DHT
* @param address address under which we are likely reachable,
* pointer will remain valid until @e address_del_cb is called; to
be used for HELLOs. Example: "ip+udp://1.1.1.1:2086/"
* @param source handle for sending from this address, NULL if we can only
receive
@@ -121,8 +96,7 @@ struct GNUNET_DHTU_PluginEnvironment
*/
void
(*address_add_cb)(void *cls,
- const struct GNUNET_DHTU_Hash *my_id,
- const struct GNUNET_DHTU_PrivateKey *pk,
+ struct GNUNET_DHTU_HashKey *key,
const char *address,
struct GNUNET_DHTU_Source *source,
void **ctx);
@@ -164,9 +138,8 @@ struct GNUNET_DHTU_PluginEnvironment
*/
void
(*connect_cb)(void *cls,
- const struct GNUNET_DHTU_PublicKey *pk,
- const struct GNUNET_DHTU_Hash *peer_id,
struct GNUNET_DHTU_Target *target,
+ struct GNUNET_DHTU_HashKey *key,
void **ctx);
/**
@@ -208,41 +181,6 @@ struct GNUNET_DHTU_PluginFunctions
*/
void *cls;
- /**
- * Use our private key to sign a message.
- *
- * @param cls closure
- * @param pk our private key to sign with
- * @param purpose what to sign
- * @param[out] signature, allocated on heap and returned
- * @return -1 on error, otherwise number of bytes in @a sig
- */
- ssize_t
- (*sign)(void *cls,
- const struct GNUNET_DHTU_PrivateKey *pk,
- const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
- void **sig);
-
- /**
- * Verify signature in @a sig over @a purpose.
- *
- * @param cls closure
- * @param pk public key to verify signature of
- * @param purpose what was being signed
- * @param sig signature data
- * @param sig_size number of bytes in @a sig
- * @return #GNUNET_OK if signature is valid
- * #GNUNET_NO if signatures are not supported
- * #GNUNET_SYSERR if signature is invalid
- */
- enum GNUNET_GenericReturnValue
- (*verify)(void *cls,
- const struct GNUNET_DHTU_PublicKey *pk,
- const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
- const void *sig,
- size_t sig_size);
-
-
/**
* Request creation of a session with a peer at the given @a address.
*
@@ -253,6 +191,7 @@ struct GNUNET_DHTU_PluginFunctions
(*try_connect) (void *cls,
const char *address);
+
/**
* Request underlay to keep the connection to @a target alive if possible.
* Hold may be called multiple times to express a strong preference to
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: -remove signing from DHTU API: no longer needed,
gnunet <=