summaryrefslogtreecommitdiff
path: root/toxcore/net_crypto.c
AgeCommit message (Collapse)Author
2017-01-07Avoid accessing uninitialised memory in `net_crypto`.iphydf
On x86 and x86_64, this change has no effect. On IA64, this fixes a potential hardware exception. A function returned a partially initialised value of aggregate type. The only caller of this function checks that the value is valid before accessing it by testing the one definitely initialised member. Therefore on x86 and derived architectures, there is no uninitialised memory access. On IA64, with the regular calling convention, the struct is allocated on the caller stack and passed as a pointer, so there the uninitialised memory is also never accessed. However, on calling conventions where one or more struct members past the first byte are passed in registers or copied in memory, this call can cause undefined behaviour. Specifically, the value can contain a trap representation of the integers (at the very least the 16 bit port) and cause a hardware exception and SIGFPE in userland. Regardless of the explanation above, this change fixes an instance of undefined behaviour that just happened to be OK on all systems we tested on.
2016-12-22Wrap all sodium/nacl functions in crypto_core.c.iphydf
2016-12-10net_crypto give handle_data_packet_helper a better nameGregory Mullen (grayhatter)
2016-11-09Remove new_nonce function in favour of random_nonce.iphydf
`new_nonce` has been an alias for `random_nonce` for a while now. Having two names for the same operation is confusing. `random_nonce` better expresses the intent. The documentation for `new_nonce` talks about guaranteeing that the nonce is different from previous ones, which is incorrect, it's just quite likely to be different.
2016-09-30Remove return after no-return situation (and other cleanups).iphydf
Cleanups: - Fix header guards to not use reserved names. - Avoid name shadowing. - Removed an unused variable found by avoiding name shadowing.
2016-09-24Make toxcore code C++ compatible.iphydf
It is still C code, so still compatible with C compilers as well. This change lets us see more clearly where implicit conversions occur by making them explicit.
2016-09-16Ensure that all TODOs have an owner.iphydf
In the future, all TODOs added either need a bug number (TODO(#NN)) or a person's github user name. By default, I made irungentoo the owner of all toxcore TODOs, mannol the owner of toxav TODOs, and myself the owner of API TODOs.
2016-09-13Use <stdbool.h> and replace _Bool with bool.iphydf
This header is a requirement for the public API, therefore is assumed to exist. It is a C99 standard library header, and _Bool is not intended to be used directly, except in legacy code that defines bool (and true/false) itself. We don't use or depend on such code. None of our client code uses or depends on such code. There is no reason to not use bool.
2016-09-13Group #include directives in 3-4 groups.iphydf
1. Current module (if C file). 2. Headers from current library. 3. Headers from other library (e.g. toxcore includes in toxav). 4. System headers.
2016-09-10make the majority of the callbacks stateless and add some status to a testcasemichael bishop
2016-09-06Improve static and const correctness.iphydf
- Any non-externally-visible declarations should be `static`. - Casting away the `const` qualifier from pointers-to-const is dangerous. All but one instance of this are now correct. The one instance where we can't keep `const` is one where toxav code actually writes to a chunk of memory marked as `const`. This code also assumes 4 byte alignment of data packets. I don't know whether that is a valid assumption, but it's likely unportable, and *not* obviously correct. - Replaced empty parameter lists with `(void)` to avoid passing parameters to it. Empty parameter lists are old style declarations for unknown number and type of arguments. - Commented out (as `#if DHT_HARDENING` block) the hardening code that was never executed. - Minor style fix: don't use `default` in enum-switches unless the number of enumerators in the default case is very large. In this case, it was 2, so we want to list them both explicitly to be warned about missing one if we add one in the future. - Removed the only two function declarations from nTox.h and put them into nTox.c. They are not used outside and nTox is not a library.
2016-09-06Make friend requests statelessGregory Mullen (grayhatter)
Messenger is slightly twisty when it comes to sending connection status callbacks It will very likely need at the very least a partial refactor to clean it up a bit. Toxcore shouldn't need void *userdata as deep as is currently does. (amend 1) Because of the nature of toxcore connection callbacks, I decided to change this commit from statelessness for connections changes to statelessness for friend requests. It's simpler this was and doesn't include doing anything foolish in the time between commits. group fixup because grayhatter doesn't want to do it "arguably correct" is not how you write security sensitive code Clear a compiler warning about types within a function.
2016-09-05Make packet data a ptr-to-const.iphydf
Ensure that nobody inadvertly modifies the temporary packet data buffer.
2016-09-02Do not use `else` after `return`.iphydf
http://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code
2016-09-01Sort #includes in all source files.iphydf
2016-08-31Add braces to all if statements.iphydf
2016-08-27Move logging to a callback.iphydf
This removes the global logger (which by the way was deleted when the first tox was killed, so other toxes would then stop logging). Various bits of the code now carry a logger or pass it around. It's a bit less transparent now, but now there is no need to have a global logger, and clients can decide what to log and where.
2016-08-26Comment out useless TODO'd if block.iphydf
The condition is a potential use after free, because `connection_kill` before it will delete the `conn` that is dereferenced.
2016-08-18Make tox_callback_friend_name stateless.iphydf
See #27 and #40 for details.
2016-01-30Fixes.irungentoo
Fixed bug from merged PR. Don't build useless files when building with libsodium.
2016-01-27 fix: replace memset with sodium_memzero for sensitive dataRoman Proskuryakov
2016-01-27 fix: compare sensitive data with sodium_memcmpRoman Proskuryakov
fix: make increment_nonce & increment_nonce_number independent of user-controlled input fix: make crypto_core more stable agains null ptr dereference
2015-12-17Fixed possible bug.irungentoo
2015-12-16Less packet spam.irungentoo
2015-11-21Increase max file transfer speed.irungentoo
Fix bug that limited it to 1K packets per second.
2015-11-21More file transfer improvements.irungentoo
2015-11-20File transfer fix.irungentoo
2015-11-20File transfer fix.irungentoo
2015-11-19Send queue size should not affect the speed of packets being resent.irungentoo
2015-11-19Fixed division by 0.irungentoo
2015-11-19Attempted fix of disconnect when switching from TCP to UDP.irungentoo
2015-11-17Send more request packets if packet receive rate is high.irungentoo
2015-11-17Don't spam request packets.irungentoo
2015-11-12Less magic numbers.irungentoo
2015-11-12Remove an old fix that didn't fix anything.irungentoo
2015-11-11Attempted fix of UDP disconnect bug that happens when both ipv4 and ipv6 are ↵irungentoo
connected.
2015-11-11Lower chances of disconnect during file transfers.irungentoo
2015-11-10More file transfer improvements.irungentoo
Use a formula instead of magic numbers.
2015-11-09File transfer fixes.irungentoo
Fixed file transfers disconnecting tox clients from each other in some network conditions.
2015-09-09Increased cookie timeout.irungentoo
2015-07-26This might improve the file transfer disconnect issue.irungentoo
2015-07-07Link changes.irungentoo
2015-06-28Fixed bug.irungentoo
2015-06-25Fixed warning.irungentoo
2015-06-23Added code to net_crypto to calculate rtt.irungentoo
2015-06-21Lower the chances of disconnect when transferring files.irungentoo
2015-06-16Made new_tcp_connections() not depend on dht.irungentoo
2015-05-31Congestion control tweaks.irungentoo
2015-05-21Load only secret key from tox save, not public key.irungentoo
Calculate public key from it.
2015-05-17Some protocol efficiency improvements.irungentoo
Reduced the amount of waste from dropped packets.