diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2023-07-29 23:54:20 +0200 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2023-07-29 23:54:20 +0200 |
commit | e2fca041289bc082d000d15469c9700487a19c3c (patch) | |
tree | d501100ee015131c70e00fdd63c20700d231ab24 | |
parent | b1c63f1b61ebf61aa22043fe988abe1e7883d067 (diff) | |
download | gnunet-e2fca041289bc082d000d15469c9700487a19c3c.tar.gz gnunet-e2fca041289bc082d000d15469c9700487a19c3c.zip |
TNG: Only inject rekey when necessary. Only send ACK from receiver.
-rw-r--r-- | src/transport/gnunet-communicator-udp.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c index f697dc02e..75f732d6c 100644 --- a/src/transport/gnunet-communicator-udp.c +++ b/src/transport/gnunet-communicator-udp.c | |||
@@ -493,6 +493,11 @@ struct SharedSecret | |||
493 | * Is the kce_task finished? | 493 | * Is the kce_task finished? |
494 | */ | 494 | */ |
495 | int kce_task_finished; | 495 | int kce_task_finished; |
496 | |||
497 | /** | ||
498 | * When KCE finishes, send ACK if GNUNET_YES | ||
499 | */ | ||
500 | int kce_send_ack_on_finish; | ||
496 | }; | 501 | }; |
497 | 502 | ||
498 | 503 | ||
@@ -1590,7 +1595,8 @@ kce_generate_cb (void *cls) | |||
1590 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1595 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1591 | "We have enough keys.\n"); | 1596 | "We have enough keys.\n"); |
1592 | ss->kce_task_finished = GNUNET_YES; | 1597 | ss->kce_task_finished = GNUNET_YES; |
1593 | consider_ss_ack (ss); | 1598 | if (ss->kce_send_ack_on_finish == GNUNET_YES) |
1599 | consider_ss_ack (ss); | ||
1594 | } | 1600 | } |
1595 | 1601 | ||
1596 | 1602 | ||
@@ -1654,6 +1660,7 @@ try_handle_plaintext (struct SenderAddress *sender, | |||
1654 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1660 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1655 | "We have %u acks available.\n", | 1661 | "We have %u acks available.\n", |
1656 | ss_rekey->sender->acks_available); | 1662 | ss_rekey->sender->acks_available); |
1663 | ss_rekey->kce_send_ack_on_finish = GNUNET_NO; | ||
1657 | ss_rekey->kce_task = GNUNET_SCHEDULER_add_delayed ( | 1664 | ss_rekey->kce_task = GNUNET_SCHEDULER_add_delayed ( |
1658 | WORKING_QUEUE_INTERVALL, | 1665 | WORKING_QUEUE_INTERVALL, |
1659 | kce_generate_cb, | 1666 | kce_generate_cb, |
@@ -1960,6 +1967,7 @@ sock_read (void *cls) | |||
1960 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1967 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1961 | "Sender has %u ack left which is under threshold.\n", | 1968 | "Sender has %u ack left which is under threshold.\n", |
1962 | kce->ss->sender->acks_available); | 1969 | kce->ss->sender->acks_available); |
1970 | kce->ss->kce_send_ack_on_finish = GNUNET_YES; | ||
1963 | kce->ss->kce_task = GNUNET_SCHEDULER_add_delayed ( | 1971 | kce->ss->kce_task = GNUNET_SCHEDULER_add_delayed ( |
1964 | WORKING_QUEUE_INTERVALL, | 1972 | WORKING_QUEUE_INTERVALL, |
1965 | kce_generate_cb, | 1973 | kce_generate_cb, |
@@ -2103,6 +2111,7 @@ sock_read (void *cls) | |||
2103 | ss->kce_task_finished)) | 2111 | ss->kce_task_finished)) |
2104 | { | 2112 | { |
2105 | // TODO This task must be per sender! FIXME: This is a nice todo, but I do not know what must be done here to fix. | 2113 | // TODO This task must be per sender! FIXME: This is a nice todo, but I do not know what must be done here to fix. |
2114 | ss->kce_send_ack_on_finish = GNUNET_YES; | ||
2106 | ss->kce_task = GNUNET_SCHEDULER_add_delayed ( | 2115 | ss->kce_task = GNUNET_SCHEDULER_add_delayed ( |
2107 | WORKING_QUEUE_INTERVALL, | 2116 | WORKING_QUEUE_INTERVALL, |
2108 | kce_generate_cb, | 2117 | kce_generate_cb, |
@@ -2564,10 +2573,13 @@ mq_send_d (struct GNUNET_MQ_Handle *mq, | |||
2564 | setup_cipher (&ss->master, ss->sequence_used, &out_cipher); | 2573 | setup_cipher (&ss->master, ss->sequence_used, &out_cipher); |
2565 | /* Append encrypted payload to dgram */ | 2574 | /* Append encrypted payload to dgram */ |
2566 | dpos = sizeof(struct UDPBox); | 2575 | dpos = sizeof(struct UDPBox); |
2567 | GNUNET_assert ( | 2576 | if (GNUNET_YES == inject_rekey) |
2568 | 0 == gcry_cipher_encrypt (out_cipher, &dgram[dpos], sizeof (rekey), | 2577 | { |
2569 | &rekey, sizeof (rekey))); | 2578 | GNUNET_assert ( |
2570 | dpos += sizeof (rekey); | 2579 | 0 == gcry_cipher_encrypt (out_cipher, &dgram[dpos], sizeof (rekey), |
2580 | &rekey, sizeof (rekey))); | ||
2581 | dpos += sizeof (rekey); | ||
2582 | } | ||
2571 | GNUNET_assert ( | 2583 | GNUNET_assert ( |
2572 | 0 == gcry_cipher_encrypt (out_cipher, &dgram[dpos], msize, msg, msize)); | 2584 | 0 == gcry_cipher_encrypt (out_cipher, &dgram[dpos], msize, msg, msize)); |
2573 | dpos += msize; | 2585 | dpos += msize; |