Commit Graph

21523 Commits

Author SHA1 Message Date
George Kadianakis 1d2333405e Remove now useless rev counter state file code.
We are not using the state file for rev counters anymore, we just generate them
on the fly!
2018-07-17 15:57:46 -04:00
George Kadianakis 2e8d4139a7 Fix up some unittests by being more careful with the local time.
Now that the rev counter depends on the local time, we need to be more careful
in the unittests. Some unittests were breaking because they were using
consensus values from 1985, but they were not updating the local time
appropriately. That was causing the OPE module to complain that it was trying
to encrypt insanely large values.
2018-07-17 15:57:46 -04:00
George Kadianakis 5fb6f656df Use approx_time() instead of time(NULL) in some HS functions.
These were breaking our unittests.
2018-07-17 15:57:46 -04:00
George Kadianakis 05c362274b Compute the description revision counter using the OPE scheme.
To do so for a given descriptor, we use the "seconds since the SR protocol run"
started, for the SRV that is relevant to this descriptor. This is guaranteed to
be a positive value (since we need an SRV to be able to build a descriptor),
and it's also guaranteed to be a small value (since SRVs stop being listed on a
consensus after 48 hours).

We cannot use the "seconds since the time period started", because for the next
descriptor we use the next time period, so the timestamp would end up negative.
See [SERVICEUPLOAD] from rend-spec-v3.txt for more details.

To do so, we have to introduce a new `is_current` argument to a bunch of
functions, because to use "seconds since the SR protocol run" we need to know
if we are building the current or the next descriptor, since we use a different
SRV for each descriptor.
2018-07-17 15:57:46 -04:00
George Kadianakis deec6913c5 Introduce useful SRV funcs (start time of prev protocol run) 2018-07-17 15:57:46 -04:00
George Kadianakis 34a5eb5904 Increase OPE_INPUT_MAX. 2018-07-17 15:57:46 -04:00
Nick Mathewson 3a45f6ffe9 Implementation for a simple order-preserving encryption scheme.
This is meant for use when encrypting the current time within the
period in order to get a monotonically increasing revision counter
without actually revealing our view of the time.

This scheme is far from the most state-of-the-art: don't use it for
anything else without careful analysis by somebody much smarter than
I am.

