Commit Graph

61 Commits

Author SHA1 Message Date
iphydf 8f96ca6d86 Update license headers and remove redundant file name comment.
"All rights reserved" was incorrect. The project was licensed under GPL3,
which means a lot of rights are licensed to everybody in the world, i.e.
not reserved to the "Tox Project".
2017-01-19 00:01:44 +00:00
iphydf ce29c8e7ec Wrap all sodium/nacl functions in crypto_core.c. 2016-12-22 10:26:59 +00:00
iphydf aed24408db Remove new_nonce function in favour of random_nonce.
`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-11-09 22:30:49 +00:00
iphydf 15cb426166 Make toxcore code C++ compatible.
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-24 21:53:50 +01:00
iphydf a8823830d3 Add some astyle options to make it do more.
It now enforces a bit more formatting. In particular, padding inside
parentheses is removed. I would like it to remove padding after unary
operators, but there seems to be no option for that.
2016-09-13 01:07:02 +01:00
iphydf 0aa2840164 Group #include directives in 3-4 groups.
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-13 00:32:02 +01:00
iphydf 77db27331e Sort #includes in all source files. 2016-09-01 16:35:46 +01:00
iphydf 633da98ae6 Add braces to all if statements. 2016-08-31 20:04:16 +01:00
iphydf a5e35180c7 Make tox_callback_friend_name stateless.
See #27 and #40 for details.
2016-08-18 00:01:53 +01:00
Roman Proskuryakov ed3a794c9b fix: compare sensitive data with sodium_memcmp
fix: make increment_nonce & increment_nonce_number independent of user-controlled input
	fix: make crypto_core more stable agains null ptr dereference
2016-01-27 02:14:59 +03:00
irungentoo 760f20c945 DHT improvements part 1. 2016-01-04 20:14:57 -05:00
irungentoo c1e00c5d39 Improved the to_ping list. 2015-12-16 11:28:30 -05:00
irungentoo 30acc33ef6 uint32_t -> unsigned int. 2015-12-08 19:09:38 -05:00
irungentoo feda36e7cf Forgot to stage this before committing. 2015-12-08 18:37:02 -05:00
irungentoo 73b2bce08a If we receive a packet from a node we are searching for, ping it. 2015-12-08 15:43:03 -05:00
irungentoo 6cb8ff4d65 Removed a useless define. 2015-08-07 20:53:53 -04:00
irungentoo dfc154cc9e client_id -> public_key 2015-07-29 22:39:56 -04:00
irungentoo 6a4c2e8fc6 Only set last_to_ping if at least one node was pinged, 2015-05-07 20:58:39 -04:00
irungentoo f463cb52a2 Code cleanups.
Rename array in Node_format from client_id to public_key.
2015-01-29 19:38:44 -05:00
irungentoo 6bbb939855 Cleaned up packet length types in toxcore.
They are now all uint16_t instead of sometimes being uint32_t.

Replaced some other uint32_t with unsigned ints.
2014-11-21 20:18:29 -05:00
irungentoo 1069b85ec4 Tweaked some values in DHT to decrease the discovery time mainly
for the auto tests.
2014-08-31 19:12:47 -04:00
Marc Schütz 4940c4c62b Const correctness for various packet callbacks 2014-06-13 22:55:15 +02:00
Marc Schütz 99d5940140 Const correctness in various interdependent files 2014-06-10 20:54:48 +02:00
irungentoo e85feb8a3d Fixed a bug where someone could just send back the ping request packet
with only the first byte set to 1 instead of 0 and the public key set
to the one of the reciever as a valid response packet.

This breaks network compatibility with all previous cores.
2014-05-19 12:56:36 -04:00
irungentoo a5ff3f8aff Nodes already in the DHT closelist should not be added to the toping list. 2014-05-13 12:14:09 -04:00
irungentoo 10da970e0d Added ping_array, a special efficient array for use in operations
that require sending ping type packets.

Made ping packets use it.
2014-05-12 14:07:03 -04:00
irungentoo 1bfe15ee88 Decided pretty much how the handshake would work.
Started writing the code.

Astyled some files.
2014-04-22 20:28:40 -04:00
irungentoo 9c6a8432ce Crypto related cleanups.
Moved Bunch of functions from net_crypto to crypto_core.

decrypt_data_fast and decrypt_data_symmetric were the same thing
therefore, removed decrypt_data_fast.

Replaced all the crypto_secretbox_* defines with the equivalent
crypto_box_* one.

New define: crypto_box_KEYBYTES that is equal to
crypto_box_BEFORENMBYTES.
2014-04-21 16:51:36 -04:00
irungentoo de079d7cf7 Some speedups and small fixes. 2014-04-16 13:53:51 -04:00
irungentoo f9c9b263e0 Renamed toping to to_ping. 2014-03-16 13:57:21 -04:00
irungentoo 3bcc6e2ae5 CPU optimizations.
Use get_shared_key() in more places.
2014-03-05 16:54:17 -05:00
irungentoo b6fe49e59a CPU usage improvements.
Shared keys for recieved DHT packets are now stored in a special array
so that they don't need to be recomputed for nodes that send us lots of
packets.
2014-03-04 15:36:29 -05:00
irungentoo c0c660c99a Small CPU optimizations to ping requests/reponses.
Same idea as last commit.
2014-03-02 19:46:47 -05:00
irungentoo de69dcef24 Some small DHT CPU optimizations.
Only compute the shared key once instead of twice for received DHT
requests/responses.
2014-03-01 21:18:53 -05:00
irungentoo 86ba735198 Improved hole punching a bit. 2014-01-25 21:09:26 -05:00
irungentoo cd2474a2f6 Incorporated onion into Tox.
Fixed a couple of issues related to that.
2014-01-17 13:35:40 -05:00
irungentoo d5092e7cf8 Cleaned up and fixed various things. 2013-12-08 19:48:18 -05:00
irungentoo 7cd43ecc76 Merge branch 'master' into harden 2013-12-06 22:51:17 -05:00
alexandervdm a93d76a958 fix 'typedef redefinition' build errors on older gcc versions
building toxcore
2013-12-01 21:06:20 +01:00
Coren[m] b132c92b3a Assoc's array is now allocated dynamically and per default much smaller (320 entries).
id_hash() was not at all working as expected for very small bucket size (when (size / 4) was zero). Simplified to be trivially correct.
Also added a used flag on adding an entry, which is set by callers if they have that association in active use. Those get priority over unused entries on collision.
Fleshed out test to be at least elementary useful.
Each group chat now uses an own, small assoc (80 entries).
2013-11-17 01:05:00 +01:00
Coren[m] 0d8329b3a9 Significantly trimmed down version of an ID<=>IP cache.
Besides acknowledging timeouts, the module isn't trying to do anything fancy with the data besides storing and retrieving.
2013-11-14 19:05:53 +01:00
irungentoo 57763f2737 Merge branch 'master' into harden
Conflicts:
	toxcore/DHT.c
2013-11-10 14:32:46 -05:00
Coren[m] aee50435c8 addto_lists(): store the IP/Port that was used to *send*.
Avoids a DOS of sending a copy of a valid response with an invalid IP.
2013-11-06 14:50:55 +01:00
irungentoo 415835ce3d Merge branch 'master' into harden
Also removed some old, useless loading code.
2013-10-28 16:01:29 -04:00
irungentoo 55692665dc Removed now useless ping_id from send/get node packets. 2013-10-24 18:59:00 -04:00
Coren[m] 065495cd7c Merge remote-tracking branch 'upstream/master' into cleanup_unix_time_id_eq_cpy_is_timeout
Conflicts:
	toxcore/net_crypto.c
2013-10-24 22:47:23 +02:00
Coren[m] 0a4c3d7e2e Move unix_time(), id_cpy()/id_eq(), is_timeout() to util.*
unix_time():
- returns local value for current epoch
- value is updated explicitly with unix_time_update() called at new_DHT()/doMessenger()/do_DHT()

is_timeout():
- uses the local value for current epoch

id_cpy()/id_eq() => id_copy()/id_equal():
- centralized duplicate definitions
- replaced (most) memcpy()/memcmp() of (*, *, CLIENT_ID_SIZE) with id_copy()/id_equal()
2013-10-24 22:32:28 +02:00
irungentoo 8e0ab68d30 Removed define that could become confusing. 2013-10-24 13:34:04 -04:00
irungentoo a67b4f8c6d Code cleanups. 2013-10-23 14:32:09 -04:00
irungentoo 3c78aefce0 Fixed bug where hole punching was attempted even though the
clients were connected.

Increased the number of ports tried per interval of time.

Also astyled the files.
2013-09-25 10:07:07 -04:00