diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-06 14:18:31 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-06 14:18:31 +0000 |
commit | fe76c075e315c0351e2fe465434ae39087daf014 (patch) | |
tree | 436887ccaf331932a3c13a8b9d2a2a710dad4be6 /src/nse/gnunet-service-nse.c | |
parent | 7eb2835d8a494c83aedb720a2ac6f6e5ba23f22f (diff) | |
download | gnunet-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/nse/gnunet-service-nse.c')
-rw-r--r-- | src/nse/gnunet-service-nse.c | 16 |
1 files changed, 8 insertions, 8 deletions
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 | */ |
292 | static struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded my_public_key; | 292 | static 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 | */ |
846 | static int | 846 | static int |
847 | check_proof_of_work (const struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded *pkey, | 847 | check_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)); |