aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/namestore_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-08-06 14:18:31 +0000
committerChristian Grothoff <christian@grothoff.org>2013-08-06 14:18:31 +0000
commitfe76c075e315c0351e2fe465434ae39087daf014 (patch)
tree436887ccaf331932a3c13a8b9d2a2a710dad4be6 /src/namestore/namestore_api.c
parent7eb2835d8a494c83aedb720a2ac6f6e5ba23f22f (diff)
downloadgnunet-fe76c075e315c0351e2fe465434ae39087daf014.tar.gz
gnunet-fe76c075e315c0351e2fe465434ae39087daf014.zip
moving to new, fixed-size encoding of public and private ECC keys everywhere, also improving ECC API to better support ECRS/GADS operations
Diffstat (limited to 'src/namestore/namestore_api.c')
-rw-r--r--src/namestore/namestore_api.c32
1 files changed, 12 insertions, 20 deletions
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",