Commit Graph

32 Commits

Author SHA1 Message Date
iphydf
6ae33c16cf
Add VLA compatibility macro for C89-ish compilers. 2017-01-28 20:49:12 +00:00
iphydf
db71602731
Use tox_options_set_* instead of direct member access.
Also added a `tox_options_copy` function for cloning an options object.
This can be useful when creating several Tox instances with slightly
varying options.
2016-12-22 10:53:39 +00:00
iphydf
ce29c8e7ec
Wrap all sodium/nacl functions in crypto_core.c. 2016-12-22 10:26:59 +00:00
iphydf
4cf69996cc
Add apidsl file for toxencryptsave.
This breaks the toxencryptsave API. It hides the Tox_Pass_Key struct
definition.
2016-12-13 14:24:40 +00:00
iphydf
82515f92ee
Move log callback to options.
Previously, all log messages generated by tox_new (which is quite a lot)
were dropped, because client code had no chance to register a logging
callback, yet. This change allows setting the log callback from the
beginning and removes the ability to unset it.

Since the log callback is forever special, since it can't be stateless,
we don't necessarily need to treat it uniformly (with `event`).
2016-11-06 20:35:09 +00:00
iphydf
1977d56caa
Remove return after no-return situation (and other cleanups).
Cleanups:
- Fix header guards to not use reserved names.
- Avoid name shadowing.
- Removed an unused variable found by avoiding name shadowing.
2016-09-30 19:06:44 +01:00
iphydf
0d347c2b2e
Minor cleanups: unused vars, unreachable code, static globals.
- All global variables should be static unless they have an explicit
  extern declaration in a header file.
- `to_compare` was not used in encryptsave and toxav tests.
- `break` in switch cases is not required directly after `return`,
  `goto`, or a noreturn function like `abort`.
2016-09-24 20:52:09 +01:00
iphydf
ad26560516
Improve static and const correctness.
- 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-06 11:54:37 +01:00
Gregory Mullen (grayhatter)
aad1e0ad3f
Make friend requests stateless
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-06 02:22:04 -07: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
6935643f9a
Fix some compiler warnings. 2016-08-18 17:10:15 +01:00
iphydf
fc330c1fa5
Silence/fix some compiler warnings.
Some of these (like the incompatible pointers one) are really annoying for
later refactoring.
2016-08-10 13:52:40 +01:00
irungentoo
dfe5d9b256
Fixes.
Fixed bug from merged PR.

Don't build useless files when building with libsodium.
2016-01-30 17:23:15 -05:00
irungentoo
3f6a8f10bb
Allow empty keys in toxencryptsave. 2015-05-27 19:54:04 -04:00
irungentoo
8e80ced6ce
Move savedata to options struct.
Add a way to select the type of savedata (normal savedata, load a
secret key, potentially others?) to load.
2015-05-22 18:23:56 -04:00
Dubslow
f7beee495e
Make keys into a struct for more programmer safety 2015-03-31 21:16:04 -05:00
Dubslow
9b66c57bd0
Fix minor code duplication 2015-03-31 19:30:09 -05:00
irungentoo
99e0fde297
Merge branch 'master' of https://github.com/dubslow/toxcore 2015-03-31 19:44:51 -04:00
Dubslow
e998aca8f7
Fix toxencryptsave to be consistent with new_api
Upon my own decision, the two tox_encryped_new convenience functions were removed due to basically needing two different sets of error codes.
At iphydf's suggestion the corresponding tox_get_encrypted_savedata convenience functions were removed as well.
2015-03-31 18:31:23 -05:00
irungentoo
06b389ea5e
Making tox_encrypted_new() use the same error codes as tox_new was a bad idea.
They now have their own error codes.
2015-03-26 12:39:09 -04:00
irungentoo
36c3a270fd
Properly fixed encryptsave_test.c 2015-03-01 20:31:55 -05:00
Dubslow
2d3077904e
Update encryption autotest 2015-02-28 12:55:40 -06:00
irungentoo
78ea33b3f0
Fixed test. 2015-02-08 17:34:49 -05:00
irungentoo
89f2436fac
Astyle autotests. 2014-11-25 15:31:46 -05:00
dubslow
d90ee9d4e4 fix #1124 by adding salt manip functions
Also, all data now has the magic number prepended. This is incompatible
for all but the save/load functions, but I think nothing besides the one
experimental qTox branch used any of those, which is why I feel confident
about the change.
2014-10-23 04:19:18 -05:00
dubslow
ff1d4faa74 add new test cases, cleanup astray printf 2014-10-17 09:23:21 -05:00
dubslow
ffb13e4716 add load/save from key instead of pw 2014-10-17 06:02:15 -05:00
dubslow
e6f30694d3 refactor toxencryptedsave to allow passphrase encryption of arbitrary data
also a minor API change for clarity
2014-10-08 18:50:40 -05:00
dubslow
eee37b5767 fix #1104 2014-10-07 21:53:04 -05:00
Dubslow
c26c6d86ae memzero() segfaulted for unknown reasons... probably pebkac... 2014-09-11 22:42:22 -05:00
Dubslow
26566666aa testing works, but doesn't pass... 2014-09-11 21:28:50 -05:00