stun

simple point to point tunnel
git clone git://git.2f30.org/stun
Log | Files | Refs | README

commit 7eec2a3e369947ad1f1b4f256b73b2977ea84726
parent 9422f660b059aed3f68ceb1729c79a1c07e69e34
Author: sin <sin@2f30.org>
Date:   Tue, 29 Mar 2016 10:37:41 +0100

some comments

Diffstat:
Mstun.c | 4++++
1 file changed, 4 insertions(+), 0 deletions(-)

diff --git a/stun.c b/stun.c @@ -415,11 +415,15 @@ writenet(int fd, unsigned char *buf, int len) { unsigned char encbuf[MTU + AES_BLOCK_SIZE + HDRLEN]; + /* fill padding with random bytes */ if (padlen(len, AES_BLOCK_SIZE) > 0) arc4random_buf(&encbuf[HDRLEN + len], padlen(len, AES_BLOCK_SIZE)); + aesenc(&enc, &encbuf[HDRLEN], buf, padto(len, AES_BLOCK_SIZE)); + /* insert unpadded payload len at the start of the packet */ pack16(encbuf, len); + /* calculate total size of packet and send it on the wire */ len = padto(len, AES_BLOCK_SIZE) + HDRLEN; return writeall(fd, encbuf, len); }