See ticket #25552 for some rationale for this logic.
2018-07-17 15:57:46 -04:00
Nick Mathewson 58fc42fdce Fix comments in lib/container/*.c 2018-06-26 11:33:53 -04:00
Nick Mathewson 92d8284a97 Merge branch 'log_dependencies' 2018-06-26 11:27:33 -04:00
Nick Mathewson b556894ef2 Include stdio.h in torerr.c. 2018-06-25 16:52:14 -04:00
Nick Mathewson b059c38d8a Merge branch 'maint-0.3.4' 2018-06-25 13:50:37 -04:00
Roger Dingledine 04b350b476 better log line for debugging #26485 2018-06-24 18:14:24 -04:00
Roger Dingledine 73ae92dc52 we've never been good at using "directory" well as a noun 2018-06-24 18:08:24 -04:00
Nick Mathewson d85fbc9a58 Add some casts to get test_dir.c compiling on windows.
Fixed bug 26479.  Bug introduced by 0a6f4627a4292e4; bug not in any
released version.
2018-06-24 14:06:39 -04:00
Nick Mathewson 3cc0a145bd Fix test_geoip failures on windows by writing file in binary mode.
Fixes bug 26480; bug appeared when we re-enabled the geoip tests on
windows.  Bug originally introduced by our fix to 25787; bug not in
any released Tor.
2018-06-24 14:06:05 -04:00
Nick Mathewson 1b93b065fc Make an inline static so we can build with coverage enabled. 2018-06-22 14:11:37 -04:00
Nick Mathewson 405fa42e8a Another windows include 2018-06-22 13:52:30 -04:00
Nick Mathewson 4b32446a4c We also need torerr in tm_cvt. 2018-06-22 13:34:35 -04:00
Nick Mathewson 145665abcb Add another include for windows, and change a log to a raw_assert 2018-06-22 13:33:48 -04:00
Nick Mathewson 76a717890e Remove an "m" that did not belong. 2018-06-22 13:32:47 -04:00
Nick Mathewson 4118ba67db Update the micro-revision.i dependencies, and add a stdlib.h 2018-06-22 13:25:58 -04:00
Nick Mathewson cf66544941 Two more small changes for CI. 2018-06-22 13:10:52 -04:00
Nick Mathewson 7aecea79cb A pair of missing includes. 2018-06-22 12:53:57 -04:00
Nick Mathewson b0adf2fc9b Fix up the rust build script library list. 2018-06-22 12:04:11 -04:00
Nick Mathewson bcf3e546d1 Move util_bug into libtor-log 2018-06-22 11:54:38 -04:00
Nick Mathewson 6fc2d53227 Remove util_bug dependency on compat.h 2018-06-22 11:51:58 -04:00
Nick Mathewson 7a93ce8f63 Update .gitignore and .may_include files 2018-06-22 11:46:44 -04:00
Nick Mathewson 79f73ab330 Finally extract the log library and make it build.
This patch:
  - introduces an fdio module for low-level fd functions that don't
    need to log.
  - moves the responsibility for opening files outside of torlog.c,
    so it won't need to call tor_open_cloexec.
2018-06-22 11:40:20 -04:00
Nick Mathewson 90a09df5ba Extract strlcpy and strlcmp to libtor-string 2018-06-22 11:18:19 -04:00
Nick Mathewson bfb39164ce Extract core part of gmtime_r, localtime_r (without logging) 2018-06-22 11:17:11 -04:00
Nick Mathewson b2d4e786b7 Remove the util_bug.h include from smartlist.h.
This change makes a whole bunch of things in torlog.c break, since
apparently I did not find all the fd dependencies.
2018-06-22 10:50:14 -04:00
Nick Mathewson da4ae8a6b6 Automated fixup of include paths after torlog.h movement. 2018-06-22 10:32:10 -04:00
Nick Mathewson 97b15a1d7c Extract the locking and logging code
The locking code gets its own module, since it's more fundamental
than the higher-level locking code.

Extracting the logging code was the whole point here. :)
2018-06-22 10:31:51 -04:00
Nick Mathewson 2cf033f238 Extract simple integer math into its own module 2018-06-22 09:49:13 -04:00
Nick Mathewson 3883338c81 Move smartlist_add_{v,}asprintf into smartlist.[ch]
Now that I know that "strings" nests below "container", I know this
is safe.
2018-06-22 09:49:13 -04:00
Nick Mathewson 1abadee3fd Extract key string manipulation functions into a new library. 2018-06-22 09:49:13 -04:00
Nick Mathewson 1e07b4031e Move ARRAY_LENGTH to compiler_compat.h 2018-06-22 09:49:13 -04:00
Nick Mathewson 0932f32291 Remove compat.h as unneeded from log.c and torlog.h 2018-06-22 09:49:13 -04:00
Nick Mathewson 9426751b72 Extract our code for answering "what time is it right now".
The other time stuff is higher-level
2018-06-22 09:49:13 -04:00
Nick Mathewson d1cada5a8a Update permissible includes 2018-06-22 09:49:13 -04:00
Nick Mathewson c2a558a346 Expunge container.h 2018-06-22 09:49:13 -04:00
Nick Mathewson de508c5f50 Extract smartlist.h from container.h 2018-06-22 09:49:13 -04:00
Nick Mathewson 9cf6fc91b1 Remove map from container.h 2018-06-22 09:49:13 -04:00
Nick Mathewson 50a5954003 Remove bloom filters, order statistics, and bitarrays from container.h 2018-06-22 09:49:13 -04:00
Nick Mathewson 932b4d0a43 Remove container->crypto dependency
Containers were using crypto_digest.h, just to see the value of
DIGEST_LEN.  Moved those constants into a new defs module.
2018-06-22 09:49:13 -04:00
Nick Mathewson 479c2ab503 Move STRUCT_VAR_P to compat_compiler. 2018-06-22 09:49:13 -04:00
Nick Mathewson 657ff55408 Split container.c based on container types, and minimize includes
Minimizing includes revealed other places includes were necessary.
2018-06-22 09:49:13 -04:00
Nick Mathewson b8be8265b6 Rectify include paths after container split (automatic) 2018-06-22 09:49:13 -04:00
Nick Mathewson 77dff00b18 Refactor container into a library. 2018-06-22 09:49:13 -04:00
Nick Mathewson f95e3bf5fc Simplify include structure of container.[ch] 2018-06-21 15:33:25 -04:00