aboutsummaryrefslogtreecommitdiff
path: root/src/revocation/test_revocation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/revocation/test_revocation.c')
-rw-r--r--src/revocation/test_revocation.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/revocation/test_revocation.c b/src/revocation/test_revocation.c
index 012bac09e..f193d5f6c 100644
--- a/src/revocation/test_revocation.c
+++ b/src/revocation/test_revocation.c
@@ -45,7 +45,7 @@ struct TestPeer
45 struct GNUNET_IDENTITY_EgoLookup *ego_lookup; 45 struct GNUNET_IDENTITY_EgoLookup *ego_lookup;
46 struct GNUNET_REVOCATION_Handle *revok_handle; 46 struct GNUNET_REVOCATION_Handle *revok_handle;
47 struct GNUNET_CORE_Handle *ch; 47 struct GNUNET_CORE_Handle *ch;
48 uint64_t pow; 48 struct GNUNET_REVOCATION_PowCalculationHandle *pow;
49}; 49};
50 50
51static struct TestPeer testpeers[2]; 51static struct TestPeer testpeers[2];
@@ -131,7 +131,7 @@ check_revocation (void *cls)
131 131
132 132
133static void 133static void
134revocation_cb (void *cls, int is_valid) 134revocation_cb (void *cls, enum GNUNET_GenericReturnValue is_valid)
135{ 135{
136 testpeers[1].revok_handle = NULL; 136 testpeers[1].revok_handle = NULL;
137 if (GNUNET_NO == is_valid) 137 if (GNUNET_NO == is_valid)
@@ -141,11 +141,14 @@ revocation_cb (void *cls, int is_valid)
141 } 141 }
142} 142}
143 143
144struct GNUNET_REVOCATION_Pow proof_of_work;
145
144 146
145static void 147static void
146ego_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego) 148ego_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
147{ 149{
148 static int completed = 0; 150 static int completed = 0;
151 const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
149 152
150 if ((NULL != ego) && (cls == &testpeers[0])) 153 if ((NULL != ego) && (cls == &testpeers[0]))
151 { 154 {
@@ -159,17 +162,20 @@ ego_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
159 testpeers[1].ego_lookup = NULL; 162 testpeers[1].ego_lookup = NULL;
160 testpeers[1].privkey = GNUNET_IDENTITY_ego_get_private_key (ego); 163 testpeers[1].privkey = GNUNET_IDENTITY_ego_get_private_key (ego);
161 GNUNET_IDENTITY_ego_get_public_key (ego, &testpeers[1].pubkey); 164 GNUNET_IDENTITY_ego_get_public_key (ego, &testpeers[1].pubkey);
162 GNUNET_REVOCATION_sign_revocation (testpeers[1].privkey, &testpeers[1].sig);
163
164 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Calculating proof of work...\n"); 165 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Calculating proof of work...\n");
165 testpeers[1].pow = 0; 166 privkey = GNUNET_IDENTITY_ego_get_private_key (ego);
167 memset (&proof_of_work, 0, sizeof (proof_of_work));
168 GNUNET_REVOCATION_pow_init (privkey,
169 &proof_of_work);
170 testpeers[1].pow = GNUNET_REVOCATION_pow_start (&proof_of_work,
171 1,
172 5);
166 int res = 173 int res =
167 GNUNET_REVOCATION_check_pow (&testpeers[1].pubkey, testpeers[1].pow, 5); 174 GNUNET_REVOCATION_pow_round (testpeers[1].pow);
168 while (GNUNET_OK != res) 175 while (GNUNET_OK != res)
169 { 176 {
170 testpeers[1].pow++;
171 res = 177 res =
172 GNUNET_REVOCATION_check_pow (&testpeers[1].pubkey, testpeers[1].pow, 5); 178 GNUNET_REVOCATION_pow_round (testpeers[1].pow);
173 } 179 }
174 fprintf (stderr, "Done calculating proof of work\n"); 180 fprintf (stderr, "Done calculating proof of work\n");
175 completed++; 181 completed++;
@@ -178,11 +184,10 @@ ego_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
178 { 184 {
179 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Egos retrieved\n"); 185 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Egos retrieved\n");
180 testpeers[1].revok_handle = GNUNET_REVOCATION_revoke (testpeers[1].cfg, 186 testpeers[1].revok_handle = GNUNET_REVOCATION_revoke (testpeers[1].cfg,
181 &testpeers[1].pubkey, 187 &proof_of_work,
182 &testpeers[1].sig,
183 testpeers[1].pow,
184 &revocation_cb, 188 &revocation_cb,
185 NULL); 189 NULL);
190 GNUNET_REVOCATION_pow_stop (testpeers[1].pow);
186 } 191 }
187} 192}
188 193