diff options
author | Dimitri Staessens <[email protected]> | 2022-02-25 18:44:12 +0100 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2022-03-03 12:00:54 +0100 |
commit | f535637a394eecca1af182fb09b175b53e9fbf1f (patch) | |
tree | f0598166eeac5ff9f1c197c7ee3103703ddc1fd5 /src/lib/frct.c | |
parent | f5d642a06f9c1a58197313b32f6b213a152e446f (diff) | |
download | ouroboros-f535637a394eecca1af182fb09b175b53e9fbf1f.tar.gz ouroboros-f535637a394eecca1af182fb09b175b53e9fbf1f.zip |
lib: Encrypt bare FRCP messages on encrypted flows
Bare FRCP messages (ACKs without data, Rendez-vous packets) were not
encrypted on encrypted flows, causing the receiver to fail decryption.
Signed-off-by: Dimitri Staessens <[email protected]>
Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/lib/frct.c')
-rw-r--r-- | src/lib/frct.c | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/src/lib/frct.c b/src/lib/frct.c index e9741aaf..2793f3c4 100644 --- a/src/lib/frct.c +++ b/src/lib/frct.c @@ -232,16 +232,29 @@ static void __send_frct_pkt(int fd, pci->ackno = hton32(ackno); f = &ai.flows[fd]; + + pthread_rwlock_rdlock(&ai.lock); + + if (f->qs.cypher_s > 0 && crypt_encrypt(f, sdb) < 0) + goto fail; + #ifdef RXM_BLOCKING - if (shm_rbuff_write_b(f->tx_rb, idx, NULL)) { + if (shm_rbuff_write_b(f->tx_rb, idx, NULL)) #else - if (shm_rbuff_write(f->tx_rb, idx)) { + if (shm_rbuff_write(f->tx_rb, idx)) #endif - ipcp_sdb_release(sdb); - return; - } + goto fail; shm_flow_set_notify(f->set, f->flow_id, FLOW_PKT); + + pthread_rwlock_unlock(&ai.lock); + + return; + + fail: + pthread_rwlock_unlock(&ai.lock); + ipcp_sdb_release(sdb); + return; } static void send_frct_pkt(struct frcti * frcti) @@ -287,29 +300,7 @@ static void send_frct_pkt(struct frcti * frcti) static void __send_rdv(int fd) { - struct shm_du_buff * sdb; - struct frct_pci * pci; - ssize_t idx; - struct flow * f; - - /* Raw calls needed to bypass frcti. */ - idx = shm_rdrbuff_alloc_b(ai.rdrb, sizeof(*pci), NULL, &sdb, NULL); - if (idx < 0) - return; - - pci = (struct frct_pci *) shm_du_buff_head(sdb); - memset(pci, 0, sizeof(*pci)); - - pci->flags = FRCT_RDVS; - - f = &ai.flows[fd]; - - if (shm_rbuff_write_b(f->tx_rb, idx, NULL)) { - ipcp_sdb_release(sdb); - return; - } - - shm_flow_set_notify(f->set, f->flow_id, FLOW_PKT); + __send_frct_pkt(fd, FRCT_RDVS, 0, 0); } static struct frcti * frcti_create(int fd) |