Mercurial > hg > quicktun
diff src/proto.nacltai.c @ 62:5b9e742bb704
Fixed compiler warnings, removed redundant version dependencies in debian package
author | Ivo Smits <Ivo@UFO-Net.nl> |
---|---|
date | Sat, 07 Jan 2017 15:47:19 +0100 |
parents | 66d9d80215f0 |
children |
line wrap: on
line diff
--- a/src/proto.nacltai.c Wed Jan 04 21:42:38 2017 +0100 +++ b/src/proto.nacltai.c Sat Jan 07 15:47:19 2017 +0100 @@ -34,14 +34,15 @@ }; struct qt_proto_data_nacltai { - unsigned char cenonce[crypto_box_curve25519xsalsa20poly1305_NONCEBYTES], cdnonce[crypto_box_curve25519xsalsa20poly1305_NONCEBYTES]; + unsigned char cenonce[crypto_box_curve25519xsalsa20poly1305_NONCEBYTES]; + unsigned char cdnonce[crypto_box_curve25519xsalsa20poly1305_NONCEBYTES]; unsigned char cbefore[crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES]; struct packedtaia cdtailog[5]; }; #define noncelength 16 #define nonceoffset (crypto_box_curve25519xsalsa20poly1305_NONCEBYTES - noncelength) -static const int overhead = crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES + noncelength; +static const int overhead = crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES + noncelength; static void taia_now_packed(unsigned char* b, int secoffset) { struct timeval now; @@ -70,7 +71,8 @@ struct qt_proto_data_nacltai* d = (struct qt_proto_data_nacltai*)sess->protocol_data; memset(raw, 0, crypto_box_curve25519xsalsa20poly1305_ZEROBYTES); taia_now_packed(d->cenonce + nonceoffset, 0); - if (crypto_box_curve25519xsalsa20poly1305_afternm((unsigned char*)enc, (unsigned char*)raw, len + crypto_box_curve25519xsalsa20poly1305_ZEROBYTES, d->cenonce, d->cbefore)) return errorexit("Encryption failed"); + if (crypto_box_curve25519xsalsa20poly1305_afternm((unsigned char*)enc, (unsigned char*)raw, len + crypto_box_curve25519xsalsa20poly1305_ZEROBYTES, d->cenonce, d->cbefore)) + return errorexit("Encryption failed"); memcpy((void*)(enc + crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES - noncelength), d->cenonce + nonceoffset, noncelength); len += overhead; if (debug) fprintf(stderr, "Encoded packet of %d bytes from %p to %p\n", len, raw, enc); @@ -138,7 +140,8 @@ } else { return errorexit("Missing PRIVATE_KEY"); } - crypto_box_curve25519xsalsa20poly1305_beforenm(d->cbefore, cpublickey, csecretkey); + if (crypto_box_curve25519xsalsa20poly1305_beforenm(d->cbefore, cpublickey, csecretkey)) + return errorexit("Encryption key calculation failed"); memset(d->cenonce, 0, crypto_box_curve25519xsalsa20poly1305_NONCEBYTES); memset(d->cdnonce, 0, crypto_box_curve25519xsalsa20poly1305_NONCEBYTES);