another fix related to #7099

This commit is contained in:
Christian Grothoff 2021-11-21 12:47:16 +01:00
parent 56318f53e2
commit 5159badd0e
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 61 additions and 23 deletions

View File

@ -229,18 +229,19 @@ TES_read_work (void *cls,
{
struct TES_Client *client = cls;
char *buf = client->iobuf;
ssize_t buf_size;
size_t off = 0;
uint16_t msize;
const struct GNUNET_MessageHeader *hdr;
do
{
buf_size = recv (client->csock,
&buf[off],
sizeof (client->iobuf) - off,
0);
if (-1 == buf_size)
ssize_t recv_size;
recv_size = recv (client->csock,
&buf[off],
sizeof (client->iobuf) - off,
0);
if (-1 == recv_size)
{
if ( (0 == off) &&
(EAGAIN == errno) )
@ -257,17 +258,23 @@ TES_read_work (void *cls,
"recv");
return GNUNET_SYSERR;
}
if (0 == buf_size)
if (0 == recv_size)
{
/* regular disconnect? */
GNUNET_break_op (0 == off);
return GNUNET_SYSERR;
}
off += buf_size;
off += recv_size;
if (off < sizeof (struct GNUNET_MessageHeader))
continue;
hdr = (const struct GNUNET_MessageHeader *) buf;
msize = ntohs (hdr->size);
#if 0
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Received message of type %u with %u bytes\n",
(unsigned int) ntohs (hdr->type),
(unsigned int) msize);
#endif
if (msize < sizeof (struct GNUNET_MessageHeader))
{
GNUNET_break_op (0);

View File

@ -282,8 +282,8 @@ handle_sign_request (struct TES_Client *client,
if (0 != key->rc)
break; /* do later */
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Removing past key %s (expired %s ago)\n",
key->filename,
"Deleting past key %s (expired %s ago)\n",
TALER_B2S (&nxt->exchange_pub),
GNUNET_STRINGS_relative_time_to_string (
GNUNET_TIME_absolute_get_duration (
GNUNET_TIME_absolute_add (key->anchor,
@ -400,7 +400,15 @@ static void
purge_key (struct Key *key)
{
if (key->purge)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Key %s already purged, skipping\n",
TALER_B2S (&key->exchange_pub));
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Purging key %s\n",
TALER_B2S (&key->exchange_pub));
if (0 != unlink (key->filename))
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
"unlink",
@ -449,8 +457,8 @@ handle_revoke_request (struct TES_Client *client,
key_gen++;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Revoking key %p, bumping generation to %llu\n",
key,
"Revoking key %s, bumping generation to %llu\n",
TALER_B2S (&key->exchange_pub),
(unsigned long long) key_gen);
purge_key (key);
@ -570,13 +578,23 @@ eddsa_client_init (struct TES_Client *client)
static enum GNUNET_GenericReturnValue
eddsa_update_client_keys (struct TES_Client *client)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Updating client %p to generation %llu\n",
client,
(unsigned long long) key_gen);
GNUNET_assert (0 == pthread_mutex_lock (&keys_lock));
for (struct Key *key = keys_head;
NULL != key;
key = key->next)
{
if (key->key_gen <= client->key_gen)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Skipping key %s, no change since generation %llu\n",
TALER_B2S (&key->exchange_pub),
(unsigned long long) client->key_gen);
continue;
}
if (key->purge)
{
if (GNUNET_OK !=
@ -715,7 +733,7 @@ update_keys (void *cls)
}
}
nxt = keys_head;
/* remove expired keys */
/* purge expired keys */
while ( (NULL != nxt) &&
GNUNET_TIME_absolute_is_past (
GNUNET_TIME_absolute_add (nxt->anchor,
@ -727,8 +745,8 @@ update_keys (void *cls)
wake = true;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Removing past key %s (expired %s ago)\n",
nxt->filename,
"Purging past key %s (expired %s ago)\n",
TALER_B2S (&nxt->exchange_pub),
GNUNET_STRINGS_relative_time_to_string (
GNUNET_TIME_absolute_get_duration (
GNUNET_TIME_absolute_add (nxt->anchor,
@ -1075,13 +1093,13 @@ run (void *cls,
global_ret = EXIT_NOTCONFIGURED;
return;
}
GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
NULL);
global_ret = TES_listen_start (cfg,
"taler-exchange-secmod-eddsa",
&cb);
if (0 != global_ret)
return;
GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
NULL);
/* Load keys */
GNUNET_break (GNUNET_OK ==
GNUNET_DISK_directory_create (keydir));

View File

@ -27,7 +27,7 @@
* we should never have more than 6 active keys, plus for during
* key expiration / revocation.
*/
#define MAX_KEYS 7
#define MAX_KEYS 20
/**
* How many random key revocations should we test?
@ -121,7 +121,14 @@ key_cb (void *cls,
(void) cls;
(void) sm_pub;
(void) sm_sig;
if (0 == validity_duration.rel_value_us)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Update on key %s (%s)...",
TALER_B2S (exchange_pub),
GNUNET_STRINGS_relative_time_to_string (validity_duration,
GNUNET_YES));
if (GNUNET_TIME_relative_is_zero (validity_duration))
{
bool found = false;
@ -190,14 +197,20 @@ test_revocation (struct TALER_CRYPTO_ExchangeSignHelper *esh)
}
keys[j].revoked = true;
fprintf (stderr,
"Revoking key ...");
"Revoking key %s ...",
TALER_B2S (&keys[j].exchange_pub));
TALER_CRYPTO_helper_esign_revoke (esh,
&keys[j].exchange_pub);
for (unsigned int k = 0; k<1000; k++)
{
TALER_CRYPTO_helper_esign_poll (esh);
if (! keys[j].revoked)
if ( (! keys[j].revoked) ||
(GNUNET_TIME_absolute_is_past (
GNUNET_TIME_absolute_add (keys[j].start_time,
keys[j].validity_duration))) )
{
break;
}
nanosleep (&req, NULL);
fprintf (stderr, ".");
}
@ -470,7 +483,7 @@ main (int argc,
(void) argc;
(void) argv;
GNUNET_log_setup ("test-helper-eddsa",
"WARNING",
"INFO",
NULL);
GNUNET_OS_init (TALER_project_data_default ());
libexec_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_BINDIR);
@ -486,7 +499,7 @@ main (int argc,
"-c",
"test_helper_eddsa.conf",
"-L",
"WARNING",
"INFO",
NULL);
if (NULL == helper)
{