X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fsptps.c;fp=src%2Fsptps.c;h=917b1e209c45cb641e8aa72ef4176b675497199c;hb=693fbd414983fdc87a34786093e0dbfab4542f6a;hp=e03b18a8b12e498182ee16b04deb37f337d90be1;hpb=58f7363afa1960bbee1fa03f3d24db3b2a66cda8;p=meshlink diff --git a/src/sptps.c b/src/sptps.c index e03b18a8..917b1e20 100644 --- a/src/sptps.c +++ b/src/sptps.c @@ -374,9 +374,14 @@ bool sptps_verify_datagram(sptps_t *s, const void *data, size_t len) { if(!s->instate || len < 21) return error(s, EIO, "Received short packet"); - // TODO: just decrypt without updating the replay window + uint32_t seqno; + memcpy(&seqno, data, 4); + seqno = ntohl(seqno); + // TODO: check whether seqno makes sense, to avoid CPU intensive decrypt - return true; + char buffer[len]; + size_t outlen; + return chacha_poly1305_decrypt(s->incipher, seqno, data + 4, len - 4, buffer, &outlen); } // Receive incoming data, datagram version.