diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-10 14:38:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-10 14:38:55 +0000 |
commit | 9351b1e9bdf2b067b6db06562c26ba658cff42b8 (patch) | |
tree | 68dc4ab447e7e8b6a20a706858cd36238c1c7c5f /src/nse/gnunet-service-nse.c | |
parent | 8beabcd96c0cf1e1873c0b5ff96e537f1beb0b34 (diff) | |
download | gnunet-9351b1e9bdf2b067b6db06562c26ba658cff42b8.tar.gz gnunet-9351b1e9bdf2b067b6db06562c26ba658cff42b8.zip |
separating ECC crypto into functions/structs for ECDHE, ECDSA and EDDSA
Diffstat (limited to 'src/nse/gnunet-service-nse.c')
-rw-r--r-- | src/nse/gnunet-service-nse.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index b69a4a7fe..366770cad 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c | |||
@@ -199,7 +199,7 @@ struct GNUNET_NSE_FloodMessage | |||
199 | /** | 199 | /** |
200 | * Signature (over range specified in purpose). | 200 | * Signature (over range specified in purpose). |
201 | */ | 201 | */ |
202 | struct GNUNET_CRYPTO_EccSignature signature; | 202 | struct GNUNET_CRYPTO_EddsaSignature signature; |
203 | }; | 203 | }; |
204 | GNUNET_NETWORK_STRUCT_END | 204 | GNUNET_NETWORK_STRUCT_END |
205 | 205 | ||
@@ -288,7 +288,7 @@ static struct GNUNET_TIME_Absolute current_timestamp; | |||
288 | /** | 288 | /** |
289 | * The private key of this peer. | 289 | * The private key of this peer. |
290 | */ | 290 | */ |
291 | static struct GNUNET_CRYPTO_EccPrivateKey *my_private_key; | 291 | static struct GNUNET_CRYPTO_EddsaPrivateKey *my_private_key; |
292 | 292 | ||
293 | /** | 293 | /** |
294 | * The peer identity of this peer. | 294 | * The peer identity of this peer. |
@@ -710,14 +710,14 @@ setup_flood_message (unsigned int slot, | |||
710 | fm->purpose.size = | 710 | fm->purpose.size = |
711 | htonl (sizeof (struct GNUNET_NSE_FloodMessage) - | 711 | htonl (sizeof (struct GNUNET_NSE_FloodMessage) - |
712 | sizeof (struct GNUNET_MessageHeader) - sizeof (uint32_t) - | 712 | sizeof (struct GNUNET_MessageHeader) - sizeof (uint32_t) - |
713 | sizeof (struct GNUNET_CRYPTO_EccSignature)); | 713 | sizeof (struct GNUNET_CRYPTO_EddsaSignature)); |
714 | fm->matching_bits = htonl (matching_bits); | 714 | fm->matching_bits = htonl (matching_bits); |
715 | fm->timestamp = GNUNET_TIME_absolute_hton (ts); | 715 | fm->timestamp = GNUNET_TIME_absolute_hton (ts); |
716 | fm->origin = my_identity; | 716 | fm->origin = my_identity; |
717 | fm->proof_of_work = my_proof; | 717 | fm->proof_of_work = my_proof; |
718 | if (nse_work_required > 0) | 718 | if (nse_work_required > 0) |
719 | GNUNET_assert (GNUNET_OK == | 719 | GNUNET_assert (GNUNET_OK == |
720 | GNUNET_CRYPTO_ecc_sign (my_private_key, &fm->purpose, | 720 | GNUNET_CRYPTO_eddsa_sign (my_private_key, &fm->purpose, |
721 | &fm->signature)); | 721 | &fm->signature)); |
722 | else | 722 | else |
723 | memset (&fm->signature, 0, sizeof (fm->signature)); | 723 | memset (&fm->signature, 0, sizeof (fm->signature)); |
@@ -849,16 +849,16 @@ count_leading_zeroes (const struct GNUNET_HashCode *hash) | |||
849 | * @return #GNUNET_YES if valid, #GNUNET_NO if not | 849 | * @return #GNUNET_YES if valid, #GNUNET_NO if not |
850 | */ | 850 | */ |
851 | static int | 851 | static int |
852 | check_proof_of_work (const struct GNUNET_CRYPTO_EccPublicSignKey *pkey, | 852 | check_proof_of_work (const struct GNUNET_CRYPTO_EddsaPublicKey *pkey, |
853 | uint64_t val) | 853 | uint64_t val) |
854 | { | 854 | { |
855 | char buf[sizeof (struct GNUNET_CRYPTO_EccPublicSignKey) + | 855 | char buf[sizeof (struct GNUNET_CRYPTO_EddsaPublicKey) + |
856 | sizeof (val)] GNUNET_ALIGN; | 856 | sizeof (val)] GNUNET_ALIGN; |
857 | struct GNUNET_HashCode result; | 857 | struct GNUNET_HashCode result; |
858 | 858 | ||
859 | memcpy (buf, &val, sizeof (val)); | 859 | memcpy (buf, &val, sizeof (val)); |
860 | memcpy (&buf[sizeof (val)], pkey, | 860 | memcpy (&buf[sizeof (val)], pkey, |
861 | sizeof (struct GNUNET_CRYPTO_EccPublicSignKey)); | 861 | sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)); |
862 | pow_hash (buf, sizeof (buf), &result); | 862 | pow_hash (buf, sizeof (buf), &result); |
863 | return (count_leading_zeroes (&result) >= | 863 | return (count_leading_zeroes (&result) >= |
864 | nse_work_required) ? GNUNET_YES : GNUNET_NO; | 864 | nse_work_required) ? GNUNET_YES : GNUNET_NO; |
@@ -898,7 +898,7 @@ find_proof (void *cls, | |||
898 | { | 898 | { |
899 | #define ROUND_SIZE 10 | 899 | #define ROUND_SIZE 10 |
900 | uint64_t counter; | 900 | uint64_t counter; |
901 | char buf[sizeof (struct GNUNET_CRYPTO_EccPublicSignKey) + | 901 | char buf[sizeof (struct GNUNET_CRYPTO_EddsaPublicKey) + |
902 | sizeof (uint64_t)] GNUNET_ALIGN; | 902 | sizeof (uint64_t)] GNUNET_ALIGN; |
903 | struct GNUNET_HashCode result; | 903 | struct GNUNET_HashCode result; |
904 | unsigned int i; | 904 | unsigned int i; |
@@ -967,7 +967,7 @@ verify_message_crypto (const struct GNUNET_NSE_FloodMessage *incoming_flood) | |||
967 | } | 967 | } |
968 | if ((nse_work_required > 0) && | 968 | if ((nse_work_required > 0) && |
969 | (GNUNET_OK != | 969 | (GNUNET_OK != |
970 | GNUNET_CRYPTO_ecc_verify (GNUNET_SIGNATURE_PURPOSE_NSE_SEND, | 970 | GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_PURPOSE_NSE_SEND, |
971 | &incoming_flood->purpose, | 971 | &incoming_flood->purpose, |
972 | &incoming_flood->signature, | 972 | &incoming_flood->signature, |
973 | &incoming_flood->origin.public_key))) | 973 | &incoming_flood->origin.public_key))) |
@@ -1421,7 +1421,7 @@ run (void *cls, | |||
1421 | {NULL, 0, 0} | 1421 | {NULL, 0, 0} |
1422 | }; | 1422 | }; |
1423 | char *proof; | 1423 | char *proof; |
1424 | struct GNUNET_CRYPTO_EccPrivateKey *pk; | 1424 | struct GNUNET_CRYPTO_EddsaPrivateKey *pk; |
1425 | 1425 | ||
1426 | cfg = c; | 1426 | cfg = c; |
1427 | srv = server; | 1427 | srv = server; |
@@ -1474,10 +1474,10 @@ run (void *cls, | |||
1474 | 1474 | ||
1475 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 1475 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, |
1476 | NULL); | 1476 | NULL); |
1477 | pk = GNUNET_CRYPTO_ecc_key_create_from_configuration (cfg); | 1477 | pk = GNUNET_CRYPTO_eddsa_key_create_from_configuration (cfg); |
1478 | GNUNET_assert (NULL != pk); | 1478 | GNUNET_assert (NULL != pk); |
1479 | my_private_key = pk; | 1479 | my_private_key = pk; |
1480 | GNUNET_CRYPTO_ecc_key_get_public_for_signature (my_private_key, | 1480 | GNUNET_CRYPTO_eddsa_key_get_public (my_private_key, |
1481 | &my_identity.public_key); | 1481 | &my_identity.public_key); |
1482 | if (GNUNET_OK != | 1482 | if (GNUNET_OK != |
1483 | GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "PROOFFILE", &proof)) | 1483 | GNUNET_CONFIGURATION_get_value_filename (cfg, "NSE", "PROOFFILE", &proof)) |