Commit af02039b authored by Antonin Décimo's avatar Antonin Décimo Committed by Juliusz Chroboczek

Append a PC message if Babel-MAC is enabled.

Don’t call `start_message()` since it may cause an infinite loop.
parent 46fc7da3
......@@ -1199,18 +1199,23 @@ accumulate_bytes(struct buffered *buf,
int
send_pc(struct buffered *buf, struct interface *ifp)
{
int space = 2 + MAX_HMAC_SPACE + 6 + NONCE_LEN;
if(buf->size - buf->len < space) {
fputs("send_pc: no space left to accumulate pc.\n", stderr);
return -1;
}
if(ifp->pc == 0) {
int rc;
rc = read_random_bytes(ifp->index, INDEX_LEN);
if(rc < INDEX_LEN)
return -1;
}
start_message(buf, ifp, MESSAGE_PC, 4 + INDEX_LEN);
accumulate_byte(buf, MESSAGE_PC);
accumulate_byte(buf, 4 + INDEX_LEN);
accumulate_int(buf, ifp->pc);
accumulate_bytes(buf, ifp->index, INDEX_LEN);
end_message(buf, MESSAGE_PC, 4 + INDEX_LEN);
ifp->pc++;
return 1;
return 0;
}
void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment