diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-05-29 08:18:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-05-29 08:18:55 +0000 |
commit | 022002438e4047d235a688cfd9da7b63ab990103 (patch) | |
tree | 8d0cb444a3ab376b5a8f614fb87bdeb31e7b3327 /src/namestore/namestore_api.c | |
parent | b62eb443ee3af84f87030fad9fd11a948b1a2503 (diff) | |
download | gnunet-022002438e4047d235a688cfd9da7b63ab990103.tar.gz gnunet-022002438e4047d235a688cfd9da7b63ab990103.zip |
-switching GNS from RSA to ECC
Diffstat (limited to 'src/namestore/namestore_api.c')
-rw-r--r-- | src/namestore/namestore_api.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c index 5e82e08ba..7a7c3eabb 100644 --- a/src/namestore/namestore_api.c +++ b/src/namestore/namestore_api.c | |||
@@ -264,9 +264,9 @@ handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, | |||
264 | { | 264 | { |
265 | const char *name; | 265 | const char *name; |
266 | const char * rd_tmp; | 266 | const char * rd_tmp; |
267 | const struct GNUNET_CRYPTO_RsaSignature *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_RsaPublicKeyBinaryEncoded *public_key_tmp; | 269 | const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *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; |
@@ -282,7 +282,7 @@ handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, | |||
282 | contains_sig = ntohs (msg->contains_sig); | 282 | contains_sig = ntohs (msg->contains_sig); |
283 | expire = GNUNET_TIME_absolute_ntoh (msg->expire); | 283 | expire = GNUNET_TIME_absolute_ntoh (msg->expire); |
284 | exp_msg_len = sizeof (struct LookupNameResponseMessage) + | 284 | exp_msg_len = sizeof (struct LookupNameResponseMessage) + |
285 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + | 285 | sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded) + |
286 | name_len + rd_len; | 286 | name_len + rd_len; |
287 | if (msg_len != exp_msg_len) | 287 | if (msg_len != exp_msg_len) |
288 | { | 288 | { |
@@ -589,7 +589,7 @@ handle_zone_iteration_response (struct GNUNET_NAMESTORE_ZoneIterator *ze, | |||
589 | const struct ZoneIterationResponseMessage *msg, | 589 | const struct ZoneIterationResponseMessage *msg, |
590 | size_t size) | 590 | size_t size) |
591 | { | 591 | { |
592 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubdummy; | 592 | struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pubdummy; |
593 | size_t msg_len; | 593 | size_t msg_len; |
594 | size_t exp_msg_len; | 594 | size_t exp_msg_len; |
595 | size_t name_len; | 595 | size_t name_len; |
@@ -1003,12 +1003,12 @@ GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h) | |||
1003 | */ | 1003 | */ |
1004 | struct GNUNET_NAMESTORE_QueueEntry * | 1004 | struct GNUNET_NAMESTORE_QueueEntry * |
1005 | GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h, | 1005 | GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h, |
1006 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | 1006 | const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *zone_key, |
1007 | const char *name, | 1007 | const char *name, |
1008 | struct GNUNET_TIME_Absolute freshness, | 1008 | struct GNUNET_TIME_Absolute freshness, |
1009 | unsigned int rd_count, | 1009 | unsigned int rd_count, |
1010 | const struct GNUNET_NAMESTORE_RecordData *rd, | 1010 | const struct GNUNET_NAMESTORE_RecordData *rd, |
1011 | const struct GNUNET_CRYPTO_RsaSignature *signature, | 1011 | const struct GNUNET_CRYPTO_EccSignature *signature, |
1012 | GNUNET_NAMESTORE_ContinuationWithStatus cont, | 1012 | GNUNET_NAMESTORE_ContinuationWithStatus cont, |
1013 | void *cont_cls) | 1013 | void *cont_cls) |
1014 | { | 1014 | { |
@@ -1088,18 +1088,18 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h, | |||
1088 | * @return GNUNET_OK if the signature is valid | 1088 | * @return GNUNET_OK if the signature is valid |
1089 | */ | 1089 | */ |
1090 | int | 1090 | int |
1091 | GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key, | 1091 | GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *public_key, |
1092 | const struct GNUNET_TIME_Absolute freshness, | 1092 | const struct GNUNET_TIME_Absolute freshness, |
1093 | const char *name, | 1093 | const char *name, |
1094 | unsigned int rd_count, | 1094 | unsigned int rd_count, |
1095 | const struct GNUNET_NAMESTORE_RecordData *rd, | 1095 | const struct GNUNET_NAMESTORE_RecordData *rd, |
1096 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 1096 | const struct GNUNET_CRYPTO_EccSignature *signature) |
1097 | { | 1097 | { |
1098 | size_t rd_ser_len; | 1098 | size_t rd_ser_len; |
1099 | size_t name_len; | 1099 | size_t name_len; |
1100 | char *name_tmp; | 1100 | char *name_tmp; |
1101 | char *rd_ser; | 1101 | char *rd_ser; |
1102 | struct GNUNET_CRYPTO_RsaSignaturePurpose *sig_purpose; | 1102 | struct GNUNET_CRYPTO_EccSignaturePurpose *sig_purpose; |
1103 | struct GNUNET_TIME_AbsoluteNBO *expire_tmp; | 1103 | struct GNUNET_TIME_AbsoluteNBO *expire_tmp; |
1104 | struct GNUNET_TIME_AbsoluteNBO expire_nbo = GNUNET_TIME_absolute_hton (freshness); | 1104 | struct GNUNET_TIME_AbsoluteNBO expire_nbo = GNUNET_TIME_absolute_hton (freshness); |
1105 | uint32_t sig_len; | 1105 | uint32_t sig_len; |
@@ -1115,11 +1115,11 @@ GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_RsaPublicKeyBinary | |||
1115 | return GNUNET_SYSERR; | 1115 | return GNUNET_SYSERR; |
1116 | } | 1116 | } |
1117 | rd_ser_len = GNUNET_NAMESTORE_records_get_size (rd_count, rd); | 1117 | rd_ser_len = GNUNET_NAMESTORE_records_get_size (rd_count, rd); |
1118 | sig_len = sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + rd_ser_len + name_len; | 1118 | sig_len = sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + rd_ser_len + name_len; |
1119 | { | 1119 | { |
1120 | char sig_buf[sig_len] GNUNET_ALIGN; | 1120 | char sig_buf[sig_len] GNUNET_ALIGN; |
1121 | 1121 | ||
1122 | sig_purpose = (struct GNUNET_CRYPTO_RsaSignaturePurpose *) sig_buf; | 1122 | sig_purpose = (struct GNUNET_CRYPTO_EccSignaturePurpose *) sig_buf; |
1123 | sig_purpose->size = htonl (sig_len); | 1123 | sig_purpose->size = htonl (sig_len); |
1124 | sig_purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN); | 1124 | sig_purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN); |
1125 | expire_tmp = (struct GNUNET_TIME_AbsoluteNBO *) &sig_purpose[1]; | 1125 | expire_tmp = (struct GNUNET_TIME_AbsoluteNBO *) &sig_purpose[1]; |
@@ -1129,7 +1129,7 @@ GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_RsaPublicKeyBinary | |||
1129 | rd_ser = &name_tmp[name_len]; | 1129 | rd_ser = &name_tmp[name_len]; |
1130 | GNUNET_assert (rd_ser_len == | 1130 | GNUNET_assert (rd_ser_len == |
1131 | GNUNET_NAMESTORE_records_serialize (rd_count, rd, rd_ser_len, rd_ser)); | 1131 | GNUNET_NAMESTORE_records_serialize (rd_count, rd, rd_ser_len, rd_ser)); |
1132 | return GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN, sig_purpose, signature, public_key); | 1132 | return GNUNET_CRYPTO_ecc_verify (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN, sig_purpose, signature, public_key); |
1133 | } | 1133 | } |
1134 | } | 1134 | } |
1135 | 1135 | ||
@@ -1149,7 +1149,7 @@ GNUNET_NAMESTORE_verify_signature (const struct GNUNET_CRYPTO_RsaPublicKeyBinary | |||
1149 | */ | 1149 | */ |
1150 | struct GNUNET_NAMESTORE_QueueEntry * | 1150 | struct GNUNET_NAMESTORE_QueueEntry * |
1151 | GNUNET_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h, | 1151 | GNUNET_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h, |
1152 | const struct GNUNET_CRYPTO_RsaPrivateKey *pkey, | 1152 | const struct GNUNET_CRYPTO_EccPrivateKey *pkey, |
1153 | const char *name, | 1153 | const char *name, |
1154 | const struct GNUNET_NAMESTORE_RecordData *rd, | 1154 | const struct GNUNET_NAMESTORE_RecordData *rd, |
1155 | GNUNET_NAMESTORE_ContinuationWithStatus cont, | 1155 | GNUNET_NAMESTORE_ContinuationWithStatus cont, |
@@ -1166,7 +1166,7 @@ GNUNET_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h, | |||
1166 | size_t key_len; | 1166 | size_t key_len; |
1167 | uint32_t rid; | 1167 | uint32_t rid; |
1168 | struct RecordCreateMessage * msg; | 1168 | struct RecordCreateMessage * msg; |
1169 | struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * pkey_enc; | 1169 | struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded * pkey_enc; |
1170 | 1170 | ||
1171 | GNUNET_assert (NULL != h); | 1171 | GNUNET_assert (NULL != h); |
1172 | GNUNET_assert (NULL != pkey); | 1172 | GNUNET_assert (NULL != pkey); |
@@ -1190,11 +1190,11 @@ GNUNET_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h, | |||
1190 | qe->op_id = rid; | 1190 | qe->op_id = rid; |
1191 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe); | 1191 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe); |
1192 | 1192 | ||
1193 | pkey_enc = GNUNET_CRYPTO_rsa_encode_key (pkey); | 1193 | pkey_enc = GNUNET_CRYPTO_ecc_encode_key (pkey); |
1194 | GNUNET_assert (NULL != pkey_enc); | 1194 | GNUNET_assert (NULL != pkey_enc); |
1195 | 1195 | ||
1196 | /* setup msg */ | 1196 | /* setup msg */ |
1197 | key_len = ntohs (pkey_enc->len); | 1197 | key_len = ntohs (pkey_enc->size); |
1198 | rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, rd); | 1198 | rd_ser_len = GNUNET_NAMESTORE_records_get_size(1, rd); |
1199 | msg_size = sizeof (struct RecordCreateMessage) + key_len + name_len + rd_ser_len; | 1199 | msg_size = sizeof (struct RecordCreateMessage) + key_len + name_len + rd_ser_len; |
1200 | pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size); | 1200 | pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size); |
@@ -1244,14 +1244,14 @@ GNUNET_NAMESTORE_record_create (struct GNUNET_NAMESTORE_Handle *h, | |||
1244 | */ | 1244 | */ |
1245 | struct GNUNET_NAMESTORE_QueueEntry * | 1245 | struct GNUNET_NAMESTORE_QueueEntry * |
1246 | GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h, | 1246 | GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h, |
1247 | const struct GNUNET_CRYPTO_RsaPrivateKey *pkey, | 1247 | const struct GNUNET_CRYPTO_EccPrivateKey *pkey, |
1248 | const char *name, | 1248 | const char *name, |
1249 | const struct GNUNET_NAMESTORE_RecordData *rd, | 1249 | const struct GNUNET_NAMESTORE_RecordData *rd, |
1250 | GNUNET_NAMESTORE_ContinuationWithStatus cont, | 1250 | GNUNET_NAMESTORE_ContinuationWithStatus cont, |
1251 | void *cont_cls) | 1251 | void *cont_cls) |
1252 | { | 1252 | { |
1253 | struct GNUNET_NAMESTORE_QueueEntry *qe; | 1253 | struct GNUNET_NAMESTORE_QueueEntry *qe; |
1254 | struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded * pkey_enc; | 1254 | struct GNUNET_CRYPTO_EccPrivateKeyBinaryEncoded *pkey_enc; |
1255 | struct PendingMessage *pe; | 1255 | struct PendingMessage *pe; |
1256 | struct RecordRemoveMessage * msg; | 1256 | struct RecordRemoveMessage * msg; |
1257 | char *pkey_tmp; | 1257 | char *pkey_tmp; |
@@ -1282,15 +1282,15 @@ GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h, | |||
1282 | qe->op_id = rid; | 1282 | qe->op_id = rid; |
1283 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe); | 1283 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe); |
1284 | 1284 | ||
1285 | pkey_enc = GNUNET_CRYPTO_rsa_encode_key (pkey); | 1285 | pkey_enc = GNUNET_CRYPTO_ecc_encode_key (pkey); |
1286 | GNUNET_assert (NULL != pkey_enc); | 1286 | GNUNET_assert (NULL != pkey_enc); |
1287 | key_len = ntohs (pkey_enc->len); | 1287 | key_len = ntohs (pkey_enc->size); |
1288 | 1288 | ||
1289 | rd_count = (NULL == rd) ? 0 : 1; | 1289 | rd_count = (NULL == rd) ? 0 : 1; |
1290 | rd_ser_len = GNUNET_NAMESTORE_records_get_size (rd_count, rd); | 1290 | rd_ser_len = GNUNET_NAMESTORE_records_get_size (rd_count, rd); |
1291 | name_len = strlen (name) + 1; | 1291 | name_len = strlen (name) + 1; |
1292 | msg_size = sizeof (struct RecordRemoveMessage) + key_len + name_len + rd_ser_len; | 1292 | msg_size = sizeof (struct RecordRemoveMessage) + key_len + name_len + rd_ser_len; |
1293 | pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size); | 1293 | pe = GNUNET_malloc (sizeof (struct PendingMessage) + msg_size); |
1294 | pe->size = msg_size; | 1294 | pe->size = msg_size; |
1295 | pe->is_init = GNUNET_NO; | 1295 | pe->is_init = GNUNET_NO; |
1296 | msg = (struct RecordRemoveMessage *) &pe[1]; | 1296 | msg = (struct RecordRemoveMessage *) &pe[1]; |