aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/Makefile.am2
-rw-r--r--src/Makefile.am1
-rw-r--r--src/core/gnunet-service-core_kx.c16
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c3
-rw-r--r--src/experimentation/gnunet-daemon-experimentation_experiments.c4
-rw-r--r--src/fs/fs_api.h2
-rw-r--r--src/fs/fs_pseudonym.c130
-rw-r--r--src/fs/fs_publish_ksk.c21
-rw-r--r--src/fs/fs_uri.c14
-rw-r--r--src/fs/test_fs_defaults.conf4
-rw-r--r--src/gns/gns.h11
-rw-r--r--src/gns/gns_api.c37
-rw-r--r--src/gns/gnunet-gns-fcfsd.c8
-rw-r--r--src/gns/gnunet-gns-helper-service-w32.c4
-rw-r--r--src/gns/gnunet-gns-proxy.c20
-rw-r--r--src/gns/gnunet-gns.c14
-rw-r--r--src/gns/gnunet-service-gns.c53
-rw-r--r--src/gns/gnunet-service-gns_resolver.c104
-rw-r--r--src/gns/plugin_block_gns.c2
-rw-r--r--src/gns/test_gns_cname_lookup.c2
-rw-r--r--src/gns/test_gns_dht_delegated_lookup.c6
-rw-r--r--src/gns/test_gns_dht_three_peers.c4
-rw-r--r--src/gns/test_gns_max_queries.c4
-rw-r--r--src/gns/test_gns_ns_lookup.c2
-rw-r--r--src/gns/test_gns_pseu_shorten.c16
-rw-r--r--src/gns/test_gns_revocation.c4
-rw-r--r--src/gns/test_gns_simple_delegated_lookup.c4
-rw-r--r--src/gns/test_gns_simple_get_authority.c6
-rw-r--r--src/gns/test_gns_simple_lookup.c2
-rw-r--r--src/gns/test_gns_simple_mx_lookup.c4
-rw-r--r--src/gns/test_gns_simple_shorten.c10
-rw-r--r--src/gns/test_gns_simple_srv_lookup.c4
-rw-r--r--src/gns/test_gns_simple_zkey_lookup.c4
-rw-r--r--src/hello/gnunet-hello.c2
-rw-r--r--src/hello/hello.c17
-rw-r--r--src/hello/test_friend_hello.c4
-rw-r--r--src/hello/test_hello.c4
-rw-r--r--src/identity/gnunet-service-identity.c81
-rw-r--r--src/identity/identity.h27
-rw-r--r--src/identity/identity_api.c158
-rw-r--r--src/include/block_dns.h2
-rw-r--r--src/include/block_gns.h6
-rw-r--r--src/include/block_regex.h2
-rw-r--r--src/include/gnunet_chat_service.h4
-rw-r--r--src/include/gnunet_crypto_lib.h146
-rw-r--r--src/include/gnunet_fs_service.h18
-rw-r--r--src/include/gnunet_hello_lib.h8
-rw-r--r--src/include/gnunet_identity_service.h41
-rw-r--r--src/include/gnunet_namestore_plugin.h6
-rw-r--r--src/include/gnunet_namestore_service.h8
-rw-r--r--src/include/gnunet_testing_lib.h7
-rw-r--r--src/mesh/gnunet-service-mesh-enc.c6
-rw-r--r--src/mesh/gnunet-service-mesh.c2
-rw-r--r--src/namestore/gnunet-namestore.c6
-rw-r--r--src/namestore/gnunet-service-namestore.c61
-rw-r--r--src/namestore/namestore.h15
-rw-r--r--src/namestore/namestore_api.c32
-rw-r--r--src/namestore/plugin_namestore_postgres.c14
-rw-r--r--src/namestore/plugin_namestore_sqlite.c12
-rw-r--r--src/namestore/test_namestore_api.c4
-rw-r--r--src/namestore/test_namestore_api_create.c12
-rw-r--r--src/namestore/test_namestore_api_create_update.c4
-rw-r--r--src/namestore/test_namestore_api_lookup.c8
-rw-r--r--src/namestore/test_namestore_api_lookup_specific_type.c10
-rw-r--r--src/namestore/test_namestore_api_monitoring.c6
-rw-r--r--src/namestore/test_namestore_api_put.c2
-rw-r--r--src/namestore/test_namestore_api_remove.c8
-rw-r--r--src/namestore/test_namestore_api_remove_not_existing_record.c4
-rw-r--r--src/namestore/test_namestore_api_sign_verify.c2
-rw-r--r--src/namestore/test_namestore_api_zone_iteration.c10
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_specific_zone.c6
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_stop.c6
-rw-r--r--src/namestore/test_namestore_api_zone_to_name.c8
-rw-r--r--src/namestore/test_plugin_namestore.c10
-rw-r--r--src/nse/gnunet-service-nse.c16
-rw-r--r--src/peerinfo-tool/gnunet-peerinfo.c2
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c2
-rwxr-xr-xsrc/peerinfo/perf_peerinfo_api.c2
-rw-r--r--src/peerinfo/test_peerinfo_api.c2
-rw-r--r--src/peerinfo/test_peerinfo_api_friend_only.c2
-rw-r--r--src/peerinfo/test_peerinfo_api_notify_friend_only.c2
-rw-r--r--src/regex/regex_internal_dht.c2
-rw-r--r--src/testing/gnunet-testing.c15
-rw-r--r--src/testing/testing.c14
-rw-r--r--src/transport/gnunet-service-transport.c2
-rw-r--r--src/transport/gnunet-service-transport.h2
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c8
-rw-r--r--src/transport/gnunet-service-transport_validation.c14
-rw-r--r--src/transport/gnunet-service-transport_validation.h3
-rw-r--r--src/transport/test_plugin_transport.c2
-rw-r--r--src/util/crypto_ecc.c727
-rw-r--r--src/util/gnunet-ecc.c25
-rw-r--r--src/util/test_crypto_ecc.c14
93 files changed, 1123 insertions, 1044 deletions
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index e32ab0e28..b87b28e41 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -77,7 +77,9 @@ do_subst = $(SED) -e 's,[@]PYTHON[@],$(PYTHON),g'
77check_PROGRAMS = \ 77check_PROGRAMS = \
78 test_gnunet_prefix 78 test_gnunet_prefix
79 79
80if ENABLE_TEST_RUN
80TESTS = $(check_PROGRAMS) 81TESTS = $(check_PROGRAMS)
82endif
81 83
82test_gnunet_prefix_SOURCES = \ 84test_gnunet_prefix_SOURCES = \
83 test_gnunet_prefix.c 85 test_gnunet_prefix.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 00c4d6f93..9126815f4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -64,7 +64,6 @@ SUBDIRS = \
64 dns \ 64 dns \
65 identity \ 65 identity \
66 set \ 66 set \
67 fs \
68 $(LINUX_DIR) \ 67 $(LINUX_DIR) \
69 $(MINGW_DIR) \ 68 $(MINGW_DIR) \
70 gns \ 69 gns \
diff --git a/src/core/gnunet-service-core_kx.c b/src/core/gnunet-service-core_kx.c
index 14b509e8f..09f92f224 100644
--- a/src/core/gnunet-service-core_kx.c
+++ b/src/core/gnunet-service-core_kx.c
@@ -111,12 +111,12 @@ struct EphemeralKeyMessage
111 * Ephemeral public ECC key (always for NIST P-521) encoded in a format suitable 111 * Ephemeral public ECC key (always for NIST P-521) encoded in a format suitable
112 * for network transmission as created using 'gcry_sexp_sprint'. 112 * for network transmission as created using 'gcry_sexp_sprint'.
113 */ 113 */
114 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded ephemeral_key; 114 struct GNUNET_CRYPTO_EccPublicKey ephemeral_key;
115 115
116 /** 116 /**
117 * Public key of the signing peer (persistent version, not the ephemeral public key). 117 * Public key of the signing peer (persistent version, not the ephemeral public key).
118 */ 118 */
119 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded origin_public_key; 119 struct GNUNET_CRYPTO_EccPublicKey origin_public_key;
120 120
121}; 121};
122 122
@@ -392,7 +392,7 @@ static struct EphemeralKeyMessage current_ekm;
392/** 392/**
393 * Our public key. 393 * Our public key.
394 */ 394 */
395static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded my_public_key; 395static struct GNUNET_CRYPTO_EccPublicKey my_public_key;
396 396
397/** 397/**
398 * Our message stream tokenizer (for encrypted payload). 398 * Our message stream tokenizer (for encrypted payload).
@@ -771,7 +771,7 @@ GSC_KX_handle_ephemeral_key (struct GSC_KeyExchangeInfo *kx,
771 "Core service receives `%s' request from `%4s'.\n", "EPHEMERAL_KEY", 771 "Core service receives `%s' request from `%4s'.\n", "EPHEMERAL_KEY",
772 GNUNET_i2s (&kx->peer)); 772 GNUNET_i2s (&kx->peer));
773 GNUNET_CRYPTO_hash (&m->origin_public_key, 773 GNUNET_CRYPTO_hash (&m->origin_public_key,
774 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 774 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
775 &signer_id.hashPubKey); 775 &signer_id.hashPubKey);
776 if (0 != 776 if (0 !=
777 memcmp (&signer_id, &kx->peer, 777 memcmp (&signer_id, &kx->peer,
@@ -784,8 +784,8 @@ GSC_KX_handle_ephemeral_key (struct GSC_KeyExchangeInfo *kx,
784 sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + 784 sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
785 sizeof (struct GNUNET_TIME_AbsoluteNBO) + 785 sizeof (struct GNUNET_TIME_AbsoluteNBO) +
786 sizeof (struct GNUNET_TIME_AbsoluteNBO) + 786 sizeof (struct GNUNET_TIME_AbsoluteNBO) +
787 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded) + 787 sizeof (struct GNUNET_CRYPTO_EccPublicKey) +
788 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)) || 788 sizeof (struct GNUNET_CRYPTO_EccPublicKey)) ||
789 (GNUNET_OK != 789 (GNUNET_OK !=
790 GNUNET_CRYPTO_ecc_verify (GNUNET_SIGNATURE_PURPOSE_SET_ECC_KEY, 790 GNUNET_CRYPTO_ecc_verify (GNUNET_SIGNATURE_PURPOSE_SET_ECC_KEY,
791 &m->purpose, 791 &m->purpose,
@@ -1476,8 +1476,8 @@ sign_ephemeral_key ()
1476 current_ekm.purpose.size = htonl (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + 1476 current_ekm.purpose.size = htonl (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
1477 sizeof (struct GNUNET_TIME_AbsoluteNBO) + 1477 sizeof (struct GNUNET_TIME_AbsoluteNBO) +
1478 sizeof (struct GNUNET_TIME_AbsoluteNBO) + 1478 sizeof (struct GNUNET_TIME_AbsoluteNBO) +
1479 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded) + 1479 sizeof (struct GNUNET_CRYPTO_EccPublicKey) +
1480 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)); 1480 sizeof (struct GNUNET_CRYPTO_EccPublicKey));
1481 current_ekm.creation_time = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); 1481 current_ekm.creation_time = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
1482 if (GNUNET_YES == 1482 if (GNUNET_YES ==
1483 GNUNET_CONFIGURATION_get_value_yesno (GSC_cfg, 1483 GNUNET_CONFIGURATION_get_value_yesno (GSC_cfg,
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index f3c868d97..16955629c 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -49,9 +49,6 @@
49#include <fenv.h> 49#include <fenv.h>
50#include "dht.h" 50#include "dht.h"
51 51
52#include "../regex/regex_block_lib.h"
53
54
55#define LOG_TRAFFIC(kind,...) GNUNET_log_from (kind, "dht-traffic",__VA_ARGS__) 52#define LOG_TRAFFIC(kind,...) GNUNET_log_from (kind, "dht-traffic",__VA_ARGS__)
56 53
57/** 54/**
diff --git a/src/experimentation/gnunet-daemon-experimentation_experiments.c b/src/experimentation/gnunet-daemon-experimentation_experiments.c
index 343544ba8..99348a2cb 100644
--- a/src/experimentation/gnunet-daemon-experimentation_experiments.c
+++ b/src/experimentation/gnunet-daemon-experimentation_experiments.c
@@ -38,7 +38,7 @@
38 */ 38 */
39struct Issuer 39struct Issuer
40{ 40{
41 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey; 41 struct GNUNET_CRYPTO_EccPublicKey pubkey;
42}; 42};
43 43
44 44
@@ -410,7 +410,7 @@ GED_experiments_start ()
410 char *pubkey; 410 char *pubkey;
411 char *pos; 411 char *pos;
412 struct GNUNET_PeerIdentity issuer_ID; 412 struct GNUNET_PeerIdentity issuer_ID;
413 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pub; 413 struct GNUNET_CRYPTO_EccPublicKey pub;
414 struct GNUNET_HashCode hash; 414 struct GNUNET_HashCode hash;
415 415
416 /* Load valid issuer */ 416 /* Load valid issuer */
diff --git a/src/fs/fs_api.h b/src/fs/fs_api.h
index f3daeb85a..2fe38f604 100644
--- a/src/fs/fs_api.h
+++ b/src/fs/fs_api.h
@@ -125,7 +125,7 @@ struct Location
125 /** 125 /**
126 * Identity of the peer sharing the file. 126 * Identity of the peer sharing the file.
127 */ 127 */
128 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded peer; 128 struct GNUNET_CRYPTO_EccPublicKey peer;
129 129
130 /** 130 /**
131 * Time when this location URI expires. 131 * Time when this location URI expires.
diff --git a/src/fs/fs_pseudonym.c b/src/fs/fs_pseudonym.c
index 49a084199..36eaab6fa 100644
--- a/src/fs/fs_pseudonym.c
+++ b/src/fs/fs_pseudonym.c
@@ -104,9 +104,8 @@ static struct GNUNET_FS_pseudonym_DiscoveryHandle *disco_head;
104static struct GNUNET_FS_pseudonym_DiscoveryHandle *disco_tail; 104static struct GNUNET_FS_pseudonym_DiscoveryHandle *disco_tail;
105 105
106/** 106/**
107 * Pointer to indiate 'anonymous' pseudonym (global static, all 107 * Pointer to indiate 'anonymous' pseudonym (global static,
108 * zeros). We actually use pointer comparisson to detect the 108 * d=1, public key = G (generator).
109 * "anonymous" pseudonym handle.
110 */ 109 */
111static struct GNUNET_FS_PseudonymHandle anonymous; 110static struct GNUNET_FS_PseudonymHandle anonymous;
112 111
@@ -1019,6 +1018,68 @@ GNUNET_FS_pseudonym_create_from_existing_file (const char *filename)
1019struct GNUNET_FS_PseudonymHandle * 1018struct GNUNET_FS_PseudonymHandle *
1020GNUNET_FS_pseudonym_get_anonymous_pseudonym_handle () 1019GNUNET_FS_pseudonym_get_anonymous_pseudonym_handle ()
1021{ 1020{
1021 static int once;
1022 gcry_mpi_t d;
1023 size_t size;
1024 gcry_ctx_t ctx;
1025 int rc;
1026 gcry_mpi_t g_x;
1027 gcry_mpi_t g_y;
1028 gcry_mpi_point_t g;
1029
1030 if (once)
1031 return &anonymous;
1032 d = gcry_mpi_new (1);
1033 gcry_mpi_set_ui (d, 1);
1034 size = sizeof (anonymous.d);
1035 GNUNET_assert (0 ==
1036 gcry_mpi_print (GCRYMPI_FMT_USG, anonymous.d, size, &size,
1037 d));
1038 gcry_mpi_release (d);
1039 adjust (anonymous.d, size, sizeof (anonymous.d));
1040
1041 /* create basic ECC context */
1042 if (0 != (rc = gcry_mpi_ec_new (&ctx, NULL, "NIST P-256")))
1043 {
1044 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR,
1045 "gcry_mpi_ec_new", rc);
1046 return NULL;
1047 }
1048
1049 g = gcry_mpi_ec_get_point ("g", ctx, 0);
1050 g_x = gcry_mpi_new (256);
1051 g_y = gcry_mpi_new (256);
1052 gcry_mpi_ec_get_affine (g_x, g_y, g, ctx);
1053 gcry_mpi_point_release (g);
1054 gcry_ctx_release (ctx);
1055
1056 /* store g_x/g_y in public key */
1057 size = sizeof (anonymous.public_key.q_x);
1058 if (0 !=
1059 gcry_mpi_print (GCRYMPI_FMT_USG, anonymous.public_key.q_x, size, &size,
1060 g_x))
1061 {
1062 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_print", rc);
1063 gcry_mpi_release (g_x);
1064 gcry_mpi_release (g_y);
1065 return NULL;
1066 }
1067 adjust (anonymous.public_key.q_x, size, sizeof (anonymous.public_key.q_x));
1068 gcry_mpi_release (g_x);
1069
1070 size = sizeof (anonymous.public_key.q_y);
1071 if (0 !=
1072 gcry_mpi_print (GCRYMPI_FMT_USG, anonymous.public_key.q_y, size, &size,
1073 g_y))
1074 {
1075 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_print", rc);
1076 gcry_mpi_release (g_y);
1077 return NULL;
1078 }
1079 adjust (anonymous.public_key.q_y, size, sizeof (anonymous.public_key.q_y));
1080 gcry_mpi_release (g_y);
1081
1082 once = 1;
1022 return &anonymous; 1083 return &anonymous;
1023} 1084}
1024 1085
@@ -1122,21 +1183,13 @@ GNUNET_FS_pseudonym_sign (struct GNUNET_FS_PseudonymHandle *ph,
1122 int rc; 1183 int rc;
1123 1184
1124 /* get private key 'd' from pseudonym */ 1185 /* get private key 'd' from pseudonym */
1125 if (&anonymous == ph) 1186 size = sizeof (ph->d);
1126 { 1187 if (0 != (rc = gcry_mpi_scan (&d, GCRYMPI_FMT_USG,
1127 d = gcry_mpi_new (0); 1188 &ph->d,
1128 gcry_mpi_set_ui (d, 0); 1189 size, &size)))
1129 }
1130 else
1131 { 1190 {
1132 size = sizeof (ph->d); 1191 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc);
1133 if (0 != (rc = gcry_mpi_scan (&d, GCRYMPI_FMT_USG, 1192 return GNUNET_SYSERR;
1134 &ph->d,
1135 size, &size)))
1136 {
1137 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc);
1138 return GNUNET_SYSERR;
1139 }
1140 } 1193 }
1141 /* get 'x' value from signing key */ 1194 /* get 'x' value from signing key */
1142 size = sizeof (struct GNUNET_HashCode); 1195 size = sizeof (struct GNUNET_HashCode);
@@ -1159,9 +1212,9 @@ GNUNET_FS_pseudonym_sign (struct GNUNET_FS_PseudonymHandle *ph,
1159 return GNUNET_SYSERR; 1212 return GNUNET_SYSERR;
1160 } 1213 }
1161 1214
1162 /* calculate dx = d + h mod n */ 1215 /* calculate dh = d * h mod n */
1163 dh = gcry_mpi_new (256); 1216 dh = gcry_mpi_new (256);
1164 gcry_mpi_addm (dh, d, h, n); 1217 gcry_mpi_mulm (dh, d, h, n);
1165 gcry_mpi_release (d); 1218 gcry_mpi_release (d);
1166 gcry_mpi_release (h); 1219 gcry_mpi_release (h);
1167 gcry_mpi_release (n); 1220 gcry_mpi_release (n);
@@ -1297,7 +1350,7 @@ get_context_from_pseudonym (struct GNUNET_FS_PseudonymIdentifier *pseudonym)
1297 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_ec_new", rc); /* erroff gives more info */ 1350 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_ec_new", rc); /* erroff gives more info */
1298 return NULL; 1351 return NULL;
1299 } 1352 }
1300 /* initialize 'ctx' with 'q' = 0 */ 1353 /* FIXME: initialize 'ctx' with 'q' = G */
1301 zero = gcry_mpi_new (0); 1354 zero = gcry_mpi_new (0);
1302 gcry_mpi_set_ui (zero, 0); 1355 gcry_mpi_set_ui (zero, 0);
1303 q = gcry_mpi_point_new (0); 1356 q = gcry_mpi_point_new (0);
@@ -1346,7 +1399,7 @@ get_context_from_pseudonym (struct GNUNET_FS_PseudonymIdentifier *pseudonym)
1346 * @param pseudonym the public key (dQ in ECDSA) 1399 * @param pseudonym the public key (dQ in ECDSA)
1347 * @param signing_key input to derive 'h' (see section 2.4 of #2564) 1400 * @param signing_key input to derive 'h' (see section 2.4 of #2564)
1348 * @param verification_key resulting public key to verify the signature 1401 * @param verification_key resulting public key to verify the signature
1349 * created from the '(d+h)' of 'pseudonym' and the 'signing_key'; 1402 * created from the '(d*h)' of 'pseudonym' and the 'signing_key';
1350 * the value stored here can then be given to GNUNET_FS_pseudonym_verify. 1403 * the value stored here can then be given to GNUNET_FS_pseudonym_verify.
1351 * @return GNUNET_OK on success, GNUNET_SYSERR on error 1404 * @return GNUNET_OK on success, GNUNET_SYSERR on error
1352 */ 1405 */
@@ -1359,12 +1412,12 @@ GNUNET_FS_pseudonym_derive_verification_key (struct GNUNET_FS_PseudonymIdentifie
1359 size_t size; 1412 size_t size;
1360 int rc; 1413 int rc;
1361 gcry_ctx_t ctx; 1414 gcry_ctx_t ctx;
1362 gcry_mpi_point_t g;
1363 gcry_mpi_point_t q; 1415 gcry_mpi_point_t q;
1364 gcry_mpi_point_t hg;
1365 gcry_mpi_point_t v; 1416 gcry_mpi_point_t v;
1366 gcry_mpi_t v_x; 1417 gcry_mpi_t v_x;
1367 gcry_mpi_t v_y; 1418 gcry_mpi_t v_y;
1419 gcry_mpi_t h_mod_n;
1420 gcry_mpi_t n; /* n from P-256 */
1368 1421
1369 /* get 'h' value from signing key */ 1422 /* get 'h' value from signing key */
1370 size = sizeof (struct GNUNET_HashCode); 1423 size = sizeof (struct GNUNET_HashCode);
@@ -1381,22 +1434,26 @@ GNUNET_FS_pseudonym_derive_verification_key (struct GNUNET_FS_PseudonymIdentifie
1381 gcry_mpi_release (h); 1434 gcry_mpi_release (h);
1382 return GNUNET_SYSERR; 1435 return GNUNET_SYSERR;
1383 } 1436 }
1384 /* get G */ 1437 /* initialize 'n' from P-256; hex copied from libgcrypt code */
1385 g = gcry_mpi_ec_get_point ("g", ctx, 0); 1438 if (0 != (rc = gcry_mpi_scan (&n, GCRYMPI_FMT_HEX,
1386 1439 "0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551", 0, NULL)))
1387 /* then call the 'multiply' function, to compute the product hG */ 1440 {
1388 hg = gcry_mpi_point_new (0); 1441 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc);
1389 gcry_mpi_ec_mul (hg, h, g, ctx); 1442 gcry_mpi_release (h);
1390 gcry_mpi_point_release (g); 1443 return GNUNET_SYSERR;
1444 }
1445 h_mod_n = gcry_mpi_new (0);
1446 gcry_mpi_mod (h_mod_n, h, n);
1391 gcry_mpi_release (h); 1447 gcry_mpi_release (h);
1392 1448
1393 /* get Q = dG from 'pseudonym' */ 1449 /* get Q = dG from 'pseudonym' */
1394 q = gcry_mpi_ec_get_point ("q", ctx, 0); 1450 q = gcry_mpi_ec_get_point ("q", ctx, 0);
1395 /* calculate V = Q + hG = dG + hG = (d + h)G*/ 1451 /* calculate V = hQ = hdG */
1396 v = gcry_mpi_point_new (0); 1452 v = gcry_mpi_point_new (0);
1397 gcry_mpi_ec_add (v, q, hg, ctx);
1398 gcry_mpi_point_release (hg);
1399 1453
1454 gcry_mpi_ec_mul (v, h_mod_n, q, ctx);
1455 gcry_mpi_release (h_mod_n);
1456
1400 /* store 'v' point in "verification_key" */ 1457 /* store 'v' point in "verification_key" */
1401 v_x = gcry_mpi_new (256); 1458 v_x = gcry_mpi_new (256);
1402 v_y = gcry_mpi_new (256); 1459 v_y = gcry_mpi_new (256);
@@ -1566,11 +1623,8 @@ void
1566GNUNET_FS_pseudonym_get_identifier (struct GNUNET_FS_PseudonymHandle *ph, 1623GNUNET_FS_pseudonym_get_identifier (struct GNUNET_FS_PseudonymHandle *ph,
1567 struct GNUNET_FS_PseudonymIdentifier *pseudonym) 1624 struct GNUNET_FS_PseudonymIdentifier *pseudonym)
1568{ 1625{
1569 if (&anonymous == ph) 1626 memcpy (pseudonym, &ph->public_key,
1570 memset (pseudonym, 0, sizeof (struct GNUNET_FS_PseudonymIdentifier)); 1627 sizeof (struct GNUNET_FS_PseudonymIdentifier));
1571 else
1572 memcpy (pseudonym, &ph->public_key,
1573 sizeof (struct GNUNET_FS_PseudonymIdentifier));
1574} 1628}
1575 1629
1576 1630
diff --git a/src/fs/fs_publish_ksk.c b/src/fs/fs_publish_ksk.c
index 3b0f1d4fb..10512af5f 100644
--- a/src/fs/fs_publish_ksk.c
+++ b/src/fs/fs_publish_ksk.c
@@ -177,23 +177,35 @@ publish_ksk_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
177 struct UBlock *ub_dst; 177 struct UBlock *ub_dst;
178 178
179 pkc->ksk_task = GNUNET_SCHEDULER_NO_TASK; 179 pkc->ksk_task = GNUNET_SCHEDULER_NO_TASK;
180 if ((pkc->i == pkc->ksk_uri->data.ksk.keywordCount) || (NULL == pkc->dsh)) 180 if ( (pkc->i == pkc->ksk_uri->data.ksk.keywordCount) ||
181 (NULL == pkc->dsh) )
181 { 182 {
182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "KSK PUT operation complete\n"); 183 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "KSK PUT operation complete\n");
183 pkc->cont (pkc->cont_cls, pkc->ksk_uri, NULL); 184 pkc->cont (pkc->cont_cls, pkc->ksk_uri, NULL);
184 GNUNET_FS_publish_ksk_cancel (pkc); 185 GNUNET_FS_publish_ksk_cancel (pkc);
185 return; 186 return;
186 } 187 }
188 keyword = pkc->ksk_uri->data.ksk.keywords[pkc->i++];
189 pkc->sks_task = GNUNET_FS_publish_sks (pkc->h,
190 anonymous,
191 keyword, NULL,
192 pkc->meta,
193 pkc->uri,
194 &pkc->bo,
195 pkc->options,
196 &publish_ksk_cont, pkc);
197
198
187 /* derive signing seed from plaintext */ 199 /* derive signing seed from plaintext */
188 GNUNET_CRYPTO_hash (&pkc->ub[1], 200 GNUNET_CRYPTO_hash (&pkc->ub[1],
189 1 + pkc->slen + pkc->mdsize, 201 1 + pkc->slen + pkc->mdsize,
190 &seed); 202 &seed);
191 keyword = pkc->ksk_uri->data.ksk.keywords[pkc->i++];
192 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing under keyword `%s'\n", 203 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Publishing under keyword `%s'\n",
193 &keyword[1]); 204 &keyword[1]);
194 /* first character of keyword indicates if it is 205 /* first character of keyword indicates if it is
195 * mandatory or not -- ignore for hashing */ 206 * mandatory or not -- ignore for hashing */
196 GNUNET_CRYPTO_hash (&keyword[1], strlen (&keyword[1]), &key); 207 GNUNET_CRYPTO_hash (&keyword[1], strlen (&keyword[1]), &key);
208
197 GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv); 209 GNUNET_CRYPTO_hash_to_aes_key (&key, &skey, &iv);
198 ub_dst = pkc->cpy; 210 ub_dst = pkc->cpy;
199 GNUNET_CRYPTO_aes_encrypt (&pkc->ub[1], 211 GNUNET_CRYPTO_aes_encrypt (&pkc->ub[1],
@@ -202,8 +214,9 @@ publish_ksk_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
202 &ub_dst[1]); 214 &ub_dst[1]);
203 ph = GNUNET_FS_pseudonym_get_anonymous_pseudonym_handle (); 215 ph = GNUNET_FS_pseudonym_get_anonymous_pseudonym_handle ();
204 GNUNET_CRYPTO_hash (&key, sizeof (key), &signing_key); 216 GNUNET_CRYPTO_hash (&key, sizeof (key), &signing_key);
205 ub_dst->purpose.size = htonl (1 + pkc->slen + pkc->mdsize + sizeof (struct UBlock) 217 ub_dst->purpose.size = htonl (1 + pkc->slen + pkc->mdsize +
206 - sizeof (struct GNUNET_FS_PseudonymSignature)); 218 sizeof (struct UBlock)
219 - sizeof (struct GNUNET_FS_PseudonymSignature));
207 ub_dst->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_UBLOCK); 220 ub_dst->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_FS_UBLOCK);
208 221
209 GNUNET_FS_pseudonym_get_identifier (ph, &pseudonym); 222 GNUNET_FS_pseudonym_get_identifier (ph, &pseudonym);
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c
index 48c347a52..78b5459fd 100644
--- a/src/fs/fs_uri.c
+++ b/src/fs/fs_uri.c
@@ -117,7 +117,7 @@ GNUNET_FS_uri_to_key (const struct GNUNET_FS_Uri *uri, struct GNUNET_HashCode *
117 case GNUNET_FS_URI_LOC: 117 case GNUNET_FS_URI_LOC:
118 GNUNET_CRYPTO_hash (&uri->data.loc.fi, 118 GNUNET_CRYPTO_hash (&uri->data.loc.fi,
119 sizeof (struct FileIdentifier) + 119 sizeof (struct FileIdentifier) +
120 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 120 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
121 key); 121 key);
122 break; 122 break;
123 default: 123 default:
@@ -520,7 +520,7 @@ struct LocUriAssembly
520 520
521 struct FileIdentifier fi; 521 struct FileIdentifier fi;
522 522
523 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded peer; 523 struct GNUNET_CRYPTO_EccPublicKey peer;
524 524
525}; 525};
526 526
@@ -591,7 +591,7 @@ uri_loc_parse (const char *s, char **emsg)
591 npos++; 591 npos++;
592 ret = 592 ret =
593 enc2bin (&s[npos], &ass.peer, 593 enc2bin (&s[npos], &ass.peer,
594 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)); 594 sizeof (struct GNUNET_CRYPTO_EccPublicKey));
595 if (ret == -1) 595 if (ret == -1)
596 { 596 {
597 *emsg = 597 *emsg =
@@ -828,7 +828,7 @@ GNUNET_FS_uri_loc_get_peer_identity (const struct GNUNET_FS_Uri *uri,
828 if (uri->type != GNUNET_FS_URI_LOC) 828 if (uri->type != GNUNET_FS_URI_LOC)
829 return GNUNET_SYSERR; 829 return GNUNET_SYSERR;
830 GNUNET_CRYPTO_hash (&uri->data.loc.peer, 830 GNUNET_CRYPTO_hash (&uri->data.loc.peer,
831 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 831 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
832 &peer->hashPubKey); 832 &peer->hashPubKey);
833 return GNUNET_OK; 833 return GNUNET_OK;
834} 834}
@@ -884,7 +884,7 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri,
884{ 884{
885 struct GNUNET_FS_Uri *uri; 885 struct GNUNET_FS_Uri *uri;
886 struct GNUNET_CRYPTO_EccPrivateKey *my_private_key; 886 struct GNUNET_CRYPTO_EccPrivateKey *my_private_key;
887 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded my_public_key; 887 struct GNUNET_CRYPTO_EccPublicKey my_public_key;
888 char *keyfile; 888 char *keyfile;
889 struct LocUriAssembly ass; 889 struct LocUriAssembly ass;
890 890
@@ -1307,7 +1307,7 @@ GNUNET_FS_uri_test_equal (const struct GNUNET_FS_Uri *u1,
1307 if (memcmp 1307 if (memcmp
1308 (&u1->data.loc, &u2->data.loc, 1308 (&u1->data.loc, &u2->data.loc,
1309 sizeof (struct FileIdentifier) + 1309 sizeof (struct FileIdentifier) +
1310 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded) + 1310 sizeof (struct GNUNET_CRYPTO_EccPublicKey) +
1311 sizeof (struct GNUNET_TIME_Absolute) + sizeof (unsigned short) + 1311 sizeof (struct GNUNET_TIME_Absolute) + sizeof (unsigned short) +
1312 sizeof (unsigned short)) != 0) 1312 sizeof (unsigned short)) != 0)
1313 return GNUNET_NO; 1313 return GNUNET_NO;
@@ -2049,7 +2049,7 @@ uri_loc_to_string (const struct GNUNET_FS_Uri *uri)
2049 GNUNET_CRYPTO_hash_to_enc (&uri->data.loc.fi.chk.query, &queryhash); 2049 GNUNET_CRYPTO_hash_to_enc (&uri->data.loc.fi.chk.query, &queryhash);
2050 peerId = 2050 peerId =
2051 bin2enc (&uri->data.loc.peer, 2051 bin2enc (&uri->data.loc.peer,
2052 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)); 2052 sizeof (struct GNUNET_CRYPTO_EccPublicKey));
2053 peerSig = 2053 peerSig =
2054 bin2enc (&uri->data.loc.contentSignature, 2054 bin2enc (&uri->data.loc.contentSignature,
2055 sizeof (struct GNUNET_CRYPTO_EccSignature)); 2055 sizeof (struct GNUNET_CRYPTO_EccSignature));
diff --git a/src/fs/test_fs_defaults.conf b/src/fs/test_fs_defaults.conf
index 7d87c0e2f..dd0d729e2 100644
--- a/src/fs/test_fs_defaults.conf
+++ b/src/fs/test_fs_defaults.conf
@@ -92,3 +92,7 @@ AUTOSTART = NO
92 92
93[consensus] 93[consensus]
94AUTOSTART = NO 94AUTOSTART = NO
95
96[mesh]
97REFRESH_PATH_TIME = 30 min
98
diff --git a/src/gns/gns.h b/src/gns/gns.h
index e5d48fa27..a4830bda4 100644
--- a/src/gns/gns.h
+++ b/src/gns/gns.h
@@ -71,9 +71,9 @@ struct GNUNET_GNS_ClientLookupMessage
71 uint32_t only_cached GNUNET_PACKED; 71 uint32_t only_cached GNUNET_PACKED;
72 72
73 /** 73 /**
74 * Should we look up in the default zone? 74 * Should we look up in the given zone, instead of the default zone?
75 */ 75 */
76 uint32_t use_default_zone GNUNET_PACKED; 76 uint32_t have_zone GNUNET_PACKED;
77 77
78 /** 78 /**
79 * Is a shorten key attached? 79 * Is a shorten key attached?
@@ -84,8 +84,11 @@ struct GNUNET_GNS_ClientLookupMessage
84 * the type of record to look up 84 * the type of record to look up
85 */ 85 */
86 /* enum GNUNET_GNS_RecordType */ uint32_t type; 86 /* enum GNUNET_GNS_RecordType */ uint32_t type;
87 87
88 /* Followed by the key for shorten (optional) see have_key */ 88 /**
89 * The key for shorten, if 'have_key' is set
90 */
91 struct GNUNET_CRYPTO_EccPrivateKey shorten_key;
89 92
90 /* Followed by the name to look up */ 93 /* Followed by the name to look up */
91}; 94};
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c
index fe378a922..e672c5687 100644
--- a/src/gns/gns_api.c
+++ b/src/gns/gns_api.c
@@ -832,35 +832,20 @@ GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle,
832 struct GNUNET_GNS_LookupRequest *lr; 832 struct GNUNET_GNS_LookupRequest *lr;
833 size_t msize; 833 size_t msize;
834 struct PendingMessage *pending; 834 struct PendingMessage *pending;
835 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *pkey_enc;
836 size_t key_len;
837 char* pkey_tmp;
838 835
839 if (NULL == name) 836 if (NULL == name)
840 { 837 {
841 GNUNET_break (0); 838 GNUNET_break (0);
842 return NULL; 839 return NULL;
843 } 840 }
844 if (NULL != shorten_key)
845 {
846 pkey_enc = GNUNET_CRYPTO_ecc_encode_key (shorten_key);
847 GNUNET_assert (pkey_enc != NULL);
848 key_len = ntohs (pkey_enc->size);
849 }
850 else
851 {
852 pkey_enc = NULL;
853 key_len = 0;
854 }
855 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 841 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
856 "Trying to lookup `%s' in GNS\n", 842 "Trying to lookup `%s' in GNS\n",
857 name); 843 name);
858 msize = sizeof (struct GNUNET_GNS_ClientLookupMessage) 844 msize = sizeof (struct GNUNET_GNS_ClientLookupMessage)
859 + key_len + strlen (name) + 1; 845 + strlen (name) + 1;
860 if (msize > UINT16_MAX) 846 if (msize > UINT16_MAX)
861 { 847 {
862 GNUNET_break (0); 848 GNUNET_break (0);
863 GNUNET_free (pkey_enc);
864 return NULL; 849 return NULL;
865 } 850 }
866 lr = GNUNET_malloc (sizeof (struct GNUNET_GNS_LookupRequest) + 851 lr = GNUNET_malloc (sizeof (struct GNUNET_GNS_LookupRequest) +
@@ -882,26 +867,16 @@ GNUNET_GNS_lookup_zone (struct GNUNET_GNS_Handle *handle,
882 lookup_msg->only_cached = htonl (only_cached); 867 lookup_msg->only_cached = htonl (only_cached);
883 if (NULL != zone) 868 if (NULL != zone)
884 { 869 {
885 lookup_msg->use_default_zone = htonl (GNUNET_NO); 870 lookup_msg->have_zone = htonl (GNUNET_YES);
886 memcpy (&lookup_msg->zone, zone, sizeof (struct GNUNET_CRYPTO_ShortHashCode)); 871 lookup_msg->zone = *zone;
887 } 872 }
888 else
889 {
890 lookup_msg->use_default_zone = htonl (GNUNET_YES);
891 memset (&lookup_msg->zone, 0, sizeof(struct GNUNET_CRYPTO_ShortHashCode));
892 }
893 lookup_msg->type = htonl (type); 873 lookup_msg->type = htonl (type);
894 pkey_tmp = (char *) &lookup_msg[1]; 874 if (NULL != shorten_key)
895 if (pkey_enc != NULL)
896 { 875 {
897 lookup_msg->have_key = htonl (GNUNET_YES); 876 lookup_msg->have_key = htonl (GNUNET_YES);
898 memcpy (pkey_tmp, pkey_enc, key_len); 877 lookup_msg->shorten_key = *shorten_key;
899 } 878 }
900 else 879 memcpy (&lookup_msg[1], name, strlen (name) + 1);
901 lookup_msg->have_key = htonl (GNUNET_NO);
902 GNUNET_free_non_null (pkey_enc);
903 memcpy (&pkey_tmp[key_len], name, strlen (name) + 1);
904
905 GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, 880 GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head,
906 handle->pending_tail, 881 handle->pending_tail,
907 pending); 882 pending);
diff --git a/src/gns/gnunet-gns-fcfsd.c b/src/gns/gnunet-gns-fcfsd.c
index 25fde90ec..832060583 100644
--- a/src/gns/gnunet-gns-fcfsd.c
+++ b/src/gns/gnunet-gns-fcfsd.c
@@ -229,7 +229,7 @@ run_httpd_now ()
229 229
230static void 230static void
231iterate_cb (void *cls, 231iterate_cb (void *cls,
232 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 232 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
233 struct GNUNET_TIME_Absolute expire, 233 struct GNUNET_TIME_Absolute expire,
234 const char *name, 234 const char *name,
235 unsigned int rd_len, 235 unsigned int rd_len,
@@ -506,7 +506,7 @@ put_continuation (void *cls,
506 */ 506 */
507static void 507static void
508zone_to_name_cb (void *cls, 508zone_to_name_cb (void *cls,
509 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 509 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
510 struct GNUNET_TIME_Absolute expire, 510 struct GNUNET_TIME_Absolute expire,
511 const char *name, 511 const char *name,
512 unsigned int rd_count, 512 unsigned int rd_count,
@@ -566,7 +566,7 @@ zone_to_name_cb (void *cls,
566 */ 566 */
567static void 567static void
568lookup_result_processor (void *cls, 568lookup_result_processor (void *cls,
569 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 569 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
570 struct GNUNET_TIME_Absolute expire, 570 struct GNUNET_TIME_Absolute expire,
571 const char *name, 571 const char *name,
572 unsigned int rd_count, 572 unsigned int rd_count,
@@ -883,7 +883,7 @@ run (void *cls, char *const *args, const char *cfgfile,
883{ 883{
884 char *keyfile; 884 char *keyfile;
885 unsigned long long port; 885 unsigned long long port;
886 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pub; 886 struct GNUNET_CRYPTO_EccPublicKey pub;
887 887
888 if (GNUNET_OK != 888 if (GNUNET_OK !=
889 GNUNET_CONFIGURATION_get_value_number (cfg, 889 GNUNET_CONFIGURATION_get_value_number (cfg,
diff --git a/src/gns/gnunet-gns-helper-service-w32.c b/src/gns/gnunet-gns-helper-service-w32.c
index a15b3547c..f0bf6577c 100644
--- a/src/gns/gnunet-gns-helper-service-w32.c
+++ b/src/gns/gnunet-gns-helper-service-w32.c
@@ -663,7 +663,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
663 663
664 char* keyfile; 664 char* keyfile;
665 struct GNUNET_CRYPTO_EccPrivateKey *key = NULL; 665 struct GNUNET_CRYPTO_EccPrivateKey *key = NULL;
666 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; 666 struct GNUNET_CRYPTO_EccPublicKey pkey;
667 struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename; 667 struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename;
668 668
669 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns", 669 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns",
@@ -680,7 +680,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
680 key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile); 680 key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile);
681 GNUNET_CRYPTO_ecc_key_get_public (key, &pkey); 681 GNUNET_CRYPTO_ecc_key_get_public (key, &pkey);
682 GNUNET_CRYPTO_short_hash(&pkey, 682 GNUNET_CRYPTO_short_hash(&pkey,
683 sizeof(struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 683 sizeof(struct GNUNET_CRYPTO_EccPublicKey),
684 &user_zone); 684 &user_zone);
685 zone = &user_zone; 685 zone = &user_zone;
686 GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename); 686 GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename);
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c
index 59e4f89fe..4752422dd 100644
--- a/src/gns/gnunet-gns-proxy.c
+++ b/src/gns/gnunet-gns-proxy.c
@@ -3189,7 +3189,7 @@ load_local_zone_key (const struct GNUNET_CONFIGURATION_Handle *cfg)
3189{ 3189{
3190 char *keyfile; 3190 char *keyfile;
3191 struct GNUNET_CRYPTO_EccPrivateKey *key; 3191 struct GNUNET_CRYPTO_EccPrivateKey *key;
3192 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; 3192 struct GNUNET_CRYPTO_EccPublicKey pkey;
3193 struct GNUNET_CRYPTO_ShortHashCode *zone; 3193 struct GNUNET_CRYPTO_ShortHashCode *zone;
3194 struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename; 3194 struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename;
3195 3195
@@ -3212,9 +3212,9 @@ load_local_zone_key (const struct GNUNET_CONFIGURATION_Handle *cfg)
3212 key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile); 3212 key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile);
3213 GNUNET_CRYPTO_ecc_key_get_public (key, &pkey); 3213 GNUNET_CRYPTO_ecc_key_get_public (key, &pkey);
3214 local_gns_zone = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_ShortHashCode)); 3214 local_gns_zone = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_ShortHashCode));
3215 GNUNET_CRYPTO_short_hash(&pkey, 3215 GNUNET_CRYPTO_short_hash (&pkey,
3216 sizeof(struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 3216 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
3217 local_gns_zone); 3217 local_gns_zone);
3218 zone = local_gns_zone; 3218 zone = local_gns_zone;
3219 GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename); 3219 GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename);
3220 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3220 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -3241,9 +3241,9 @@ load_local_zone_key (const struct GNUNET_CONFIGURATION_Handle *cfg)
3241 key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile); 3241 key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile);
3242 GNUNET_CRYPTO_ecc_key_get_public (key, &pkey); 3242 GNUNET_CRYPTO_ecc_key_get_public (key, &pkey);
3243 local_private_zone = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_ShortHashCode)); 3243 local_private_zone = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_ShortHashCode));
3244 GNUNET_CRYPTO_short_hash(&pkey, 3244 GNUNET_CRYPTO_short_hash (&pkey,
3245 sizeof(struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 3245 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
3246 local_private_zone); 3246 local_private_zone);
3247 GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename); 3247 GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename);
3248 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3248 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3249 "Using private zone: %s!\n", &zonename); 3249 "Using private zone: %s!\n", &zonename);
@@ -3270,9 +3270,9 @@ load_local_zone_key (const struct GNUNET_CONFIGURATION_Handle *cfg)
3270 key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile); 3270 key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile);
3271 GNUNET_CRYPTO_ecc_key_get_public (key, &pkey); 3271 GNUNET_CRYPTO_ecc_key_get_public (key, &pkey);
3272 local_shorten_zone = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_ShortHashCode)); 3272 local_shorten_zone = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_ShortHashCode));
3273 GNUNET_CRYPTO_short_hash(&pkey, 3273 GNUNET_CRYPTO_short_hash (&pkey,
3274 sizeof(struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 3274 sizeof(struct GNUNET_CRYPTO_EccPublicKey),
3275 local_shorten_zone); 3275 local_shorten_zone);
3276 GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename); 3276 GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename);
3277 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3277 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3278 "Using shorten zone: %s!\n", &zonename); 3278 "Using shorten zone: %s!\n", &zonename);
diff --git a/src/gns/gnunet-gns.c b/src/gns/gnunet-gns.c
index 542a8106d..fa0a99590 100644
--- a/src/gns/gnunet-gns.c
+++ b/src/gns/gnunet-gns.c
@@ -205,7 +205,7 @@ run (void *cls, char *const *args, const char *cfgfile,
205{ 205{
206 char* keyfile; 206 char* keyfile;
207 struct GNUNET_CRYPTO_EccPrivateKey *key = NULL; 207 struct GNUNET_CRYPTO_EccPrivateKey *key = NULL;
208 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; 208 struct GNUNET_CRYPTO_EccPublicKey pkey;
209 struct GNUNET_CRYPTO_ShortHashCode *zone = NULL; 209 struct GNUNET_CRYPTO_ShortHashCode *zone = NULL;
210 struct GNUNET_CRYPTO_ShortHashCode user_zone; 210 struct GNUNET_CRYPTO_ShortHashCode user_zone;
211 struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename; 211 struct GNUNET_CRYPTO_ShortHashAsciiEncoded zonename;
@@ -233,7 +233,7 @@ run (void *cls, char *const *args, const char *cfgfile,
233 key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile); 233 key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile);
234 GNUNET_CRYPTO_ecc_key_get_public (key, &pkey); 234 GNUNET_CRYPTO_ecc_key_get_public (key, &pkey);
235 GNUNET_CRYPTO_short_hash (&pkey, 235 GNUNET_CRYPTO_short_hash (&pkey,
236 sizeof(struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 236 sizeof(struct GNUNET_CRYPTO_EccPublicKey),
237 &user_zone); 237 &user_zone);
238 zone = &user_zone; 238 zone = &user_zone;
239 GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename); 239 GNUNET_CRYPTO_short_hash_to_enc (zone, &zonename);
@@ -257,7 +257,7 @@ run (void *cls, char *const *args, const char *cfgfile,
257 GNUNET_CRYPTO_ecc_key_get_public (shorten_key, &pkey); 257 GNUNET_CRYPTO_ecc_key_get_public (shorten_key, &pkey);
258 shorten_zone = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_ShortHashCode)); 258 shorten_zone = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_ShortHashCode));
259 GNUNET_CRYPTO_short_hash(&pkey, 259 GNUNET_CRYPTO_short_hash(&pkey,
260 sizeof(struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 260 sizeof(struct GNUNET_CRYPTO_EccPublicKey),
261 shorten_zone); 261 shorten_zone);
262 GNUNET_CRYPTO_short_hash_to_enc (shorten_zone, &zonename); 262 GNUNET_CRYPTO_short_hash_to_enc (shorten_zone, &zonename);
263 if (! raw) 263 if (! raw)
@@ -277,10 +277,10 @@ run (void *cls, char *const *args, const char *cfgfile,
277 { 277 {
278 private_key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile); 278 private_key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile);
279 GNUNET_CRYPTO_ecc_key_get_public (private_key, &pkey); 279 GNUNET_CRYPTO_ecc_key_get_public (private_key, &pkey);
280 private_zone = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_ShortHashCode)); 280 private_zone = GNUNET_new (struct GNUNET_CRYPTO_ShortHashCode);
281 GNUNET_CRYPTO_short_hash(&pkey, 281 GNUNET_CRYPTO_short_hash (&pkey,
282 sizeof(struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 282 sizeof(struct GNUNET_CRYPTO_EccPublicKey),
283 private_zone); 283 private_zone);
284 GNUNET_CRYPTO_short_hash_to_enc (private_zone, &zonename); 284 GNUNET_CRYPTO_short_hash_to_enc (private_zone, &zonename);
285 if (! raw) 285 if (! raw)
286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c
index fcfa4b138..8200e3f87 100644
--- a/src/gns/gnunet-service-gns.c
+++ b/src/gns/gnunet-service-gns.c
@@ -382,7 +382,7 @@ publish_zone_dht_start (void *cls,
382 */ 382 */
383static void 383static void
384put_gns_record (void *cls, 384put_gns_record (void *cls,
385 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key, 385 const struct GNUNET_CRYPTO_EccPublicKey *key,
386 struct GNUNET_TIME_Absolute expiration, 386 struct GNUNET_TIME_Absolute expiration,
387 const char *name, 387 const char *name,
388 unsigned int rd_count, 388 unsigned int rd_count,
@@ -486,7 +486,7 @@ put_gns_record (void *cls,
486 nrb_data += namelen; 486 nrb_data += namelen;
487 rd_payload_length += sizeof(struct GNSNameRecordBlock) + namelen; 487 rd_payload_length += sizeof(struct GNSNameRecordBlock) + namelen;
488 GNUNET_CRYPTO_short_hash (key, 488 GNUNET_CRYPTO_short_hash (key,
489 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 489 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
490 &zhash); 490 &zhash);
491 if (-1 == GNUNET_NAMESTORE_records_serialize (rd_count, 491 if (-1 == GNUNET_NAMESTORE_records_serialize (rd_count,
492 rd, 492 rd,
@@ -637,7 +637,7 @@ send_shorten_response (void* cls, const char* name)
637 */ 637 */
638static void 638static void
639process_shorten_in_private_zone_lookup (void *cls, 639process_shorten_in_private_zone_lookup (void *cls,
640 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key, 640 const struct GNUNET_CRYPTO_EccPublicKey *key,
641 struct GNUNET_TIME_Absolute expiration, 641 struct GNUNET_TIME_Absolute expiration,
642 const char *name, 642 const char *name,
643 unsigned int rd_count, 643 unsigned int rd_count,
@@ -693,7 +693,7 @@ process_shorten_in_private_zone_lookup (void *cls,
693 */ 693 */
694static void 694static void
695process_shorten_in_root_zone_lookup (void *cls, 695process_shorten_in_root_zone_lookup (void *cls,
696 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key, 696 const struct GNUNET_CRYPTO_EccPublicKey *key,
697 struct GNUNET_TIME_Absolute expiration, 697 struct GNUNET_TIME_Absolute expiration,
698 const char *name, 698 const char *name,
699 unsigned int rd_count, 699 unsigned int rd_count,
@@ -749,7 +749,7 @@ process_shorten_in_root_zone_lookup (void *cls,
749 */ 749 */
750static void 750static void
751process_private_in_root_zone_lookup (void *cls, 751process_private_in_root_zone_lookup (void *cls,
752 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key, 752 const struct GNUNET_CRYPTO_EccPublicKey *key,
753 struct GNUNET_TIME_Absolute expiration, 753 struct GNUNET_TIME_Absolute expiration,
754 const char *name, 754 const char *name,
755 unsigned int rd_count, 755 unsigned int rd_count,
@@ -1075,9 +1075,7 @@ handle_lookup (void *cls,
1075 char* nameptr = name; 1075 char* nameptr = name;
1076 const char *utf_in; 1076 const char *utf_in;
1077 int only_cached; 1077 int only_cached;
1078 struct GNUNET_CRYPTO_EccPrivateKey *key; 1078 const struct GNUNET_CRYPTO_EccPrivateKey *key;
1079 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *pkey;
1080 char* tmp_pkey;
1081 uint16_t msg_size; 1079 uint16_t msg_size;
1082 const struct GNUNET_GNS_ClientLookupMessage *sh_msg; 1080 const struct GNUNET_GNS_ClientLookupMessage *sh_msg;
1083 1081
@@ -1094,24 +1092,20 @@ handle_lookup (void *cls,
1094 GNUNET_SERVER_notification_context_add (nc, client); 1092 GNUNET_SERVER_notification_context_add (nc, client);
1095 if (GNUNET_YES == ntohl (sh_msg->have_key)) 1093 if (GNUNET_YES == ntohl (sh_msg->have_key))
1096 { 1094 {
1097 pkey = (struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *) &sh_msg[1]; 1095 key = &sh_msg->shorten_key;
1098 tmp_pkey = (char*) &sh_msg[1];
1099 key = GNUNET_CRYPTO_ecc_decode_key (tmp_pkey, ntohs (pkey->size),
1100 GNUNET_NO);
1101 GNUNET_STRINGS_utf8_tolower (&tmp_pkey[ntohs (pkey->size)], &nameptr);
1102 } 1096 }
1103 else 1097 else
1104 { 1098 {
1105 key = NULL; 1099 key = NULL;
1106 utf_in = (const char *) &sh_msg[1];
1107 if ('\0' != utf_in[msg_size - sizeof (struct GNUNET_GNS_ClientLookupMessage) - 1])
1108 {
1109 GNUNET_break (0);
1110 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1111 return;
1112 }
1113 GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr);
1114 } 1100 }
1101 utf_in = (const char *) &sh_msg[1];
1102 if ('\0' != utf_in[msg_size - sizeof (struct GNUNET_GNS_ClientLookupMessage) - 1])
1103 {
1104 GNUNET_break (0);
1105 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1106 return;
1107 }
1108 GNUNET_STRINGS_utf8_tolower (utf_in, &nameptr);
1115 1109
1116 namelen = strlen (name) + 1; 1110 namelen = strlen (name) + 1;
1117 clh = GNUNET_malloc (sizeof (struct ClientLookupHandle)); 1111 clh = GNUNET_malloc (sizeof (struct ClientLookupHandle));
@@ -1121,8 +1115,11 @@ handle_lookup (void *cls,
1121 strcpy (clh->name, name); 1115 strcpy (clh->name, name);
1122 clh->request_id = sh_msg->id; 1116 clh->request_id = sh_msg->id;
1123 clh->type = ntohl (sh_msg->type); 1117 clh->type = ntohl (sh_msg->type);
1124 clh->shorten_key = key; 1118 if (NULL != key)
1125 1119 {
1120 clh->shorten_key = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey);
1121 *clh->shorten_key = *key;
1122 }
1126 only_cached = ntohl (sh_msg->only_cached); 1123 only_cached = ntohl (sh_msg->only_cached);
1127 1124
1128 if (strlen (name) > GNUNET_DNSPARSER_MAX_NAME_LENGTH) { 1125 if (strlen (name) > GNUNET_DNSPARSER_MAX_NAME_LENGTH) {
@@ -1153,7 +1150,7 @@ handle_lookup (void *cls,
1153 return; 1150 return;
1154 } 1151 }
1155 1152
1156 if (1 == ntohl (sh_msg->use_default_zone)) 1153 if (GNUNET_NO == ntohl (sh_msg->have_zone))
1157 clh->zone = zone_hash; /* Default zone */ 1154 clh->zone = zone_hash; /* Default zone */
1158 else 1155 else
1159 clh->zone = sh_msg->zone; 1156 clh->zone = sh_msg->zone;
@@ -1196,7 +1193,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1196 {&handle_get_authority, NULL, GNUNET_MESSAGE_TYPE_GNS_GET_AUTH, 0} 1193 {&handle_get_authority, NULL, GNUNET_MESSAGE_TYPE_GNS_GET_AUTH, 0}
1197 }; 1194 };
1198 char* keyfile; 1195 char* keyfile;
1199 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; 1196 struct GNUNET_CRYPTO_EccPublicKey pkey;
1200 unsigned long long max_parallel_bg_queries = 0; 1197 unsigned long long max_parallel_bg_queries = 0;
1201 int ignore_pending = GNUNET_NO; 1198 int ignore_pending = GNUNET_NO;
1202 1199
@@ -1217,9 +1214,9 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
1217 1214
1218 zone_key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile); 1215 zone_key = GNUNET_CRYPTO_ecc_key_create_from_file (keyfile);
1219 GNUNET_CRYPTO_ecc_key_get_public (zone_key, &pkey); 1216 GNUNET_CRYPTO_ecc_key_get_public (zone_key, &pkey);
1220 GNUNET_CRYPTO_short_hash(&pkey, 1217 GNUNET_CRYPTO_short_hash (&pkey,
1221 sizeof(struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 1218 sizeof(struct GNUNET_CRYPTO_EccPublicKey),
1222 &zone_hash); 1219 &zone_hash);
1223 GNUNET_free(keyfile); 1220 GNUNET_free(keyfile);
1224 namestore_handle = GNUNET_NAMESTORE_connect (c); 1221 namestore_handle = GNUNET_NAMESTORE_connect (c);
1225 if (NULL == namestore_handle) 1222 if (NULL == namestore_handle)
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 2cde3e37e..2e96b60ea 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -270,7 +270,7 @@ create_pkey_cont (void* cls, int32_t success, const char* emsg)
270 */ 270 */
271static void 271static void
272process_pseu_lookup_ns (void* cls, 272process_pseu_lookup_ns (void* cls,
273 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key, 273 const struct GNUNET_CRYPTO_EccPublicKey *key,
274 struct GNUNET_TIME_Absolute expiration, 274 struct GNUNET_TIME_Absolute expiration,
275 const char *name, unsigned int rd_count, 275 const char *name, unsigned int rd_count,
276 const struct GNUNET_NAMESTORE_RecordData *rd, 276 const struct GNUNET_NAMESTORE_RecordData *rd,
@@ -464,12 +464,12 @@ process_auth_discovery_dht_result (void* cls,
464 */ 464 */
465static void 465static void
466process_auth_discovery_ns_result (void* cls, 466process_auth_discovery_ns_result (void* cls,
467 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key, 467 const struct GNUNET_CRYPTO_EccPublicKey *key,
468 struct GNUNET_TIME_Absolute expiration, 468 struct GNUNET_TIME_Absolute expiration,
469 const char *name, 469 const char *name,
470 unsigned int rd_count, 470 unsigned int rd_count,
471 const struct GNUNET_NAMESTORE_RecordData *rd, 471 const struct GNUNET_NAMESTORE_RecordData *rd,
472 const struct GNUNET_CRYPTO_EccSignature *signature) 472 const struct GNUNET_CRYPTO_EccSignature *signature)
473{ 473{
474 struct GetPseuAuthorityHandle* gph = cls; 474 struct GetPseuAuthorityHandle* gph = cls;
475 struct GNUNET_HashCode lookup_key; 475 struct GNUNET_HashCode lookup_key;
@@ -537,7 +537,7 @@ process_auth_discovery_ns_result (void* cls,
537 */ 537 */
538static void 538static void
539process_zone_to_name_discover (void *cls, 539process_zone_to_name_discover (void *cls,
540 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 540 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
541 struct GNUNET_TIME_Absolute expire, 541 struct GNUNET_TIME_Absolute expire,
542 const char *name, 542 const char *name,
543 unsigned int rd_len, 543 unsigned int rd_len,
@@ -575,12 +575,11 @@ shorten_authority_chain (struct GetPseuAuthorityHandle *gph)
575 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 575 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
576 "GNS_AUTO_PSEU: New authority %s discovered\n", 576 "GNS_AUTO_PSEU: New authority %s discovered\n",
577 gph->auth->name); 577 gph->auth->name);
578
579 gph->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle, 578 gph->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle,
580 &gph->our_zone, 579 &gph->our_zone,
581 &gph->auth->zone, 580 &gph->auth->zone,
582 &process_zone_to_name_discover, 581 &process_zone_to_name_discover,
583 gph); 582 gph);
584} 583}
585 584
586 585
@@ -596,21 +595,12 @@ start_shorten (struct AuthorityChain *auth,
596 const struct GNUNET_CRYPTO_EccPrivateKey *key) 595 const struct GNUNET_CRYPTO_EccPrivateKey *key)
597{ 596{
598 struct GetPseuAuthorityHandle *gph; 597 struct GetPseuAuthorityHandle *gph;
599 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; 598 struct GNUNET_CRYPTO_EccPublicKey pkey;
600 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *pb_key;
601 599
602 GNUNET_CRYPTO_ecc_key_get_public (key, &pkey); 600 GNUNET_CRYPTO_ecc_key_get_public (key, &pkey);
603 if (NULL == (pb_key = GNUNET_CRYPTO_ecc_encode_key (key)))
604 {
605 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
606 "Failed to encode ECC key on shorten\n");
607 return;
608 }
609 gph = GNUNET_new (struct GetPseuAuthorityHandle); 601 gph = GNUNET_new (struct GetPseuAuthorityHandle);
610 gph->key = GNUNET_CRYPTO_ecc_decode_key ((const char*) pb_key, 602 gph->key = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey);
611 ntohs (pb_key->size), 603 *gph->key = *key;
612 GNUNET_YES);
613 GNUNET_free (pb_key);
614 if (NULL == gph->key) 604 if (NULL == gph->key)
615 { 605 {
616 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 606 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -619,7 +609,7 @@ start_shorten (struct AuthorityChain *auth,
619 return; 609 return;
620 } 610 }
621 GNUNET_CRYPTO_short_hash (&pkey, 611 GNUNET_CRYPTO_short_hash (&pkey,
622 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 612 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
623 &gph->our_zone); 613 &gph->our_zone);
624 gph->auth = GNUNET_malloc (sizeof (struct AuthorityChain)); 614 gph->auth = GNUNET_malloc (sizeof (struct AuthorityChain));
625 memcpy (gph->auth, auth, sizeof (struct AuthorityChain)); 615 memcpy (gph->auth, auth, sizeof (struct AuthorityChain));
@@ -1157,7 +1147,7 @@ resolve_record_dht (struct ResolverHandle *rh)
1157 */ 1147 */
1158static void 1148static void
1159process_record_result_ns (void* cls, 1149process_record_result_ns (void* cls,
1160 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key, 1150 const struct GNUNET_CRYPTO_EccPublicKey *key,
1161 struct GNUNET_TIME_Absolute expiration, 1151 struct GNUNET_TIME_Absolute expiration,
1162 const char *name, unsigned int rd_count, 1152 const char *name, unsigned int rd_count,
1163 const struct GNUNET_NAMESTORE_RecordData *rd, 1153 const struct GNUNET_NAMESTORE_RecordData *rd,
@@ -1172,7 +1162,7 @@ process_record_result_ns (void* cls,
1172 1162
1173 rh->namestore_task = NULL; 1163 rh->namestore_task = NULL;
1174 GNUNET_CRYPTO_short_hash (key, 1164 GNUNET_CRYPTO_short_hash (key,
1175 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 1165 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
1176 &zone); 1166 &zone);
1177 remaining_time = GNUNET_TIME_absolute_get_remaining (expiration); 1167 remaining_time = GNUNET_TIME_absolute_get_remaining (expiration);
1178 rh->status = 0; 1168 rh->status = 0;
@@ -2040,7 +2030,7 @@ handle_delegation_ns (void* cls, struct ResolverHandle *rh,
2040 */ 2030 */
2041static void 2031static void
2042process_pkey_revocation_result_ns (void *cls, 2032process_pkey_revocation_result_ns (void *cls,
2043 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key, 2033 const struct GNUNET_CRYPTO_EccPublicKey *key,
2044 struct GNUNET_TIME_Absolute expiration, 2034 struct GNUNET_TIME_Absolute expiration,
2045 const char *name, 2035 const char *name,
2046 unsigned int rd_count, 2036 unsigned int rd_count,
@@ -3069,7 +3059,7 @@ handle_delegation_ns (void* cls, struct ResolverHandle *rh,
3069 */ 3059 */
3070static void 3060static void
3071process_delegation_result_ns (void* cls, 3061process_delegation_result_ns (void* cls,
3072 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *key, 3062 const struct GNUNET_CRYPTO_EccPublicKey *key,
3073 struct GNUNET_TIME_Absolute expiration, 3063 struct GNUNET_TIME_Absolute expiration,
3074 const char *name, 3064 const char *name,
3075 unsigned int rd_count, 3065 unsigned int rd_count,
@@ -3086,7 +3076,7 @@ process_delegation_result_ns (void* cls,
3086 3076
3087 rh->namestore_task = NULL; 3077 rh->namestore_task = NULL;
3088 GNUNET_CRYPTO_short_hash (key, 3078 GNUNET_CRYPTO_short_hash (key,
3089 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 3079 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
3090 &zone); 3080 &zone);
3091 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3081 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3092 "GNS_PHASE_DELEGATE_NS-%llu: Got %d records from authority lookup for `%s' in zone %s\n", 3082 "GNS_PHASE_DELEGATE_NS-%llu: Got %d records from authority lookup for `%s' in zone %s\n",
@@ -3515,7 +3505,7 @@ finish_shorten (struct ResolverHandle *rh,
3515 */ 3505 */
3516static void 3506static void
3517process_zone_to_name_shorten_root (void *cls, 3507process_zone_to_name_shorten_root (void *cls,
3518 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 3508 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
3519 struct GNUNET_TIME_Absolute expire, 3509 struct GNUNET_TIME_Absolute expire,
3520 const char *name, 3510 const char *name,
3521 unsigned int rd_len, 3511 unsigned int rd_len,
@@ -3537,12 +3527,12 @@ process_zone_to_name_shorten_root (void *cls,
3537 */ 3527 */
3538static void 3528static void
3539process_zone_to_name_shorten_shorten (void *cls, 3529process_zone_to_name_shorten_shorten (void *cls,
3540 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 3530 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
3541 struct GNUNET_TIME_Absolute expire, 3531 struct GNUNET_TIME_Absolute expire,
3542 const char *name, 3532 const char *name,
3543 unsigned int rd_len, 3533 unsigned int rd_len,
3544 const struct GNUNET_NAMESTORE_RecordData *rd, 3534 const struct GNUNET_NAMESTORE_RecordData *rd,
3545 const struct GNUNET_CRYPTO_EccSignature *signature) 3535 const struct GNUNET_CRYPTO_EccSignature *signature)
3546{ 3536{
3547 struct ResolverHandle *rh = cls; 3537 struct ResolverHandle *rh = cls;
3548 struct NameShortenHandle* nsh = rh->proc_cls; 3538 struct NameShortenHandle* nsh = rh->proc_cls;
@@ -3653,12 +3643,12 @@ process_zone_to_name_shorten_shorten (void *cls,
3653 */ 3643 */
3654static void 3644static void
3655process_zone_to_name_shorten_private (void *cls, 3645process_zone_to_name_shorten_private (void *cls,
3656 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 3646 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
3657 struct GNUNET_TIME_Absolute expire, 3647 struct GNUNET_TIME_Absolute expire,
3658 const char *name, 3648 const char *name,
3659 unsigned int rd_len, 3649 unsigned int rd_len,
3660 const struct GNUNET_NAMESTORE_RecordData *rd, 3650 const struct GNUNET_NAMESTORE_RecordData *rd,
3661 const struct GNUNET_CRYPTO_EccSignature *signature) 3651 const struct GNUNET_CRYPTO_EccSignature *signature)
3662{ 3652{
3663 struct ResolverHandle *rh = cls; 3653 struct ResolverHandle *rh = cls;
3664 struct NameShortenHandle* nsh = rh->proc_cls; 3654 struct NameShortenHandle* nsh = rh->proc_cls;
@@ -3768,12 +3758,12 @@ process_zone_to_name_shorten_private (void *cls,
3768 */ 3758 */
3769static void 3759static void
3770process_zone_to_name_shorten_root (void *cls, 3760process_zone_to_name_shorten_root (void *cls,
3771 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 3761 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
3772 struct GNUNET_TIME_Absolute expire, 3762 struct GNUNET_TIME_Absolute expire,
3773 const char *name, 3763 const char *name,
3774 unsigned int rd_len, 3764 unsigned int rd_len,
3775 const struct GNUNET_NAMESTORE_RecordData *rd, 3765 const struct GNUNET_NAMESTORE_RecordData *rd,
3776 const struct GNUNET_CRYPTO_EccSignature *signature) 3766 const struct GNUNET_CRYPTO_EccSignature *signature)
3777{ 3767{
3778 struct ResolverHandle *rh = cls; 3768 struct ResolverHandle *rh = cls;
3779 struct NameShortenHandle* nsh = rh->proc_cls; 3769 struct NameShortenHandle* nsh = rh->proc_cls;
@@ -3990,13 +3980,13 @@ handle_delegation_ns_shorten (void* cls,
3990 * @param signature the signature for the record data 3980 * @param signature the signature for the record data
3991 */ 3981 */
3992static void 3982static void
3993process_zone_to_name_zkey(void *cls, 3983process_zone_to_name_zkey (void *cls,
3994 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 3984 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
3995 struct GNUNET_TIME_Absolute expire, 3985 struct GNUNET_TIME_Absolute expire,
3996 const char *name, 3986 const char *name,
3997 unsigned int rd_len, 3987 unsigned int rd_len,
3998 const struct GNUNET_NAMESTORE_RecordData *rd, 3988 const struct GNUNET_NAMESTORE_RecordData *rd,
3999 const struct GNUNET_CRYPTO_EccSignature *signature) 3989 const struct GNUNET_CRYPTO_EccSignature *signature)
4000{ 3990{
4001 struct ResolverHandle *rh = cls; 3991 struct ResolverHandle *rh = cls;
4002 struct NameShortenHandle *nsh = rh->proc_cls; 3992 struct NameShortenHandle *nsh = rh->proc_cls;
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c
index 72149ef4f..ffc38c99b 100644
--- a/src/gns/plugin_block_gns.c
+++ b/src/gns/plugin_block_gns.c
@@ -237,7 +237,7 @@ block_plugin_gns_get_key (void *cls, enum GNUNET_BLOCK_Type type,
237 return GNUNET_SYSERR; 237 return GNUNET_SYSERR;
238 } 238 }
239 GNUNET_CRYPTO_short_hash (&nrb->public_key, 239 GNUNET_CRYPTO_short_hash (&nrb->public_key,
240 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 240 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
241 &pkey_hash); 241 &pkey_hash);
242 GNUNET_GNS_get_key_for_record (name, &pkey_hash, key); 242 GNUNET_GNS_get_key_for_record (name, &pkey_hash, key);
243 return GNUNET_OK; 243 return GNUNET_OK;
diff --git a/src/gns/test_gns_cname_lookup.c b/src/gns/test_gns_cname_lookup.c
index cc1df9407..325583001 100644
--- a/src/gns/test_gns_cname_lookup.c
+++ b/src/gns/test_gns_cname_lookup.c
@@ -334,7 +334,7 @@ do_check (void *cls,
334 const struct GNUNET_CONFIGURATION_Handle *ccfg, 334 const struct GNUNET_CONFIGURATION_Handle *ccfg,
335 struct GNUNET_TESTING_Peer *peer) 335 struct GNUNET_TESTING_Peer *peer)
336{ 336{
337 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded alice_pkey; 337 struct GNUNET_CRYPTO_EccPublicKey alice_pkey;
338 struct GNUNET_CRYPTO_EccPrivateKey *alice_key; 338 struct GNUNET_CRYPTO_EccPrivateKey *alice_key;
339 struct GNUNET_CRYPTO_EccPrivateKey *bob_key; 339 struct GNUNET_CRYPTO_EccPrivateKey *bob_key;
340 char* alice_keyfile; 340 char* alice_keyfile;
diff --git a/src/gns/test_gns_dht_delegated_lookup.c b/src/gns/test_gns_dht_delegated_lookup.c
index e743e0fd3..fbaacfdfa 100644
--- a/src/gns/test_gns_dht_delegated_lookup.c
+++ b/src/gns/test_gns_dht_delegated_lookup.c
@@ -65,8 +65,8 @@ static struct GNUNET_DHT_Handle *dht_handle;
65 65
66static const struct GNUNET_CONFIGURATION_Handle *cfg; 66static const struct GNUNET_CONFIGURATION_Handle *cfg;
67 67
68static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded alice_pkey; 68static struct GNUNET_CRYPTO_EccPublicKey alice_pkey;
69static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded bob_pkey; 69static struct GNUNET_CRYPTO_EccPublicKey bob_pkey;
70static struct GNUNET_CRYPTO_EccPrivateKey *alice_key; 70static struct GNUNET_CRYPTO_EccPrivateKey *alice_key;
71static struct GNUNET_CRYPTO_EccPrivateKey *bob_key; 71static struct GNUNET_CRYPTO_EccPrivateKey *bob_key;
72 72
@@ -262,7 +262,7 @@ put_dht(void *cls, int32_t success, const char *emsg)
262 } 262 }
263 GNUNET_CRYPTO_short_hash(TEST_RECORD_NAME, strlen(TEST_RECORD_NAME), &name_hash); 263 GNUNET_CRYPTO_short_hash(TEST_RECORD_NAME, strlen(TEST_RECORD_NAME), &name_hash);
264 GNUNET_CRYPTO_short_hash(&bob_pkey, 264 GNUNET_CRYPTO_short_hash(&bob_pkey,
265 sizeof(struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 265 sizeof(struct GNUNET_CRYPTO_EccPublicKey),
266 &zone_hash); 266 &zone_hash);
267 GNUNET_CRYPTO_short_hash_double(&zone_hash, &zone_hash_double); 267 GNUNET_CRYPTO_short_hash_double(&zone_hash, &zone_hash_double);
268 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double); 268 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
diff --git a/src/gns/test_gns_dht_three_peers.c b/src/gns/test_gns_dht_three_peers.c
index 58edb9cc5..35a738aef 100644
--- a/src/gns/test_gns_dht_three_peers.c
+++ b/src/gns/test_gns_dht_three_peers.c
@@ -309,7 +309,7 @@ setup_dave (const struct GNUNET_CONFIGURATION_Handle * cfg)
309{ 309{
310 char* keyfile; 310 char* keyfile;
311 struct GNUNET_CRYPTO_EccPrivateKey *key; 311 struct GNUNET_CRYPTO_EccPrivateKey *key;
312 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; 312 struct GNUNET_CRYPTO_EccPublicKey pkey;
313 struct in_addr *web; 313 struct in_addr *web;
314 struct GNUNET_NAMESTORE_RecordData rd; 314 struct GNUNET_NAMESTORE_RecordData rd;
315 315
@@ -380,7 +380,7 @@ setup_bob (const struct GNUNET_CONFIGURATION_Handle * cfg)
380{ 380{
381 char* keyfile; 381 char* keyfile;
382 struct GNUNET_CRYPTO_EccPrivateKey *key; 382 struct GNUNET_CRYPTO_EccPrivateKey *key;
383 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; 383 struct GNUNET_CRYPTO_EccPublicKey pkey;
384 struct GNUNET_NAMESTORE_RecordData rd; 384 struct GNUNET_NAMESTORE_RecordData rd;
385 385
386 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up bob\n"); 386 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Setting up bob\n");
diff --git a/src/gns/test_gns_max_queries.c b/src/gns/test_gns_max_queries.c
index 82273798f..cc993e347 100644
--- a/src/gns/test_gns_max_queries.c
+++ b/src/gns/test_gns_max_queries.c
@@ -252,8 +252,8 @@ do_check (void *cls,
252 const struct GNUNET_CONFIGURATION_Handle *ccfg, 252 const struct GNUNET_CONFIGURATION_Handle *ccfg,
253 struct GNUNET_TESTING_Peer *peer) 253 struct GNUNET_TESTING_Peer *peer)
254{ 254{
255 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded alice_pkey; 255 struct GNUNET_CRYPTO_EccPublicKey alice_pkey;
256 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded bob_pkey; 256 struct GNUNET_CRYPTO_EccPublicKey bob_pkey;
257 struct GNUNET_CRYPTO_EccPrivateKey *alice_key; 257 struct GNUNET_CRYPTO_EccPrivateKey *alice_key;
258 struct GNUNET_CRYPTO_EccPrivateKey *bob_key; 258 struct GNUNET_CRYPTO_EccPrivateKey *bob_key;
259 char* alice_keyfile; 259 char* alice_keyfile;
diff --git a/src/gns/test_gns_ns_lookup.c b/src/gns/test_gns_ns_lookup.c
index e62d34e9a..0673243b6 100644
--- a/src/gns/test_gns_ns_lookup.c
+++ b/src/gns/test_gns_ns_lookup.c
@@ -561,7 +561,7 @@ do_check (void *cls,
561 const struct GNUNET_CONFIGURATION_Handle *ccfg, 561 const struct GNUNET_CONFIGURATION_Handle *ccfg,
562 struct GNUNET_TESTING_Peer *peer) 562 struct GNUNET_TESTING_Peer *peer)
563{ 563{
564 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded alice_pkey; 564 struct GNUNET_CRYPTO_EccPublicKey alice_pkey;
565 char* alice_keyfile; 565 char* alice_keyfile;
566 struct GNUNET_NAMESTORE_RecordData rd[2]; 566 struct GNUNET_NAMESTORE_RecordData rd[2];
567 struct in_addr ns; 567 struct in_addr ns;
diff --git a/src/gns/test_gns_pseu_shorten.c b/src/gns/test_gns_pseu_shorten.c
index 28f92f8b5..7413c7074 100644
--- a/src/gns/test_gns_pseu_shorten.c
+++ b/src/gns/test_gns_pseu_shorten.c
@@ -69,11 +69,11 @@ static struct GNUNET_DHT_Handle *dht_handle;
69 69
70static const struct GNUNET_CONFIGURATION_Handle *cfg; 70static const struct GNUNET_CONFIGURATION_Handle *cfg;
71 71
72static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded alice_pkey; 72static struct GNUNET_CRYPTO_EccPublicKey alice_pkey;
73static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded bob_pkey; 73static struct GNUNET_CRYPTO_EccPublicKey bob_pkey;
74static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded our_pkey; 74static struct GNUNET_CRYPTO_EccPublicKey our_pkey;
75static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded priv_pkey; 75static struct GNUNET_CRYPTO_EccPublicKey priv_pkey;
76static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded short_pkey; 76static struct GNUNET_CRYPTO_EccPublicKey short_pkey;
77static struct GNUNET_CRYPTO_EccPrivateKey *alice_key; 77static struct GNUNET_CRYPTO_EccPrivateKey *alice_key;
78static struct GNUNET_CRYPTO_EccPrivateKey *bob_key; 78static struct GNUNET_CRYPTO_EccPrivateKey *bob_key;
79static struct GNUNET_CRYPTO_EccPrivateKey *our_key; 79static struct GNUNET_CRYPTO_EccPrivateKey *our_key;
@@ -316,7 +316,7 @@ put_pseu_dht (void *cls, int success)
316 } 316 }
317 GNUNET_CRYPTO_short_hash(GNUNET_GNS_MASTERZONE_STR, strlen(GNUNET_GNS_MASTERZONE_STR), &name_hash); 317 GNUNET_CRYPTO_short_hash(GNUNET_GNS_MASTERZONE_STR, strlen(GNUNET_GNS_MASTERZONE_STR), &name_hash);
318 GNUNET_CRYPTO_short_hash(&alice_pkey, 318 GNUNET_CRYPTO_short_hash(&alice_pkey,
319 sizeof(struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 319 sizeof(struct GNUNET_CRYPTO_EccPublicKey),
320 &zone_hash); 320 &zone_hash);
321 321
322 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double); 322 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
@@ -405,7 +405,7 @@ put_www_dht (void *cls, int success)
405 } 405 }
406 GNUNET_CRYPTO_short_hash(TEST_RECORD_NAME, strlen(TEST_RECORD_NAME), &name_hash); 406 GNUNET_CRYPTO_short_hash(TEST_RECORD_NAME, strlen(TEST_RECORD_NAME), &name_hash);
407 GNUNET_CRYPTO_short_hash(&alice_pkey, 407 GNUNET_CRYPTO_short_hash(&alice_pkey,
408 sizeof(struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 408 sizeof(struct GNUNET_CRYPTO_EccPublicKey),
409 &zone_hash); 409 &zone_hash);
410 GNUNET_CRYPTO_short_hash_double(&zone_hash, &zone_hash_double); 410 GNUNET_CRYPTO_short_hash_double(&zone_hash, &zone_hash_double);
411 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double); 411 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
@@ -488,7 +488,7 @@ put_pkey_dht (void *cls, int32_t success, const char *emsg)
488 GNUNET_CRYPTO_short_hash (TEST_AUTHORITY_ALICE, 488 GNUNET_CRYPTO_short_hash (TEST_AUTHORITY_ALICE,
489 strlen (TEST_AUTHORITY_ALICE), &name_hash); 489 strlen (TEST_AUTHORITY_ALICE), &name_hash);
490 GNUNET_CRYPTO_short_hash (&bob_pkey, 490 GNUNET_CRYPTO_short_hash (&bob_pkey,
491 sizeof(struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 491 sizeof(struct GNUNET_CRYPTO_EccPublicKey),
492 &zone_hash); 492 &zone_hash);
493 GNUNET_CRYPTO_short_hash_double(&zone_hash, &zone_hash_double); 493 GNUNET_CRYPTO_short_hash_double(&zone_hash, &zone_hash_double);
494 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double); 494 GNUNET_CRYPTO_short_hash_double(&name_hash, &name_hash_double);
diff --git a/src/gns/test_gns_revocation.c b/src/gns/test_gns_revocation.c
index c491db4aa..e66655203 100644
--- a/src/gns/test_gns_revocation.c
+++ b/src/gns/test_gns_revocation.c
@@ -180,8 +180,8 @@ do_check (void *cls,
180 const struct GNUNET_CONFIGURATION_Handle *ccfg, 180 const struct GNUNET_CONFIGURATION_Handle *ccfg,
181 struct GNUNET_TESTING_Peer *peer) 181 struct GNUNET_TESTING_Peer *peer)
182{ 182{
183 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded alice_pkey; 183 struct GNUNET_CRYPTO_EccPublicKey alice_pkey;
184 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded bob_pkey; 184 struct GNUNET_CRYPTO_EccPublicKey bob_pkey;
185 struct GNUNET_CRYPTO_EccPrivateKey *alice_key; 185 struct GNUNET_CRYPTO_EccPrivateKey *alice_key;
186 struct GNUNET_CRYPTO_EccPrivateKey *bob_key; 186 struct GNUNET_CRYPTO_EccPrivateKey *bob_key;
187 struct GNUNET_CRYPTO_ShortHashCode bob_hash; 187 struct GNUNET_CRYPTO_ShortHashCode bob_hash;
diff --git a/src/gns/test_gns_simple_delegated_lookup.c b/src/gns/test_gns_simple_delegated_lookup.c
index 4804de6f8..ff19569d6 100644
--- a/src/gns/test_gns_simple_delegated_lookup.c
+++ b/src/gns/test_gns_simple_delegated_lookup.c
@@ -189,8 +189,8 @@ do_check (void *cls,
189 const struct GNUNET_CONFIGURATION_Handle *ccfg, 189 const struct GNUNET_CONFIGURATION_Handle *ccfg,
190 struct GNUNET_TESTING_Peer *peer) 190 struct GNUNET_TESTING_Peer *peer)
191{ 191{
192 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded alice_pkey; 192 struct GNUNET_CRYPTO_EccPublicKey alice_pkey;
193 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded bob_pkey; 193 struct GNUNET_CRYPTO_EccPublicKey bob_pkey;
194 struct GNUNET_CRYPTO_EccPrivateKey *alice_key; 194 struct GNUNET_CRYPTO_EccPrivateKey *alice_key;
195 struct GNUNET_CRYPTO_EccPrivateKey *bob_key; 195 struct GNUNET_CRYPTO_EccPrivateKey *bob_key;
196 struct GNUNET_CRYPTO_ShortHashCode bob_hash; 196 struct GNUNET_CRYPTO_ShortHashCode bob_hash;
diff --git a/src/gns/test_gns_simple_get_authority.c b/src/gns/test_gns_simple_get_authority.c
index 7a25e7ca1..7a3e8af93 100644
--- a/src/gns/test_gns_simple_get_authority.c
+++ b/src/gns/test_gns_simple_get_authority.c
@@ -178,9 +178,9 @@ void do_check (void *cls,
178 const struct GNUNET_CONFIGURATION_Handle *ccfg, 178 const struct GNUNET_CONFIGURATION_Handle *ccfg,
179 struct GNUNET_TESTING_Peer *peer) 179 struct GNUNET_TESTING_Peer *peer)
180{ 180{
181 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded our_pkey; 181 struct GNUNET_CRYPTO_EccPublicKey our_pkey;
182 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded alice_pkey; 182 struct GNUNET_CRYPTO_EccPublicKey alice_pkey;
183 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded bob_pkey; 183 struct GNUNET_CRYPTO_EccPublicKey bob_pkey;
184 struct GNUNET_CRYPTO_EccPrivateKey *our_key; 184 struct GNUNET_CRYPTO_EccPrivateKey *our_key;
185 struct GNUNET_CRYPTO_EccPrivateKey *alice_key; 185 struct GNUNET_CRYPTO_EccPrivateKey *alice_key;
186 struct GNUNET_CRYPTO_EccPrivateKey *bob_key; 186 struct GNUNET_CRYPTO_EccPrivateKey *bob_key;
diff --git a/src/gns/test_gns_simple_lookup.c b/src/gns/test_gns_simple_lookup.c
index a7c3348fd..fceb8f052 100644
--- a/src/gns/test_gns_simple_lookup.c
+++ b/src/gns/test_gns_simple_lookup.c
@@ -221,7 +221,7 @@ do_check (void *cls,
221 const struct GNUNET_CONFIGURATION_Handle *ccfg, 221 const struct GNUNET_CONFIGURATION_Handle *ccfg,
222 struct GNUNET_TESTING_Peer *peer) 222 struct GNUNET_TESTING_Peer *peer)
223{ 223{
224 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded alice_pkey; 224 struct GNUNET_CRYPTO_EccPublicKey alice_pkey;
225 struct GNUNET_CRYPTO_EccPrivateKey *alice_key; 225 struct GNUNET_CRYPTO_EccPrivateKey *alice_key;
226 struct GNUNET_NAMESTORE_RecordData rd; 226 struct GNUNET_NAMESTORE_RecordData rd;
227 char* alice_keyfile; 227 char* alice_keyfile;
diff --git a/src/gns/test_gns_simple_mx_lookup.c b/src/gns/test_gns_simple_mx_lookup.c
index f3cfaac27..904758bde 100644
--- a/src/gns/test_gns_simple_mx_lookup.c
+++ b/src/gns/test_gns_simple_mx_lookup.c
@@ -180,8 +180,8 @@ do_check (void *cls,
180 const struct GNUNET_CONFIGURATION_Handle *ccfg, 180 const struct GNUNET_CONFIGURATION_Handle *ccfg,
181 struct GNUNET_TESTING_Peer *peer) 181 struct GNUNET_TESTING_Peer *peer)
182{ 182{
183 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded alice_pkey; 183 struct GNUNET_CRYPTO_EccPublicKey alice_pkey;
184 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded bob_pkey; 184 struct GNUNET_CRYPTO_EccPublicKey bob_pkey;
185 struct GNUNET_CRYPTO_EccPrivateKey *alice_key; 185 struct GNUNET_CRYPTO_EccPrivateKey *alice_key;
186 struct GNUNET_CRYPTO_EccPrivateKey *bob_key; 186 struct GNUNET_CRYPTO_EccPrivateKey *bob_key;
187 struct GNUNET_CRYPTO_ShortHashCode bob_hash; 187 struct GNUNET_CRYPTO_ShortHashCode bob_hash;
diff --git a/src/gns/test_gns_simple_shorten.c b/src/gns/test_gns_simple_shorten.c
index 600cb0733..679a74dc8 100644
--- a/src/gns/test_gns_simple_shorten.c
+++ b/src/gns/test_gns_simple_shorten.c
@@ -61,8 +61,8 @@ static struct GNUNET_GNS_Handle *gns_handle;
61 61
62const struct GNUNET_CONFIGURATION_Handle *cfg; 62const struct GNUNET_CONFIGURATION_Handle *cfg;
63 63
64struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded priv_pkey; 64struct GNUNET_CRYPTO_EccPublicKey priv_pkey;
65struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded short_pkey; 65struct GNUNET_CRYPTO_EccPublicKey short_pkey;
66struct GNUNET_CRYPTO_EccPrivateKey *priv_key; 66struct GNUNET_CRYPTO_EccPrivateKey *priv_key;
67struct GNUNET_CRYPTO_EccPrivateKey *short_key; 67struct GNUNET_CRYPTO_EccPrivateKey *short_key;
68 68
@@ -170,9 +170,9 @@ void do_check (void *cls,
170 const struct GNUNET_CONFIGURATION_Handle *ccfg, 170 const struct GNUNET_CONFIGURATION_Handle *ccfg,
171 struct GNUNET_TESTING_Peer *peer) 171 struct GNUNET_TESTING_Peer *peer)
172{ 172{
173 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded our_pkey; 173 struct GNUNET_CRYPTO_EccPublicKey our_pkey;
174 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded alice_pkey; 174 struct GNUNET_CRYPTO_EccPublicKey alice_pkey;
175 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded bob_pkey; 175 struct GNUNET_CRYPTO_EccPublicKey bob_pkey;
176 struct GNUNET_CRYPTO_EccPrivateKey *our_key; 176 struct GNUNET_CRYPTO_EccPrivateKey *our_key;
177 struct GNUNET_CRYPTO_EccPrivateKey *alice_key; 177 struct GNUNET_CRYPTO_EccPrivateKey *alice_key;
178 struct GNUNET_CRYPTO_EccPrivateKey *bob_key; 178 struct GNUNET_CRYPTO_EccPrivateKey *bob_key;
diff --git a/src/gns/test_gns_simple_srv_lookup.c b/src/gns/test_gns_simple_srv_lookup.c
index 3b1cd46a0..a403bf554 100644
--- a/src/gns/test_gns_simple_srv_lookup.c
+++ b/src/gns/test_gns_simple_srv_lookup.c
@@ -182,8 +182,8 @@ do_check (void *cls,
182 const struct GNUNET_CONFIGURATION_Handle *ccfg, 182 const struct GNUNET_CONFIGURATION_Handle *ccfg,
183 struct GNUNET_TESTING_Peer *peer) 183 struct GNUNET_TESTING_Peer *peer)
184{ 184{
185 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded alice_pkey; 185 struct GNUNET_CRYPTO_EccPublicKey alice_pkey;
186 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded bob_pkey; 186 struct GNUNET_CRYPTO_EccPublicKey bob_pkey;
187 struct GNUNET_CRYPTO_EccPrivateKey *alice_key; 187 struct GNUNET_CRYPTO_EccPrivateKey *alice_key;
188 struct GNUNET_CRYPTO_EccPrivateKey *bob_key; 188 struct GNUNET_CRYPTO_EccPrivateKey *bob_key;
189 struct GNUNET_CRYPTO_ShortHashCode bob_hash; 189 struct GNUNET_CRYPTO_ShortHashCode bob_hash;
diff --git a/src/gns/test_gns_simple_zkey_lookup.c b/src/gns/test_gns_simple_zkey_lookup.c
index 311282535..c0e3afc8d 100644
--- a/src/gns/test_gns_simple_zkey_lookup.c
+++ b/src/gns/test_gns_simple_zkey_lookup.c
@@ -199,8 +199,8 @@ do_check (void *cls,
199 const struct GNUNET_CONFIGURATION_Handle *ccfg, 199 const struct GNUNET_CONFIGURATION_Handle *ccfg,
200 struct GNUNET_TESTING_Peer *peer) 200 struct GNUNET_TESTING_Peer *peer)
201{ 201{
202 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded alice_pkey; 202 struct GNUNET_CRYPTO_EccPublicKey alice_pkey;
203 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded bob_pkey; 203 struct GNUNET_CRYPTO_EccPublicKey bob_pkey;
204 struct GNUNET_CRYPTO_EccPrivateKey *alice_key; 204 struct GNUNET_CRYPTO_EccPrivateKey *alice_key;
205 struct GNUNET_CRYPTO_EccPrivateKey *bob_key; 205 struct GNUNET_CRYPTO_EccPrivateKey *bob_key;
206 struct GNUNET_CRYPTO_EccSignature *sig; 206 struct GNUNET_CRYPTO_EccSignature *sig;
diff --git a/src/hello/gnunet-hello.c b/src/hello/gnunet-hello.c
index 816a89936..e4e0978ee 100644
--- a/src/hello/gnunet-hello.c
+++ b/src/hello/gnunet-hello.c
@@ -108,7 +108,7 @@ main (int argc, char *argv[])
108 struct GNUNET_DISK_FileHandle *fh; 108 struct GNUNET_DISK_FileHandle *fh;
109 struct GNUNET_HELLO_Message *orig; 109 struct GNUNET_HELLO_Message *orig;
110 struct GNUNET_HELLO_Message *result; 110 struct GNUNET_HELLO_Message *result;
111 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pk; 111 struct GNUNET_CRYPTO_EccPublicKey pk;
112 uint64_t fsize; 112 uint64_t fsize;
113 113
114 GNUNET_log_setup ("gnunet-hello", "INFO", NULL); 114 GNUNET_log_setup ("gnunet-hello", "INFO", NULL);
diff --git a/src/hello/hello.c b/src/hello/hello.c
index a85a6ee97..d2e143579 100644
--- a/src/hello/hello.c
+++ b/src/hello/hello.c
@@ -59,7 +59,7 @@ struct GNUNET_HELLO_Message
59 /** 59 /**
60 * The public key of the peer. 60 * The public key of the peer.
61 */ 61 */
62 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded publicKey; 62 struct GNUNET_CRYPTO_EccPublicKey publicKey;
63 63
64}; 64};
65GNUNET_NETWORK_STRUCT_END 65GNUNET_NETWORK_STRUCT_END
@@ -216,8 +216,7 @@ get_hello_address_size (const char *buf, size_t max, uint16_t * ralen)
216 * @return the hello message 216 * @return the hello message
217 */ 217 */
218struct GNUNET_HELLO_Message * 218struct GNUNET_HELLO_Message *
219GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded 219GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EccPublicKey *publicKey,
220 *publicKey,
221 GNUNET_HELLO_GenerateAddressListCallback addrgen, 220 GNUNET_HELLO_GenerateAddressListCallback addrgen,
222 void *addrgen_cls, 221 void *addrgen_cls,
223 int friend_only) 222 int friend_only)
@@ -248,7 +247,7 @@ GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded
248 hello->friend_only = htonl (friend_only); 247 hello->friend_only = htonl (friend_only);
249 248
250 memcpy (&hello->publicKey, publicKey, 249 memcpy (&hello->publicKey, publicKey,
251 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)); 250 sizeof (struct GNUNET_CRYPTO_EccPublicKey));
252 memcpy (&hello[1], buffer, used); 251 memcpy (&hello[1], buffer, used);
253 return hello; 252 return hello;
254} 253}
@@ -296,7 +295,7 @@ GNUNET_HELLO_iterate_addresses (const struct GNUNET_HELLO_Message *msg,
296 wpos = 0; 295 wpos = 0;
297 woff = (ret != NULL) ? (char *) &ret[1] : NULL; 296 woff = (ret != NULL) ? (char *) &ret[1] : NULL;
298 GNUNET_CRYPTO_hash (&msg->publicKey, 297 GNUNET_CRYPTO_hash (&msg->publicKey,
299 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 298 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
300 &address.peer.hashPubKey); 299 &address.peer.hashPubKey);
301 while (insize > 0) 300 while (insize > 0)
302 { 301 {
@@ -531,7 +530,7 @@ GNUNET_HELLO_size (const struct GNUNET_HELLO_Message *hello)
531 */ 530 */
532int 531int
533GNUNET_HELLO_get_key (const struct GNUNET_HELLO_Message *hello, 532GNUNET_HELLO_get_key (const struct GNUNET_HELLO_Message *hello,
534 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *publicKey) 533 struct GNUNET_CRYPTO_EccPublicKey *publicKey)
535{ 534{
536 uint16_t ret = ntohs (hello->header.size); 535 uint16_t ret = ntohs (hello->header.size);
537 536
@@ -560,7 +559,7 @@ GNUNET_HELLO_get_id (const struct GNUNET_HELLO_Message *hello,
560 (ntohs (hello->header.type) != GNUNET_MESSAGE_TYPE_HELLO)) 559 (ntohs (hello->header.type) != GNUNET_MESSAGE_TYPE_HELLO))
561 return GNUNET_SYSERR; 560 return GNUNET_SYSERR;
562 GNUNET_CRYPTO_hash (&hello->publicKey, 561 GNUNET_CRYPTO_hash (&hello->publicKey,
563 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 562 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
564 &peer->hashPubKey); 563 &peer->hashPubKey);
565 return GNUNET_OK; 564 return GNUNET_OK;
566} 565}
@@ -672,7 +671,7 @@ GNUNET_HELLO_equals (const struct GNUNET_HELLO_Message *h1,
672 671
673 if (0 != 672 if (0 !=
674 memcmp (&h1->publicKey, &h2->publicKey, 673 memcmp (&h1->publicKey, &h2->publicKey,
675 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded))) 674 sizeof (struct GNUNET_CRYPTO_EccPublicKey)))
676 return GNUNET_TIME_UNIT_ZERO_ABS; 675 return GNUNET_TIME_UNIT_ZERO_ABS;
677 ec.expiration_limit = now; 676 ec.expiration_limit = now;
678 ec.result = GNUNET_TIME_UNIT_FOREVER_ABS; 677 ec.result = GNUNET_TIME_UNIT_FOREVER_ABS;
@@ -1047,7 +1046,7 @@ add_address_to_hello (void *cls, size_t max, void *buffer)
1047 */ 1046 */
1048int 1047int
1049GNUNET_HELLO_parse_uri (const char *uri, 1048GNUNET_HELLO_parse_uri (const char *uri,
1050 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *pubkey, 1049 struct GNUNET_CRYPTO_EccPublicKey *pubkey,
1051 struct GNUNET_HELLO_Message **hello, 1050 struct GNUNET_HELLO_Message **hello,
1052 GNUNET_HELLO_TransportPluginsFind plugins_find) 1051 GNUNET_HELLO_TransportPluginsFind plugins_find)
1053{ 1052{
diff --git a/src/hello/test_friend_hello.c b/src/hello/test_friend_hello.c
index fb14817c7..7d0348339 100644
--- a/src/hello/test_friend_hello.c
+++ b/src/hello/test_friend_hello.c
@@ -93,8 +93,8 @@ main (int argc, char *argv[])
93 struct GNUNET_HELLO_Message *msg1; 93 struct GNUNET_HELLO_Message *msg1;
94 struct GNUNET_HELLO_Message *msg2; 94 struct GNUNET_HELLO_Message *msg2;
95 struct GNUNET_HELLO_Message *msg3; 95 struct GNUNET_HELLO_Message *msg3;
96 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded publicKey; 96 struct GNUNET_CRYPTO_EccPublicKey publicKey;
97 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pk; 97 struct GNUNET_CRYPTO_EccPublicKey pk;
98 struct GNUNET_TIME_Absolute startup_time; 98 struct GNUNET_TIME_Absolute startup_time;
99 unsigned int i; 99 unsigned int i;
100 100
diff --git a/src/hello/test_hello.c b/src/hello/test_hello.c
index 64abec5e4..67f7318b2 100644
--- a/src/hello/test_hello.c
+++ b/src/hello/test_hello.c
@@ -93,8 +93,8 @@ main (int argc, char *argv[])
93 struct GNUNET_HELLO_Message *msg1; 93 struct GNUNET_HELLO_Message *msg1;
94 struct GNUNET_HELLO_Message *msg2; 94 struct GNUNET_HELLO_Message *msg2;
95 struct GNUNET_HELLO_Message *msg3; 95 struct GNUNET_HELLO_Message *msg3;
96 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded publicKey; 96 struct GNUNET_CRYPTO_EccPublicKey publicKey;
97 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pk; 97 struct GNUNET_CRYPTO_EccPublicKey pk;
98 struct GNUNET_TIME_Absolute startup_time; 98 struct GNUNET_TIME_Absolute startup_time;
99 unsigned int i; 99 unsigned int i;
100 100
diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c
index eeaa4e253..b9384ea65 100644
--- a/src/identity/gnunet-service-identity.c
+++ b/src/identity/gnunet-service-identity.c
@@ -209,23 +209,16 @@ static struct GNUNET_IDENTITY_UpdateMessage *
209create_update_message (struct Ego *ego) 209create_update_message (struct Ego *ego)
210{ 210{
211 struct GNUNET_IDENTITY_UpdateMessage *um; 211 struct GNUNET_IDENTITY_UpdateMessage *um;
212 char *str;
213 uint16_t pk_len;
214 size_t name_len; 212 size_t name_len;
215 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *enc; 213
216
217 name_len = (NULL == ego->identifier) ? 0 : (strlen (ego->identifier) + 1); 214 name_len = (NULL == ego->identifier) ? 0 : (strlen (ego->identifier) + 1);
218 enc = GNUNET_CRYPTO_ecc_encode_key (ego->pk); 215 um = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_UpdateMessage) + name_len);
219 pk_len = ntohs (enc->size);
220 um = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_UpdateMessage) + pk_len + name_len);
221 um->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE); 216 um->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE);
222 um->header.size = htons (sizeof (struct GNUNET_IDENTITY_UpdateMessage) + pk_len + name_len); 217 um->header.size = htons (sizeof (struct GNUNET_IDENTITY_UpdateMessage) + name_len);
223 um->name_len = htons (name_len); 218 um->name_len = htons (name_len);
224 um->pk_len = htons (pk_len); 219 um->end_of_list = htons (GNUNET_NO);
225 str = (char *) &um[1]; 220 um->private_key = *ego->pk;
226 memcpy (str, enc, pk_len); 221 memcpy (&um[1], ego->identifier, name_len);
227 memcpy (&str[pk_len], ego->identifier, name_len);
228 GNUNET_free (enc);
229 return um; 222 return um;
230} 223}
231 224
@@ -242,23 +235,16 @@ create_set_default_message (struct Ego *ego,
242 const char *servicename) 235 const char *servicename)
243{ 236{
244 struct GNUNET_IDENTITY_SetDefaultMessage *sdm; 237 struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
245 char *str;
246 uint16_t pk_len;
247 size_t name_len; 238 size_t name_len;
248 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *enc;
249 239
250 name_len = (NULL == servicename) ? 0 : (strlen (servicename) + 1); 240 name_len = (NULL == servicename) ? 0 : (strlen (servicename) + 1);
251 enc = GNUNET_CRYPTO_ecc_encode_key (ego->pk); 241 sdm = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) + name_len);
252 pk_len = ntohs (enc->size);
253 sdm = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) + pk_len + name_len);
254 sdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT); 242 sdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT);
255 sdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) + pk_len + name_len); 243 sdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) + name_len);
256 sdm->name_len = htons (name_len); 244 sdm->name_len = htons (name_len);
257 sdm->pk_len = htons (pk_len); 245 sdm->reserved = htons (0);
258 str = (char *) &sdm[1]; 246 sdm->private_key = *ego->pk;
259 memcpy (str, enc, pk_len); 247 memcpy (&sdm[1], servicename, name_len);
260 memcpy (&str[pk_len], servicename, name_len);
261 GNUNET_free (enc);
262 return sdm; 248 return sdm;
263} 249}
264 250
@@ -290,9 +276,10 @@ handle_start_message (void *cls, struct GNUNET_SERVER_Client *client,
290 GNUNET_SERVER_notification_context_unicast (nc, client, &um->header, GNUNET_NO); 276 GNUNET_SERVER_notification_context_unicast (nc, client, &um->header, GNUNET_NO);
291 GNUNET_free (um); 277 GNUNET_free (um);
292 } 278 }
279 memset (&ume, 0, sizeof (ume));
293 ume.header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE); 280 ume.header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_UPDATE);
294 ume.header.size = htons (sizeof (struct GNUNET_IDENTITY_UpdateMessage)); 281 ume.header.size = htons (sizeof (struct GNUNET_IDENTITY_UpdateMessage));
295 ume.pk_len = htons (0); 282 ume.end_of_list = htons (GNUNET_YES);
296 ume.name_len = htons (0); 283 ume.name_len = htons (0);
297 GNUNET_SERVER_notification_context_unicast (nc, client, &ume.header, GNUNET_NO); 284 GNUNET_SERVER_notification_context_unicast (nc, client, &ume.header, GNUNET_NO);
298 GNUNET_SERVER_receive_done (client, GNUNET_OK); 285 GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -383,12 +370,7 @@ static int
383key_cmp (const struct GNUNET_CRYPTO_EccPrivateKey *pk1, 370key_cmp (const struct GNUNET_CRYPTO_EccPrivateKey *pk1,
384 const struct GNUNET_CRYPTO_EccPrivateKey *pk2) 371 const struct GNUNET_CRYPTO_EccPrivateKey *pk2)
385{ 372{
386 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded p1; 373 return memcmp (pk1, pk2, sizeof (struct GNUNET_CRYPTO_EccPrivateKey));
387 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded p2;
388
389 GNUNET_CRYPTO_ecc_key_get_public (pk1, &p1);
390 GNUNET_CRYPTO_ecc_key_get_public (pk2, &p2);
391 return memcmp (&p1, &p2, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded));
392} 374}
393 375
394 376
@@ -407,10 +389,8 @@ handle_set_default_message (void *cls, struct GNUNET_SERVER_Client *client,
407 const struct GNUNET_IDENTITY_SetDefaultMessage *sdm; 389 const struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
408 uint16_t size; 390 uint16_t size;
409 uint16_t name_len; 391 uint16_t name_len;
410 uint16_t pk_len;
411 struct Ego *ego; 392 struct Ego *ego;
412 const char *str; 393 const char *str;
413 struct GNUNET_CRYPTO_EccPrivateKey *pk;
414 394
415 size = ntohs (message->size); 395 size = ntohs (message->size);
416 if (size <= sizeof (struct GNUNET_IDENTITY_SetDefaultMessage)) 396 if (size <= sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
@@ -421,16 +401,14 @@ handle_set_default_message (void *cls, struct GNUNET_SERVER_Client *client,
421 } 401 }
422 sdm = (const struct GNUNET_IDENTITY_SetDefaultMessage *) message; 402 sdm = (const struct GNUNET_IDENTITY_SetDefaultMessage *) message;
423 name_len = ntohs (sdm->name_len); 403 name_len = ntohs (sdm->name_len);
424 pk_len = ntohs (sdm->pk_len); 404 GNUNET_break (0 == ntohs (sdm->reserved));
425 str = (const char *) &sdm[1]; 405 if (name_len + sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) != size)
426 if ( (name_len + pk_len + sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) != size) ||
427 (NULL == (pk = GNUNET_CRYPTO_ecc_decode_key (str, pk_len, GNUNET_YES))) )
428 { 406 {
429 GNUNET_break (0); 407 GNUNET_break (0);
430 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 408 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
431 return; 409 return;
432 } 410 }
433 str = &str[pk_len]; 411 str = (const char *) &sdm[1];
434 if ('\0' != str[name_len - 1]) 412 if ('\0' != str[name_len - 1])
435 { 413 {
436 GNUNET_break (0); 414 GNUNET_break (0);
@@ -443,7 +421,7 @@ handle_set_default_message (void *cls, struct GNUNET_SERVER_Client *client,
443 for (ego = ego_head; NULL != ego; ego = ego->next) 421 for (ego = ego_head; NULL != ego; ego = ego->next)
444 { 422 {
445 if (0 == key_cmp (ego->pk, 423 if (0 == key_cmp (ego->pk,
446 pk)) 424 &sdm->private_key))
447 { 425 {
448 GNUNET_CONFIGURATION_set_value_string (subsystem_cfg, 426 GNUNET_CONFIGURATION_set_value_string (subsystem_cfg,
449 str, 427 str,
@@ -457,13 +435,11 @@ handle_set_default_message (void *cls, struct GNUNET_SERVER_Client *client,
457 subsystem_cfg_file); 435 subsystem_cfg_file);
458 send_result_code (client, 0, NULL); 436 send_result_code (client, 0, NULL);
459 GNUNET_SERVER_receive_done (client, GNUNET_OK); 437 GNUNET_SERVER_receive_done (client, GNUNET_OK);
460 GNUNET_CRYPTO_ecc_key_free (pk);
461 return; 438 return;
462 } 439 }
463 } 440 }
464 send_result_code (client, 1, _("Unknown ego specified for service (internal error)")); 441 send_result_code (client, 1, _("Unknown ego specified for service (internal error)"));
465 GNUNET_SERVER_receive_done (client, GNUNET_OK); 442 GNUNET_SERVER_receive_done (client, GNUNET_OK);
466 GNUNET_CRYPTO_ecc_key_free (pk);
467} 443}
468 444
469 445
@@ -498,11 +474,8 @@ handle_create_message (void *cls, struct GNUNET_SERVER_Client *client,
498 const struct GNUNET_IDENTITY_CreateRequestMessage *crm; 474 const struct GNUNET_IDENTITY_CreateRequestMessage *crm;
499 uint16_t size; 475 uint16_t size;
500 uint16_t name_len; 476 uint16_t name_len;
501 uint16_t pk_len;
502 struct Ego *ego; 477 struct Ego *ego;
503 const char *pks;
504 const char *str; 478 const char *str;
505 struct GNUNET_CRYPTO_EccPrivateKey *pk;
506 char *fn; 479 char *fn;
507 480
508 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 481 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -516,16 +489,14 @@ handle_create_message (void *cls, struct GNUNET_SERVER_Client *client,
516 } 489 }
517 crm = (const struct GNUNET_IDENTITY_CreateRequestMessage *) message; 490 crm = (const struct GNUNET_IDENTITY_CreateRequestMessage *) message;
518 name_len = ntohs (crm->name_len); 491 name_len = ntohs (crm->name_len);
519 pk_len = ntohs (crm->pk_len); 492 GNUNET_break (0 == ntohs (crm->reserved));
520 pks = (const char *) &crm[1]; 493 if (name_len + sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) != size)
521 if ( (name_len + pk_len + sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) != size) ||
522 (NULL == (pk = GNUNET_CRYPTO_ecc_decode_key (pks, pk_len, GNUNET_YES))) )
523 { 494 {
524 GNUNET_break (0); 495 GNUNET_break (0);
525 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 496 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
526 return; 497 return;
527 } 498 }
528 str = &pks[pk_len]; 499 str = (const char *) &crm[1];
529 if ('\0' != str[name_len - 1]) 500 if ('\0' != str[name_len - 1])
530 { 501 {
531 GNUNET_break (0); 502 GNUNET_break (0);
@@ -539,12 +510,12 @@ handle_create_message (void *cls, struct GNUNET_SERVER_Client *client,
539 { 510 {
540 send_result_code (client, 1, gettext_noop ("identifier already in use for another ego")); 511 send_result_code (client, 1, gettext_noop ("identifier already in use for another ego"));
541 GNUNET_SERVER_receive_done (client, GNUNET_OK); 512 GNUNET_SERVER_receive_done (client, GNUNET_OK);
542 GNUNET_CRYPTO_ecc_key_free (pk);
543 return; 513 return;
544 } 514 }
545 } 515 }
546 ego = GNUNET_new (struct Ego); 516 ego = GNUNET_new (struct Ego);
547 ego->pk = pk; 517 ego->pk = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey);
518 *ego->pk = crm->private_key;
548 ego->identifier = GNUNET_strdup (str); 519 ego->identifier = GNUNET_strdup (str);
549 GNUNET_CONTAINER_DLL_insert (ego_head, 520 GNUNET_CONTAINER_DLL_insert (ego_head,
550 ego_tail, 521 ego_tail,
@@ -552,8 +523,10 @@ handle_create_message (void *cls, struct GNUNET_SERVER_Client *client,
552 send_result_code (client, 0, NULL); 523 send_result_code (client, 0, NULL);
553 fn = get_ego_filename (ego); 524 fn = get_ego_filename (ego);
554 (void) GNUNET_DISK_directory_create_for_file (fn); 525 (void) GNUNET_DISK_directory_create_for_file (fn);
555 if (pk_len != 526 if (sizeof (struct GNUNET_CRYPTO_EccPrivateKey) !=
556 GNUNET_DISK_fn_write (fn, pks, pk_len, 527 GNUNET_DISK_fn_write (fn,
528 &crm->private_key,
529 sizeof (struct GNUNET_CRYPTO_EccPrivateKey),
557 GNUNET_DISK_PERM_USER_READ | 530 GNUNET_DISK_PERM_USER_READ |
558 GNUNET_DISK_PERM_USER_WRITE)) 531 GNUNET_DISK_PERM_USER_WRITE))
559 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, 532 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
diff --git a/src/identity/identity.h b/src/identity/identity.h
index 181f5c353..13ac91e46 100644
--- a/src/identity/identity.h
+++ b/src/identity/identity.h
@@ -74,11 +74,14 @@ struct GNUNET_IDENTITY_UpdateMessage
74 uint16_t name_len GNUNET_PACKED; 74 uint16_t name_len GNUNET_PACKED;
75 75
76 /** 76 /**
77 * Number of bytes of private key data that follow, in NBO. 77 * Usually GNUNET_NO, GNUNET_YES to signal end of list.
78 */ 78 */
79 uint16_t pk_len GNUNET_PACKED; 79 uint16_t end_of_list GNUNET_PACKED;
80 80
81 /* followed by private key */ 81 /**
82 * The private key
83 */
84 struct GNUNET_CRYPTO_EccPrivateKey private_key;
82 85
83 /* followed by 0-terminated identity name */ 86 /* followed by 0-terminated identity name */
84 87
@@ -130,11 +133,14 @@ struct GNUNET_IDENTITY_SetDefaultMessage
130 uint16_t name_len GNUNET_PACKED; 133 uint16_t name_len GNUNET_PACKED;
131 134
132 /** 135 /**
133 * Number of bytes of private key data that follow, in NBO. 136 * Always zero.
134 */ 137 */
135 uint16_t pk_len GNUNET_PACKED; 138 uint16_t reserved GNUNET_PACKED;
136 139
137 /* followed by private key */ 140 /**
141 * The private key
142 */
143 struct GNUNET_CRYPTO_EccPrivateKey private_key;
138 144
139 /* followed by 0-terminated service name */ 145 /* followed by 0-terminated service name */
140 146
@@ -158,11 +164,14 @@ struct GNUNET_IDENTITY_CreateRequestMessage
158 uint16_t name_len GNUNET_PACKED; 164 uint16_t name_len GNUNET_PACKED;
159 165
160 /** 166 /**
161 * Number of bytes of private key data that follow, in NBO. 167 * Always zero.
162 */ 168 */
163 uint16_t pk_len GNUNET_PACKED; 169 uint16_t reserved GNUNET_PACKED;
164 170
165 /* followed by private key */ 171 /**
172 * The private key
173 */
174 struct GNUNET_CRYPTO_EccPrivateKey private_key;
166 175
167 /* followed by 0-terminated identity name */ 176 /* followed by 0-terminated identity name */
168 177
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c
index 54144c5bc..2062ddc63 100644
--- a/src/identity/identity_api.c
+++ b/src/identity/identity_api.c
@@ -48,9 +48,9 @@ struct GNUNET_IDENTITY_Ego
48 struct GNUNET_CRYPTO_EccPrivateKey *pk; 48 struct GNUNET_CRYPTO_EccPrivateKey *pk;
49 49
50 /** 50 /**
51 * Current identifier (name) associated with this ego. 51 * Current name associated with this ego.
52 */ 52 */
53 char *identifier; 53 char *name;
54 54
55 /** 55 /**
56 * Client context associated with this ego. 56 * Client context associated with this ego.
@@ -234,12 +234,10 @@ message_handler (void *cls,
234 const struct GNUNET_IDENTITY_ResultCodeMessage *rcm; 234 const struct GNUNET_IDENTITY_ResultCodeMessage *rcm;
235 const struct GNUNET_IDENTITY_UpdateMessage *um; 235 const struct GNUNET_IDENTITY_UpdateMessage *um;
236 const struct GNUNET_IDENTITY_SetDefaultMessage *sdm; 236 const struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
237 struct GNUNET_CRYPTO_EccPrivateKey *priv; 237 struct GNUNET_CRYPTO_EccPublicKey pub;
238 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pub;
239 struct GNUNET_HashCode id; 238 struct GNUNET_HashCode id;
240 const char *str; 239 const char *str;
241 uint16_t size; 240 uint16_t size;
242 uint16_t pk_len;
243 uint16_t name_len; 241 uint16_t name_len;
244 242
245 if (NULL == msg) 243 if (NULL == msg)
@@ -291,39 +289,31 @@ message_handler (void *cls,
291 return; 289 return;
292 } 290 }
293 um = (const struct GNUNET_IDENTITY_UpdateMessage *) msg; 291 um = (const struct GNUNET_IDENTITY_UpdateMessage *) msg;
294 pk_len = ntohs (um->pk_len); 292 name_len = ntohs (um->name_len);
295 name_len = ntohs (um->name_len); 293
296 str = (const char *) &um[1]; 294 str = (const char *) &um[1];
297 if ( (size != pk_len + name_len + sizeof (struct GNUNET_IDENTITY_UpdateMessage)) || 295 if ( (size != name_len + sizeof (struct GNUNET_IDENTITY_UpdateMessage)) ||
298 ( (0 != name_len) && 296 ( (0 != name_len) &&
299 ('\0' != str[pk_len + name_len - 1])) ) 297 ('\0' != str[name_len - 1])) )
300 { 298 {
301 GNUNET_break (0); 299 GNUNET_break (0);
302 reschedule_connect (h); 300 reschedule_connect (h);
303 return; 301 return;
304 } 302 }
305 if ( (0 == pk_len) && 303 if (GNUNET_YES == ntohs (um->end_of_list))
306 (0 == name_len) )
307 { 304 {
308 /* end of initial list of data */ 305 /* end of initial list of data */
309 if (NULL != h->cb) 306 if (NULL != h->cb)
310 h->cb (h->cb_cls, NULL, NULL, NULL); 307 h->cb (h->cb_cls, NULL, NULL, NULL);
311 break; 308 break;
312 } 309 }
313 priv = GNUNET_CRYPTO_ecc_decode_key (str, pk_len, GNUNET_YES); 310 GNUNET_CRYPTO_ecc_key_get_public (&um->private_key,
314 if (NULL == priv)
315 {
316 GNUNET_break (0);
317 reschedule_connect (h);
318 return;
319 }
320 GNUNET_CRYPTO_ecc_key_get_public (priv,
321 &pub); 311 &pub);
322 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id); 312 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id);
323 if (0 == name_len) 313 if (0 == name_len)
324 str = NULL; 314 str = NULL;
325 else 315 else
326 str = &str[pk_len]; 316 str = (const char *) &um[1];
327 ego = GNUNET_CONTAINER_multihashmap_get (h->egos, 317 ego = GNUNET_CONTAINER_multihashmap_get (h->egos,
328 &id); 318 &id);
329 if (NULL == ego) 319 if (NULL == ego)
@@ -333,13 +323,13 @@ message_handler (void *cls,
333 { 323 {
334 /* deletion of unknown ego? not allowed */ 324 /* deletion of unknown ego? not allowed */
335 GNUNET_break (0); 325 GNUNET_break (0);
336 GNUNET_CRYPTO_ecc_key_free (priv);
337 reschedule_connect (h); 326 reschedule_connect (h);
338 return; 327 return;
339 } 328 }
340 ego = GNUNET_new (struct GNUNET_IDENTITY_Ego); 329 ego = GNUNET_new (struct GNUNET_IDENTITY_Ego);
341 ego->pk = priv; 330 ego->pk = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey);
342 ego->identifier = GNUNET_strdup (str); 331 *ego->pk = um->private_key;
332 ego->name = GNUNET_strdup (str);
343 ego->id = id; 333 ego->id = id;
344 GNUNET_assert (GNUNET_YES == 334 GNUNET_assert (GNUNET_YES ==
345 GNUNET_CONTAINER_multihashmap_put (h->egos, 335 GNUNET_CONTAINER_multihashmap_put (h->egos,
@@ -347,10 +337,6 @@ message_handler (void *cls,
347 ego, 337 ego,
348 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 338 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
349 } 339 }
350 else
351 {
352 GNUNET_CRYPTO_ecc_key_free (priv);
353 }
354 /* inform application about change */ 340 /* inform application about change */
355 if (NULL != h->cb) 341 if (NULL != h->cb)
356 h->cb (h->cb_cls, 342 h->cb (h->cb_cls,
@@ -365,14 +351,14 @@ message_handler (void *cls,
365 &ego->id, 351 &ego->id,
366 ego)); 352 ego));
367 GNUNET_CRYPTO_ecc_key_free (ego->pk); 353 GNUNET_CRYPTO_ecc_key_free (ego->pk);
368 GNUNET_free (ego->identifier); 354 GNUNET_free (ego->name);
369 GNUNET_free (ego); 355 GNUNET_free (ego);
370 } 356 }
371 else 357 else
372 { 358 {
373 /* ego changed name */ 359 /* ego changed name */
374 GNUNET_free (ego->identifier); 360 GNUNET_free (ego->name);
375 ego->identifier = GNUNET_strdup (str); 361 ego->name = GNUNET_strdup (str);
376 } 362 }
377 break; 363 break;
378 case GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT: 364 case GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT:
@@ -383,32 +369,24 @@ message_handler (void *cls,
383 return; 369 return;
384 } 370 }
385 sdm = (const struct GNUNET_IDENTITY_SetDefaultMessage *) msg; 371 sdm = (const struct GNUNET_IDENTITY_SetDefaultMessage *) msg;
386 pk_len = ntohs (sdm->pk_len); 372 GNUNET_break (0 == ntohs (sdm->reserved));
387 name_len = ntohs (sdm->name_len); 373 name_len = ntohs (sdm->name_len);
388 str = (const char *) &sdm[1]; 374 str = (const char *) &sdm[1];
389 if ( (size != pk_len + name_len + sizeof (struct GNUNET_IDENTITY_SetDefaultMessage)) || 375 if ( (size != name_len + sizeof (struct GNUNET_IDENTITY_SetDefaultMessage)) ||
390 ( (0 != name_len) && 376 ( (0 != name_len) &&
391 ('\0' != str[pk_len + name_len - 1]) ) ) 377 ('\0' != str[name_len - 1]) ) )
392 { 378 {
393 GNUNET_break (0); 379 GNUNET_break (0);
394 reschedule_connect (h); 380 reschedule_connect (h);
395 return; 381 return;
396 } 382 }
397 priv = GNUNET_CRYPTO_ecc_decode_key (str, pk_len, GNUNET_YES); 383 GNUNET_CRYPTO_ecc_key_get_public (&sdm->private_key,
398 if (NULL == priv)
399 {
400 GNUNET_break (0);
401 reschedule_connect (h);
402 return;
403 }
404 GNUNET_CRYPTO_ecc_key_get_public (priv,
405 &pub); 384 &pub);
406 GNUNET_CRYPTO_ecc_key_free (priv);
407 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id); 385 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &id);
408 if (0 == name_len) 386 if (0 == name_len)
409 str = NULL; 387 str = NULL;
410 else 388 else
411 str = &str[pk_len]; 389 str = (const char *) &sdm[1];
412 ego = GNUNET_CONTAINER_multihashmap_get (h->egos, 390 ego = GNUNET_CONTAINER_multihashmap_get (h->egos,
413 &id); 391 &id);
414 if (NULL == ego) 392 if (NULL == ego)
@@ -425,7 +403,7 @@ message_handler (void *cls,
425 op->cb (op->cls, 403 op->cb (op->cls,
426 ego, 404 ego,
427 &ego->ctx, 405 &ego->ctx,
428 ego->identifier); 406 ego->name);
429 GNUNET_free (op); 407 GNUNET_free (op);
430 break; 408 break;
431 default: 409 default:
@@ -588,13 +566,27 @@ GNUNET_IDENTITY_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
588 * @return associated ECC key, valid as long as the ego is valid 566 * @return associated ECC key, valid as long as the ego is valid
589 */ 567 */
590const struct GNUNET_CRYPTO_EccPrivateKey * 568const struct GNUNET_CRYPTO_EccPrivateKey *
591GNUNET_IDENTITY_ego_get_key (struct GNUNET_IDENTITY_Ego *ego) 569GNUNET_IDENTITY_ego_get_private_key (struct GNUNET_IDENTITY_Ego *ego)
592{ 570{
593 return ego->pk; 571 return ego->pk;
594} 572}
595 573
596 574
597/** 575/**
576 * Get the identifier (public key) of an ego.
577 *
578 * @param ego identity handle with the private key
579 * @param pk set to ego's public key
580 */
581void
582GNUNET_IDENTITY_ego_get_public_key (struct GNUNET_IDENTITY_Ego *ego,
583 struct GNUNET_CRYPTO_EccPublicKey *pk)
584{
585 GNUNET_assert (0);
586}
587
588
589/**
598 * Obtain the identity that is currently preferred/default 590 * Obtain the identity that is currently preferred/default
599 * for a service. 591 * for a service.
600 * 592 *
@@ -660,38 +652,30 @@ GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *id,
660 GNUNET_IDENTITY_Continuation cont, 652 GNUNET_IDENTITY_Continuation cont,
661 void *cont_cls) 653 void *cont_cls)
662{ 654{
663 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *enc;
664 struct GNUNET_IDENTITY_Operation *op; 655 struct GNUNET_IDENTITY_Operation *op;
665 struct GNUNET_IDENTITY_SetDefaultMessage *sdm; 656 struct GNUNET_IDENTITY_SetDefaultMessage *sdm;
666 char *str;
667 uint16_t enc_len;
668 size_t slen; 657 size_t slen;
669 658
670 slen = strlen (service_name) + 1; 659 slen = strlen (service_name) + 1;
671 enc = GNUNET_CRYPTO_ecc_encode_key (ego->pk); 660 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_SetDefaultMessage))
672 enc_len = ntohs (enc->size);
673
674 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) - enc_len)
675 { 661 {
676 GNUNET_break (0); 662 GNUNET_break (0);
677 GNUNET_free (enc);
678 return NULL; 663 return NULL;
679 } 664 }
680 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) + 665 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
681 sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) + 666 sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) +
682 enc_len + slen); 667 slen);
683 op->h = id; 668 op->h = id;
684 op->cont = cont; 669 op->cont = cont;
685 op->cls = cont_cls; 670 op->cls = cont_cls;
686 sdm = (struct GNUNET_IDENTITY_SetDefaultMessage *) &op[1]; 671 sdm = (struct GNUNET_IDENTITY_SetDefaultMessage *) &op[1];
687 sdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT); 672 sdm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_SET_DEFAULT);
688 sdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) + 673 sdm->header.size = htons (sizeof (struct GNUNET_IDENTITY_SetDefaultMessage) +
689 slen + enc_len); 674 slen);
690 sdm->name_len = htons (slen); 675 sdm->name_len = htons (slen);
691 sdm->pk_len = htons (enc_len); 676 sdm->reserved = htons (0);
692 str = (char *) &sdm[1]; 677 sdm->private_key = *ego->pk;
693 memcpy (str, enc, enc_len); 678 memcpy (&sdm[1], service_name, slen);
694 memcpy (&str[enc_len], service_name, slen);
695 op->msg = &sdm->header; 679 op->msg = &sdm->header;
696 GNUNET_CONTAINER_DLL_insert_tail (id->op_head, 680 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
697 id->op_tail, 681 id->op_tail,
@@ -703,61 +687,55 @@ GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *id,
703 687
704 688
705/** 689/**
706 * Create a new identity with the given identifier. 690 * Create a new identity with the given name.
707 * 691 *
708 * @param id identity service to use 692 * @param id identity service to use
709 * @param identifier desired identifier 693 * @param name desired name
710 * @param cont function to call with the result (will only be called once) 694 * @param cont function to call with the result (will only be called once)
711 * @param cont_cls closure for cont 695 * @param cont_cls closure for cont
712 * @return handle to abort the operation 696 * @return handle to abort the operation
713 */ 697 */
714struct GNUNET_IDENTITY_Operation * 698struct GNUNET_IDENTITY_Operation *
715GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id, 699GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id,
716 const char *identifier, 700 const char *name,
717 GNUNET_IDENTITY_Continuation cont, 701 GNUNET_IDENTITY_Continuation cont,
718 void *cont_cls) 702 void *cont_cls)
719{ 703{
720 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *enc;
721 struct GNUNET_IDENTITY_Operation *op; 704 struct GNUNET_IDENTITY_Operation *op;
722 struct GNUNET_IDENTITY_CreateRequestMessage *crm; 705 struct GNUNET_IDENTITY_CreateRequestMessage *crm;
723 struct GNUNET_CRYPTO_EccPrivateKey *pk; 706 struct GNUNET_CRYPTO_EccPrivateKey *pk;
724 char *str;
725 uint16_t enc_len;
726 size_t slen; 707 size_t slen;
727 708
728 slen = strlen (identifier) + 1; 709 slen = strlen (name) + 1;
729 pk = GNUNET_CRYPTO_ecc_key_create (); 710 pk = GNUNET_CRYPTO_ecc_key_create ();
730 enc = GNUNET_CRYPTO_ecc_encode_key (pk);
731 GNUNET_CRYPTO_ecc_key_free (pk);
732 enc_len = ntohs (enc->size);
733 711
734 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) - enc_len) 712 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_CreateRequestMessage))
735 { 713 {
736 GNUNET_break (0); 714 GNUNET_break (0);
737 GNUNET_free (enc); 715 GNUNET_CRYPTO_ecc_key_free (pk);
738 return NULL; 716 return NULL;
739 } 717 }
740 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) + 718 op = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_Operation) +
741 sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) + 719 sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) +
742 enc_len + slen); 720 slen);
743 op->h = id; 721 op->h = id;
744 op->cont = cont; 722 op->cont = cont;
745 op->cls = cont_cls; 723 op->cls = cont_cls;
746 crm = (struct GNUNET_IDENTITY_CreateRequestMessage *) &op[1]; 724 crm = (struct GNUNET_IDENTITY_CreateRequestMessage *) &op[1];
747 crm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_CREATE); 725 crm->header.type = htons (GNUNET_MESSAGE_TYPE_IDENTITY_CREATE);
748 crm->header.size = htons (sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) + 726 crm->header.size = htons (sizeof (struct GNUNET_IDENTITY_CreateRequestMessage) +
749 slen + enc_len); 727 slen);
750 crm->name_len = htons (slen); 728 crm->name_len = htons (slen);
751 crm->pk_len = htons (enc_len); 729 crm->reserved = htons (0);
752 str = (char *) &crm[1]; 730 crm->private_key = *pk;
753 memcpy (str, enc, enc_len); 731 memcpy (&crm[1], name, slen);
754 memcpy (&str[enc_len], identifier, slen);
755 op->msg = &crm->header; 732 op->msg = &crm->header;
756 GNUNET_CONTAINER_DLL_insert_tail (id->op_head, 733 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
757 id->op_tail, 734 id->op_tail,
758 op); 735 op);
759 if (NULL == id->th) 736 if (NULL == id->th)
760 transmit_next (id); 737 transmit_next (id);
738 GNUNET_CRYPTO_ecc_key_free (pk);
761 return op; 739 return op;
762} 740}
763 741
@@ -766,16 +744,16 @@ GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id,
766 * Renames an existing identity. 744 * Renames an existing identity.
767 * 745 *
768 * @param id identity service to use 746 * @param id identity service to use
769 * @param old_identifier old identifier 747 * @param old_name old name
770 * @param new_identifier desired new identifier 748 * @param new_name desired new name
771 * @param cb function to call with the result (will only be called once) 749 * @param cb function to call with the result (will only be called once)
772 * @param cb_cls closure for cb 750 * @param cb_cls closure for cb
773 * @return handle to abort the operation 751 * @return handle to abort the operation
774 */ 752 */
775struct GNUNET_IDENTITY_Operation * 753struct GNUNET_IDENTITY_Operation *
776GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id, 754GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id,
777 const char *old_identifier, 755 const char *old_name,
778 const char *new_identifier, 756 const char *new_name,
779 GNUNET_IDENTITY_Continuation cb, 757 GNUNET_IDENTITY_Continuation cb,
780 void *cb_cls) 758 void *cb_cls)
781{ 759{
@@ -785,8 +763,8 @@ GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id,
785 size_t slen_new; 763 size_t slen_new;
786 char *dst; 764 char *dst;
787 765
788 slen_old = strlen (old_identifier) + 1; 766 slen_old = strlen (old_name) + 1;
789 slen_new = strlen (new_identifier) + 1; 767 slen_new = strlen (new_name) + 1;
790 if ( (slen_old >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || 768 if ( (slen_old >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
791 (slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || 769 (slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
792 (slen_old + slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_RenameMessage)) ) 770 (slen_old + slen_new >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_RenameMessage)) )
@@ -807,8 +785,8 @@ GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id,
807 grm->old_name_len = htons (slen_old); 785 grm->old_name_len = htons (slen_old);
808 grm->new_name_len = htons (slen_new); 786 grm->new_name_len = htons (slen_new);
809 dst = (char *) &grm[1]; 787 dst = (char *) &grm[1];
810 memcpy (dst, old_identifier, slen_old); 788 memcpy (dst, old_name, slen_old);
811 memcpy (&dst[slen_old], new_identifier, slen_new); 789 memcpy (&dst[slen_old], new_name, slen_new);
812 op->msg = &grm->header; 790 op->msg = &grm->header;
813 GNUNET_CONTAINER_DLL_insert_tail (id->op_head, 791 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
814 id->op_tail, 792 id->op_tail,
@@ -823,14 +801,14 @@ GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id,
823 * Delete an existing identity. 801 * Delete an existing identity.
824 * 802 *
825 * @param id identity service to use 803 * @param id identity service to use
826 * @param identifier identifier of the identity to delete 804 * @param name name of the identity to delete
827 * @param cb function to call with the result (will only be called once) 805 * @param cb function to call with the result (will only be called once)
828 * @param cb_cls closure for cb 806 * @param cb_cls closure for cb
829 * @return handle to abort the operation 807 * @return handle to abort the operation
830 */ 808 */
831struct GNUNET_IDENTITY_Operation * 809struct GNUNET_IDENTITY_Operation *
832GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id, 810GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id,
833 const char *identifier, 811 const char *name,
834 GNUNET_IDENTITY_Continuation cb, 812 GNUNET_IDENTITY_Continuation cb,
835 void *cb_cls) 813 void *cb_cls)
836{ 814{
@@ -838,7 +816,7 @@ GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id,
838 struct GNUNET_IDENTITY_DeleteMessage *gdm; 816 struct GNUNET_IDENTITY_DeleteMessage *gdm;
839 size_t slen; 817 size_t slen;
840 818
841 slen = strlen (identifier) + 1; 819 slen = strlen (name) + 1;
842 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_DeleteMessage)) 820 if (slen >= GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct GNUNET_IDENTITY_DeleteMessage))
843 { 821 {
844 GNUNET_break (0); 822 GNUNET_break (0);
@@ -856,7 +834,7 @@ GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id,
856 slen); 834 slen);
857 gdm->name_len = htons (slen); 835 gdm->name_len = htons (slen);
858 gdm->reserved = htons (0); 836 gdm->reserved = htons (0);
859 memcpy (&gdm[1], identifier, slen); 837 memcpy (&gdm[1], name, slen);
860 op->msg = &gdm->header; 838 op->msg = &gdm->header;
861 GNUNET_CONTAINER_DLL_insert_tail (id->op_head, 839 GNUNET_CONTAINER_DLL_insert_tail (id->op_head,
862 id->op_tail, 840 id->op_tail,
@@ -929,7 +907,7 @@ free_ego (void *cls,
929 &ego->ctx, 907 &ego->ctx,
930 NULL); 908 NULL);
931 GNUNET_CRYPTO_ecc_key_free (ego->pk); 909 GNUNET_CRYPTO_ecc_key_free (ego->pk);
932 GNUNET_free (ego->identifier); 910 GNUNET_free (ego->name);
933 GNUNET_free (ego); 911 GNUNET_free (ego);
934 return GNUNET_OK; 912 return GNUNET_OK;
935} 913}
diff --git a/src/include/block_dns.h b/src/include/block_dns.h
index c7e1fbb55..198bba2c0 100644
--- a/src/include/block_dns.h
+++ b/src/include/block_dns.h
@@ -58,7 +58,7 @@ struct GNUNET_DNS_Record
58 /** 58 /**
59 * The peer providing this service 59 * The peer providing this service
60 */ 60 */
61 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded peer; 61 struct GNUNET_CRYPTO_EccPublicKey peer;
62 62
63 /** 63 /**
64 * The descriptor for the service 64 * The descriptor for the service
diff --git a/src/include/block_gns.h b/src/include/block_gns.h
index 2f864f4d3..21f0b097c 100644
--- a/src/include/block_gns.h
+++ b/src/include/block_gns.h
@@ -39,14 +39,16 @@ struct GNSNameRecordBlock
39 /** 39 /**
40 * The public key of the authority 40 * The public key of the authority
41 */ 41 */
42 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key; 42 struct GNUNET_CRYPTO_EccPublicKey public_key;
43 43
44 /** 44 /**
45 * GNUNET_RSA_Signature using RSA-key generated from the records. 45 * GNUNET_RSA_Signature using RSA-key generated from the records.
46 */ 46 */
47 struct GNUNET_CRYPTO_EccSignature signature; 47 struct GNUNET_CRYPTO_EccSignature signature;
48 48
49 /* number of records that follow */ 49 /**
50 * number of records that follow
51 */
50 uint32_t rd_count GNUNET_PACKED; 52 uint32_t rd_count GNUNET_PACKED;
51 53
52 /* 0-terminated name here */ 54 /* 0-terminated name here */
diff --git a/src/include/block_regex.h b/src/include/block_regex.h
index bfaf411eb..5995f70a2 100644
--- a/src/include/block_regex.h
+++ b/src/include/block_regex.h
@@ -67,7 +67,7 @@ struct RegexAcceptBlock
67 /** 67 /**
68 * Public key of the peer signing. 68 * Public key of the peer signing.
69 */ 69 */
70 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key; 70 struct GNUNET_CRYPTO_EccPublicKey public_key;
71 71
72 /** 72 /**
73 * The signature. 73 * The signature.
diff --git a/src/include/gnunet_chat_service.h b/src/include/gnunet_chat_service.h
index 8e77f9b65..d539197a0 100644
--- a/src/include/gnunet_chat_service.h
+++ b/src/include/gnunet_chat_service.h
@@ -135,7 +135,7 @@ typedef int (*GNUNET_CHAT_MemberListCallback) (void *cls,
135 GNUNET_CONTAINER_MetaData * 135 GNUNET_CONTAINER_MetaData *
136 member_info, 136 member_info,
137 const struct 137 const struct
138 GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 138 GNUNET_CRYPTO_RsaPublicKey
139 * member_id, 139 * member_id,
140 enum GNUNET_CHAT_MsgOptions 140 enum GNUNET_CHAT_MsgOptions
141 options); 141 options);
@@ -209,7 +209,7 @@ GNUNET_CHAT_join_room (const struct GNUNET_CONFIGURATION_Handle *cfg,
209void 209void
210GNUNET_CHAT_send_message (struct GNUNET_CHAT_Room *room, const char *message, 210GNUNET_CHAT_send_message (struct GNUNET_CHAT_Room *room, const char *message,
211 enum GNUNET_CHAT_MsgOptions options, 211 enum GNUNET_CHAT_MsgOptions options,
212 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded 212 const struct GNUNET_CRYPTO_RsaPublicKey
213 *receiver, uint32_t * sequence_number); 213 *receiver, uint32_t * sequence_number);
214 214
215 215
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index da2fe860e..5f209efea 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -43,6 +43,14 @@ extern "C"
43#include "gnunet_common.h" 43#include "gnunet_common.h"
44#include "gnunet_scheduler_lib.h" 44#include "gnunet_scheduler_lib.h"
45 45
46
47/**
48 * Maximum length of an ECC signature.
49 * Note: round up to multiple of 8 minus 2 for alignment.
50 */
51#define GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH 126
52
53
46/** 54/**
47 * Desired quality level for cryptographic operations. 55 * Desired quality level for cryptographic operations.
48 */ 56 */
@@ -77,24 +85,6 @@ enum GNUNET_CRYPTO_Quality
77#define GNUNET_CRYPTO_HASH_LENGTH (512/8) 85#define GNUNET_CRYPTO_HASH_LENGTH (512/8)
78 86
79/** 87/**
80 * Maximum length of an ECC signature.
81 * Note: round up to multiple of 8 minus 2 for alignment.
82 */
83#define GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH 126
84
85/**
86 * Maximum length of the public key (q-point, Q = dP) when encoded.
87 */
88#define GNUNET_CRYPTO_ECC_MAX_PUBLIC_KEY_LENGTH 76
89
90
91/**
92 * The private information of an ECC private key.
93 */
94struct GNUNET_CRYPTO_EccPrivateKey;
95
96
97/**
98 * @brief 0-terminated ASCII encoding of a struct GNUNET_HashCode. 88 * @brief 0-terminated ASCII encoding of a struct GNUNET_HashCode.
99 */ 89 */
100struct GNUNET_CRYPTO_HashAsciiEncoded 90struct GNUNET_CRYPTO_HashAsciiEncoded
@@ -112,7 +102,6 @@ struct GNUNET_CRYPTO_ShortHashAsciiEncoded
112}; 102};
113 103
114 104
115
116GNUNET_NETWORK_STRUCT_BEGIN 105GNUNET_NETWORK_STRUCT_BEGIN
117 106
118 107
@@ -146,54 +135,50 @@ struct GNUNET_CRYPTO_EccSignaturePurpose
146 */ 135 */
147struct GNUNET_CRYPTO_EccSignature 136struct GNUNET_CRYPTO_EccSignature
148{ 137{
138
149 /** 139 /**
150 * Overall size of the signature data. 140 * R value.
151 */ 141 */
152 uint16_t size GNUNET_PACKED; 142 unsigned char r[256 / 8];
153 143
154 /** 144 /**
155 * S-expression, padded with zeros. 145 * S value.
156 */ 146 */
157 char sexpr[GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH]; 147 unsigned char s[256 / 8];
148
158}; 149};
159 150
160 151
161/** 152/**
162 * Public ECC key (always for NIST P-521) encoded in a format suitable 153 * Public ECC key (always for NIST P-521) encoded in a format suitable
163 * for network transmission as created using 'gcry_sexp_sprint'. 154 * for network transmission.
164 */ 155 */
165struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded 156struct GNUNET_CRYPTO_EccPublicKey
166{ 157{
167 /** 158 /**
168 * Size of the encoding, in network byte order. 159 * Q consists of an x- and a y-value, each mod p (256 bits),
160 * given here in affine coordinates.
169 */ 161 */
170 uint16_t size GNUNET_PACKED; 162 unsigned char q_x[256 / 8];
171 163
172 /** 164 /**
173 * Actual length of the q-point binary encoding. 165 * Q consists of an x- and a y-value, each mod p (256 bits),
166 * given here in affine coordinates.
174 */ 167 */
175 uint16_t len GNUNET_PACKED; 168 unsigned char q_y[256 / 8];
176 169
177 /**
178 * 0-padded q-point in binary encoding (GCRYPT_MPI_FMT_USG).
179 */
180 unsigned char key[GNUNET_CRYPTO_ECC_MAX_PUBLIC_KEY_LENGTH];
181}; 170};
182 171
183 172
184/** 173/**
185 * Private ECC key encoded for transmission (with length prefix). 174 * Private ECC key encoded for transmission.
186 */ 175 */
187struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded 176struct GNUNET_CRYPTO_EccPrivateKey
188{ 177{
189 /** 178 /**
190 * Overall size of the private key in network byte order. 179 * d is a value mod n, where n has at most 256 bits.
191 */ 180 */
192 uint16_t size; 181 unsigned char d[256 / 8];
193
194 /* followd by S-expression, opaque to applications */
195
196 /* FIXME: consider defining padding to make this a fixed-size struct */
197 182
198}; 183};
199 184
@@ -828,10 +813,10 @@ typedef void (*GNUNET_CRYPTO_EccKeyCallback)(void *cls,
828/** 813/**
829 * Free memory occupied by ECC key 814 * Free memory occupied by ECC key
830 * 815 *
831 * @param privatekey pointer to the memory to free 816 * @param priv pointer to the memory to free
832 */ 817 */
833void 818void
834GNUNET_CRYPTO_ecc_key_free (struct GNUNET_CRYPTO_EccPrivateKey *privatekey); 819GNUNET_CRYPTO_ecc_key_free (struct GNUNET_CRYPTO_EccPrivateKey *priv);
835 820
836 821
837/** 822/**
@@ -842,7 +827,7 @@ GNUNET_CRYPTO_ecc_key_free (struct GNUNET_CRYPTO_EccPrivateKey *privatekey);
842 */ 827 */
843void 828void
844GNUNET_CRYPTO_ecc_key_get_public (const struct GNUNET_CRYPTO_EccPrivateKey *priv, 829GNUNET_CRYPTO_ecc_key_get_public (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
845 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *pub); 830 struct GNUNET_CRYPTO_EccPublicKey *pub);
846 831
847 832
848/** 833/**
@@ -852,7 +837,7 @@ GNUNET_CRYPTO_ecc_key_get_public (const struct GNUNET_CRYPTO_EccPrivateKey *priv
852 * @return string representing 'pub' 837 * @return string representing 'pub'
853 */ 838 */
854char * 839char *
855GNUNET_CRYPTO_ecc_public_key_to_string (const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *pub); 840GNUNET_CRYPTO_ecc_public_key_to_string (const struct GNUNET_CRYPTO_EccPublicKey *pub);
856 841
857 842
858/** 843/**
@@ -866,36 +851,7 @@ GNUNET_CRYPTO_ecc_public_key_to_string (const struct GNUNET_CRYPTO_EccPublicKeyB
866int 851int
867GNUNET_CRYPTO_ecc_public_key_from_string (const char *enc, 852GNUNET_CRYPTO_ecc_public_key_from_string (const char *enc,
868 size_t enclen, 853 size_t enclen,
869 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *pub); 854 struct GNUNET_CRYPTO_EccPublicKey *pub);
870
871
872/**
873 * Encode the private key in a format suitable for
874 * storing it into a file.
875 *
876 * @param key key to encode
877 * @return encoding of the private key.
878 * The first 4 bytes give the size of the array, as usual.
879 */
880struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *
881GNUNET_CRYPTO_ecc_encode_key (const struct GNUNET_CRYPTO_EccPrivateKey *key);
882
883
884/**
885 * Decode the private key from the file-format back
886 * to the "normal", internal format.
887 *
888 * @param buf the buffer where the private key data is stored
889 * @param len the length of the data in 'buffer'
890 * @param validate GNUNET_YES to validate that the key is well-formed,
891 * GNUNET_NO if the key comes from a totally trusted source
892 * and validation is considered too expensive
893 * @return NULL on error
894 */
895struct GNUNET_CRYPTO_EccPrivateKey *
896GNUNET_CRYPTO_ecc_decode_key (const char *buf,
897 size_t len,
898 int validate);
899 855
900 856
901/** 857/**
@@ -972,20 +928,20 @@ GNUNET_CRYPTO_get_host_identity (const struct GNUNET_CONFIGURATION_Handle *cfg,
972 */ 928 */
973int 929int
974GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EccPrivateKey *key, 930GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EccPrivateKey *key,
975 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *pub, 931 const struct GNUNET_CRYPTO_EccPublicKey *pub,
976 struct GNUNET_HashCode *key_material); 932 struct GNUNET_HashCode *key_material);
977 933
978 934
979/** 935/**
980 * Sign a given block. 936 * Sign a given block.
981 * 937 *
982 * @param key private key to use for the signing 938 * @param priv private key to use for the signing
983 * @param purpose what to sign (size, purpose) 939 * @param purpose what to sign (size, purpose)
984 * @param sig where to write the signature 940 * @param sig where to write the signature
985 * @return GNUNET_SYSERR on error, GNUNET_OK on success 941 * @return GNUNET_SYSERR on error, GNUNET_OK on success
986 */ 942 */
987int 943int
988GNUNET_CRYPTO_ecc_sign (const struct GNUNET_CRYPTO_EccPrivateKey *key, 944GNUNET_CRYPTO_ecc_sign (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
989 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, 945 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
990 struct GNUNET_CRYPTO_EccSignature *sig); 946 struct GNUNET_CRYPTO_EccSignature *sig);
991 947
@@ -996,7 +952,7 @@ GNUNET_CRYPTO_ecc_sign (const struct GNUNET_CRYPTO_EccPrivateKey *key,
996 * @param purpose what is the purpose that the signature should have? 952 * @param purpose what is the purpose that the signature should have?
997 * @param validate block to validate (size, purpose, data) 953 * @param validate block to validate (size, purpose, data)
998 * @param sig signature that is being validated 954 * @param sig signature that is being validated
999 * @param publicKey public key of the signer 955 * @param pub public key of the signer
1000 * @returns GNUNET_OK if ok, GNUNET_SYSERR if invalid 956 * @returns GNUNET_OK if ok, GNUNET_SYSERR if invalid
1001 */ 957 */
1002int 958int
@@ -1004,8 +960,36 @@ GNUNET_CRYPTO_ecc_verify (uint32_t purpose,
1004 const struct GNUNET_CRYPTO_EccSignaturePurpose 960 const struct GNUNET_CRYPTO_EccSignaturePurpose
1005 *validate, 961 *validate,
1006 const struct GNUNET_CRYPTO_EccSignature *sig, 962 const struct GNUNET_CRYPTO_EccSignature *sig,
1007 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded 963 const struct GNUNET_CRYPTO_EccPublicKey *pub);
1008 *publicKey); 964
965
966/**
967 * Derive a private key from a given private key and a label.
968 * Essentially calculates a private key 'h = H(l,P) * d mod n'
969 * where n is the size of the ECC group and P is the public
970 * key associated with the private key 'd'.
971 *
972 * @param priv original private key
973 * @param label label to use for key deriviation
974 * @return derived private key
975 */
976struct GNUNET_CRYPTO_EccPrivateKey *
977GNUNET_CRYPTO_ecc_key_derive (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
978 const char *label);
979
980
981/**
982 * Derive a public key from a given public key and a label.
983 * Essentially calculates a public key 'V = H(l,P) * P'.
984 *
985 * @param pub original public key
986 * @param label label to use for key deriviation
987 * @param result where to write the derived public key
988 */
989void
990GNUNET_CRYPTO_ecc_public_key_derive (const struct GNUNET_CRYPTO_EccPublicKey *pub,
991 const char *label,
992 struct GNUNET_CRYPTO_EccPublicKey *result);
1009 993
1010 994
1011#if 0 /* keep Emacsens' auto-indent happy */ 995#if 0 /* keep Emacsens' auto-indent happy */
diff --git a/src/include/gnunet_fs_service.h b/src/include/gnunet_fs_service.h
index a1e2dca23..afe53b0e0 100644
--- a/src/include/gnunet_fs_service.h
+++ b/src/include/gnunet_fs_service.h
@@ -81,13 +81,9 @@ struct GNUNET_FS_Uri;
81 81
82 82
83/** 83/**
84 * Identifier for a GNUnet pseudonym (the public key). Q-point, Q=dp. 84 * Identifier for a GNUnet pseudonym (the public key). Q-point, Q=dP.
85 * Note that we (ab)use an identifier of 'all zeros' to mean the 85 * Note that we (ab)use an identifier of 'Q=G=1P' to mean the
86 * 'anonymous' pseudonym, where the value is actually the point at 86 * 'anonymous' pseudonym.
87 * infinity; however, that value cannot be represented here. We do
88 * not handle the case where the actual q-Value of some pseudonym
89 * happens to be all zeros as well (as the chance of that is
90 * negligible).
91 */ 87 */
92struct GNUNET_FS_PseudonymIdentifier 88struct GNUNET_FS_PseudonymIdentifier
93{ 89{
@@ -274,7 +270,7 @@ GNUNET_FS_pseudonym_verify (const struct GNUNET_FS_PseudonymSignaturePurpose *pu
274 */ 270 */
275void 271void
276GNUNET_FS_pseudonym_get_identifier (struct GNUNET_FS_PseudonymHandle *ph, 272GNUNET_FS_pseudonym_get_identifier (struct GNUNET_FS_PseudonymHandle *ph,
277 struct GNUNET_FS_PseudonymIdentifier *pseudonym); 273 struct GNUNET_FS_PseudonymIdentifier *pseudonym);
278 274
279 275
280 276
@@ -531,6 +527,7 @@ GNUNET_FS_uri_ksk_remove_keyword (struct GNUNET_FS_Uri *uri,
531struct GNUNET_FS_Uri * 527struct GNUNET_FS_Uri *
532GNUNET_FS_uri_parse (const char *uri, char **emsg); 528GNUNET_FS_uri_parse (const char *uri, char **emsg);
533 529
530
534/** 531/**
535 * Free URI. 532 * Free URI.
536 * 533 *
@@ -2604,8 +2601,9 @@ GNUNET_FS_namespace_open_existing (struct GNUNET_FS_Handle *h, const char *name)
2604 * @return GNUNET_OK on success, GNUNET_SYSERR on error (see errno for details) 2601 * @return GNUNET_OK on success, GNUNET_SYSERR on error (see errno for details)
2605 */ 2602 */
2606int 2603int
2607GNUNET_FS_namespace_rename (struct GNUNET_FS_Handle *h, const char *old_name, 2604GNUNET_FS_namespace_rename (struct GNUNET_FS_Handle *h,
2608 const char *new_name); 2605 const char *old_name,
2606 const char *new_name);
2609 2607
2610 2608
2611/** 2609/**
diff --git a/src/include/gnunet_hello_lib.h b/src/include/gnunet_hello_lib.h
index b60353ee7..583a33f7d 100644
--- a/src/include/gnunet_hello_lib.h
+++ b/src/include/gnunet_hello_lib.h
@@ -199,8 +199,7 @@ typedef size_t (*GNUNET_HELLO_GenerateAddressListCallback) (void *cls,
199 * @return the hello message 199 * @return the hello message
200 */ 200 */
201struct GNUNET_HELLO_Message * 201struct GNUNET_HELLO_Message *
202GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded 202GNUNET_HELLO_create (const struct GNUNET_CRYPTO_EccPublicKey *publicKey,
203 *publicKey,
204 GNUNET_HELLO_GenerateAddressListCallback addrgen, 203 GNUNET_HELLO_GenerateAddressListCallback addrgen,
205 void *addrgen_cls, 204 void *addrgen_cls,
206 int friend_only); 205 int friend_only);
@@ -327,8 +326,7 @@ GNUNET_HELLO_iterate_new_addresses (const struct GNUNET_HELLO_Message
327 */ 326 */
328int 327int
329GNUNET_HELLO_get_key (const struct GNUNET_HELLO_Message *hello, 328GNUNET_HELLO_get_key (const struct GNUNET_HELLO_Message *hello,
330 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded 329 struct GNUNET_CRYPTO_EccPublicKey *publicKey);
331 *publicKey);
332 330
333 331
334/** 332/**
@@ -381,7 +379,7 @@ GNUNET_HELLO_compose_uri (const struct GNUNET_HELLO_Message *hello,
381 */ 379 */
382int 380int
383GNUNET_HELLO_parse_uri (const char *uri, 381GNUNET_HELLO_parse_uri (const char *uri,
384 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *pubkey, 382 struct GNUNET_CRYPTO_EccPublicKey *pubkey,
385 struct GNUNET_HELLO_Message **hello, 383 struct GNUNET_HELLO_Message **hello,
386 GNUNET_HELLO_TransportPluginsFind plugins_find); 384 GNUNET_HELLO_TransportPluginsFind plugins_find);
387 385
diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h
index 1d67c568c..dfc643d22 100644
--- a/src/include/gnunet_identity_service.h
+++ b/src/include/gnunet_identity_service.h
@@ -74,7 +74,18 @@ struct GNUNET_IDENTITY_Operation;
74 * @return associated ECC key, valid as long as the ego is valid 74 * @return associated ECC key, valid as long as the ego is valid
75 */ 75 */
76const struct GNUNET_CRYPTO_EccPrivateKey * 76const struct GNUNET_CRYPTO_EccPrivateKey *
77GNUNET_IDENTITY_ego_get_key (struct GNUNET_IDENTITY_Ego *ego); 77GNUNET_IDENTITY_ego_get_private_key (struct GNUNET_IDENTITY_Ego *ego);
78
79
80/**
81 * Get the identifier (public key) of an ego.
82 *
83 * @param ego identity handle with the private key
84 * @param pk set to ego's public key
85 */
86void
87GNUNET_IDENTITY_ego_get_public_key (struct GNUNET_IDENTITY_Ego *ego,
88 struct GNUNET_CRYPTO_EccPublicKey *pk);
78 89
79 90
80/** 91/**
@@ -83,7 +94,7 @@ GNUNET_IDENTITY_ego_get_key (struct GNUNET_IDENTITY_Ego *ego);
83 * 94 *
84 * When used with 'GNUNET_IDENTITY_connect', this function is 95 * When used with 'GNUNET_IDENTITY_connect', this function is
85 * initially called for all egos and then again whenever a 96 * initially called for all egos and then again whenever a
86 * ego's identifier changes or if it is deleted. At the end of 97 * ego's name changes or if it is deleted. At the end of
87 * the initial pass over all egos, the function is once called 98 * the initial pass over all egos, the function is once called
88 * with 'NULL' for 'ego'. That does NOT mean that the callback won't 99 * with 'NULL' for 'ego'. That does NOT mean that the callback won't
89 * be invoked in the future or that there was an error. 100 * be invoked in the future or that there was an error.
@@ -97,10 +108,10 @@ GNUNET_IDENTITY_ego_get_key (struct GNUNET_IDENTITY_Ego *ego);
97 * that one was not NULL). 108 * that one was not NULL).
98 * 109 *
99 * When an identity is renamed, this function is called with the 110 * When an identity is renamed, this function is called with the
100 * (known) ego but the NEW identifier. 111 * (known) ego but the NEW name.
101 * 112 *
102 * When an identity is deleted, this function is called with the 113 * When an identity is deleted, this function is called with the
103 * (known) ego and "NULL" for the 'identifier'. In this case, 114 * (known) ego and "NULL" for the 'name'. In this case,
104 * the 'ego' is henceforth invalid (and the 'ctx' should also be 115 * the 'ego' is henceforth invalid (and the 'ctx' should also be
105 * cleaned up). 116 * cleaned up).
106 * 117 *
@@ -108,14 +119,14 @@ GNUNET_IDENTITY_ego_get_key (struct GNUNET_IDENTITY_Ego *ego);
108 * @param ego ego handle 119 * @param ego ego handle
109 * @param ego_ctx context for application to store data for this ego 120 * @param ego_ctx context for application to store data for this ego
110 * (during the lifetime of this process, initially NULL) 121 * (during the lifetime of this process, initially NULL)
111 * @param identifier identifier assigned by the user for this ego, 122 * @param name name assigned by the user for this ego,
112 * NULL if the user just deleted the ego and it 123 * NULL if the user just deleted the ego and it
113 * must thus no longer be used 124 * must thus no longer be used
114 */ 125 */
115typedef void (*GNUNET_IDENTITY_Callback)(void *cls, 126typedef void (*GNUNET_IDENTITY_Callback)(void *cls,
116 struct GNUNET_IDENTITY_Ego *ego, 127 struct GNUNET_IDENTITY_Ego *ego,
117 void **ctx, 128 void **ctx,
118 const char *identifier); 129 const char *name);
119 130
120 131
121/** 132/**
@@ -188,17 +199,17 @@ GNUNET_IDENTITY_disconnect (struct GNUNET_IDENTITY_Handle *h);
188 199
189 200
190/** 201/**
191 * Create a new identity with the given identifier. 202 * Create a new identity with the given name.
192 * 203 *
193 * @param id identity service to use 204 * @param id identity service to use
194 * @param identifier desired identifier 205 * @param name desired name
195 * @param cont function to call with the result (will only be called once) 206 * @param cont function to call with the result (will only be called once)
196 * @param cont_cls closure for cont 207 * @param cont_cls closure for cont
197 * @return handle to abort the operation 208 * @return handle to abort the operation
198 */ 209 */
199struct GNUNET_IDENTITY_Operation * 210struct GNUNET_IDENTITY_Operation *
200GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id, 211GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id,
201 const char *identifier, 212 const char *name,
202 GNUNET_IDENTITY_Continuation cont, 213 GNUNET_IDENTITY_Continuation cont,
203 void *cont_cls); 214 void *cont_cls);
204 215
@@ -207,16 +218,16 @@ GNUNET_IDENTITY_create (struct GNUNET_IDENTITY_Handle *id,
207 * Renames an existing identity. 218 * Renames an existing identity.
208 * 219 *
209 * @param id identity service to use 220 * @param id identity service to use
210 * @param old_identifier old identifier 221 * @param old_name old name
211 * @param new_identifier desired new identifier 222 * @param new_name desired new name
212 * @param cb function to call with the result (will only be called once) 223 * @param cb function to call with the result (will only be called once)
213 * @param cb_cls closure for cb 224 * @param cb_cls closure for cb
214 * @return handle to abort the operation 225 * @return handle to abort the operation
215 */ 226 */
216struct GNUNET_IDENTITY_Operation * 227struct GNUNET_IDENTITY_Operation *
217GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id, 228GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id,
218 const char *old_identifier, 229 const char *old_name,
219 const char *new_identifier, 230 const char *new_name,
220 GNUNET_IDENTITY_Continuation cb, 231 GNUNET_IDENTITY_Continuation cb,
221 void *cb_cls); 232 void *cb_cls);
222 233
@@ -225,14 +236,14 @@ GNUNET_IDENTITY_rename (struct GNUNET_IDENTITY_Handle *id,
225 * Delete an existing identity. 236 * Delete an existing identity.
226 * 237 *
227 * @param id identity service to use 238 * @param id identity service to use
228 * @param identifier identifier of the identity to delete 239 * @param name name of the identity to delete
229 * @param cb function to call with the result (will only be called once) 240 * @param cb function to call with the result (will only be called once)
230 * @param cb_cls closure for cb 241 * @param cb_cls closure for cb
231 * @return handle to abort the operation 242 * @return handle to abort the operation
232 */ 243 */
233struct GNUNET_IDENTITY_Operation * 244struct GNUNET_IDENTITY_Operation *
234GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id, 245GNUNET_IDENTITY_delete (struct GNUNET_IDENTITY_Handle *id,
235 const char *identifier, 246 const char *name,
236 GNUNET_IDENTITY_Continuation cb, 247 GNUNET_IDENTITY_Continuation cb,
237 void *cb_cls); 248 void *cb_cls);
238 249
diff --git a/src/include/gnunet_namestore_plugin.h b/src/include/gnunet_namestore_plugin.h
index e969170e5..b4ffc257d 100644
--- a/src/include/gnunet_namestore_plugin.h
+++ b/src/include/gnunet_namestore_plugin.h
@@ -4,7 +4,7 @@
4 4
5 GNUnet is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
@@ -53,7 +53,7 @@ extern "C"
53 * because the user queried for a particular record type only) 53 * because the user queried for a particular record type only)
54 */ 54 */
55typedef void (*GNUNET_NAMESTORE_RecordIterator) (void *cls, 55typedef void (*GNUNET_NAMESTORE_RecordIterator) (void *cls,
56 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 56 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
57 struct GNUNET_TIME_Absolute expire, 57 struct GNUNET_TIME_Absolute expire,
58 const char *name, 58 const char *name,
59 unsigned int rd_len, 59 unsigned int rd_len,
@@ -88,7 +88,7 @@ struct GNUNET_NAMESTORE_PluginFunctions
88 * @return GNUNET_OK on success, else GNUNET_SYSERR 88 * @return GNUNET_OK on success, else GNUNET_SYSERR
89 */ 89 */
90 int (*put_records) (void *cls, 90 int (*put_records) (void *cls,
91 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 91 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
92 struct GNUNET_TIME_Absolute expire, 92 struct GNUNET_TIME_Absolute expire,
93 const char *name, 93 const char *name,
94 unsigned int rd_len, 94 unsigned int rd_len,
diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h
index 700122507..77da67312 100644
--- a/src/include/gnunet_namestore_service.h
+++ b/src/include/gnunet_namestore_service.h
@@ -247,7 +247,7 @@ struct GNUNET_NAMESTORE_RecordData
247 */ 247 */
248struct GNUNET_NAMESTORE_QueueEntry * 248struct GNUNET_NAMESTORE_QueueEntry *
249GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h, 249GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
250 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 250 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
251 const char *name, 251 const char *name,
252 struct GNUNET_TIME_Absolute freshness, 252 struct GNUNET_TIME_Absolute freshness,
253 unsigned int rd_count, 253 unsigned int rd_count,
@@ -270,7 +270,7 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
270 * @return GNUNET_OK if the signature is valid 270 * @return GNUNET_OK if the signature is valid
271 */ 271 */
272int 272int
273GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *public_key, 273GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_EccPublicKey *public_key,
274 const struct GNUNET_TIME_Absolute freshness, 274 const struct GNUNET_TIME_Absolute freshness,
275 const char *name, 275 const char *name,
276 unsigned int rd_count, 276 unsigned int rd_count,
@@ -319,7 +319,7 @@ GNUNET_NAMESTORE_record_put_by_authority (struct GNUNET_NAMESTORE_Handle *h,
319 * because the user queried for a particular record type only) 319 * because the user queried for a particular record type only)
320 */ 320 */
321typedef void (*GNUNET_NAMESTORE_RecordProcessor) (void *cls, 321typedef void (*GNUNET_NAMESTORE_RecordProcessor) (void *cls,
322 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 322 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
323 struct GNUNET_TIME_Absolute freshness, 323 struct GNUNET_TIME_Absolute freshness,
324 const char *name, 324 const char *name,
325 unsigned int rd_count, 325 unsigned int rd_count,
@@ -480,7 +480,7 @@ struct GNUNET_NAMESTORE_ZoneMonitor;
480 * @param signature signature of the record block 480 * @param signature signature of the record block
481 */ 481 */
482typedef void (*GNUNET_NAMESTORE_RecordMonitor)(void *cls, 482typedef void (*GNUNET_NAMESTORE_RecordMonitor)(void *cls,
483 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 483 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
484 struct GNUNET_TIME_Absolute freshness, 484 struct GNUNET_TIME_Absolute freshness,
485 const char *name, 485 const char *name,
486 unsigned int rd_len, 486 unsigned int rd_len,
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h
index 6bb92e05d..3b6fabb6e 100644
--- a/src/include/gnunet_testing_lib.h
+++ b/src/include/gnunet_testing_lib.h
@@ -46,12 +46,9 @@ extern "C"
46#endif 46#endif
47 47
48/** 48/**
49 * Size of each hostkey in the hostkey file (in BYTES). This is the 49 * Size of each hostkey in the hostkey file (in BYTES).
50 * maximum length of the S-expressions generated by libgcrypt for the
51 * curves (rounded up to the next full KB to make IO nicer); it is NOT
52 * the number of bits in the key.
53 */ 50 */
54#define GNUNET_TESTING_HOSTKEYFILESIZE 1024 51#define GNUNET_TESTING_HOSTKEYFILESIZE sizeof (struct GNUNET_CRYPTO_EccPrivateKey)
55 52
56/** 53/**
57 * Handle for a system on which GNUnet peers are executed; 54 * Handle for a system on which GNUnet peers are executed;
diff --git a/src/mesh/gnunet-service-mesh-enc.c b/src/mesh/gnunet-service-mesh-enc.c
index 5cd6e71a3..3707fc028 100644
--- a/src/mesh/gnunet-service-mesh-enc.c
+++ b/src/mesh/gnunet-service-mesh-enc.c
@@ -584,12 +584,12 @@ struct MeshTunnel2
584 /** 584 /**
585 * Local peer ephemeral public key 585 * Local peer ephemeral public key
586 */ 586 */
587 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *my_eph; 587 struct GNUNET_CRYPTO_EccPublicKey *my_eph;
588 588
589 /** 589 /**
590 * Remote peer's public key. 590 * Remote peer's public key.
591 */ 591 */
592 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *peers_eph; 592 struct GNUNET_CRYPTO_EccPublicKey *peers_eph;
593 593
594 /** 594 /**
595 * Encryption ("our") key. 595 * Encryption ("our") key.
@@ -837,7 +837,7 @@ static struct GNUNET_CRYPTO_EccPrivateKey *my_private_key;
837/** 837/**
838 * Own public key. 838 * Own public key.
839 */ 839 */
840static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded my_public_key; 840static struct GNUNET_CRYPTO_EccPublicKey my_public_key;
841 841
842/** 842/**
843 * All ports clients of this peer have opened. 843 * All ports clients of this peer have opened.
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index 6fa9d1d17..0dfac410d 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -722,7 +722,7 @@ static struct GNUNET_CRYPTO_EccPrivateKey *my_private_key;
722/** 722/**
723 * Own public key. 723 * Own public key.
724 */ 724 */
725static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded my_public_key; 725static struct GNUNET_CRYPTO_EccPublicKey my_public_key;
726 726
727/** 727/**
728 * Tunnel ID for the next created tunnel (global tunnel number). 728 * Tunnel ID for the next created tunnel (global tunnel number).
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index 56e2859d0..50a8601f8 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -305,7 +305,7 @@ del_continuation (void *cls,
305 */ 305 */
306static void 306static void
307display_record (void *cls, 307display_record (void *cls,
308 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 308 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
309 struct GNUNET_TIME_Absolute expire, 309 struct GNUNET_TIME_Absolute expire,
310 const char *name, 310 const char *name,
311 unsigned int rd_len, 311 unsigned int rd_len,
@@ -396,7 +396,7 @@ sync_cb (void *cls)
396 */ 396 */
397static void 397static void
398get_existing_record (void *cls, 398get_existing_record (void *cls,
399 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 399 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
400 struct GNUNET_TIME_Absolute freshness, 400 struct GNUNET_TIME_Absolute freshness,
401 const char *rec_name, 401 const char *rec_name,
402 unsigned int rd_count, 402 unsigned int rd_count,
@@ -453,7 +453,7 @@ testservice_task (void *cls,
453 int result) 453 int result)
454{ 454{
455 const struct GNUNET_CONFIGURATION_Handle *cfg = cls; 455 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
456 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pub; 456 struct GNUNET_CRYPTO_EccPublicKey pub;
457 struct GNUNET_NAMESTORE_RecordData rd; 457 struct GNUNET_NAMESTORE_RecordData rd;
458 458
459 if (GNUNET_YES != result) 459 if (GNUNET_YES != result)
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index f8663775b..a4e463642 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -283,10 +283,9 @@ write_key_to_file (const char *filename,
283 struct GNUNET_NAMESTORE_CryptoContainer *c) 283 struct GNUNET_NAMESTORE_CryptoContainer *c)
284{ 284{
285 struct GNUNET_CRYPTO_EccPrivateKey *ret = c->privkey; 285 struct GNUNET_CRYPTO_EccPrivateKey *ret = c->privkey;
286 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *enc;
287 struct GNUNET_DISK_FileHandle *fd; 286 struct GNUNET_DISK_FileHandle *fd;
288 struct GNUNET_CRYPTO_ShortHashCode zone; 287 struct GNUNET_CRYPTO_ShortHashCode zone;
289 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey; 288 struct GNUNET_CRYPTO_EccPublicKey pubkey;
290 struct GNUNET_CRYPTO_EccPrivateKey *privkey; 289 struct GNUNET_CRYPTO_EccPrivateKey *privkey;
291 290
292 fd = GNUNET_DISK_file_open (filename, 291 fd = GNUNET_DISK_file_open (filename,
@@ -305,7 +304,7 @@ write_key_to_file (const char *filename,
305 } 304 }
306 GNUNET_CRYPTO_ecc_key_get_public (privkey, &pubkey); 305 GNUNET_CRYPTO_ecc_key_get_public (privkey, &pubkey);
307 GNUNET_CRYPTO_short_hash (&pubkey, 306 GNUNET_CRYPTO_short_hash (&pubkey,
308 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 307 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
309 &zone); 308 &zone);
310 GNUNET_CRYPTO_ecc_key_free (privkey); 309 GNUNET_CRYPTO_ecc_key_free (privkey);
311 if (0 == memcmp (&zone, &c->zone, sizeof(zone))) 310 if (0 == memcmp (&zone, &c->zone, sizeof(zone)))
@@ -326,17 +325,21 @@ write_key_to_file (const char *filename,
326 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "open", filename); 325 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "open", filename);
327 return GNUNET_SYSERR; 326 return GNUNET_SYSERR;
328 } 327 }
329 if (GNUNET_YES != GNUNET_DISK_file_lock (fd, 0, sizeof (struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded), GNUNET_YES)) 328 if (GNUNET_YES !=
329 GNUNET_DISK_file_lock (fd, 0,
330 sizeof (struct GNUNET_CRYPTO_EccPrivateKey),
331 GNUNET_YES))
330 { 332 {
331 GNUNET_break (GNUNET_YES == GNUNET_DISK_file_close (fd)); 333 GNUNET_break (GNUNET_YES == GNUNET_DISK_file_close (fd));
332 return GNUNET_SYSERR; 334 return GNUNET_SYSERR;
333 } 335 }
334 enc = GNUNET_CRYPTO_ecc_encode_key (ret); 336 GNUNET_assert (sizeof (struct GNUNET_CRYPTO_EccPrivateKey) ==
335 GNUNET_assert (NULL != enc); 337 GNUNET_DISK_file_write (fd, ret,
336 GNUNET_assert (ntohs (enc->size) == GNUNET_DISK_file_write (fd, enc, ntohs (enc->size))); 338 sizeof (struct GNUNET_CRYPTO_EccPrivateKey)));
337 GNUNET_free (enc);
338 GNUNET_DISK_file_sync (fd); 339 GNUNET_DISK_file_sync (fd);
339 if (GNUNET_YES != GNUNET_DISK_file_unlock (fd, 0, sizeof (struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded))) 340 if (GNUNET_YES !=
341 GNUNET_DISK_file_unlock (fd, 0,
342 sizeof (struct GNUNET_CRYPTO_EccPrivateKey)))
340 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename); 343 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
341 GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd)); 344 GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
342 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 345 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -387,14 +390,14 @@ zone_to_disk_it (void *cls,
387static void 390static void
388learn_private_key (struct GNUNET_CRYPTO_EccPrivateKey *pkey) 391learn_private_key (struct GNUNET_CRYPTO_EccPrivateKey *pkey)
389{ 392{
390 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pub; 393 struct GNUNET_CRYPTO_EccPublicKey pub;
391 struct GNUNET_HashCode long_hash; 394 struct GNUNET_HashCode long_hash;
392 struct GNUNET_CRYPTO_ShortHashCode pubkey_hash; 395 struct GNUNET_CRYPTO_ShortHashCode pubkey_hash;
393 struct GNUNET_NAMESTORE_CryptoContainer *cc; 396 struct GNUNET_NAMESTORE_CryptoContainer *cc;
394 397
395 GNUNET_CRYPTO_ecc_key_get_public (pkey, &pub); 398 GNUNET_CRYPTO_ecc_key_get_public (pkey, &pub);
396 GNUNET_CRYPTO_short_hash (&pub, 399 GNUNET_CRYPTO_short_hash (&pub,
397 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 400 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
398 &pubkey_hash); 401 &pubkey_hash);
399 GNUNET_CRYPTO_short_hash_double (&pubkey_hash, &long_hash); 402 GNUNET_CRYPTO_short_hash_double (&pubkey_hash, &long_hash);
400 403
@@ -643,7 +646,7 @@ struct LookupNameContext
643 */ 646 */
644static void 647static void
645handle_lookup_name_it (void *cls, 648handle_lookup_name_it (void *cls,
646 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 649 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
647 struct GNUNET_TIME_Absolute expire, 650 struct GNUNET_TIME_Absolute expire,
648 const char *name, 651 const char *name,
649 unsigned int rd_count, 652 unsigned int rd_count,
@@ -680,7 +683,7 @@ handle_lookup_name_it (void *cls,
680 if (NULL != zone_key) 683 if (NULL != zone_key)
681 { 684 {
682 GNUNET_CRYPTO_short_hash (zone_key, 685 GNUNET_CRYPTO_short_hash (zone_key,
683 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 686 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
684 &zone_key_hash); 687 &zone_key_hash);
685 GNUNET_CRYPTO_short_hash_double (&zone_key_hash, &long_hash); 688 GNUNET_CRYPTO_short_hash_double (&zone_key_hash, &long_hash);
686 if (NULL != (cc = GNUNET_CONTAINER_multihashmap_get (zonekeys, &long_hash))) 689 if (NULL != (cc = GNUNET_CONTAINER_multihashmap_get (zonekeys, &long_hash)))
@@ -991,7 +994,7 @@ static void
991send_lookup_response (struct GNUNET_SERVER_NotificationContext *nc, 994send_lookup_response (struct GNUNET_SERVER_NotificationContext *nc,
992 struct GNUNET_SERVER_Client *client, 995 struct GNUNET_SERVER_Client *client,
993 uint32_t request_id, 996 uint32_t request_id,
994 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 997 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
995 struct GNUNET_TIME_Absolute expire, 998 struct GNUNET_TIME_Absolute expire,
996 const char *name, 999 const char *name,
997 unsigned int rd_count, 1000 unsigned int rd_count,
@@ -1198,16 +1201,14 @@ handle_record_create (void *cls,
1198 size_t msg_size; 1201 size_t msg_size;
1199 size_t msg_size_exp; 1202 size_t msg_size_exp;
1200 size_t rd_ser_len; 1203 size_t rd_ser_len;
1201 size_t key_len;
1202 uint32_t rid; 1204 uint32_t rid;
1203 const char *pkey_tmp;
1204 const char *name_tmp; 1205 const char *name_tmp;
1205 char *conv_name; 1206 char *conv_name;
1206 const char *rd_ser; 1207 const char *rd_ser;
1207 unsigned int rd_count; 1208 unsigned int rd_count;
1208 int res; 1209 int res;
1209 struct GNUNET_CRYPTO_ShortHashCode pubkey_hash; 1210 struct GNUNET_CRYPTO_ShortHashCode pubkey_hash;
1210 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey; 1211 struct GNUNET_CRYPTO_EccPublicKey pubkey;
1211 1212
1212 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1213 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1213 "Received `%s' message\n", "NAMESTORE_RECORD_CREATE"); 1214 "Received `%s' message\n", "NAMESTORE_RECORD_CREATE");
@@ -1229,8 +1230,8 @@ handle_record_create (void *cls,
1229 msg_size = ntohs (message->size); 1230 msg_size = ntohs (message->size);
1230 rd_count = ntohs (rp_msg->rd_count); 1231 rd_count = ntohs (rp_msg->rd_count);
1231 rd_ser_len = ntohs (rp_msg->rd_len); 1232 rd_ser_len = ntohs (rp_msg->rd_len);
1232 key_len = ntohs (rp_msg->pkey_len); 1233 GNUNET_break (0 == ntohs (rp_msg->reserved));
1233 msg_size_exp = sizeof (struct RecordCreateMessage) + key_len + name_len + rd_ser_len; 1234 msg_size_exp = sizeof (struct RecordCreateMessage) + name_len + rd_ser_len;
1234 if (msg_size != msg_size_exp) 1235 if (msg_size != msg_size_exp)
1235 { 1236 {
1236 GNUNET_break (0); 1237 GNUNET_break (0);
@@ -1243,8 +1244,7 @@ handle_record_create (void *cls,
1243 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1244 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1244 return; 1245 return;
1245 } 1246 }
1246 pkey_tmp = (const char *) &rp_msg[1]; 1247 name_tmp = (const char *) &rp_msg[1];
1247 name_tmp = &pkey_tmp[key_len];
1248 rd_ser = &name_tmp[name_len]; 1248 rd_ser = &name_tmp[name_len];
1249 if ('\0' != name_tmp[name_len -1]) 1249 if ('\0' != name_tmp[name_len -1])
1250 { 1250 {
@@ -1252,13 +1252,8 @@ handle_record_create (void *cls,
1252 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); 1252 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1253 return; 1253 return;
1254 } 1254 }
1255 if (NULL == (pkey = GNUNET_CRYPTO_ecc_decode_key (pkey_tmp, key_len, 1255 pkey = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey);
1256 GNUNET_NO))) 1256 memcpy (pkey, &rp_msg->private_key, sizeof (struct GNUNET_CRYPTO_EccPrivateKey));
1257 {
1258 GNUNET_break (0);
1259 GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
1260 return;
1261 }
1262 { 1257 {
1263 struct GNUNET_NAMESTORE_RecordData rd[rd_count]; 1258 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
1264 1259
@@ -1274,7 +1269,7 @@ handle_record_create (void *cls,
1274 /* Extracting and converting private key */ 1269 /* Extracting and converting private key */
1275 GNUNET_CRYPTO_ecc_key_get_public (pkey, &pubkey); 1270 GNUNET_CRYPTO_ecc_key_get_public (pkey, &pubkey);
1276 GNUNET_CRYPTO_short_hash (&pubkey, 1271 GNUNET_CRYPTO_short_hash (&pubkey,
1277 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 1272 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
1278 &pubkey_hash); 1273 &pubkey_hash);
1279 learn_private_key (pkey); 1274 learn_private_key (pkey);
1280 conv_name = GNUNET_NAMESTORE_normalize_string (name_tmp); 1275 conv_name = GNUNET_NAMESTORE_normalize_string (name_tmp);
@@ -1373,7 +1368,7 @@ struct ZoneToNameCtx
1373 */ 1368 */
1374static void 1369static void
1375handle_zone_to_name_it (void *cls, 1370handle_zone_to_name_it (void *cls,
1376 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 1371 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
1377 struct GNUNET_TIME_Absolute expire, 1372 struct GNUNET_TIME_Absolute expire,
1378 const char *name, 1373 const char *name,
1379 unsigned int rd_count, 1374 unsigned int rd_count,
@@ -1552,7 +1547,7 @@ struct ZoneIterationProcResult
1552 */ 1547 */
1553static void 1548static void
1554zone_iteraterate_proc (void *cls, 1549zone_iteraterate_proc (void *cls,
1555 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 1550 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
1556 struct GNUNET_TIME_Absolute expire, 1551 struct GNUNET_TIME_Absolute expire,
1557 const char *name, 1552 const char *name,
1558 unsigned int rd_count, 1553 unsigned int rd_count,
@@ -1633,7 +1628,7 @@ zone_iteraterate_proc (void *cls,
1633 /* compute / obtain signature, but only if we (a) have records and (b) expiration times were 1628 /* compute / obtain signature, but only if we (a) have records and (b) expiration times were
1634 converted to absolute expiration times */ 1629 converted to absolute expiration times */
1635 GNUNET_CRYPTO_short_hash (zone_key, 1630 GNUNET_CRYPTO_short_hash (zone_key,
1636 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 1631 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
1637 &zone_hash); 1632 &zone_hash);
1638 GNUNET_CRYPTO_short_hash_double (&zone_hash, &long_hash); 1633 GNUNET_CRYPTO_short_hash_double (&zone_hash, &long_hash);
1639 if (NULL != (cc = GNUNET_CONTAINER_multihashmap_get (zonekeys, &long_hash))) 1634 if (NULL != (cc = GNUNET_CONTAINER_multihashmap_get (zonekeys, &long_hash)))
@@ -1976,7 +1971,7 @@ monitor_next (void *cls,
1976 */ 1971 */
1977static void 1972static void
1978monitor_iterate_cb (void *cls, 1973monitor_iterate_cb (void *cls,
1979 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 1974 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
1980 struct GNUNET_TIME_Absolute expire, 1975 struct GNUNET_TIME_Absolute expire,
1981 const char *name, 1976 const char *name,
1982 unsigned int rd_count, 1977 unsigned int rd_count,
diff --git a/src/namestore/namestore.h b/src/namestore/namestore.h
index 7245e1631..58ecbf65d 100644
--- a/src/namestore/namestore.h
+++ b/src/namestore/namestore.h
@@ -166,7 +166,7 @@ struct LookupNameResponseMessage
166 /** 166 /**
167 * The public key for the name 167 * The public key for the name
168 */ 168 */
169 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key; 169 struct GNUNET_CRYPTO_EccPublicKey public_key;
170 170
171 /* 0-terminated name and serialized record data */ 171 /* 0-terminated name and serialized record data */
172 /* rd_len bytes serialized record data */ 172 /* rd_len bytes serialized record data */
@@ -216,7 +216,7 @@ struct RecordPutMessage
216 /** 216 /**
217 * The public key 217 * The public key
218 */ 218 */
219 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key; 219 struct GNUNET_CRYPTO_EccPublicKey public_key;
220 220
221 /* name (0-terminated) followed by "rd_count" serialized records */ 221 /* name (0-terminated) followed by "rd_count" serialized records */
222 222
@@ -271,15 +271,16 @@ struct RecordCreateMessage
271 uint16_t rd_count; 271 uint16_t rd_count;
272 272
273 /** 273 /**
274 * private key length 274 * always zero
275 */ 275 */
276 uint16_t pkey_len; 276 uint16_t reserved;
277
278 struct GNUNET_CRYPTO_EccPrivateKey private_key;
277 279
278 /* followed by: 280 /* followed by:
279 * GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded private key with length pkey_len
280 * name with length name_len 281 * name with length name_len
281 * serialized record data with length rd_len 282 * serialized record data with length rd_len
282 * */ 283 */
283}; 284};
284 285
285 286
@@ -366,7 +367,7 @@ struct ZoneToNameResponseMessage
366 /** 367 /**
367 * Publik key 368 * Publik key
368 */ 369 */
369 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded zone_key; 370 struct GNUNET_CRYPTO_EccPublicKey zone_key;
370 371
371}; 372};
372 373
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index 19ba86980..c5b213954 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -266,7 +266,7 @@ handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe,
266 const char * rd_tmp; 266 const char * rd_tmp;
267 const struct GNUNET_CRYPTO_EccSignature *signature; 267 const struct GNUNET_CRYPTO_EccSignature *signature;
268 struct GNUNET_TIME_Absolute expire; 268 struct GNUNET_TIME_Absolute expire;
269 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *public_key_tmp; 269 const struct GNUNET_CRYPTO_EccPublicKey *public_key_tmp;
270 size_t exp_msg_len; 270 size_t exp_msg_len;
271 size_t msg_len; 271 size_t msg_len;
272 size_t name_len; 272 size_t name_len;
@@ -518,7 +518,7 @@ handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze,
518 const struct LookupNameResponseMessage *msg, 518 const struct LookupNameResponseMessage *msg,
519 size_t size) 519 size_t size)
520{ 520{
521 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubdummy; 521 struct GNUNET_CRYPTO_EccPublicKey pubdummy;
522 size_t msg_len; 522 size_t msg_len;
523 size_t exp_msg_len; 523 size_t exp_msg_len;
524 size_t name_len; 524 size_t name_len;
@@ -931,7 +931,7 @@ GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h)
931 */ 931 */
932struct GNUNET_NAMESTORE_QueueEntry * 932struct GNUNET_NAMESTORE_QueueEntry *
933GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h, 933GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
934 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 934 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
935 const char *name, 935 const char *name,
936 struct GNUNET_TIME_Absolute freshness, 936 struct GNUNET_TIME_Absolute freshness,
937 unsigned int rd_count, 937 unsigned int rd_count,
@@ -1016,7 +1016,7 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
1016 * @return GNUNET_OK if the signature is valid 1016 * @return GNUNET_OK if the signature is valid
1017 */ 1017 */
1018int 1018int
1019GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *public_key, 1019GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_EccPublicKey *public_key,
1020 const struct GNUNET_TIME_Absolute freshness, 1020 const struct GNUNET_TIME_Absolute freshness,
1021 const char *name, 1021 const char *name,
1022 unsigned int rd_count, 1022 unsigned int rd_count,
@@ -1087,16 +1087,13 @@ GNUNET_NAMESTORE_record_put_by_authority (struct GNUNET_NAMESTORE_Handle *h,
1087{ 1087{
1088 struct GNUNET_NAMESTORE_QueueEntry *qe; 1088 struct GNUNET_NAMESTORE_QueueEntry *qe;
1089 struct PendingMessage *pe; 1089 struct PendingMessage *pe;
1090 char * name_tmp; 1090 char *name_tmp;
1091 char * pkey_tmp; 1091 char *rd_ser;
1092 char * rd_ser;
1093 size_t rd_ser_len; 1092 size_t rd_ser_len;
1094 size_t msg_size; 1093 size_t msg_size;
1095 size_t name_len; 1094 size_t name_len;
1096 size_t key_len;
1097 uint32_t rid; 1095 uint32_t rid;
1098 struct RecordCreateMessage * msg; 1096 struct RecordCreateMessage *msg;
1099 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded * pkey_enc;
1100 1097
1101 GNUNET_assert (NULL != h); 1098 GNUNET_assert (NULL != h);
1102 GNUNET_assert (NULL != pkey); 1099 GNUNET_assert (NULL != pkey);
@@ -1115,13 +1112,9 @@ GNUNET_NAMESTORE_record_put_by_authority (struct GNUNET_NAMESTORE_Handle *h,
1115 qe->op_id = rid; 1112 qe->op_id = rid;
1116 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe); 1113 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
1117 1114
1118 pkey_enc = GNUNET_CRYPTO_ecc_encode_key (pkey);
1119 GNUNET_assert (NULL != pkey_enc);
1120
1121 /* setup msg */ 1115 /* setup msg */
1122 key_len = ntohs (pkey_enc->size);
1123 rd_ser_len = GNUNET_NAMESTORE_records_get_size (rd_count, rd); 1116 rd_ser_len = GNUNET_NAMESTORE_records_get_size (rd_count, rd);
1124 msg_size = sizeof (struct RecordCreateMessage) + key_len + name_len + rd_ser_len; 1117 msg_size = sizeof (struct RecordCreateMessage) + name_len + rd_ser_len;
1125 pe = GNUNET_malloc (sizeof (struct PendingMessage) + msg_size); 1118 pe = GNUNET_malloc (sizeof (struct PendingMessage) + msg_size);
1126 pe->size = msg_size; 1119 pe->size = msg_size;
1127 pe->is_init = GNUNET_NO; 1120 pe->is_init = GNUNET_NO;
@@ -1132,15 +1125,14 @@ GNUNET_NAMESTORE_record_put_by_authority (struct GNUNET_NAMESTORE_Handle *h,
1132 msg->name_len = htons (name_len); 1125 msg->name_len = htons (name_len);
1133 msg->rd_count = htons (rd_count); 1126 msg->rd_count = htons (rd_count);
1134 msg->rd_len = htons (rd_ser_len); 1127 msg->rd_len = htons (rd_ser_len);
1135 msg->pkey_len = htons (key_len); 1128 msg->reserved = htons (0);
1136 msg->expire = GNUNET_TIME_absolute_hton (GNUNET_TIME_UNIT_FOREVER_ABS); 1129 msg->expire = GNUNET_TIME_absolute_hton (GNUNET_TIME_UNIT_FOREVER_ABS);
1137 pkey_tmp = (char *) &msg[1]; 1130 msg->private_key = *pkey;
1138 memcpy (pkey_tmp, pkey_enc, key_len); 1131
1139 name_tmp = &pkey_tmp[key_len]; 1132 name_tmp = (char *) &msg[1];
1140 memcpy (name_tmp, name, name_len); 1133 memcpy (name_tmp, name, name_len);
1141 rd_ser = &name_tmp[name_len]; 1134 rd_ser = &name_tmp[name_len];
1142 GNUNET_break (rd_ser_len == GNUNET_NAMESTORE_records_serialize (rd_count, rd, rd_ser_len, rd_ser)); 1135 GNUNET_break (rd_ser_len == GNUNET_NAMESTORE_records_serialize (rd_count, rd, rd_ser_len, rd_ser));
1143 GNUNET_free (pkey_enc);
1144 1136
1145 LOG (GNUNET_ERROR_TYPE_DEBUG, 1137 LOG (GNUNET_ERROR_TYPE_DEBUG,
1146 "Sending `%s' message for name `%s' with size %u\n", 1138 "Sending `%s' message for name `%s' with size %u\n",
diff --git a/src/namestore/plugin_namestore_postgres.c b/src/namestore/plugin_namestore_postgres.c
index 070549b33..64bfa631c 100644
--- a/src/namestore/plugin_namestore_postgres.c
+++ b/src/namestore/plugin_namestore_postgres.c
@@ -1,6 +1,6 @@
1 /* 1 /*
2 * This file is part of GNUnet 2 * This file is part of GNUnet
3 * (C) 2009, 2011, 2012 Christian Grothoff (and other contributing authors) 3 * (C) 2009-2013 Christian Grothoff (and other contributing authors)
4 * 4 *
5 * GNUnet is free software; you can redistribute it and/or modify 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 6 * it under the terms of the GNU General Public License as published
@@ -269,7 +269,7 @@ namestore_postgres_remove_records (void *cls,
269 */ 269 */
270static int 270static int
271namestore_postgres_put_records (void *cls, 271namestore_postgres_put_records (void *cls,
272 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 272 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
273 struct GNUNET_TIME_Absolute expire, 273 struct GNUNET_TIME_Absolute expire,
274 const char *name, 274 const char *name,
275 unsigned int rd_count, 275 unsigned int rd_count,
@@ -287,7 +287,7 @@ namestore_postgres_put_records (void *cls,
287 unsigned int i; 287 unsigned int i;
288 288
289 GNUNET_CRYPTO_short_hash (zone_key, 289 GNUNET_CRYPTO_short_hash (zone_key,
290 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 290 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
291 &zone); 291 &zone);
292 (void) namestore_postgres_remove_records (plugin, &zone, name); 292 (void) namestore_postgres_remove_records (plugin, &zone, name);
293 name_len = strlen (name); 293 name_len = strlen (name);
@@ -327,7 +327,7 @@ namestore_postgres_put_records (void *cls,
327 (const char *) &rvalue_be 327 (const char *) &rvalue_be
328 }; 328 };
329 int paramLengths[] = { 329 int paramLengths[] = {
330 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 330 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
331 name_len, 331 name_len,
332 sizeof (uint32_t), 332 sizeof (uint32_t),
333 data_size, 333 data_size,
@@ -378,7 +378,7 @@ get_record_and_call_iterator (struct Plugin *plugin,
378{ 378{
379 unsigned int record_count; 379 unsigned int record_count;
380 size_t data_size; 380 size_t data_size;
381 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key; 381 const struct GNUNET_CRYPTO_EccPublicKey *zone_key;
382 const struct GNUNET_CRYPTO_EccSignature *sig; 382 const struct GNUNET_CRYPTO_EccSignature *sig;
383 struct GNUNET_TIME_Absolute expiration; 383 struct GNUNET_TIME_Absolute expiration;
384 const char *data; 384 const char *data;
@@ -406,7 +406,7 @@ get_record_and_call_iterator (struct Plugin *plugin,
406 } 406 }
407 GNUNET_assert (1 == cnt); 407 GNUNET_assert (1 == cnt);
408 if ((6 != PQnfields (res)) || 408 if ((6 != PQnfields (res)) ||
409 (sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded) != PQgetlength (res, 0, 0)) || 409 (sizeof (struct GNUNET_CRYPTO_EccPublicKey) != PQgetlength (res, 0, 0)) ||
410 (sizeof (uint32_t) != PQfsize (res, 2)) || 410 (sizeof (uint32_t) != PQfsize (res, 2)) ||
411 (sizeof (uint64_t) != PQfsize (res, 4)) || 411 (sizeof (uint64_t) != PQfsize (res, 4)) ||
412 (sizeof (struct GNUNET_CRYPTO_EccSignature) != PQgetlength (res, 0, 5))) 412 (sizeof (struct GNUNET_CRYPTO_EccSignature) != PQgetlength (res, 0, 5)))
@@ -415,7 +415,7 @@ get_record_and_call_iterator (struct Plugin *plugin,
415 PQclear (res); 415 PQclear (res);
416 return GNUNET_SYSERR; 416 return GNUNET_SYSERR;
417 } 417 }
418 zone_key = (const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *) PQgetvalue (res, 0, 0); 418 zone_key = (const struct GNUNET_CRYPTO_EccPublicKey *) PQgetvalue (res, 0, 0);
419 name = PQgetvalue (res, 0, 1); 419 name = PQgetvalue (res, 0, 1);
420 name_len = PQgetlength (res, 0, 1); 420 name_len = PQgetlength (res, 0, 1);
421 record_count = ntohl (*(uint32_t *) PQgetvalue (res, 0, 2)); 421 record_count = ntohl (*(uint32_t *) PQgetvalue (res, 0, 2));
diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c
index 6c76d12e9..6ee3de495 100644
--- a/src/namestore/plugin_namestore_sqlite.c
+++ b/src/namestore/plugin_namestore_sqlite.c
@@ -1,6 +1,6 @@
1 /* 1 /*
2 * This file is part of GNUnet 2 * This file is part of GNUnet
3 * (C) 2009, 2011, 2012 Christian Grothoff (and other contributing authors) 3 * (C) 2009-2013 Christian Grothoff (and other contributing authors)
4 * 4 *
5 * GNUnet is free software; you can redistribute it and/or modify 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 6 * it under the terms of the GNU General Public License as published
@@ -450,7 +450,7 @@ namestore_sqlite_remove_records (void *cls,
450 */ 450 */
451static int 451static int
452namestore_sqlite_put_records (void *cls, 452namestore_sqlite_put_records (void *cls,
453 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 453 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
454 struct GNUNET_TIME_Absolute expire, 454 struct GNUNET_TIME_Absolute expire,
455 const char *name, 455 const char *name,
456 unsigned int rd_count, 456 unsigned int rd_count,
@@ -467,7 +467,7 @@ namestore_sqlite_put_records (void *cls,
467 size_t data_size; 467 size_t data_size;
468 unsigned int i; 468 unsigned int i;
469 469
470 GNUNET_CRYPTO_short_hash (zone_key, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), &zone); 470 GNUNET_CRYPTO_short_hash (zone_key, sizeof (struct GNUNET_CRYPTO_EccPublicKey), &zone);
471 (void) namestore_sqlite_remove_records (plugin, &zone, name); 471 (void) namestore_sqlite_remove_records (plugin, &zone, name);
472 name_len = strlen (name); 472 name_len = strlen (name);
473 GNUNET_CRYPTO_short_hash (name, name_len, &nh); 473 GNUNET_CRYPTO_short_hash (name, name_len, &nh);
@@ -497,7 +497,7 @@ namestore_sqlite_put_records (void *cls,
497 GNUNET_break (0); 497 GNUNET_break (0);
498 return GNUNET_SYSERR; 498 return GNUNET_SYSERR;
499 } 499 }
500 if ((SQLITE_OK != sqlite3_bind_blob (plugin->put_records, 1, zone_key, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), SQLITE_STATIC)) || 500 if ((SQLITE_OK != sqlite3_bind_blob (plugin->put_records, 1, zone_key, sizeof (struct GNUNET_CRYPTO_EccPublicKey), SQLITE_STATIC)) ||
501 (SQLITE_OK != sqlite3_bind_text (plugin->put_records, 2, name, -1, SQLITE_STATIC)) || 501 (SQLITE_OK != sqlite3_bind_text (plugin->put_records, 2, name, -1, SQLITE_STATIC)) ||
502 (SQLITE_OK != sqlite3_bind_int (plugin->put_records, 3, rd_count)) || 502 (SQLITE_OK != sqlite3_bind_int (plugin->put_records, 3, rd_count)) ||
503 (SQLITE_OK != sqlite3_bind_blob (plugin->put_records, 4, data, data_size, SQLITE_STATIC)) || 503 (SQLITE_OK != sqlite3_bind_blob (plugin->put_records, 4, data, data_size, SQLITE_STATIC)) ||
@@ -560,7 +560,7 @@ get_record_and_call_iterator (struct Plugin *plugin,
560 int sret; 560 int sret;
561 unsigned int record_count; 561 unsigned int record_count;
562 size_t data_size; 562 size_t data_size;
563 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key; 563 const struct GNUNET_CRYPTO_EccPublicKey *zone_key;
564 const struct GNUNET_CRYPTO_EccSignature *sig; 564 const struct GNUNET_CRYPTO_EccSignature *sig;
565 struct GNUNET_TIME_Absolute expiration; 565 struct GNUNET_TIME_Absolute expiration;
566 const char *data; 566 const char *data;
@@ -578,7 +578,7 @@ get_record_and_call_iterator (struct Plugin *plugin,
578 expiration.abs_value = (uint64_t) sqlite3_column_int64 (stmt, 4); 578 expiration.abs_value = (uint64_t) sqlite3_column_int64 (stmt, 4);
579 sig = sqlite3_column_blob (stmt, 5); 579 sig = sqlite3_column_blob (stmt, 5);
580 580
581 if ( (sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded) != sqlite3_column_bytes (stmt, 0)) || 581 if ( (sizeof (struct GNUNET_CRYPTO_EccPublicKey) != sqlite3_column_bytes (stmt, 0)) ||
582 (sizeof (struct GNUNET_CRYPTO_EccSignature) != sqlite3_column_bytes (stmt, 5)) ) 582 (sizeof (struct GNUNET_CRYPTO_EccSignature) != sqlite3_column_bytes (stmt, 5)) )
583 { 583 {
584 GNUNET_break (0); 584 GNUNET_break (0);
diff --git a/src/namestore/test_namestore_api.c b/src/namestore/test_namestore_api.c
index 32dd4844c..3397b35f1 100644
--- a/src/namestore/test_namestore_api.c
+++ b/src/namestore/test_namestore_api.c
@@ -41,7 +41,7 @@ static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
41 41
42static struct GNUNET_CRYPTO_EccPrivateKey *privkey; 42static struct GNUNET_CRYPTO_EccPrivateKey *privkey;
43 43
44static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey; 44static struct GNUNET_CRYPTO_EccPublicKey pubkey;
45 45
46static struct GNUNET_CRYPTO_ShortHashCode zone; 46static struct GNUNET_CRYPTO_ShortHashCode zone;
47 47
@@ -96,7 +96,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
96 96
97static void 97static void
98name_lookup_proc (void *cls, 98name_lookup_proc (void *cls,
99 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 99 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
100 struct GNUNET_TIME_Absolute expire, 100 struct GNUNET_TIME_Absolute expire,
101 const char *name, 101 const char *name,
102 unsigned int rd_count, 102 unsigned int rd_count,
diff --git a/src/namestore/test_namestore_api_create.c b/src/namestore/test_namestore_api_create.c
index aba18c192..4eac96df6 100644
--- a/src/namestore/test_namestore_api_create.c
+++ b/src/namestore/test_namestore_api_create.c
@@ -52,7 +52,7 @@ static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
52 52
53static struct GNUNET_CRYPTO_EccPrivateKey * privkey; 53static struct GNUNET_CRYPTO_EccPrivateKey * privkey;
54 54
55static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey; 55static struct GNUNET_CRYPTO_EccPublicKey pubkey;
56 56
57static struct GNUNET_CRYPTO_ShortHashCode s_zone; 57static struct GNUNET_CRYPTO_ShortHashCode s_zone;
58 58
@@ -108,7 +108,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
108 108
109static void 109static void
110name_lookup_second_proc (void *cls, 110name_lookup_second_proc (void *cls,
111 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 111 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
112 struct GNUNET_TIME_Absolute expire, 112 struct GNUNET_TIME_Absolute expire,
113 const char *n, 113 const char *n,
114 unsigned int rd_count, 114 unsigned int rd_count,
@@ -122,7 +122,7 @@ name_lookup_second_proc (void *cls,
122 if (n != NULL) 122 if (n != NULL)
123 { 123 {
124 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking returned results\n"); 124 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking returned results\n");
125 if (0 != memcmp (zone_key, &pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded))) 125 if (0 != memcmp (zone_key, &pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKey)))
126 { 126 {
127 GNUNET_break (0); 127 GNUNET_break (0);
128 failed = GNUNET_YES; 128 failed = GNUNET_YES;
@@ -203,7 +203,7 @@ create_second_cont (void *cls, int32_t success, const char *emsg)
203 203
204static void 204static void
205name_lookup_initial_proc (void *cls, 205name_lookup_initial_proc (void *cls,
206 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 206 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
207 struct GNUNET_TIME_Absolute expire, 207 struct GNUNET_TIME_Absolute expire,
208 const char *n, 208 const char *n,
209 unsigned int rd_count, 209 unsigned int rd_count,
@@ -219,7 +219,7 @@ name_lookup_initial_proc (void *cls,
219 if (n != NULL) 219 if (n != NULL)
220 { 220 {
221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking returned results\n"); 221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking returned results\n");
222 if (0 != memcmp (zone_key, &pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded))) 222 if (0 != memcmp (zone_key, &pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKey)))
223 { 223 {
224 GNUNET_break (0); 224 GNUNET_break (0);
225 failed = GNUNET_YES; 225 failed = GNUNET_YES;
@@ -353,7 +353,7 @@ run (void *cls,
353 GNUNET_NAMESTORE_records_serialize(1, s_first_record, rd_ser_len, rd_ser); 353 GNUNET_NAMESTORE_records_serialize(1, s_first_record, rd_ser_len, rd_ser);
354 354
355 /* create random zone hash */ 355 /* create random zone hash */
356 GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), &s_zone); 356 GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKey), &s_zone);
357 357
358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_NAMESTORE_short_h2s (&s_zone)); 358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_NAMESTORE_short_h2s (&s_zone));
359 nsh = GNUNET_NAMESTORE_connect (cfg); 359 nsh = GNUNET_NAMESTORE_connect (cfg);
diff --git a/src/namestore/test_namestore_api_create_update.c b/src/namestore/test_namestore_api_create_update.c
index 28211d439..f1e66963f 100644
--- a/src/namestore/test_namestore_api_create_update.c
+++ b/src/namestore/test_namestore_api_create_update.c
@@ -52,7 +52,7 @@ static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
52 52
53static struct GNUNET_CRYPTO_EccPrivateKey * privkey; 53static struct GNUNET_CRYPTO_EccPrivateKey * privkey;
54 54
55static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey; 55static struct GNUNET_CRYPTO_EccPublicKey pubkey;
56 56
57static struct GNUNET_CRYPTO_EccSignature *s_signature; 57static struct GNUNET_CRYPTO_EccSignature *s_signature;
58 58
@@ -243,7 +243,7 @@ run (void *cls,
243 s_signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, s_first_record, 1); 243 s_signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, s_first_record, 1);
244 244
245 /* create random zone hash */ 245 /* create random zone hash */
246 GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), &s_zone); 246 GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKey), &s_zone);
247 247
248 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_NAMESTORE_short_h2s (&s_zone)); 248 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_NAMESTORE_short_h2s (&s_zone));
249 nsh = GNUNET_NAMESTORE_connect (cfg); 249 nsh = GNUNET_NAMESTORE_connect (cfg);
diff --git a/src/namestore/test_namestore_api_lookup.c b/src/namestore/test_namestore_api_lookup.c
index 7673e0fa7..d8f6fe056 100644
--- a/src/namestore/test_namestore_api_lookup.c
+++ b/src/namestore/test_namestore_api_lookup.c
@@ -45,7 +45,7 @@ static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
45 45
46static struct GNUNET_CRYPTO_EccPrivateKey * privkey; 46static struct GNUNET_CRYPTO_EccPrivateKey * privkey;
47 47
48static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey; 48static struct GNUNET_CRYPTO_EccPublicKey pubkey;
49 49
50static struct GNUNET_CRYPTO_EccSignature *s_signature; 50static struct GNUNET_CRYPTO_EccSignature *s_signature;
51 51
@@ -105,7 +105,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
105 105
106static void 106static void
107name_lookup_proc (void *cls, 107name_lookup_proc (void *cls,
108 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 108 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
109 struct GNUNET_TIME_Absolute expire, 109 struct GNUNET_TIME_Absolute expire,
110 const char *n, 110 const char *n,
111 unsigned int rd_count, 111 unsigned int rd_count,
@@ -119,7 +119,7 @@ name_lookup_proc (void *cls,
119 { 119 {
120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking returned results\n"); 120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking returned results\n");
121 if (0 != memcmp (zone_key, &pubkey, 121 if (0 != memcmp (zone_key, &pubkey,
122 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded))) 122 sizeof (struct GNUNET_CRYPTO_EccPublicKey)))
123 { 123 {
124 GNUNET_break (0); 124 GNUNET_break (0);
125 } 125 }
@@ -243,7 +243,7 @@ run (void *cls,
243 243
244 /* create random zone hash */ 244 /* create random zone hash */
245 GNUNET_CRYPTO_short_hash (&pubkey, 245 GNUNET_CRYPTO_short_hash (&pubkey,
246 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 246 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
247 &s_zone); 247 &s_zone);
248 nsh = GNUNET_NAMESTORE_connect (cfg); 248 nsh = GNUNET_NAMESTORE_connect (cfg);
249 GNUNET_break (NULL != nsh); 249 GNUNET_break (NULL != nsh);
diff --git a/src/namestore/test_namestore_api_lookup_specific_type.c b/src/namestore/test_namestore_api_lookup_specific_type.c
index 49988ed3f..28632c83f 100644
--- a/src/namestore/test_namestore_api_lookup_specific_type.c
+++ b/src/namestore/test_namestore_api_lookup_specific_type.c
@@ -50,7 +50,7 @@ static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
50 50
51static struct GNUNET_CRYPTO_EccPrivateKey * privkey; 51static struct GNUNET_CRYPTO_EccPrivateKey * privkey;
52 52
53static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey; 53static struct GNUNET_CRYPTO_EccPublicKey pubkey;
54 54
55static struct GNUNET_CRYPTO_EccSignature *s_signature; 55static struct GNUNET_CRYPTO_EccSignature *s_signature;
56 56
@@ -110,7 +110,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
110 110
111static void 111static void
112name_lookup_existing_record_type (void *cls, 112name_lookup_existing_record_type (void *cls,
113 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 113 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
114 struct GNUNET_TIME_Absolute expire, 114 struct GNUNET_TIME_Absolute expire,
115 const char *n, 115 const char *n,
116 unsigned int rd_count, 116 unsigned int rd_count,
@@ -121,7 +121,7 @@ name_lookup_existing_record_type (void *cls,
121 121
122 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore returned %u records\n", rd_count); 122 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore returned %u records\n", rd_count);
123 123
124 if ((NULL == n) || (0 != memcmp(zone_key, &pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)))) 124 if ((NULL == n) || (0 != memcmp(zone_key, &pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKey))))
125 { 125 {
126 GNUNET_break(0); 126 GNUNET_break(0);
127 failed = GNUNET_YES; 127 failed = GNUNET_YES;
@@ -156,7 +156,7 @@ name_lookup_existing_record_type (void *cls,
156 156
157static void 157static void
158name_lookup_non_existing_record_type (void *cls, 158name_lookup_non_existing_record_type (void *cls,
159 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 159 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
160 struct GNUNET_TIME_Absolute expire, 160 struct GNUNET_TIME_Absolute expire,
161 const char *n, 161 const char *n,
162 unsigned int rd_count, 162 unsigned int rd_count,
@@ -300,7 +300,7 @@ run (void *cls,
300 s_signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, s_rd, RECORDS); 300 s_signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, s_rd, RECORDS);
301 301
302 /* create random zone hash */ 302 /* create random zone hash */
303 GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), &s_zone); 303 GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKey), &s_zone);
304 nsh = GNUNET_NAMESTORE_connect (cfg); 304 nsh = GNUNET_NAMESTORE_connect (cfg);
305 GNUNET_break (NULL != nsh); 305 GNUNET_break (NULL != nsh);
306 GNUNET_break (s_rd != NULL); 306 GNUNET_break (s_rd != NULL);
diff --git a/src/namestore/test_namestore_api_monitoring.c b/src/namestore/test_namestore_api_monitoring.c
index b3147c43a..c103952fa 100644
--- a/src/namestore/test_namestore_api_monitoring.c
+++ b/src/namestore/test_namestore_api_monitoring.c
@@ -39,13 +39,13 @@ static GNUNET_SCHEDULER_TaskIdentifier stopiteration_task;
39 39
40static struct GNUNET_CRYPTO_EccPrivateKey * privkey; 40static struct GNUNET_CRYPTO_EccPrivateKey * privkey;
41 41
42static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey; 42static struct GNUNET_CRYPTO_EccPublicKey pubkey;
43 43
44static struct GNUNET_HashCode zone; 44static struct GNUNET_HashCode zone;
45 45
46static struct GNUNET_CRYPTO_EccPrivateKey * privkey2; 46static struct GNUNET_CRYPTO_EccPrivateKey * privkey2;
47 47
48static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey2; 48static struct GNUNET_CRYPTO_EccPublicKey pubkey2;
49 49
50static struct GNUNET_HashCode zone2; 50static struct GNUNET_HashCode zone2;
51 51
@@ -152,7 +152,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
152 152
153static void 153static void
154zone_proc (void *cls, 154zone_proc (void *cls,
155 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 155 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
156 struct GNUNET_TIME_Absolute expire, 156 struct GNUNET_TIME_Absolute expire,
157 const char *name, 157 const char *name,
158 unsigned int rd_count, 158 unsigned int rd_count,
diff --git a/src/namestore/test_namestore_api_put.c b/src/namestore/test_namestore_api_put.c
index df5cb336e..ff99b60f9 100644
--- a/src/namestore/test_namestore_api_put.c
+++ b/src/namestore/test_namestore_api_put.c
@@ -44,7 +44,7 @@ static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
44 44
45static struct GNUNET_CRYPTO_EccPrivateKey * privkey; 45static struct GNUNET_CRYPTO_EccPrivateKey * privkey;
46 46
47static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey; 47static struct GNUNET_CRYPTO_EccPublicKey pubkey;
48 48
49static struct GNUNET_NAMESTORE_RecordData *s_rd; 49static struct GNUNET_NAMESTORE_RecordData *s_rd;
50 50
diff --git a/src/namestore/test_namestore_api_remove.c b/src/namestore/test_namestore_api_remove.c
index 77edd3fa9..f278b30db 100644
--- a/src/namestore/test_namestore_api_remove.c
+++ b/src/namestore/test_namestore_api_remove.c
@@ -51,7 +51,7 @@ static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
51 51
52static struct GNUNET_CRYPTO_EccPrivateKey * privkey; 52static struct GNUNET_CRYPTO_EccPrivateKey * privkey;
53 53
54static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey; 54static struct GNUNET_CRYPTO_EccPublicKey pubkey;
55 55
56static struct GNUNET_CRYPTO_EccSignature *s_signature; 56static struct GNUNET_CRYPTO_EccSignature *s_signature;
57 57
@@ -109,7 +109,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
109 109
110static void 110static void
111name_lookup_proc (void *cls, 111name_lookup_proc (void *cls,
112 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 112 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
113 struct GNUNET_TIME_Absolute expire, 113 struct GNUNET_TIME_Absolute expire,
114 const char *n, 114 const char *n,
115 unsigned int rd_count, 115 unsigned int rd_count,
@@ -124,7 +124,7 @@ name_lookup_proc (void *cls,
124 "Lookup for name `%s' returned %u records\n", n, rd_count); 124 "Lookup for name `%s' returned %u records\n", n, rd_count);
125 if (0 != memcmp (zone_key, 125 if (0 != memcmp (zone_key,
126 &pubkey, 126 &pubkey,
127 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded))) 127 sizeof (struct GNUNET_CRYPTO_EccPublicKey)))
128 { 128 {
129 GNUNET_break (0); 129 GNUNET_break (0);
130 failed = GNUNET_YES; 130 failed = GNUNET_YES;
@@ -254,7 +254,7 @@ run (void *cls,
254 s_signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, s_rd, RECORDS); 254 s_signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, s_rd, RECORDS);
255 255
256 /* create random zone hash */ 256 /* create random zone hash */
257 GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), &s_zone); 257 GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKey), &s_zone);
258 258
259 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_NAMESTORE_short_h2s (&s_zone)); 259 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_NAMESTORE_short_h2s (&s_zone));
260 nsh = GNUNET_NAMESTORE_connect (cfg); 260 nsh = GNUNET_NAMESTORE_connect (cfg);
diff --git a/src/namestore/test_namestore_api_remove_not_existing_record.c b/src/namestore/test_namestore_api_remove_not_existing_record.c
index 4e207257e..a85bc8c05 100644
--- a/src/namestore/test_namestore_api_remove_not_existing_record.c
+++ b/src/namestore/test_namestore_api_remove_not_existing_record.c
@@ -51,7 +51,7 @@ static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
51 51
52static struct GNUNET_CRYPTO_EccPrivateKey * privkey; 52static struct GNUNET_CRYPTO_EccPrivateKey * privkey;
53 53
54static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey; 54static struct GNUNET_CRYPTO_EccPublicKey pubkey;
55 55
56static struct GNUNET_CRYPTO_EccSignature *s_signature; 56static struct GNUNET_CRYPTO_EccSignature *s_signature;
57 57
@@ -202,7 +202,7 @@ run (void *cls,
202 s_signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, s_rd, RECORDS); 202 s_signature = GNUNET_NAMESTORE_create_signature(privkey, et, s_name, s_rd, RECORDS);
203 203
204 /* create random zone hash */ 204 /* create random zone hash */
205 GNUNET_CRYPTO_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), &s_zone); 205 GNUNET_CRYPTO_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKey), &s_zone);
206 206
207 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_h2s_full(&s_zone)); 207 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name: `%s' Zone: `%s' \n", s_name, GNUNET_h2s_full(&s_zone));
208 nsh = GNUNET_NAMESTORE_connect (cfg); 208 nsh = GNUNET_NAMESTORE_connect (cfg);
diff --git a/src/namestore/test_namestore_api_sign_verify.c b/src/namestore/test_namestore_api_sign_verify.c
index 647cc59be..e2913991c 100644
--- a/src/namestore/test_namestore_api_sign_verify.c
+++ b/src/namestore/test_namestore_api_sign_verify.c
@@ -44,7 +44,7 @@
44 44
45static struct GNUNET_CRYPTO_EccPrivateKey * privkey; 45static struct GNUNET_CRYPTO_EccPrivateKey * privkey;
46 46
47static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey; 47static struct GNUNET_CRYPTO_EccPublicKey pubkey;
48 48
49static struct GNUNET_NAMESTORE_RecordData *s_rd; 49static struct GNUNET_NAMESTORE_RecordData *s_rd;
50 50
diff --git a/src/namestore/test_namestore_api_zone_iteration.c b/src/namestore/test_namestore_api_zone_iteration.c
index f2d77d2ac..63e4adf40 100644
--- a/src/namestore/test_namestore_api_zone_iteration.c
+++ b/src/namestore/test_namestore_api_zone_iteration.c
@@ -39,13 +39,13 @@ static GNUNET_SCHEDULER_TaskIdentifier stopiteration_task;
39 39
40static struct GNUNET_CRYPTO_EccPrivateKey * privkey; 40static struct GNUNET_CRYPTO_EccPrivateKey * privkey;
41 41
42static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey; 42static struct GNUNET_CRYPTO_EccPublicKey pubkey;
43 43
44static struct GNUNET_HashCode zone; 44static struct GNUNET_HashCode zone;
45 45
46static struct GNUNET_CRYPTO_EccPrivateKey * privkey2; 46static struct GNUNET_CRYPTO_EccPrivateKey * privkey2;
47 47
48static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey2; 48static struct GNUNET_CRYPTO_EccPublicKey pubkey2;
49 49
50static struct GNUNET_HashCode zone2; 50static struct GNUNET_HashCode zone2;
51 51
@@ -179,7 +179,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
179 179
180static void 180static void
181zone_proc (void *cls, 181zone_proc (void *cls,
182 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 182 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
183 struct GNUNET_TIME_Absolute expire, 183 struct GNUNET_TIME_Absolute expire,
184 const char *name, 184 const char *name,
185 unsigned int rd_count, 185 unsigned int rd_count,
@@ -204,7 +204,7 @@ zone_proc (void *cls,
204 if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (zone_key, expire, name, rd_count, rd, signature)) 204 if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (zone_key, expire, name, rd_count, rd, signature))
205 { 205 {
206 struct GNUNET_HashCode zone_key_hash; 206 struct GNUNET_HashCode zone_key_hash;
207 GNUNET_CRYPTO_hash (zone_key, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), &zone_key_hash); 207 GNUNET_CRYPTO_hash (zone_key, sizeof (struct GNUNET_CRYPTO_EccPublicKey), &zone_key_hash);
208 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Verifying signature for `%s' in zone `%s' with %u records and expiration %llu failed\n", name, GNUNET_h2s(&zone_key_hash), rd_count, expire.abs_value); 208 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Verifying signature for `%s' in zone `%s' with %u records and expiration %llu failed\n", name, GNUNET_h2s(&zone_key_hash), rd_count, expire.abs_value);
209 209
210 failed = GNUNET_YES; 210 failed = GNUNET_YES;
@@ -354,7 +354,7 @@ create_record (unsigned int count)
354 */ 354 */
355static void 355static void
356empty_zone_proc (void *cls, 356empty_zone_proc (void *cls,
357 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 357 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
358 struct GNUNET_TIME_Absolute expire, 358 struct GNUNET_TIME_Absolute expire,
359 const char *name, 359 const char *name,
360 unsigned int rd_count, 360 unsigned int rd_count,
diff --git a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
index 3dce51d90..020c8358f 100644
--- a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
+++ b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c
@@ -39,13 +39,13 @@ static GNUNET_SCHEDULER_TaskIdentifier stopiteration_task;
39 39
40static struct GNUNET_CRYPTO_EccPrivateKey * privkey; 40static struct GNUNET_CRYPTO_EccPrivateKey * privkey;
41 41
42static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey; 42static struct GNUNET_CRYPTO_EccPublicKey pubkey;
43 43
44static struct GNUNET_CRYPTO_ShortHashCode zone; 44static struct GNUNET_CRYPTO_ShortHashCode zone;
45 45
46static struct GNUNET_CRYPTO_EccPrivateKey * privkey2; 46static struct GNUNET_CRYPTO_EccPrivateKey * privkey2;
47 47
48static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey2; 48static struct GNUNET_CRYPTO_EccPublicKey pubkey2;
49 49
50static struct GNUNET_CRYPTO_ShortHashCode zone2; 50static struct GNUNET_CRYPTO_ShortHashCode zone2;
51 51
@@ -174,7 +174,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
174 174
175static void 175static void
176zone_proc (void *cls, 176zone_proc (void *cls,
177 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 177 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
178 struct GNUNET_TIME_Absolute expire, 178 struct GNUNET_TIME_Absolute expire,
179 const char *name, 179 const char *name,
180 unsigned int rd_count, 180 unsigned int rd_count,
diff --git a/src/namestore/test_namestore_api_zone_iteration_stop.c b/src/namestore/test_namestore_api_zone_iteration_stop.c
index 9c1829e91..5d44555d1 100644
--- a/src/namestore/test_namestore_api_zone_iteration_stop.c
+++ b/src/namestore/test_namestore_api_zone_iteration_stop.c
@@ -38,13 +38,13 @@ static GNUNET_SCHEDULER_TaskIdentifier stopiteration_task;
38 38
39static struct GNUNET_CRYPTO_EccPrivateKey * privkey; 39static struct GNUNET_CRYPTO_EccPrivateKey * privkey;
40 40
41static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey; 41static struct GNUNET_CRYPTO_EccPublicKey pubkey;
42 42
43static struct GNUNET_HashCode zone; 43static struct GNUNET_HashCode zone;
44 44
45static struct GNUNET_CRYPTO_EccPrivateKey * privkey2; 45static struct GNUNET_CRYPTO_EccPrivateKey * privkey2;
46 46
47static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey2; 47static struct GNUNET_CRYPTO_EccPublicKey pubkey2;
48 48
49static struct GNUNET_HashCode zone2; 49static struct GNUNET_HashCode zone2;
50 50
@@ -177,7 +177,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
177 177
178static void 178static void
179zone_proc (void *cls, 179zone_proc (void *cls,
180 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 180 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
181 struct GNUNET_TIME_Absolute expire, 181 struct GNUNET_TIME_Absolute expire,
182 const char *name, 182 const char *name,
183 unsigned int rd_count, 183 unsigned int rd_count,
diff --git a/src/namestore/test_namestore_api_zone_to_name.c b/src/namestore/test_namestore_api_zone_to_name.c
index f0b712eb9..e1fefec09 100644
--- a/src/namestore/test_namestore_api_zone_to_name.c
+++ b/src/namestore/test_namestore_api_zone_to_name.c
@@ -45,7 +45,7 @@ static GNUNET_SCHEDULER_TaskIdentifier endbadly_task;
45 45
46static struct GNUNET_CRYPTO_EccPrivateKey * privkey; 46static struct GNUNET_CRYPTO_EccPrivateKey * privkey;
47 47
48static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubkey; 48static struct GNUNET_CRYPTO_EccPublicKey pubkey;
49 49
50static struct GNUNET_TIME_Absolute expire; 50static struct GNUNET_TIME_Absolute expire;
51 51
@@ -98,7 +98,7 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
98 98
99static void 99static void
100zone_to_name_proc (void *cls, 100zone_to_name_proc (void *cls,
101 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 101 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
102 struct GNUNET_TIME_Absolute expire, 102 struct GNUNET_TIME_Absolute expire,
103 const char *n, 103 const char *n,
104 unsigned int rd_count, 104 unsigned int rd_count,
@@ -125,7 +125,7 @@ zone_to_name_proc (void *cls,
125 fail = GNUNET_YES; 125 fail = GNUNET_YES;
126 GNUNET_break (0); 126 GNUNET_break (0);
127 } 127 }
128 if ((zone_key == NULL) || (0 != memcmp (zone_key, &pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)))) 128 if ((zone_key == NULL) || (0 != memcmp (zone_key, &pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKey))))
129 { 129 {
130 fail = GNUNET_YES; 130 fail = GNUNET_YES;
131 GNUNET_break (0); 131 GNUNET_break (0);
@@ -182,7 +182,7 @@ run (void *cls,
182 GNUNET_CRYPTO_ecc_key_get_public(privkey, &pubkey); 182 GNUNET_CRYPTO_ecc_key_get_public(privkey, &pubkey);
183 183
184 /* zone hash */ 184 /* zone hash */
185 GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), &s_zone); 185 GNUNET_CRYPTO_short_hash (&pubkey, sizeof (struct GNUNET_CRYPTO_EccPublicKey), &s_zone);
186 GNUNET_CRYPTO_short_hash (s_name, strlen (s_name) + 1, &s_zone_value); 186 GNUNET_CRYPTO_short_hash (s_name, strlen (s_name) + 1, &s_zone_value);
187 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using PKEY `%s' \n", GNUNET_NAMESTORE_short_h2s (&s_zone_value)); 187 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using PKEY `%s' \n", GNUNET_NAMESTORE_short_h2s (&s_zone_value));
188 188
diff --git a/src/namestore/test_plugin_namestore.c b/src/namestore/test_plugin_namestore.c
index b7d2341e4..35c9e920f 100644
--- a/src/namestore/test_plugin_namestore.c
+++ b/src/namestore/test_plugin_namestore.c
@@ -95,7 +95,7 @@ load_plugin (const struct GNUNET_CONFIGURATION_Handle *cfg)
95 */ 95 */
96static void 96static void
97test_record (void *cls, 97test_record (void *cls,
98 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, 98 const struct GNUNET_CRYPTO_EccPublicKey *zone_key,
99 struct GNUNET_TIME_Absolute expire, 99 struct GNUNET_TIME_Absolute expire,
100 const char *name, 100 const char *name,
101 unsigned int rd_count, 101 unsigned int rd_count,
@@ -104,7 +104,7 @@ test_record (void *cls,
104{ 104{
105 int *idp = cls; 105 int *idp = cls;
106 int id = *idp; 106 int id = *idp;
107 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded tzone_key; 107 struct GNUNET_CRYPTO_EccPublicKey tzone_key;
108 char tname[64]; 108 char tname[64];
109 unsigned int trd_count = 1 + (id % 1024); 109 unsigned int trd_count = 1 + (id % 1024);
110 struct GNUNET_CRYPTO_EccSignature tsignature; 110 struct GNUNET_CRYPTO_EccSignature tsignature;
@@ -122,7 +122,7 @@ test_record (void *cls,
122 memset (&tzone_key, (id % 241), sizeof (tzone_key)); 122 memset (&tzone_key, (id % 241), sizeof (tzone_key));
123 memset (&tsignature, (id % 243), sizeof (tsignature)); 123 memset (&tsignature, (id % 243), sizeof (tsignature));
124 GNUNET_assert (0 == strcmp (name, tname)); 124 GNUNET_assert (0 == strcmp (name, tname));
125 GNUNET_assert (0 == memcmp (&tzone_key, zone_key, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded))); 125 GNUNET_assert (0 == memcmp (&tzone_key, zone_key, sizeof (struct GNUNET_CRYPTO_EccPublicKey)));
126 GNUNET_assert (0 == memcmp (&tsignature, signature, sizeof (struct GNUNET_CRYPTO_EccSignature))); 126 GNUNET_assert (0 == memcmp (&tsignature, signature, sizeof (struct GNUNET_CRYPTO_EccSignature)));
127} 127}
128 128
@@ -139,7 +139,7 @@ get_record (struct GNUNET_NAMESTORE_PluginFunctions *nsp, int id)
139static void 139static void
140put_record (struct GNUNET_NAMESTORE_PluginFunctions *nsp, int id) 140put_record (struct GNUNET_NAMESTORE_PluginFunctions *nsp, int id)
141{ 141{
142 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded zone_key; 142 struct GNUNET_CRYPTO_EccPublicKey zone_key;
143 struct GNUNET_TIME_Absolute expire; 143 struct GNUNET_TIME_Absolute expire;
144 char name[64]; 144 char name[64];
145 unsigned int rd_count = 1 + (id % 1024); 145 unsigned int rd_count = 1 + (id % 1024);
@@ -175,7 +175,7 @@ run (void *cls, char *const *args, const char *cfgfile,
175 const struct GNUNET_CONFIGURATION_Handle *cfg) 175 const struct GNUNET_CONFIGURATION_Handle *cfg)
176{ 176{
177 struct GNUNET_NAMESTORE_PluginFunctions *nsp; 177 struct GNUNET_NAMESTORE_PluginFunctions *nsp;
178 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded zone_key; 178 struct GNUNET_CRYPTO_EccPublicKey zone_key;
179 struct GNUNET_CRYPTO_ShortHashCode zone; 179 struct GNUNET_CRYPTO_ShortHashCode zone;
180 180
181 ok = 0; 181 ok = 0;
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c
index b39891e7e..832c43abc 100644
--- a/src/nse/gnunet-service-nse.c
+++ b/src/nse/gnunet-service-nse.c
@@ -190,7 +190,7 @@ struct GNUNET_NSE_FloodMessage
190 /** 190 /**
191 * Public key of the originator. 191 * Public key of the originator.
192 */ 192 */
193 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; 193 struct GNUNET_CRYPTO_EccPublicKey pkey;
194 194
195 /** 195 /**
196 * Proof of work, causing leading zeros when hashed with pkey. 196 * Proof of work, causing leading zeros when hashed with pkey.
@@ -289,7 +289,7 @@ static struct GNUNET_TIME_Absolute current_timestamp;
289/** 289/**
290 * The public key of this peer. 290 * The public key of this peer.
291 */ 291 */
292static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded my_public_key; 292static struct GNUNET_CRYPTO_EccPublicKey my_public_key;
293 293
294/** 294/**
295 * The private key of this peer. 295 * The private key of this peer.
@@ -844,16 +844,16 @@ count_leading_zeroes (const struct GNUNET_HashCode * hash)
844 * @return GNUNET_YES if valid, GNUNET_NO if not 844 * @return GNUNET_YES if valid, GNUNET_NO if not
845 */ 845 */
846static int 846static int
847check_proof_of_work (const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *pkey, 847check_proof_of_work (const struct GNUNET_CRYPTO_EccPublicKey *pkey,
848 uint64_t val) 848 uint64_t val)
849{ 849{
850 char buf[sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded) + 850 char buf[sizeof (struct GNUNET_CRYPTO_EccPublicKey) +
851 sizeof (val)] GNUNET_ALIGN; 851 sizeof (val)] GNUNET_ALIGN;
852 struct GNUNET_HashCode result; 852 struct GNUNET_HashCode result;
853 853
854 memcpy (buf, &val, sizeof (val)); 854 memcpy (buf, &val, sizeof (val));
855 memcpy (&buf[sizeof (val)], pkey, 855 memcpy (&buf[sizeof (val)], pkey,
856 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)); 856 sizeof (struct GNUNET_CRYPTO_EccPublicKey));
857 pow_hash (buf, sizeof (buf), &result); 857 pow_hash (buf, sizeof (buf), &result);
858 return (count_leading_zeroes (&result) >= 858 return (count_leading_zeroes (&result) >=
859 nse_work_required) ? GNUNET_YES : GNUNET_NO; 859 nse_work_required) ? GNUNET_YES : GNUNET_NO;
@@ -892,14 +892,14 @@ find_proof (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
892{ 892{
893#define ROUND_SIZE 10 893#define ROUND_SIZE 10
894 uint64_t counter; 894 uint64_t counter;
895 char buf[sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded) + 895 char buf[sizeof (struct GNUNET_CRYPTO_EccPublicKey) +
896 sizeof (uint64_t)] GNUNET_ALIGN; 896 sizeof (uint64_t)] GNUNET_ALIGN;
897 struct GNUNET_HashCode result; 897 struct GNUNET_HashCode result;
898 unsigned int i; 898 unsigned int i;
899 899
900 proof_task = GNUNET_SCHEDULER_NO_TASK; 900 proof_task = GNUNET_SCHEDULER_NO_TASK;
901 memcpy (&buf[sizeof (uint64_t)], &my_public_key, 901 memcpy (&buf[sizeof (uint64_t)], &my_public_key,
902 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)); 902 sizeof (struct GNUNET_CRYPTO_EccPublicKey));
903 i = 0; 903 i = 0;
904 counter = my_proof; 904 counter = my_proof;
905 while ((counter != UINT64_MAX) && (i < ROUND_SIZE)) 905 while ((counter != UINT64_MAX) && (i < ROUND_SIZE))
@@ -1052,7 +1052,7 @@ handle_p2p_size_estimate (void *cls, const struct GNUNET_PeerIdentity *peer,
1052 struct GNUNET_PeerIdentity os; 1052 struct GNUNET_PeerIdentity os;
1053 1053
1054 GNUNET_CRYPTO_hash (&incoming_flood->pkey, 1054 GNUNET_CRYPTO_hash (&incoming_flood->pkey,
1055 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 1055 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
1056 &os.hashPubKey); 1056 &os.hashPubKey);
1057 GNUNET_snprintf (origin, sizeof (origin), "%s", GNUNET_i2s (&os)); 1057 GNUNET_snprintf (origin, sizeof (origin), "%s", GNUNET_i2s (&os));
1058 GNUNET_snprintf (pred, sizeof (pred), "%s", GNUNET_i2s (peer)); 1058 GNUNET_snprintf (pred, sizeof (pred), "%s", GNUNET_i2s (peer));
diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c
index 545f8a7e8..d0f9edb06 100644
--- a/src/peerinfo-tool/gnunet-peerinfo.c
+++ b/src/peerinfo-tool/gnunet-peerinfo.c
@@ -192,7 +192,7 @@ static struct GNUNET_PeerIdentity my_peer_identity;
192/** 192/**
193 * My public key. 193 * My public key.
194 */ 194 */
195static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded my_public_key; 195static struct GNUNET_CRYPTO_EccPublicKey my_public_key;
196 196
197/** 197/**
198 * Head of list of print contexts. 198 * Head of list of print contexts.
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c
index dc4c9fa07..6be98879f 100644
--- a/src/peerinfo/gnunet-service-peerinfo.c
+++ b/src/peerinfo/gnunet-service-peerinfo.c
@@ -655,7 +655,7 @@ update_friend_hello (const struct GNUNET_HELLO_Message *hello,
655{ 655{
656 struct GNUNET_HELLO_Message * res; 656 struct GNUNET_HELLO_Message * res;
657 struct GNUNET_HELLO_Message * tmp; 657 struct GNUNET_HELLO_Message * tmp;
658 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pk; 658 struct GNUNET_CRYPTO_EccPublicKey pk;
659 659
660 if (NULL != friend_hello) 660 if (NULL != friend_hello)
661 { 661 {
diff --git a/src/peerinfo/perf_peerinfo_api.c b/src/peerinfo/perf_peerinfo_api.c
index d55ccce2b..7a1266b62 100755
--- a/src/peerinfo/perf_peerinfo_api.c
+++ b/src/peerinfo/perf_peerinfo_api.c
@@ -82,7 +82,7 @@ address_generator (void *cls, size_t max, void *buf)
82static void 82static void
83add_peer (size_t i) 83add_peer (size_t i)
84{ 84{
85 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; 85 struct GNUNET_CRYPTO_EccPublicKey pkey;
86 struct GNUNET_HELLO_Message *h2; 86 struct GNUNET_HELLO_Message *h2;
87 87
88 memset (&pkey, i, sizeof (pkey)); 88 memset (&pkey, i, sizeof (pkey));
diff --git a/src/peerinfo/test_peerinfo_api.c b/src/peerinfo/test_peerinfo_api.c
index a68b2bdb7..202ebf13a 100644
--- a/src/peerinfo/test_peerinfo_api.c
+++ b/src/peerinfo/test_peerinfo_api.c
@@ -86,7 +86,7 @@ struct GNUNET_PeerIdentity pid;
86static void 86static void
87add_peer () 87add_peer ()
88{ 88{
89 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; 89 struct GNUNET_CRYPTO_EccPublicKey pkey;
90 struct GNUNET_HELLO_Message *h2; 90 struct GNUNET_HELLO_Message *h2;
91 size_t agc; 91 size_t agc;
92 92
diff --git a/src/peerinfo/test_peerinfo_api_friend_only.c b/src/peerinfo/test_peerinfo_api_friend_only.c
index 4c3d3b3ef..6b91757e5 100644
--- a/src/peerinfo/test_peerinfo_api_friend_only.c
+++ b/src/peerinfo/test_peerinfo_api_friend_only.c
@@ -68,7 +68,7 @@ struct GNUNET_PeerIdentity pid;
68static void 68static void
69add_peer () 69add_peer ()
70{ 70{
71 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; 71 struct GNUNET_CRYPTO_EccPublicKey pkey;
72 struct GNUNET_HELLO_Message *h2; 72 struct GNUNET_HELLO_Message *h2;
73 size_t agc; 73 size_t agc;
74 74
diff --git a/src/peerinfo/test_peerinfo_api_notify_friend_only.c b/src/peerinfo/test_peerinfo_api_notify_friend_only.c
index 700bac755..ae2ac5190 100644
--- a/src/peerinfo/test_peerinfo_api_notify_friend_only.c
+++ b/src/peerinfo/test_peerinfo_api_notify_friend_only.c
@@ -227,7 +227,7 @@ add_peer_done (void *cls, const char *emsg)
227static void 227static void
228add_peer () 228add_peer ()
229{ 229{
230 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; 230 struct GNUNET_CRYPTO_EccPublicKey pkey;
231 struct GNUNET_HELLO_Message *h2; 231 struct GNUNET_HELLO_Message *h2;
232 size_t agc; 232 size_t agc;
233 233
diff --git a/src/regex/regex_internal_dht.c b/src/regex/regex_internal_dht.c
index 317c6ef48..4f7b16705 100644
--- a/src/regex/regex_internal_dht.c
+++ b/src/regex/regex_internal_dht.c
@@ -381,7 +381,7 @@ dht_get_string_accept_handler (void *cls, struct GNUNET_TIME_Absolute exp,
381 "# regex accepting block bytes found", 381 "# regex accepting block bytes found",
382 size, GNUNET_NO); 382 size, GNUNET_NO);
383 GNUNET_CRYPTO_hash (&block->public_key, 383 GNUNET_CRYPTO_hash (&block->public_key,
384 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 384 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
385 &pid.hashPubKey); 385 &pid.hashPubKey);
386 info->callback (info->callback_cls, 386 info->callback (info->callback_cls,
387 &pid, 387 &pid,
diff --git a/src/testing/gnunet-testing.c b/src/testing/gnunet-testing.c
index 574b585fc..45ca4978c 100644
--- a/src/testing/gnunet-testing.c
+++ b/src/testing/gnunet-testing.c
@@ -118,13 +118,10 @@ create_unique_cfgs (const char * template, const unsigned int no)
118static int 118static int
119create_hostkeys (const unsigned int no) 119create_hostkeys (const unsigned int no)
120{ 120{
121 static char pad[GNUNET_TESTING_HOSTKEYFILESIZE];
122 struct GNUNET_TESTING_System *system; 121 struct GNUNET_TESTING_System *system;
123 struct GNUNET_PeerIdentity id; 122 struct GNUNET_PeerIdentity id;
124 struct GNUNET_DISK_FileHandle *fd; 123 struct GNUNET_DISK_FileHandle *fd;
125 struct GNUNET_CRYPTO_EccPrivateKey *pk; 124 struct GNUNET_CRYPTO_EccPrivateKey *pk;
126 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *pkb;
127 ssize_t ret;
128 125
129 system = GNUNET_TESTING_system_create ("testing", NULL, NULL, NULL); 126 system = GNUNET_TESTING_system_create ("testing", NULL, NULL, NULL);
130 pk = GNUNET_TESTING_hostkey_get (system, create_no, &id); 127 pk = GNUNET_TESTING_hostkey_get (system, create_no, &id);
@@ -141,19 +138,11 @@ create_hostkeys (const unsigned int no)
141 GNUNET_DISK_PERM_USER_READ | 138 GNUNET_DISK_PERM_USER_READ |
142 GNUNET_DISK_PERM_USER_WRITE); 139 GNUNET_DISK_PERM_USER_WRITE);
143 GNUNET_assert (fd != NULL); 140 GNUNET_assert (fd != NULL);
144 pkb = GNUNET_CRYPTO_ecc_encode_key (pk); 141 ret = GNUNET_DISK_file_write (fd, pk,
145 ret = GNUNET_DISK_file_write (fd, pkb, 142 sizeof (struct GNUNET_CRYPTO_EccPrivateKey));
146 ntohs (pkb->size));
147 GNUNET_assert (ntohs (pkb->size) == ret);
148 GNUNET_assert (ntohs (pkb->size) < GNUNET_TESTING_HOSTKEYFILESIZE);
149 GNUNET_assert (GNUNET_TESTING_HOSTKEYFILESIZE - ret ==
150 GNUNET_DISK_file_write (fd, pad,
151 GNUNET_TESTING_HOSTKEYFILESIZE - ret));
152
153 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd)); 143 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd));
154 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 144 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
155 "Wrote hostkey to file: `%s'\n", create_hostkey); 145 "Wrote hostkey to file: `%s'\n", create_hostkey);
156 GNUNET_free (pkb);
157 GNUNET_CRYPTO_ecc_key_free (pk); 146 GNUNET_CRYPTO_ecc_key_free (pk);
158 GNUNET_TESTING_system_destroy (system, GNUNET_YES); 147 GNUNET_TESTING_system_destroy (system, GNUNET_YES);
159 return 0; 148 return 0;
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 898af1674..73b2a4ee1 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -712,7 +712,7 @@ GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
712 struct GNUNET_PeerIdentity *id) 712 struct GNUNET_PeerIdentity *id)
713{ 713{
714 struct GNUNET_CRYPTO_EccPrivateKey *private_key; 714 struct GNUNET_CRYPTO_EccPrivateKey *private_key;
715 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key; 715 struct GNUNET_CRYPTO_EccPublicKey public_key;
716 716
717 if ((NULL == id) || (NULL == system->hostkeys_data)) 717 if ((NULL == id) || (NULL == system->hostkeys_data))
718 return NULL; 718 return NULL;
@@ -722,11 +722,11 @@ GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
722 _("Key number %u does not exist\n"), key_number); 722 _("Key number %u does not exist\n"), key_number);
723 return NULL; 723 return NULL;
724 } 724 }
725 private_key = GNUNET_CRYPTO_ecc_decode_key (system->hostkeys_data + 725 private_key = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey);
726 (key_number * 726 memcpy (private_key,
727 GNUNET_TESTING_HOSTKEYFILESIZE), 727 system->hostkeys_data +
728 GNUNET_TESTING_HOSTKEYFILESIZE, 728 (key_number * GNUNET_TESTING_HOSTKEYFILESIZE),
729 GNUNET_NO); 729 GNUNET_TESTING_HOSTKEYFILESIZE);
730 if (NULL == private_key) 730 if (NULL == private_key)
731 { 731 {
732 LOG (GNUNET_ERROR_TYPE_ERROR, 732 LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -735,7 +735,7 @@ GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
735 } 735 }
736 GNUNET_CRYPTO_ecc_key_get_public (private_key, &public_key); 736 GNUNET_CRYPTO_ecc_key_get_public (private_key, &public_key);
737 GNUNET_CRYPTO_hash (&public_key, 737 GNUNET_CRYPTO_hash (&public_key,
738 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 738 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
739 &(id->hashPubKey)); 739 &(id->hashPubKey));
740 return private_key; 740 return private_key;
741} 741}
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 0039b9a4c..3ef5e1dbf 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -70,7 +70,7 @@ static struct GNUNET_SERVER_Handle *GST_server;
70/** 70/**
71 * Our public key. 71 * Our public key.
72 */ 72 */
73struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded GST_my_public_key; 73struct GNUNET_CRYPTO_EccPublicKey GST_my_public_key;
74 74
75/** 75/**
76 * Our private key. 76 * Our private key.
diff --git a/src/transport/gnunet-service-transport.h b/src/transport/gnunet-service-transport.h
index cb2c11a9b..a9f455b6a 100644
--- a/src/transport/gnunet-service-transport.h
+++ b/src/transport/gnunet-service-transport.h
@@ -55,7 +55,7 @@ extern struct GNUNET_PEERINFO_Handle *GST_peerinfo;
55/** 55/**
56 * Our public key. 56 * Our public key.
57 */ 57 */
58extern struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded GST_my_public_key; 58extern struct GNUNET_CRYPTO_EccPublicKey GST_my_public_key;
59 59
60/** 60/**
61 * Our private key. 61 * Our private key.
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 269525a55..e0e549a3a 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -329,7 +329,7 @@ struct SessionDisconnectMessage
329 /** 329 /**
330 * Public key of the sender. 330 * Public key of the sender.
331 */ 331 */
332 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key; 332 struct GNUNET_CRYPTO_EccPublicKey public_key;
333 333
334 /** 334 /**
335 * Signature of the peer that sends us the disconnect. Only 335 * Signature of the peer that sends us the disconnect. Only
@@ -1195,7 +1195,7 @@ send_disconnect (struct NeighbourMapEntry *n)
1195 disconnect_msg.reserved = htonl (0); 1195 disconnect_msg.reserved = htonl (0);
1196 disconnect_msg.purpose.size = 1196 disconnect_msg.purpose.size =
1197 htonl (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + 1197 htonl (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
1198 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded) + 1198 sizeof (struct GNUNET_CRYPTO_EccPublicKey) +
1199 sizeof (struct GNUNET_TIME_AbsoluteNBO)); 1199 sizeof (struct GNUNET_TIME_AbsoluteNBO));
1200 disconnect_msg.purpose.purpose = 1200 disconnect_msg.purpose.purpose =
1201 htonl (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT); 1201 htonl (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT);
@@ -3151,7 +3151,7 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity
3151 return; 3151 return;
3152 } 3152 }
3153 GNUNET_CRYPTO_hash (&sdm->public_key, 3153 GNUNET_CRYPTO_hash (&sdm->public_key,
3154 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 3154 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
3155 &hc); 3155 &hc);
3156 if (0 != memcmp (peer, &hc, sizeof (struct GNUNET_PeerIdentity))) 3156 if (0 != memcmp (peer, &hc, sizeof (struct GNUNET_PeerIdentity)))
3157 { 3157 {
@@ -3160,7 +3160,7 @@ GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity
3160 } 3160 }
3161 if (ntohl (sdm->purpose.size) != 3161 if (ntohl (sdm->purpose.size) !=
3162 sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + 3162 sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
3163 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded) + 3163 sizeof (struct GNUNET_CRYPTO_EccPublicKey) +
3164 sizeof (struct GNUNET_TIME_AbsoluteNBO)) 3164 sizeof (struct GNUNET_TIME_AbsoluteNBO))
3165 { 3165 {
3166 GNUNET_break_op (0); 3166 GNUNET_break_op (0);
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index 4ea0f07a6..087c52411 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -189,7 +189,7 @@ struct ValidationEntry
189 /** 189 /**
190 * Public key of the peer. 190 * Public key of the peer.
191 */ 191 */
192 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key; 192 struct GNUNET_CRYPTO_EccPublicKey public_key;
193 193
194 /** 194 /**
195 * The identity of the peer. FIXME: duplicated (also in 'address') 195 * The identity of the peer. FIXME: duplicated (also in 'address')
@@ -682,8 +682,8 @@ revalidate_address (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
682 * if we don't have an existing entry and no public key was given 682 * if we don't have an existing entry and no public key was given
683 */ 683 */
684static struct ValidationEntry * 684static struct ValidationEntry *
685find_validation_entry (const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded 685find_validation_entry (const struct GNUNET_CRYPTO_EccPublicKey *public_key,
686 *public_key, const struct GNUNET_HELLO_Address *address) 686 const struct GNUNET_HELLO_Address *address)
687{ 687{
688 struct ValidationEntryMatchContext vemc; 688 struct ValidationEntryMatchContext vemc;
689 struct ValidationEntry *ve; 689 struct ValidationEntry *ve;
@@ -737,7 +737,7 @@ add_valid_address (void *cls, const struct GNUNET_HELLO_Address *address,
737 struct ValidationEntry *ve; 737 struct ValidationEntry *ve;
738 struct GNUNET_PeerIdentity pid; 738 struct GNUNET_PeerIdentity pid;
739 struct GNUNET_ATS_Information ats; 739 struct GNUNET_ATS_Information ats;
740 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key; 740 struct GNUNET_CRYPTO_EccPublicKey public_key;
741 741
742 if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0) 742 if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value == 0)
743 return GNUNET_OK; /* expired */ 743 return GNUNET_OK; /* expired */
@@ -857,8 +857,8 @@ GST_validation_stop ()
857 */ 857 */
858static void 858static void
859multicast_pong (void *cls, 859multicast_pong (void *cls,
860 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded 860 const struct GNUNET_CRYPTO_EccPublicKey *public_key,
861 *public_key, struct GNUNET_TIME_Absolute valid_until, 861 struct GNUNET_TIME_Absolute valid_until,
862 struct GNUNET_TIME_Absolute validation_block, 862 struct GNUNET_TIME_Absolute validation_block,
863 const struct GNUNET_HELLO_Address *address) 863 const struct GNUNET_HELLO_Address *address)
864{ 864{
@@ -1139,7 +1139,7 @@ struct ValidateAddressContext
1139 /** 1139 /**
1140 * Public key of the peer whose address is being validated. 1140 * Public key of the peer whose address is being validated.
1141 */ 1141 */
1142 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded public_key; 1142 struct GNUNET_CRYPTO_EccPublicKey public_key;
1143}; 1143};
1144 1144
1145 1145
diff --git a/src/transport/gnunet-service-transport_validation.h b/src/transport/gnunet-service-transport_validation.h
index 929e97a5c..46d3162c4 100644
--- a/src/transport/gnunet-service-transport_validation.h
+++ b/src/transport/gnunet-service-transport_validation.h
@@ -134,8 +134,7 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello);
134 */ 134 */
135typedef void (*GST_ValidationAddressCallback) (void *cls, 135typedef void (*GST_ValidationAddressCallback) (void *cls,
136 const struct 136 const struct
137 GNUNET_CRYPTO_EccPublicKeyBinaryEncoded 137 GNUNET_CRYPTO_EccPublicKey *public_key,
138 * public_key,
139 struct GNUNET_TIME_Absolute 138 struct GNUNET_TIME_Absolute
140 valid_until, 139 valid_until,
141 struct GNUNET_TIME_Absolute 140 struct GNUNET_TIME_Absolute
diff --git a/src/transport/test_plugin_transport.c b/src/transport/test_plugin_transport.c
index c48fc2d49..ffaad19ff 100644
--- a/src/transport/test_plugin_transport.c
+++ b/src/transport/test_plugin_transport.c
@@ -48,7 +48,7 @@
48/** 48/**
49 * Our public key. 49 * Our public key.
50 */ 50 */
51static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded my_public_key; 51static struct GNUNET_CRYPTO_EccPublicKey my_public_key;
52 52
53/** 53/**
54 * Our identity. 54 * Our identity.
diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c
index 2561ab2e6..a93512e38 100644
--- a/src/util/crypto_ecc.c
+++ b/src/util/crypto_ecc.c
@@ -4,7 +4,7 @@
4 4
5 GNUnet is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your 7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
@@ -30,6 +30,12 @@
30 30
31#define EXTRA_CHECKS ALLOW_EXTRA_CHECKS 31#define EXTRA_CHECKS ALLOW_EXTRA_CHECKS
32 32
33/**
34 * Name of the curve we are using. Note that we have hard-coded
35 * structs that use 256 bits, so using a bigger curve will require
36 * changes that break stuff badly. The name of the curve given here
37 * must be agreed by all peers and be supported by libgcrypt.
38 */
33#define CURVE "NIST P-256" 39#define CURVE "NIST P-256"
34 40
35#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__) 41#define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
@@ -47,28 +53,14 @@
47 53
48 54
49/** 55/**
50 * The private information of an ECC private key.
51 */
52struct GNUNET_CRYPTO_EccPrivateKey
53{
54
55 /**
56 * Libgcrypt S-expression for the ECC key.
57 */
58 gcry_sexp_t sexp;
59};
60
61
62/**
63 * Free memory occupied by ECC key 56 * Free memory occupied by ECC key
64 * 57 *
65 * @param privatekey pointer to the memory to free 58 * @param priv pointer to the memory to free
66 */ 59 */
67void 60void
68GNUNET_CRYPTO_ecc_key_free (struct GNUNET_CRYPTO_EccPrivateKey *privatekey) 61GNUNET_CRYPTO_ecc_key_free (struct GNUNET_CRYPTO_EccPrivateKey *priv)
69{ 62{
70 gcry_sexp_release (privatekey->sexp); 63 GNUNET_free (priv);
71 GNUNET_free (privatekey);
72} 64}
73 65
74 66
@@ -133,6 +125,141 @@ key_from_sexp (gcry_mpi_t * array, gcry_sexp_t sexp, const char *topname,
133 125
134 126
135/** 127/**
128 * If target != size, move target bytes to the end of the size-sized
129 * buffer and zero out the first target-size bytes.
130 *
131 * @param buf original buffer
132 * @param size number of bytes in the buffer
133 * @param target target size of the buffer
134 */
135static void
136adjust (unsigned char *buf,
137 size_t size,
138 size_t target)
139{
140 if (size < target)
141 {
142 memmove (&buf[target - size], buf, size);
143 memset (buf, 0, target - size);
144 }
145}
146
147
148/**
149 * Output the given MPI value to the given buffer.
150 *
151 * @param buf where to output to
152 * @param size number of bytes in buf
153 * @param val value to write to buf
154 */
155static void
156mpi_print (unsigned char *buf,
157 size_t size,
158 gcry_mpi_t val)
159{
160 size_t rsize;
161
162 rsize = size;
163 GNUNET_assert (0 ==
164 gcry_mpi_print (GCRYMPI_FMT_USG, buf, rsize, &rsize,
165 val));
166 adjust (buf, rsize, size);
167}
168
169
170/**
171 * Convert data buffer into MPI value.
172 *
173 * @param result where to store MPI value (allocated)
174 * @param data raw data (GCRYMPI_FMT_USG)
175 * @param size number of bytes in data
176 */
177static void
178mpi_scan (gcry_mpi_t *result,
179 const unsigned char *data,
180 size_t size)
181{
182 int rc;
183
184 if (0 != (rc = gcry_mpi_scan (result,
185 GCRYMPI_FMT_USG,
186 data, size, &size)))
187 {
188 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc);
189 GNUNET_assert (0);
190 }
191}
192
193
194/**
195 * Convert the given private key from the network format to the
196 * S-expression that can be used by libgcrypt.
197 *
198 * @param priv private key to decode
199 * @return NULL on error
200 */
201static gcry_sexp_t
202decode_private_key (const struct GNUNET_CRYPTO_EccPrivateKey *priv)
203{
204 gcry_sexp_t result;
205 gcry_mpi_t d;
206 size_t erroff;
207 int rc;
208
209 mpi_scan (&d,
210 priv->d,
211 sizeof (priv->d));
212 rc = gcry_sexp_build (&result, &erroff,
213 "(private-key(ecdsa(curve \"" CURVE "\")(d %m)))",
214 d);
215 gcry_mpi_release (d);
216 if (0 != rc)
217 {
218 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); /* erroff gives more info */
219 GNUNET_assert (0);
220 }
221#if EXTRA_CHECKS
222 if (0 != (rc = gcry_pk_testkey (result)))
223 {
224 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc);
225 GNUNET_assert (0);
226 }
227#endif
228 return result;
229}
230
231
232/**
233 * Initialize public key struct from the respective point
234 * on the curve.
235 *
236 * @param q point on curve
237 * @param pub public key struct to initialize
238 * @param ctx context to use for ECC operations
239 */
240static void
241point_to_public_key (gcry_mpi_point_t q,
242 gcry_ctx_t ctx,
243 struct GNUNET_CRYPTO_EccPublicKey *pub)
244{
245 gcry_mpi_t q_x;
246 gcry_mpi_t q_y;
247
248 q_x = gcry_mpi_new (256);
249 q_y = gcry_mpi_new (256);
250 if (gcry_mpi_ec_get_affine (q_x, q_y, q, ctx))
251 {
252 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "get_affine failed", 0);
253 return;
254 }
255 mpi_print (pub->q_x, sizeof (pub->q_x), q_x);
256 mpi_print (pub->q_y, sizeof (pub->q_y), q_y);
257 gcry_mpi_release (q_x);
258 gcry_mpi_release (q_y);
259}
260
261
262/**
136 * Extract the public key for the given private key. 263 * Extract the public key for the given private key.
137 * 264 *
138 * @param priv the private key 265 * @param priv the private key
@@ -140,26 +267,25 @@ key_from_sexp (gcry_mpi_t * array, gcry_sexp_t sexp, const char *topname,
140 */ 267 */
141void 268void
142GNUNET_CRYPTO_ecc_key_get_public (const struct GNUNET_CRYPTO_EccPrivateKey *priv, 269GNUNET_CRYPTO_ecc_key_get_public (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
143 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *pub) 270 struct GNUNET_CRYPTO_EccPublicKey *pub)
144{ 271{
145 gcry_mpi_t skey; 272 gcry_sexp_t sexp;
146 size_t size; 273 gcry_ctx_t ctx;
274 gcry_mpi_point_t q;
147 int rc; 275 int rc;
148 276
149 memset (pub, 0, sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)); 277 sexp = decode_private_key (priv);
150 rc = key_from_sexp (&skey, priv->sexp, "public-key", "q"); 278 GNUNET_assert (NULL != sexp);
151 if (rc) 279 if (0 != (rc = gcry_mpi_ec_new (&ctx, sexp, NULL)))
152 rc = key_from_sexp (&skey, priv->sexp, "private-key", "q"); 280 {
153 if (rc) 281 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_ec_new", rc); /* erroff gives more info */
154 rc = key_from_sexp (&skey, priv->sexp, "ecc", "q"); 282 return;
155 GNUNET_assert (0 == rc); 283 }
156 pub->size = htons (sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)); 284 gcry_sexp_release (sexp);
157 size = GNUNET_CRYPTO_ECC_MAX_PUBLIC_KEY_LENGTH; 285 q = gcry_mpi_ec_get_point ("q", ctx, 0);
158 GNUNET_assert (0 == 286 point_to_public_key (q, ctx, pub);
159 gcry_mpi_print (GCRYMPI_FMT_USG, pub->key, size, &size, 287 gcry_ctx_release (ctx);
160 skey)); 288 gcry_mpi_point_release (q);
161 pub->len = htons (size);
162 gcry_mpi_release (skey);
163} 289}
164 290
165 291
@@ -170,10 +296,10 @@ GNUNET_CRYPTO_ecc_key_get_public (const struct GNUNET_CRYPTO_EccPrivateKey *priv
170 * @return string representing 'pub' 296 * @return string representing 'pub'
171 */ 297 */
172char * 298char *
173GNUNET_CRYPTO_ecc_public_key_to_string (const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *pub) 299GNUNET_CRYPTO_ecc_public_key_to_string (const struct GNUNET_CRYPTO_EccPublicKey *pub)
174{ 300{
175 char *pubkeybuf; 301 char *pubkeybuf;
176 size_t keylen = (sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)) * 8; 302 size_t keylen = (sizeof (struct GNUNET_CRYPTO_EccPublicKey)) * 8;
177 char *end; 303 char *end;
178 304
179 if (keylen % 5 > 0) 305 if (keylen % 5 > 0)
@@ -181,7 +307,7 @@ GNUNET_CRYPTO_ecc_public_key_to_string (const struct GNUNET_CRYPTO_EccPublicKeyB
181 keylen /= 5; 307 keylen /= 5;
182 pubkeybuf = GNUNET_malloc (keylen + 1); 308 pubkeybuf = GNUNET_malloc (keylen + 1);
183 end = GNUNET_STRINGS_data_to_string ((unsigned char *) pub, 309 end = GNUNET_STRINGS_data_to_string ((unsigned char *) pub,
184 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded), 310 sizeof (struct GNUNET_CRYPTO_EccPublicKey),
185 pubkeybuf, 311 pubkeybuf,
186 keylen); 312 keylen);
187 if (NULL == end) 313 if (NULL == end)
@@ -205,9 +331,9 @@ GNUNET_CRYPTO_ecc_public_key_to_string (const struct GNUNET_CRYPTO_EccPublicKeyB
205int 331int
206GNUNET_CRYPTO_ecc_public_key_from_string (const char *enc, 332GNUNET_CRYPTO_ecc_public_key_from_string (const char *enc,
207 size_t enclen, 333 size_t enclen,
208 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *pub) 334 struct GNUNET_CRYPTO_EccPublicKey *pub)
209{ 335{
210 size_t keylen = (sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)) * 8; 336 size_t keylen = (sizeof (struct GNUNET_CRYPTO_EccPublicKey)) * 8;
211 337
212 if (keylen % 5 > 0) 338 if (keylen % 5 > 0)
213 keylen += 5 - keylen % 5; 339 keylen += 5 - keylen % 5;
@@ -217,10 +343,7 @@ GNUNET_CRYPTO_ecc_public_key_from_string (const char *enc,
217 343
218 if (GNUNET_OK != GNUNET_STRINGS_string_to_data (enc, enclen, 344 if (GNUNET_OK != GNUNET_STRINGS_string_to_data (enc, enclen,
219 pub, 345 pub,
220 sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded))) 346 sizeof (struct GNUNET_CRYPTO_EccPublicKey)))
221 return GNUNET_SYSERR;
222 if ( (ntohs (pub->size) != sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)) ||
223 (ntohs (pub->len) > GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH) )
224 return GNUNET_SYSERR; 347 return GNUNET_SYSERR;
225 return GNUNET_OK; 348 return GNUNET_OK;
226} 349}
@@ -230,137 +353,46 @@ GNUNET_CRYPTO_ecc_public_key_from_string (const char *enc,
230 * Convert the given public key from the network format to the 353 * Convert the given public key from the network format to the
231 * S-expression that can be used by libgcrypt. 354 * S-expression that can be used by libgcrypt.
232 * 355 *
233 * @param publicKey public key to decode 356 * @param pub public key to decode
234 * @return NULL on error 357 * @return NULL on error
235 */ 358 */
236static gcry_sexp_t 359static gcry_sexp_t
237decode_public_key (const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *publicKey) 360decode_public_key (const struct GNUNET_CRYPTO_EccPublicKey *pub)
238{ 361{
239 gcry_sexp_t result; 362 gcry_sexp_t pub_sexp;
240 gcry_mpi_t q; 363 gcry_mpi_t q_x;
241 size_t size; 364 gcry_mpi_t q_y;
242 size_t erroff; 365 gcry_mpi_point_t q;
366 gcry_ctx_t ctx;
243 int rc; 367 int rc;
244 368
245 if (ntohs (publicKey->len) > GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH) 369 mpi_scan (&q_x, pub->q_x, sizeof (pub->q_x));
246 { 370 mpi_scan (&q_y, pub->q_y, sizeof (pub->q_y));
247 GNUNET_break (0); 371 q = gcry_mpi_point_new (256);
248 return NULL; 372 gcry_mpi_point_set (q, q_x, q_y, GCRYMPI_CONST_ONE);
249 } 373 gcry_mpi_release (q_x);
250 size = ntohs (publicKey->len); 374 gcry_mpi_release (q_y);
251 if (0 != (rc = gcry_mpi_scan (&q, GCRYMPI_FMT_USG, publicKey->key, size, &size)))
252 {
253 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc);
254 return NULL;
255 }
256
257 rc = gcry_sexp_build (&result, &erroff,
258 "(public-key(ecdsa(curve \"" CURVE "\")(q %m)))",
259 q);
260 gcry_mpi_release (q);
261 if (0 != rc)
262 {
263 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); /* erroff gives more info */
264 return NULL;
265 }
266#if EXTRA_CHECKS
267 if (0 != (rc = gcry_pk_testkey (result)))
268 {
269 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc);
270 gcry_sexp_release (result);
271 return NULL;
272 }
273#endif
274 return result;
275}
276
277
278/**
279 * Encode the private key in a format suitable for
280 * storing it into a file.
281 *
282 * @param key key to encode
283 * @return encoding of the private key.
284 * The first 4 bytes give the size of the array, as usual.
285 */
286struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *
287GNUNET_CRYPTO_ecc_encode_key (const struct GNUNET_CRYPTO_EccPrivateKey *key)
288{
289 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *retval;
290 char buf[65536];
291 uint16_t be;
292 size_t size;
293
294#if EXTRA_CHECKS
295 if (0 != gcry_pk_testkey (key->sexp))
296 {
297 GNUNET_break (0);
298 return NULL;
299 }
300#endif
301 size = gcry_sexp_sprint (key->sexp,
302 GCRYSEXP_FMT_DEFAULT,
303 &buf[2], sizeof (buf) - sizeof (uint16_t));
304 if (0 == size)
305 {
306 GNUNET_break (0);
307 return NULL;
308 }
309 GNUNET_assert (size < 65536 - sizeof (uint16_t));
310 be = htons ((uint16_t) size + (sizeof (be)));
311 memcpy (buf, &be, sizeof (be));
312 size += sizeof (be);
313 retval = GNUNET_malloc (size);
314 memcpy (retval, buf, size);
315 return retval;
316}
317
318
319/**
320 * Decode the private key from the file-format back
321 * to the "normal", internal format.
322 *
323 * @param buf the buffer where the private key data is stored
324 * @param len the length of the data in 'buffer'
325 * @param validate GNUNET_YES to validate that the key is well-formed,
326 * GNUNET_NO if the key comes from a totally trusted source
327 * and validation is considered too expensive
328 * @return NULL on error
329 */
330struct GNUNET_CRYPTO_EccPrivateKey *
331GNUNET_CRYPTO_ecc_decode_key (const char *buf,
332 size_t len,
333 int validate)
334{
335 struct GNUNET_CRYPTO_EccPrivateKey *ret;
336 uint16_t be;
337 gcry_sexp_t sexp;
338 int rc;
339 size_t erroff;
340 375
341 if (len < sizeof (uint16_t)) 376 /* create basic ECC context */
342 return NULL; 377 if (0 != (rc = gcry_mpi_ec_new (&ctx, NULL, CURVE)))
343 memcpy (&be, buf, sizeof (be));
344 if (len < ntohs (be))
345 return NULL;
346 len = ntohs (be);
347 if (0 != (rc = gcry_sexp_sscan (&sexp,
348 &erroff,
349 &buf[2],
350 len - sizeof (uint16_t))))
351 { 378 {
352 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_scan", rc); 379 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_ec_new", rc); /* erroff gives more info */
380 gcry_mpi_point_release (q);
353 return NULL; 381 return NULL;
354 } 382 }
355 if ( (GNUNET_YES == validate) && 383 /* initialize 'ctx' with 'q' */
356 (0 != (rc = gcry_pk_testkey (sexp))) ) 384 gcry_mpi_ec_set_point ("q", q, ctx);
385 gcry_mpi_point_release (q);
386
387 /* convert 'ctx' to 'sexp' */
388 if (0 != (rc = gcry_pubkey_get_sexp (&pub_sexp, GCRY_PK_GET_PUBKEY, ctx)))
357 { 389 {
358 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc); 390 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_from_context", rc);
391 gcry_ctx_release (ctx);
359 return NULL; 392 return NULL;
360 } 393 }
361 ret = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_EccPrivateKey)); 394 gcry_ctx_release (ctx);
362 ret->sexp = sexp; 395 return pub_sexp;
363 return ret;
364} 396}
365 397
366 398
@@ -372,9 +404,10 @@ GNUNET_CRYPTO_ecc_decode_key (const char *buf,
372struct GNUNET_CRYPTO_EccPrivateKey * 404struct GNUNET_CRYPTO_EccPrivateKey *
373GNUNET_CRYPTO_ecc_key_create () 405GNUNET_CRYPTO_ecc_key_create ()
374{ 406{
375 struct GNUNET_CRYPTO_EccPrivateKey *ret; 407 struct GNUNET_CRYPTO_EccPrivateKey *priv;
376 gcry_sexp_t s_key; 408 gcry_sexp_t priv_sexp;
377 gcry_sexp_t s_keyparam; 409 gcry_sexp_t s_keyparam;
410 gcry_mpi_t d;
378 int rc; 411 int rc;
379 412
380 if (0 != (rc = gcry_sexp_build (&s_keyparam, NULL, 413 if (0 != (rc = gcry_sexp_build (&s_keyparam, NULL,
@@ -383,7 +416,7 @@ GNUNET_CRYPTO_ecc_key_create ()
383 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc); 416 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc);
384 return NULL; 417 return NULL;
385 } 418 }
386 if (0 != (rc = gcry_pk_genkey (&s_key, s_keyparam))) 419 if (0 != (rc = gcry_pk_genkey (&priv_sexp, s_keyparam)))
387 { 420 {
388 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_genkey", rc); 421 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_genkey", rc);
389 gcry_sexp_release (s_keyparam); 422 gcry_sexp_release (s_keyparam);
@@ -391,16 +424,24 @@ GNUNET_CRYPTO_ecc_key_create ()
391 } 424 }
392 gcry_sexp_release (s_keyparam); 425 gcry_sexp_release (s_keyparam);
393#if EXTRA_CHECKS 426#if EXTRA_CHECKS
394 if (0 != (rc = gcry_pk_testkey (s_key))) 427 if (0 != (rc = gcry_pk_testkey (priv_sexp)))
395 { 428 {
396 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc); 429 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc);
397 gcry_sexp_release (s_key); 430 gcry_sexp_release (priv_sexp);
398 return NULL; 431 return NULL;
399 } 432 }
400#endif 433#endif
401 ret = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_EccPrivateKey)); 434 if (0 != (rc = key_from_sexp (&d, priv_sexp, "private-key", "d")))
402 ret->sexp = s_key; 435 {
403 return ret; 436 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "key_from_sexp", rc);
437 gcry_sexp_release (priv_sexp);
438 return NULL;
439 }
440 gcry_sexp_release (priv_sexp);
441 priv = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_EccPrivateKey));
442 mpi_print (priv->d, sizeof (priv->d), d);
443 gcry_mpi_release (d);
444 return priv;
404} 445}
405 446
406 447
@@ -438,15 +479,11 @@ short_wait ()
438struct GNUNET_CRYPTO_EccPrivateKey * 479struct GNUNET_CRYPTO_EccPrivateKey *
439GNUNET_CRYPTO_ecc_key_create_from_file (const char *filename) 480GNUNET_CRYPTO_ecc_key_create_from_file (const char *filename)
440{ 481{
441 struct GNUNET_CRYPTO_EccPrivateKey *ret; 482 struct GNUNET_CRYPTO_EccPrivateKey *priv;
442 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *enc;
443 uint16_t len;
444 struct GNUNET_DISK_FileHandle *fd; 483 struct GNUNET_DISK_FileHandle *fd;
445 unsigned int cnt; 484 unsigned int cnt;
446 int ec; 485 int ec;
447 uint64_t fs; 486 uint64_t fs;
448 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pub;
449 struct GNUNET_PeerIdentity pid;
450 487
451 if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename)) 488 if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename))
452 return NULL; 489 return NULL;
@@ -479,7 +516,7 @@ GNUNET_CRYPTO_ecc_key_create_from_file (const char *filename)
479 516
480 while (GNUNET_YES != 517 while (GNUNET_YES !=
481 GNUNET_DISK_file_lock (fd, 0, 518 GNUNET_DISK_file_lock (fd, 0,
482 sizeof (struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded), 519 sizeof (struct GNUNET_CRYPTO_EccPrivateKey),
483 GNUNET_YES)) 520 GNUNET_YES))
484 { 521 {
485 short_wait (); 522 short_wait ();
@@ -493,23 +530,17 @@ GNUNET_CRYPTO_ecc_key_create_from_file (const char *filename)
493 } 530 }
494 LOG (GNUNET_ERROR_TYPE_INFO, 531 LOG (GNUNET_ERROR_TYPE_INFO,
495 _("Creating a new private key. This may take a while.\n")); 532 _("Creating a new private key. This may take a while.\n"));
496 ret = GNUNET_CRYPTO_ecc_key_create (); 533 priv = GNUNET_CRYPTO_ecc_key_create ();
497 GNUNET_assert (ret != NULL); 534 GNUNET_assert (NULL != priv);
498 enc = GNUNET_CRYPTO_ecc_encode_key (ret); 535 GNUNET_assert (sizeof (*priv) ==
499 GNUNET_assert (enc != NULL); 536 GNUNET_DISK_file_write (fd, priv, sizeof (*priv)));
500 GNUNET_assert (ntohs (enc->size) ==
501 GNUNET_DISK_file_write (fd, enc, ntohs (enc->size)));
502 GNUNET_free (enc);
503
504 GNUNET_DISK_file_sync (fd); 537 GNUNET_DISK_file_sync (fd);
505 if (GNUNET_YES != 538 if (GNUNET_YES !=
506 GNUNET_DISK_file_unlock (fd, 0, 539 GNUNET_DISK_file_unlock (fd, 0,
507 sizeof (struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded))) 540 sizeof (struct GNUNET_CRYPTO_EccPrivateKey)))
508 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename); 541 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
509 GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd)); 542 GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
510 GNUNET_CRYPTO_ecc_key_get_public (ret, &pub); 543 return priv;
511 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &pid.hashPubKey);
512 return ret;
513 } 544 }
514 /* key file exists already, read it! */ 545 /* key file exists already, read it! */
515 fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, 546 fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ,
@@ -524,7 +555,7 @@ GNUNET_CRYPTO_ecc_key_create_from_file (const char *filename)
524 { 555 {
525 if (GNUNET_YES != 556 if (GNUNET_YES !=
526 GNUNET_DISK_file_lock (fd, 0, 557 GNUNET_DISK_file_lock (fd, 0,
527 sizeof (struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded), 558 sizeof (struct GNUNET_CRYPTO_EccPrivateKey),
528 GNUNET_NO)) 559 GNUNET_NO))
529 { 560 {
530 if (0 == ++cnt % 60) 561 if (0 == ++cnt % 60)
@@ -546,7 +577,7 @@ GNUNET_CRYPTO_ecc_key_create_from_file (const char *filename)
546 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "stat", filename); 577 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "stat", filename);
547 if (GNUNET_YES != 578 if (GNUNET_YES !=
548 GNUNET_DISK_file_unlock (fd, 0, 579 GNUNET_DISK_file_unlock (fd, 0,
549 sizeof (struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded))) 580 sizeof (struct GNUNET_CRYPTO_EccPrivateKey)))
550 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename); 581 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
551 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd)); 582 GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fd));
552 583
@@ -554,13 +585,13 @@ GNUNET_CRYPTO_ecc_key_create_from_file (const char *filename)
554 } 585 }
555 if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES)) 586 if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
556 fs = 0; 587 fs = 0;
557 if (fs < sizeof (struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded)) 588 if (fs < sizeof (struct GNUNET_CRYPTO_EccPrivateKey))
558 { 589 {
559 /* maybe we got the read lock before the key generating 590 /* maybe we got the read lock before the key generating
560 * process had a chance to get the write lock; give it up! */ 591 * process had a chance to get the write lock; give it up! */
561 if (GNUNET_YES != 592 if (GNUNET_YES !=
562 GNUNET_DISK_file_unlock (fd, 0, 593 GNUNET_DISK_file_unlock (fd, 0,
563 sizeof (struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded))) 594 sizeof (struct GNUNET_CRYPTO_EccPrivateKey)))
564 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename); 595 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
565 if (0 == ++cnt % 10) 596 if (0 == ++cnt % 10)
566 { 597 {
@@ -568,7 +599,7 @@ GNUNET_CRYPTO_ecc_key_create_from_file (const char *filename)
568 _ 599 _
569 ("When trying to read key file `%s' I found %u bytes but I need at least %u.\n"), 600 ("When trying to read key file `%s' I found %u bytes but I need at least %u.\n"),
570 filename, (unsigned int) fs, 601 filename, (unsigned int) fs,
571 (unsigned int) sizeof (struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded)); 602 (unsigned int) sizeof (struct GNUNET_CRYPTO_EccPrivateKey));
572 LOG (GNUNET_ERROR_TYPE_ERROR, 603 LOG (GNUNET_ERROR_TYPE_ERROR,
573 _ 604 _
574 ("This may be ok if someone is currently generating a key.\n")); 605 ("This may be ok if someone is currently generating a key.\n"));
@@ -578,33 +609,15 @@ GNUNET_CRYPTO_ecc_key_create_from_file (const char *filename)
578 } 609 }
579 break; 610 break;
580 } 611 }
581 enc = GNUNET_malloc (fs); 612 fs = sizeof (struct GNUNET_CRYPTO_EccPrivateKey);
582 GNUNET_assert (fs == GNUNET_DISK_file_read (fd, enc, fs)); 613 priv = GNUNET_malloc (fs);
583 len = ntohs (enc->size); 614 GNUNET_assert (fs == GNUNET_DISK_file_read (fd, priv, fs));
584 ret = NULL;
585 if ((len > fs) ||
586 (NULL == (ret = GNUNET_CRYPTO_ecc_decode_key ((char *) enc, len, GNUNET_YES))))
587 {
588 LOG (GNUNET_ERROR_TYPE_ERROR,
589 _("File `%s' does not contain a valid private key. Deleting it.\n"),
590 filename);
591 if (0 != UNLINK (filename))
592 {
593 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "unlink", filename);
594 }
595 }
596 GNUNET_free (enc);
597 if (GNUNET_YES != 615 if (GNUNET_YES !=
598 GNUNET_DISK_file_unlock (fd, 0, 616 GNUNET_DISK_file_unlock (fd, 0,
599 sizeof (struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded))) 617 sizeof (struct GNUNET_CRYPTO_EccPrivateKey)))
600 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename); 618 LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fcntl", filename);
601 GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd)); 619 GNUNET_assert (GNUNET_YES == GNUNET_DISK_file_close (fd));
602 if (ret != NULL) 620 return priv;
603 {
604 GNUNET_CRYPTO_ecc_key_get_public (ret, &pub);
605 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &pid.hashPubKey);
606 }
607 return ret;
608} 621}
609 622
610 623
@@ -618,15 +631,15 @@ GNUNET_CRYPTO_ecc_key_create_from_file (const char *filename)
618struct GNUNET_CRYPTO_EccPrivateKey * 631struct GNUNET_CRYPTO_EccPrivateKey *
619GNUNET_CRYPTO_ecc_key_create_from_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg) 632GNUNET_CRYPTO_ecc_key_create_from_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
620{ 633{
621 struct GNUNET_CRYPTO_EccPrivateKey *pk; 634 struct GNUNET_CRYPTO_EccPrivateKey *priv;
622 char *fn; 635 char *fn;
623 636
624 if (GNUNET_OK != 637 if (GNUNET_OK !=
625 GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER", "PRIVATE_KEY", &fn)) 638 GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER", "PRIVATE_KEY", &fn))
626 return NULL; 639 return NULL;
627 pk = GNUNET_CRYPTO_ecc_key_create_from_file (fn); 640 priv = GNUNET_CRYPTO_ecc_key_create_from_file (fn);
628 GNUNET_free (fn); 641 GNUNET_free (fn);
629 return pk; 642 return priv;
630} 643}
631 644
632 645
@@ -642,13 +655,13 @@ void
642GNUNET_CRYPTO_ecc_setup_key (const char *cfg_name) 655GNUNET_CRYPTO_ecc_setup_key (const char *cfg_name)
643{ 656{
644 struct GNUNET_CONFIGURATION_Handle *cfg; 657 struct GNUNET_CONFIGURATION_Handle *cfg;
645 struct GNUNET_CRYPTO_EccPrivateKey *pk; 658 struct GNUNET_CRYPTO_EccPrivateKey *priv;
646 659
647 cfg = GNUNET_CONFIGURATION_create (); 660 cfg = GNUNET_CONFIGURATION_create ();
648 (void) GNUNET_CONFIGURATION_load (cfg, cfg_name); 661 (void) GNUNET_CONFIGURATION_load (cfg, cfg_name);
649 pk = GNUNET_CRYPTO_ecc_key_create_from_configuration (cfg); 662 priv = GNUNET_CRYPTO_ecc_key_create_from_configuration (cfg);
650 if (NULL != pk) 663 if (NULL != priv)
651 GNUNET_CRYPTO_ecc_key_free (pk); 664 GNUNET_CRYPTO_ecc_key_free (priv);
652 GNUNET_CONFIGURATION_destroy (cfg); 665 GNUNET_CONFIGURATION_destroy (cfg);
653} 666}
654 667
@@ -665,18 +678,18 @@ int
665GNUNET_CRYPTO_get_host_identity (const struct GNUNET_CONFIGURATION_Handle *cfg, 678GNUNET_CRYPTO_get_host_identity (const struct GNUNET_CONFIGURATION_Handle *cfg,
666 struct GNUNET_PeerIdentity *dst) 679 struct GNUNET_PeerIdentity *dst)
667{ 680{
668 struct GNUNET_CRYPTO_EccPrivateKey *my_private_key; 681 struct GNUNET_CRYPTO_EccPrivateKey *priv;
669 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded my_public_key; 682 struct GNUNET_CRYPTO_EccPublicKey pub;
670 683
671 if (NULL == (my_private_key = GNUNET_CRYPTO_ecc_key_create_from_configuration (cfg))) 684 if (NULL == (priv = GNUNET_CRYPTO_ecc_key_create_from_configuration (cfg)))
672 { 685 {
673 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 686 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
674 _("Could not load peer's private key\n")); 687 _("Could not load peer's private key\n"));
675 return GNUNET_SYSERR; 688 return GNUNET_SYSERR;
676 } 689 }
677 GNUNET_CRYPTO_ecc_key_get_public (my_private_key, &my_public_key); 690 GNUNET_CRYPTO_ecc_key_get_public (priv, &pub);
678 GNUNET_CRYPTO_ecc_key_free (my_private_key); 691 GNUNET_CRYPTO_ecc_key_free (priv);
679 GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), &dst->hashPubKey); 692 GNUNET_CRYPTO_hash (&pub, sizeof (pub), &dst->hashPubKey);
680 return GNUNET_OK; 693 return GNUNET_OK;
681} 694}
682 695
@@ -692,24 +705,19 @@ static gcry_sexp_t
692data_to_pkcs1 (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose) 705data_to_pkcs1 (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose)
693{ 706{
694 struct GNUNET_CRYPTO_ShortHashCode hc; 707 struct GNUNET_CRYPTO_ShortHashCode hc;
695 size_t bufSize;
696 gcry_sexp_t data; 708 gcry_sexp_t data;
709 int rc;
697 710
698 GNUNET_CRYPTO_short_hash (purpose, ntohl (purpose->size), &hc); 711 GNUNET_CRYPTO_short_hash (purpose, ntohl (purpose->size), &hc);
699#define FORMATSTRING "(4:data(5:flags3:raw)(5:value32:01234567890123456789012345678901))" 712 if (0 != (rc = gcry_sexp_build (&data, NULL,
700 bufSize = strlen (FORMATSTRING) + 1; 713 "(data(flags rfc6979)(hash %s %b))",
714 "sha256",
715 sizeof (hc),
716 &hc)))
701 { 717 {
702 char buff[bufSize]; 718 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc);
703 719 return NULL;
704 memcpy (buff, FORMATSTRING, bufSize);
705 memcpy (&buff
706 [bufSize -
707 strlen
708 ("01234567890123456789012345678901))")
709 - 1], &hc, sizeof (struct GNUNET_CRYPTO_ShortHashCode));
710 GNUNET_assert (0 == gcry_sexp_new (&data, buff, bufSize, 0));
711 } 720 }
712#undef FORMATSTRING
713 return data; 721 return data;
714} 722}
715 723
@@ -717,44 +725,49 @@ data_to_pkcs1 (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose)
717/** 725/**
718 * Sign a given block. 726 * Sign a given block.
719 * 727 *
720 * @param key private key to use for the signing 728 * @param priv private key to use for the signing
721 * @param purpose what to sign (size, purpose) 729 * @param purpose what to sign (size, purpose)
722 * @param sig where to write the signature 730 * @param sig where to write the signature
723 * @return GNUNET_SYSERR on error, GNUNET_OK on success 731 * @return GNUNET_SYSERR on error, GNUNET_OK on success
724 */ 732 */
725int 733int
726GNUNET_CRYPTO_ecc_sign (const struct GNUNET_CRYPTO_EccPrivateKey *key, 734GNUNET_CRYPTO_ecc_sign (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
727 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, 735 const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose,
728 struct GNUNET_CRYPTO_EccSignature *sig) 736 struct GNUNET_CRYPTO_EccSignature *sig)
729{ 737{
730 gcry_sexp_t result; 738 gcry_sexp_t priv_sexp;
739 gcry_sexp_t sig_sexp;
731 gcry_sexp_t data; 740 gcry_sexp_t data;
732 size_t ssize;
733 int rc; 741 int rc;
742 gcry_mpi_t rs[2];
734 743
744 priv_sexp = decode_private_key (priv);
735 data = data_to_pkcs1 (purpose); 745 data = data_to_pkcs1 (purpose);
736 if (0 != (rc = gcry_pk_sign (&result, data, key->sexp))) 746 if (0 != (rc = gcry_pk_sign (&sig_sexp, data, priv_sexp)))
737 { 747 {
738 LOG (GNUNET_ERROR_TYPE_WARNING, 748 LOG (GNUNET_ERROR_TYPE_WARNING,
739 _("ECC signing failed at %s:%d: %s\n"), __FILE__, 749 _("ECC signing failed at %s:%d: %s\n"), __FILE__,
740 __LINE__, gcry_strerror (rc)); 750 __LINE__, gcry_strerror (rc));
741 gcry_sexp_release (data); 751 gcry_sexp_release (data);
752 gcry_sexp_release (priv_sexp);
742 return GNUNET_SYSERR; 753 return GNUNET_SYSERR;
743 } 754 }
755 gcry_sexp_release (priv_sexp);
744 gcry_sexp_release (data); 756 gcry_sexp_release (data);
745 ssize = gcry_sexp_sprint (result, 757
746 GCRYSEXP_FMT_DEFAULT, 758 /* extract 'r' and 's' values from sexpression 'sig_sexp' and store in
747 sig->sexpr, 759 'signature' */
748 GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH); 760 if (0 != (rc = key_from_sexp (rs, sig_sexp, "sig-val", "rs")))
749 if (0 == ssize)
750 { 761 {
751 GNUNET_break (0); 762 GNUNET_break (0);
763 gcry_sexp_release (sig_sexp);
752 return GNUNET_SYSERR; 764 return GNUNET_SYSERR;
753 } 765 }
754 sig->size = htons ((uint16_t) (ssize + sizeof (uint16_t))); 766 gcry_sexp_release (sig_sexp);
755 /* padd with zeros */ 767 mpi_print (sig->r, sizeof (sig->r), rs[0]);
756 memset (&sig->sexpr[ssize], 0, GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH - ssize); 768 mpi_print (sig->s, sizeof (sig->s), rs[1]);
757 gcry_sexp_release (result); 769 gcry_mpi_release (rs[0]);
770 gcry_mpi_release (rs[1]);
758 return GNUNET_OK; 771 return GNUNET_OK;
759} 772}
760 773
@@ -765,7 +778,7 @@ GNUNET_CRYPTO_ecc_sign (const struct GNUNET_CRYPTO_EccPrivateKey *key,
765 * @param purpose what is the purpose that the signature should have? 778 * @param purpose what is the purpose that the signature should have?
766 * @param validate block to validate (size, purpose, data) 779 * @param validate block to validate (size, purpose, data)
767 * @param sig signature that is being validated 780 * @param sig signature that is being validated
768 * @param publicKey public key of the signer 781 * @param pub public key of the signer
769 * @returns GNUNET_OK if ok, GNUNET_SYSERR if invalid 782 * @returns GNUNET_OK if ok, GNUNET_SYSERR if invalid
770 */ 783 */
771int 784int
@@ -773,36 +786,43 @@ GNUNET_CRYPTO_ecc_verify (uint32_t purpose,
773 const struct GNUNET_CRYPTO_EccSignaturePurpose 786 const struct GNUNET_CRYPTO_EccSignaturePurpose
774 *validate, 787 *validate,
775 const struct GNUNET_CRYPTO_EccSignature *sig, 788 const struct GNUNET_CRYPTO_EccSignature *sig,
776 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded 789 const struct GNUNET_CRYPTO_EccPublicKey *pub)
777 *publicKey)
778{ 790{
779 gcry_sexp_t data; 791 gcry_sexp_t data;
780 gcry_sexp_t sigdata; 792 gcry_sexp_t sig_sexpr;
781 size_t size; 793 gcry_sexp_t pub_sexpr;
782 gcry_sexp_t psexp;
783 size_t erroff; 794 size_t erroff;
784 int rc; 795 int rc;
796 gcry_mpi_t r;
797 gcry_mpi_t s;
785 798
786 if (purpose != ntohl (validate->purpose)) 799 if (purpose != ntohl (validate->purpose))
787 return GNUNET_SYSERR; /* purpose mismatch */ 800 return GNUNET_SYSERR; /* purpose mismatch */
788 size = ntohs (sig->size); 801
789 if ( (size < sizeof (uint16_t)) || 802 /* build s-expression for signature */
790 (size > GNUNET_CRYPTO_ECC_SIGNATURE_DATA_ENCODING_LENGTH - sizeof (uint16_t)) ) 803 mpi_scan (&r, sig->r, sizeof (sig->r));
791 return GNUNET_SYSERR; /* size out of range */ 804 mpi_scan (&s, sig->s, sizeof (sig->s));
805 if (0 != (rc = gcry_sexp_build (&sig_sexpr, &erroff, "(sig-val(ecdsa(r %m)(s %m)))",
806 r, s)))
807 {
808 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc);
809 gcry_mpi_release (r);
810 gcry_mpi_release (s);
811 return GNUNET_SYSERR;
812 }
813 gcry_mpi_release (r);
814 gcry_mpi_release (s);
792 data = data_to_pkcs1 (validate); 815 data = data_to_pkcs1 (validate);
793 GNUNET_assert (0 == 816 if (! (pub_sexpr = decode_public_key (pub)))
794 gcry_sexp_sscan (&sigdata, &erroff,
795 sig->sexpr, size - sizeof (uint16_t)));
796 if (! (psexp = decode_public_key (publicKey)))
797 { 817 {
798 gcry_sexp_release (data); 818 gcry_sexp_release (data);
799 gcry_sexp_release (sigdata); 819 gcry_sexp_release (sig_sexpr);
800 return GNUNET_SYSERR; 820 return GNUNET_SYSERR;
801 } 821 }
802 rc = gcry_pk_verify (sigdata, data, psexp); 822 rc = gcry_pk_verify (sig_sexpr, data, pub_sexpr);
803 gcry_sexp_release (psexp); 823 gcry_sexp_release (pub_sexpr);
804 gcry_sexp_release (data); 824 gcry_sexp_release (data);
805 gcry_sexp_release (sigdata); 825 gcry_sexp_release (sig_sexpr);
806 if (0 != rc) 826 if (0 != rc)
807 { 827 {
808 LOG (GNUNET_ERROR_TYPE_WARNING, 828 LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -817,14 +837,14 @@ GNUNET_CRYPTO_ecc_verify (uint32_t purpose,
817/** 837/**
818 * Derive key material from a public and a private ECC key. 838 * Derive key material from a public and a private ECC key.
819 * 839 *
820 * @param key private key to use for the ECDH (x) 840 * @param priv private key to use for the ECDH (x)
821 * @param pub public key to use for the ECDY (yG) 841 * @param pub public key to use for the ECDH (yG)
822 * @param key_material where to write the key material (xyG) 842 * @param key_material where to write the key material (xyG)
823 * @return GNUNET_SYSERR on error, GNUNET_OK on success 843 * @return GNUNET_SYSERR on error, GNUNET_OK on success
824 */ 844 */
825int 845int
826GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EccPrivateKey *key, 846GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
827 const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *pub, 847 const struct GNUNET_CRYPTO_EccPublicKey *pub,
828 struct GNUNET_HashCode *key_material) 848 struct GNUNET_HashCode *key_material)
829{ 849{
830 size_t slen; 850 size_t slen;
@@ -835,36 +855,29 @@ GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EccPrivateKey *key,
835 gcry_mpi_point_t q; 855 gcry_mpi_point_t q;
836 gcry_mpi_t d; 856 gcry_mpi_t d;
837 gcry_ctx_t ctx; 857 gcry_ctx_t ctx;
838 gcry_sexp_t psexp; 858 gcry_sexp_t pub_sexpr;
859 gcry_sexp_t ecdh_sexp;
839 gcry_mpi_t result_x; 860 gcry_mpi_t result_x;
840 gcry_mpi_t result_y; 861 gcry_mpi_t result_y;
841 862
842 /* first, extract the q = dP value from the public key */ 863 /* first, extract the q = dP value from the public key */
843 if (! (psexp = decode_public_key (pub))) 864 if (! (pub_sexpr = decode_public_key (pub)))
844 return GNUNET_SYSERR; 865 return GNUNET_SYSERR;
845 if (0 != (rc = gcry_mpi_ec_new (&ctx, psexp, NULL))) 866 if (0 != (rc = gcry_mpi_ec_new (&ctx, pub_sexpr, NULL)))
846 { 867 {
847 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_ec_new", rc); /* erroff gives more info */ 868 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_ec_new", rc); /* erroff gives more info */
848 return GNUNET_SYSERR; 869 return GNUNET_SYSERR;
849 } 870 }
850 gcry_sexp_release (psexp); 871 gcry_sexp_release (pub_sexpr);
851 q = gcry_mpi_ec_get_point ("q", ctx, 0); 872 q = gcry_mpi_ec_get_point ("q", ctx, 0);
852 gcry_ctx_release (ctx); 873 gcry_ctx_release (ctx);
853 874
854 /* second, extract the d value from our private key */ 875 /* second, extract the d value from our private key */
855 rc = key_from_sexp (&d, key->sexp, "private-key", "d"); 876 mpi_scan (&d, priv->d, sizeof (priv->d));
856 if (rc)
857 rc = key_from_sexp (&d, key->sexp, "ecc", "d");
858 if (0 != rc)
859 {
860 GNUNET_break (0);
861 gcry_mpi_point_release (q);
862 return GNUNET_SYSERR;
863 }
864 877
865 /* create a new context for definitively the correct curve; 878 /* create a new context for definitively the correct curve;
866 theoretically the 'public_key' might not use the right curve */ 879 theoretically the 'public_key' might not use the right curve */
867 if (0 != (rc = gcry_mpi_ec_new (&ctx, NULL, "NIST P-256"))) 880 if (0 != (rc = gcry_mpi_ec_new (&ctx, NULL, CURVE)))
868 { 881 {
869 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_ec_new", rc); /* erroff gives more info */ 882 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_ec_new", rc); /* erroff gives more info */
870 gcry_mpi_release (d); 883 gcry_mpi_release (d);
@@ -891,7 +904,7 @@ GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EccPrivateKey *key,
891 } 904 }
892 gcry_mpi_point_release (result); 905 gcry_mpi_point_release (result);
893 gcry_ctx_release (ctx); 906 gcry_ctx_release (ctx);
894 if (0 != (rc = gcry_sexp_build (&psexp, &erroff, 907 if (0 != (rc = gcry_sexp_build (&ecdh_sexp, &erroff,
895 "(dh-shared-secret (x %m)(y %m))", 908 "(dh-shared-secret (x %m)(y %m))",
896 result_x, 909 result_x,
897 result_y))) 910 result_y)))
@@ -903,13 +916,135 @@ GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EccPrivateKey *key,
903 } 916 }
904 gcry_mpi_release (result_x); 917 gcry_mpi_release (result_x);
905 gcry_mpi_release (result_y); 918 gcry_mpi_release (result_y);
906 slen = gcry_sexp_sprint (psexp, GCRYSEXP_FMT_DEFAULT, sdata_buf, sizeof (sdata_buf)); 919 slen = gcry_sexp_sprint (ecdh_sexp,
920 GCRYSEXP_FMT_DEFAULT,
921 sdata_buf, sizeof (sdata_buf));
907 GNUNET_assert (0 != slen); 922 GNUNET_assert (0 != slen);
908 gcry_sexp_release (psexp); 923 gcry_sexp_release (ecdh_sexp);
909 /* finally, get a string of the resulting S-expression and hash it to generate the key material */ 924 /* finally, get a string of the resulting S-expression and hash it
925 to generate the key material */
910 GNUNET_CRYPTO_hash (sdata_buf, slen, key_material); 926 GNUNET_CRYPTO_hash (sdata_buf, slen, key_material);
911 return GNUNET_OK; 927 return GNUNET_OK;
912} 928}
913 929
914 930
931/**
932 * Derive the 'h' value for key derivation, where
933 * 'h = H(l,P)'.
934 *
935 * @param pub public key for deriviation
936 * @param label label for deriviation
937 * @return h value
938 */
939static gcry_mpi_t
940derive_h (const struct GNUNET_CRYPTO_EccPublicKey *pub,
941 const char *label)
942{
943 gcry_mpi_t h;
944 struct GNUNET_HashCode hc;
945
946 GNUNET_CRYPTO_kdf (&hc, sizeof (hc),
947 "key-derivation", strlen ("key-derivation"),
948 pub, sizeof (*pub),
949 label, sizeof (label),
950 NULL, 0);
951 mpi_scan (&h, (unsigned char *) &hc, sizeof (hc));
952 return h;
953}
954
955
956/**
957 * Derive a private key from a given private key and a label.
958 * Essentially calculates a private key 'd = H(l,P) * x mod n'
959 * where n is the size of the ECC group and P is the public
960 * key associated with the private key 'd'.
961 *
962 * @param priv original private key
963 * @param label label to use for key deriviation
964 * @return derived private key
965 */
966struct GNUNET_CRYPTO_EccPrivateKey *
967GNUNET_CRYPTO_ecc_key_derive (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
968 const char *label)
969{
970 struct GNUNET_CRYPTO_EccPublicKey pub;
971 struct GNUNET_CRYPTO_EccPrivateKey *ret;
972 gcry_mpi_t h;
973 gcry_mpi_t x;
974 gcry_mpi_t d;
975 gcry_mpi_t n;
976 int rc;
977
978 GNUNET_CRYPTO_ecc_key_get_public (priv, &pub);
979 h = derive_h (&pub, label);
980 mpi_scan (&x, priv->d, sizeof (priv->d));
981 /* initialize 'n' from P-256; hex copied from libgcrypt code */
982 if (0 != (rc = gcry_mpi_scan (&n, GCRYMPI_FMT_HEX,
983 "0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551", 0, NULL)))
984 {
985 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc);
986 gcry_mpi_release (h);
987 return NULL;
988 }
989 d = gcry_mpi_new (256);
990 gcry_mpi_mulm (d, h, x, n);
991 gcry_mpi_release (h);
992 gcry_mpi_release (x);
993 gcry_mpi_release (n);
994 ret = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey);
995 mpi_print (ret->d, sizeof (ret->d), d);
996 gcry_mpi_release (d);
997 return ret;
998}
999
1000
1001/**
1002 * Derive a public key from a given public key and a label.
1003 * Essentially calculates a public key 'V = H(l,P) * P'.
1004 *
1005 * @param pub original public key
1006 * @param label label to use for key deriviation
1007 * @param result where to write the derived public key
1008 */
1009void
1010GNUNET_CRYPTO_ecc_public_key_derive (const struct GNUNET_CRYPTO_EccPublicKey *pub,
1011 const char *label,
1012 struct GNUNET_CRYPTO_EccPublicKey *result)
1013{
1014 gcry_mpi_t h;
1015 gcry_ctx_t ctx;
1016 gcry_mpi_t q_x;
1017 gcry_mpi_t q_y;
1018 gcry_mpi_point_t q;
1019 gcry_mpi_point_t v;
1020 int rc;
1021
1022 h = derive_h (pub, label);
1023 mpi_scan (&q_x, pub->q_x, sizeof (pub->q_x));
1024 mpi_scan (&q_y, pub->q_y, sizeof (pub->q_y));
1025 q = gcry_mpi_point_new (256);
1026 gcry_mpi_point_set (q, q_x, q_y, GCRYMPI_CONST_ONE);
1027 gcry_mpi_release (q_x);
1028 gcry_mpi_release (q_y);
1029
1030 /* create basic ECC context */
1031 if (0 != (rc = gcry_mpi_ec_new (&ctx, NULL, CURVE)))
1032 {
1033 LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_ec_new", rc);
1034 gcry_mpi_point_release (q);
1035 gcry_mpi_release (h);
1036 return;
1037 }
1038 v = gcry_mpi_point_new (256);
1039 /* we could calculate 'h mod n' here first, but hopefully
1040 libgcrypt is smart enough to do that for us... */
1041 gcry_mpi_ec_mul (v, h, q, ctx);
1042 gcry_mpi_release (h);
1043 gcry_mpi_point_release (q);
1044 point_to_public_key (v, ctx, result);
1045 gcry_mpi_point_release (v);
1046 gcry_ctx_release (ctx);
1047}
1048
1049
915/* end of crypto_ecc.c */ 1050/* end of crypto_ecc.c */
diff --git a/src/util/gnunet-ecc.c b/src/util/gnunet-ecc.c
index a00ef0573..0805e3f94 100644
--- a/src/util/gnunet-ecc.c
+++ b/src/util/gnunet-ecc.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2012 Christian Grothoff (and other contributing authors) 3 (C) 2012, 2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published
@@ -49,15 +49,6 @@ static int print_short_identity;
49 */ 49 */
50static unsigned int make_keys; 50static unsigned int make_keys;
51 51
52/**
53 * The private information of an ECC key pair.
54 * NOTE: this must match the definition in crypto_ksk.c and crypto_ecc.c!
55 */
56struct GNUNET_CRYPTO_EccPrivateKey
57{
58 gcry_sexp_t sexp;
59};
60
61 52
62/** 53/**
63 * Create a flat file with a large number of key pairs for testing. 54 * Create a flat file with a large number of key pairs for testing.
@@ -65,10 +56,8 @@ struct GNUNET_CRYPTO_EccPrivateKey
65static void 56static void
66create_keys (const char *fn) 57create_keys (const char *fn)
67{ 58{
68 static char pad[GNUNET_TESTING_HOSTKEYFILESIZE];
69 FILE *f; 59 FILE *f;
70 struct GNUNET_CRYPTO_EccPrivateKey *pk; 60 struct GNUNET_CRYPTO_EccPrivateKey *pk;
71 struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *enc;
72 61
73 if (NULL == (f = fopen (fn, "w+"))) 62 if (NULL == (f = fopen (fn, "w+")))
74 { 63 {
@@ -90,22 +79,18 @@ create_keys (const char *fn)
90 GNUNET_break (0); 79 GNUNET_break (0);
91 break; 80 break;
92 } 81 }
93 enc = GNUNET_CRYPTO_ecc_encode_key (pk); 82 if (GNUNET_TESTING_HOSTKEYFILESIZE !=
94 GNUNET_assert (ntohs (enc->size) <= GNUNET_TESTING_HOSTKEYFILESIZE); 83 fwrite (pk, 1,
95 if ( (ntohs (enc->size) != fwrite (enc, 1, ntohs (enc->size), f)) || 84 GNUNET_TESTING_HOSTKEYFILESIZE, f))
96 (GNUNET_TESTING_HOSTKEYFILESIZE - ntohs (enc->size)
97 != fwrite (pad, 1, GNUNET_TESTING_HOSTKEYFILESIZE - ntohs (enc->size), f)) )
98 { 85 {
99 fprintf (stderr, 86 fprintf (stderr,
100 _("\nFailed to write to `%s': %s\n"), 87 _("\nFailed to write to `%s': %s\n"),
101 fn, 88 fn,
102 STRERROR (errno)); 89 STRERROR (errno));
103 GNUNET_CRYPTO_ecc_key_free (pk); 90 GNUNET_CRYPTO_ecc_key_free (pk);
104 GNUNET_free (enc);
105 break; 91 break;
106 } 92 }
107 GNUNET_CRYPTO_ecc_key_free (pk); 93 GNUNET_CRYPTO_ecc_key_free (pk);
108 GNUNET_free (enc);
109 } 94 }
110 if (UINT_MAX == make_keys) 95 if (UINT_MAX == make_keys)
111 fprintf (stderr, 96 fprintf (stderr,
@@ -130,7 +115,7 @@ run (void *cls, char *const *args, const char *cfgfile,
130 const struct GNUNET_CONFIGURATION_Handle *cfg) 115 const struct GNUNET_CONFIGURATION_Handle *cfg)
131{ 116{
132 struct GNUNET_CRYPTO_EccPrivateKey *pk; 117 struct GNUNET_CRYPTO_EccPrivateKey *pk;
133 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pub; 118 struct GNUNET_CRYPTO_EccPublicKey pub;
134 struct GNUNET_PeerIdentity pid; 119 struct GNUNET_PeerIdentity pid;
135 120
136 if (NULL == args[0]) 121 if (NULL == args[0])
diff --git a/src/util/test_crypto_ecc.c b/src/util/test_crypto_ecc.c
index 1d58e9607..668f15761 100644
--- a/src/util/test_crypto_ecc.c
+++ b/src/util/test_crypto_ecc.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2002, 2003, 2004, 2006, 2009 Christian Grothoff (and other contributing authors) 3 (C) 2002-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published
@@ -44,7 +44,7 @@ testSignVerify ()
44{ 44{
45 struct GNUNET_CRYPTO_EccSignature sig; 45 struct GNUNET_CRYPTO_EccSignature sig;
46 struct GNUNET_CRYPTO_EccSignaturePurpose purp; 46 struct GNUNET_CRYPTO_EccSignaturePurpose purp;
47 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; 47 struct GNUNET_CRYPTO_EccPublicKey pkey;
48 int i; 48 int i;
49 struct GNUNET_TIME_Absolute start; 49 struct GNUNET_TIME_Absolute start;
50 int ok = GNUNET_OK; 50 int ok = GNUNET_OK;
@@ -93,7 +93,7 @@ testSignPerformance ()
93{ 93{
94 struct GNUNET_CRYPTO_EccSignaturePurpose purp; 94 struct GNUNET_CRYPTO_EccSignaturePurpose purp;
95 struct GNUNET_CRYPTO_EccSignature sig; 95 struct GNUNET_CRYPTO_EccSignature sig;
96 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; 96 struct GNUNET_CRYPTO_EccPublicKey pkey;
97 int i; 97 int i;
98 struct GNUNET_TIME_Absolute start; 98 struct GNUNET_TIME_Absolute start;
99 int ok = GNUNET_OK; 99 int ok = GNUNET_OK;
@@ -124,8 +124,8 @@ testSignPerformance ()
124static int 124static int
125testCreateFromFile () 125testCreateFromFile ()
126{ 126{
127 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded p1; 127 struct GNUNET_CRYPTO_EccPublicKey p1;
128 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded p2; 128 struct GNUNET_CRYPTO_EccPublicKey p2;
129 129
130 key = GNUNET_CRYPTO_ecc_key_create_from_file (KEYFILE); 130 key = GNUNET_CRYPTO_ecc_key_create_from_file (KEYFILE);
131 GNUNET_assert (NULL != key); 131 GNUNET_assert (NULL != key);
@@ -150,8 +150,8 @@ test_ecdh ()
150{ 150{
151 struct GNUNET_CRYPTO_EccPrivateKey *priv1; 151 struct GNUNET_CRYPTO_EccPrivateKey *priv1;
152 struct GNUNET_CRYPTO_EccPrivateKey *priv2; 152 struct GNUNET_CRYPTO_EccPrivateKey *priv2;
153 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pub1; 153 struct GNUNET_CRYPTO_EccPublicKey pub1;
154 struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pub2; 154 struct GNUNET_CRYPTO_EccPublicKey pub2;
155 struct GNUNET_HashCode ecdh1; 155 struct GNUNET_HashCode ecdh1;
156 struct GNUNET_HashCode ecdh2; 156 struct GNUNET_HashCode ecdh2;
157 157