diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-02-07 17:15:57 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-02-07 17:15:57 +0000 |
commit | 053b02677cdd94ef56a12f58849910a96649dd21 (patch) | |
tree | 295ccae873ee58eeff297d005f467ef8881f18ad /src/nse | |
parent | 46ecdb6cd88f76fc6c56368743740fce56b52cfc (diff) | |
download | gnunet-053b02677cdd94ef56a12f58849910a96649dd21.tar.gz gnunet-053b02677cdd94ef56a12f58849910a96649dd21.zip |
- change RSA for ECC in NSE
Diffstat (limited to 'src/nse')
-rw-r--r-- | src/nse/gnunet-service-nse.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index f7352f08c..8a7eb0ddd 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c | |||
@@ -170,7 +170,7 @@ struct GNUNET_NSE_FloodMessage | |||
170 | /** | 170 | /** |
171 | * Purpose. | 171 | * Purpose. |
172 | */ | 172 | */ |
173 | struct GNUNET_CRYPTO_RsaSignaturePurpose purpose; | 173 | struct GNUNET_CRYPTO_EccSignaturePurpose purpose; |
174 | 174 | ||
175 | /** | 175 | /** |
176 | * The current timestamp value (which all | 176 | * The current timestamp value (which all |
@@ -188,7 +188,7 @@ struct GNUNET_NSE_FloodMessage | |||
188 | /** | 188 | /** |
189 | * Public key of the originator. | 189 | * Public key of the originator. |
190 | */ | 190 | */ |
191 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; | 191 | struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded pkey; |
192 | 192 | ||
193 | /** | 193 | /** |
194 | * Proof of work, causing leading zeros when hashed with pkey. | 194 | * Proof of work, causing leading zeros when hashed with pkey. |
@@ -198,7 +198,7 @@ struct GNUNET_NSE_FloodMessage | |||
198 | /** | 198 | /** |
199 | * Signature (over range specified in purpose). | 199 | * Signature (over range specified in purpose). |
200 | */ | 200 | */ |
201 | struct GNUNET_CRYPTO_RsaSignature signature; | 201 | struct GNUNET_CRYPTO_EccSignature signature; |
202 | }; | 202 | }; |
203 | GNUNET_NETWORK_STRUCT_END | 203 | GNUNET_NETWORK_STRUCT_END |
204 | 204 | ||
@@ -287,12 +287,12 @@ static struct GNUNET_TIME_Absolute current_timestamp; | |||
287 | /** | 287 | /** |
288 | * The public key of this peer. | 288 | * The public key of this peer. |
289 | */ | 289 | */ |
290 | static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded my_public_key; | 290 | static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded my_public_key; |
291 | 291 | ||
292 | /** | 292 | /** |
293 | * The private key of this peer. | 293 | * The private key of this peer. |
294 | */ | 294 | */ |
295 | static struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key; | 295 | static struct GNUNET_CRYPTO_EccPrivateKey *my_private_key; |
296 | 296 | ||
297 | /** | 297 | /** |
298 | * The peer identity of this peer. | 298 | * The peer identity of this peer. |
@@ -312,7 +312,7 @@ static struct GNUNET_SERVER_Handle *srv; | |||
312 | /** | 312 | /** |
313 | * Hostkey generation context | 313 | * Hostkey generation context |
314 | */ | 314 | */ |
315 | static struct GNUNET_CRYPTO_RsaKeyGenerationContext *keygen; | 315 | static struct GNUNET_CRYPTO_EccKeyGenerationContext *keygen; |
316 | 316 | ||
317 | 317 | ||
318 | /** | 318 | /** |
@@ -693,7 +693,7 @@ setup_flood_message (unsigned int slot, | |||
693 | fm->proof_of_work = my_proof; | 693 | fm->proof_of_work = my_proof; |
694 | if (nse_work_required > 0) | 694 | if (nse_work_required > 0) |
695 | GNUNET_assert (GNUNET_OK == | 695 | GNUNET_assert (GNUNET_OK == |
696 | GNUNET_CRYPTO_rsa_sign (my_private_key, &fm->purpose, | 696 | GNUNET_CRYPTO_ecc_sign (my_private_key, &fm->purpose, |
697 | &fm->signature)); | 697 | &fm->signature)); |
698 | else | 698 | else |
699 | memset (&fm->signature, 0, sizeof (fm->signature)); | 699 | memset (&fm->signature, 0, sizeof (fm->signature)); |
@@ -825,16 +825,16 @@ count_leading_zeroes (const struct GNUNET_HashCode * hash) | |||
825 | * @return GNUNET_YES if valid, GNUNET_NO if not | 825 | * @return GNUNET_YES if valid, GNUNET_NO if not |
826 | */ | 826 | */ |
827 | static int | 827 | static int |
828 | check_proof_of_work (const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *pkey, | 828 | check_proof_of_work (const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *pkey, |
829 | uint64_t val) | 829 | uint64_t val) |
830 | { | 830 | { |
831 | char buf[sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + | 831 | char buf[sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded) + |
832 | sizeof (val)] GNUNET_ALIGN; | 832 | sizeof (val)] GNUNET_ALIGN; |
833 | struct GNUNET_HashCode result; | 833 | struct GNUNET_HashCode result; |
834 | 834 | ||
835 | memcpy (buf, &val, sizeof (val)); | 835 | memcpy (buf, &val, sizeof (val)); |
836 | memcpy (&buf[sizeof (val)], pkey, | 836 | memcpy (&buf[sizeof (val)], pkey, |
837 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); | 837 | sizeof (struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded)); |
838 | GNUNET_CRYPTO_hash (buf, sizeof (buf), &result); | 838 | GNUNET_CRYPTO_hash (buf, sizeof (buf), &result); |
839 | return (count_leading_zeroes (&result) >= | 839 | return (count_leading_zeroes (&result) >= |
840 | nse_work_required) ? GNUNET_YES : GNUNET_NO; | 840 | nse_work_required) ? GNUNET_YES : GNUNET_NO; |
@@ -943,7 +943,7 @@ verify_message_crypto (const struct GNUNET_NSE_FloodMessage *incoming_flood) | |||
943 | } | 943 | } |
944 | if ((nse_work_required > 0) && | 944 | if ((nse_work_required > 0) && |
945 | (GNUNET_OK != | 945 | (GNUNET_OK != |
946 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_NSE_SEND, | 946 | GNUNET_CRYPTO_ecc_verify (GNUNET_SIGNATURE_PURPOSE_NSE_SEND, |
947 | &incoming_flood->purpose, | 947 | &incoming_flood->purpose, |
948 | &incoming_flood->signature, | 948 | &incoming_flood->signature, |
949 | &incoming_flood->pkey))) | 949 | &incoming_flood->pkey))) |
@@ -1273,7 +1273,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1273 | } | 1273 | } |
1274 | if (NULL != keygen) | 1274 | if (NULL != keygen) |
1275 | { | 1275 | { |
1276 | GNUNET_CRYPTO_rsa_key_create_stop (keygen); | 1276 | GNUNET_CRYPTO_ecc_key_create_stop (keygen); |
1277 | keygen = NULL; | 1277 | keygen = NULL; |
1278 | } | 1278 | } |
1279 | if (NULL != nc) | 1279 | if (NULL != nc) |
@@ -1298,7 +1298,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1298 | } | 1298 | } |
1299 | if (NULL != my_private_key) | 1299 | if (NULL != my_private_key) |
1300 | { | 1300 | { |
1301 | GNUNET_CRYPTO_rsa_key_free (my_private_key); | 1301 | GNUNET_CRYPTO_ecc_key_free (my_private_key); |
1302 | my_private_key = NULL; | 1302 | my_private_key = NULL; |
1303 | } | 1303 | } |
1304 | #if ENABLE_HISTOGRAM | 1304 | #if ENABLE_HISTOGRAM |
@@ -1367,7 +1367,7 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server, | |||
1367 | */ | 1367 | */ |
1368 | static void | 1368 | static void |
1369 | key_generation_cb (void *cls, | 1369 | key_generation_cb (void *cls, |
1370 | struct GNUNET_CRYPTO_RsaPrivateKey *pk, | 1370 | struct GNUNET_CRYPTO_EccPrivateKey *pk, |
1371 | const char *emsg) | 1371 | const char *emsg) |
1372 | { | 1372 | { |
1373 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | 1373 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { |
@@ -1392,7 +1392,7 @@ key_generation_cb (void *cls, | |||
1392 | return; | 1392 | return; |
1393 | } | 1393 | } |
1394 | my_private_key = pk; | 1394 | my_private_key = pk; |
1395 | GNUNET_CRYPTO_rsa_key_get_public (my_private_key, &my_public_key); | 1395 | GNUNET_CRYPTO_ecc_key_get_public (my_private_key, &my_public_key); |
1396 | GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), | 1396 | GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), |
1397 | &my_identity.hashPubKey); | 1397 | &my_identity.hashPubKey); |
1398 | if (GNUNET_OK != | 1398 | if (GNUNET_OK != |
@@ -1401,7 +1401,7 @@ key_generation_cb (void *cls, | |||
1401 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1401 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1402 | _ | 1402 | _ |
1403 | ("NSE service is lacking key configuration settings. Exiting.\n")); | 1403 | ("NSE service is lacking key configuration settings. Exiting.\n")); |
1404 | GNUNET_CRYPTO_rsa_key_free (my_private_key); | 1404 | GNUNET_CRYPTO_ecc_key_free (my_private_key); |
1405 | my_private_key = NULL; | 1405 | my_private_key = NULL; |
1406 | GNUNET_SCHEDULER_shutdown (); | 1406 | GNUNET_SCHEDULER_shutdown (); |
1407 | return; | 1407 | return; |
@@ -1499,7 +1499,7 @@ run (void *cls, | |||
1499 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 1499 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, |
1500 | NULL); | 1500 | NULL); |
1501 | GNUNET_SERVER_suspend (srv); | 1501 | GNUNET_SERVER_suspend (srv); |
1502 | keygen = GNUNET_CRYPTO_rsa_key_create_start (keyfile, &key_generation_cb, NULL); | 1502 | keygen = GNUNET_CRYPTO_ecc_key_create_start (keyfile, &key_generation_cb, NULL); |
1503 | GNUNET_free (keyfile); | 1503 | GNUNET_free (keyfile); |
1504 | } | 1504 | } |
1505 | 1505 | ||