Browse Source

ratchet after nonces, this will help prevent leaking the shared key...

irr_shared
John-Mark Gurney 3 years ago
parent
commit
5a0def61d6
3 changed files with 9 additions and 0 deletions
  1. +2
    -0
      PROTOCOL.md
  2. +3
    -0
      comms.c
  3. +4
    -0
      lora.py

+ 2
- 0
PROTOCOL.md View File

@@ -29,6 +29,8 @@ respondent:
send_enc(<16 bytes random data>) # nonce injection send_enc(<16 bytes random data>) # nonce injection
send_mac(8) send_mac(8)


ratchet() # prevent backtracking

initiator: initiator:
send_enc('confirm') send_enc('confirm')
send_mac(8) send_mac(8)


+ 3
- 0
comms.c View File

@@ -74,6 +74,9 @@ comms_process(struct comms_state *cs, struct pktbuf pbin, struct pktbuf *pbout)
ret = strobe_put(&cs->cs_state, APP_CIPHERTEXT, buf, ret = strobe_put(&cs->cs_state, APP_CIPHERTEXT, buf,
CHALLENGE_LEN); CHALLENGE_LEN);
ret += strobe_put(&cs->cs_state, MAC, NULL, MAC_LEN); ret += strobe_put(&cs->cs_state, MAC, NULL, MAC_LEN);

strobe_operate(&cs->cs_state, RATCHET, NULL, 32);

cs->cs_comm_state = COMMS_WAIT_CONFIRM; cs->cs_comm_state = COMMS_WAIT_CONFIRM;
break; break;




+ 4
- 0
lora.py View File

@@ -35,6 +35,8 @@ class LORANode(object):
self.st.recv_enc(resp[:16]) self.st.recv_enc(resp[:16])
self.st.recv_mac(resp[16:]) self.st.recv_mac(resp[16:])


self.st.ratchet()

resp = await self.sd.sendtillrecv( resp = await self.sd.sendtillrecv(
self.st.send_enc(b'confirm') + self.st.send_mac(8), 1) self.st.send_enc(b'confirm') + self.st.send_mac(8), 1)


@@ -190,6 +192,8 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase):
await self.put(l.send_enc(os.urandom(16)) + await self.put(l.send_enc(os.urandom(16)) +
l.send_mac(8)) l.send_mac(8))


l.ratchet()

r = await self.get() r = await self.get()
c = l.recv_enc(r[:-8]) c = l.recv_enc(r[:-8])
l.recv_mac(r[-8:]) l.recv_mac(r[-8:])


Loading…
Cancel
Save