Commit Graph

3980 Commits

Author SHA1 Message Date
George Kadianakis
a71999462b Fix test prob distr parameters that caused warnings.
They were causing the following warnings in circuitpadding/circuitpadding_sample_distribution:

     src/lib/math/prob_distr.c:1311:17: runtime error: division by zero
     SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/lib/math/prob_distr.c:1311:17 in
     src/lib/math/prob_distr.c:1219:49: runtime error: division by zero
     SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/lib/math/prob_distr.c:1219:49 in

because the distributions were called with erroneous parameters (e.g. geometric
distribution with p=0).

We now defined these test probability distributions with more realistic
parameters.

As far as the circuitpadding_sample_distribution() test is concerned, it
doesn't matter if the distributions return values outside of [0,10] since we
already restrict the values into that interval using min=0 and max=10 (and RTT
estimate is disabled).
2019-03-13 10:36:26 -04:00
Nick Mathewson
58fd864a85 Merge remote-tracking branch 'tor-github/pr/705' 2019-03-13 09:36:47 -04:00
George Kadianakis
cdaff26f91 circpad: Machines MUST have strictly increasing histogram edges.
Add a basic validation function for the histograms. It can be a building block
for the future
2019-03-13 13:35:52 +02:00
teor
a9c3101e21 test/sr: Clear SRVs after init, and before setup
Part of 29706.
2019-03-13 15:29:46 +10:00
Nick Mathewson
065b74fa36 Fix all nonconformant headers' guard macros. 2019-03-12 15:20:22 -04:00
George Kadianakis
18a4f535d3 Merge branch 'maint-0.4.0' 2019-03-12 18:11:53 +02:00
George Kadianakis
0ce32affc2 Merge branch 'tor-github/pr/763' into maint-0.4.0 2019-03-12 18:11:35 +02:00
Nick Mathewson
61adcb22c5 Merge branch 'bug23576-041-rebased-squashed' 2019-03-12 11:10:01 -04:00
teor
257cea8876 test/hs: minor hs test fixes
Cleanup some bugs discovered during 23576:

* stop copying the first 20 characters of a 40-character hex string
  to a binary fingerprint
* stop putting IPv6 addresses in a variable called "ipv4"
* explain why we do a duplicate tt_int_op() to deliberately fail and
  print a value

Fixes bug 29243; bugfix on 0.3.2.1-alpha.
2019-03-12 11:09:53 -04:00
teor
bb98bc8562 hs: abolish hs_desc_link_specifier_t
The previous commits for 23576 confused hs_desc_link_specifier_t
and link_specifier_t. Removing hs_desc_link_specifier_t fixes this
confusion.

Fixes bug 22781; bugfix on 0.3.2.1-alpha.
2019-03-12 11:09:53 -04:00
Nick Mathewson
c01c6123fa Merge remote-tracking branch 'tor-github/pr/779' 2019-03-12 11:05:27 -04:00
Nick Mathewson
1c9b629284 Merge branch 'maint-0.4.0' 2019-03-12 11:03:47 -04:00
Nick Mathewson
9c9214f2c9 Merge remote-tracking branch 'tor-github/pr/776' into maint-0.4.0 2019-03-12 11:03:37 -04:00
rl1987
e52653e01a USe uintptr_t for unsigned ints 2019-03-12 12:14:22 +02:00
rl1987
052ec08a08 Refrain from doing exhaustive iteration over all values of integers 2019-03-12 12:01:26 +02:00
teor
dfc3e552a3
test/sr: update sr_state_free() to sr_state_free_all()
The function name changed between 0.2.9 and 0.3.4.
2019-03-12 11:34:52 +10:00
teor
c7854933e9
Merge branch bug29706_029_refactor into bug29706_034_refactor 2019-03-12 11:31:52 +10:00
teor
0cca554110 sr: Check for replacing a SRV pointer with the same pointer
Check if the new pointer is the same as the old one: if it is, it's
probably a bug:
* the caller may have confused current and previous, or
* they may have forgotten to sr_srv_dup().

Putting NULL multiple times is allowed.

Part of 29706.
2019-03-12 11:14:30 +10:00
rl1987
4773fa6474 Revert "Walk back from requiring bash"
This reverts commit c346eff223.
2019-03-10 18:16:58 +02:00
teor
593fde930f sr: rename srv_dup() to sr_srv_dup() 2019-03-09 12:03:12 +10:00
teor
26e6f56023 sr: Free SRVs before replacing them in state_query_put_()
Refactor the shared random state's memory management so that it actually
takes ownership of the shared random value pointers.

Fixes bug 29706; bugfix on 0.2.9.1-alpha.
2019-03-09 12:03:00 +10:00
teor
9400da9b5e test/sr: Free SRVs before replacing them in test_sr_setup_srv()
Stop leaking parts of the shared random state in the shared-random unit
tests. The previous fix in 29599 was incomplete.

Fixes bug 29706; bugfix on 0.2.9.1-alpha.
2019-03-09 11:59:52 +10:00
teor
e91b999cf2
Merge branch 'bug23512-v4-029-fixes-keep-typedef' into bug23512-v4-034-fixes 2019-03-08 19:37:18 +10:00
teor
08ddf1f62b
Merge remote-tracking branch 'bug28525_029' into maint-0.3.5 2019-03-08 12:33:00 +10:00
Neel Chauhan
63b4049114
Make tor_addr_is_internal_() RFC6598 (Carrier Grade NAT) aware
Fixes 28525.
2019-03-08 12:19:12 +10:00
Nick Mathewson
72751f0c30 Merge remote-tracking branch 'tor-github/pr/680' 2019-03-05 11:53:31 -05:00
George Kadianakis
c5da1f1cd5 Merge branch 'tor-github/pr/723' 2019-03-04 18:55:28 +02:00
Nick Mathewson
cb0d403049 Merge remote-tracking branch 'tor-github/pr/677' 2019-03-01 08:22:43 -05:00
teor
c1ab538479
Merge remote-tracking branch 'tor-github/pr/748' into maint-0.2.9 2019-03-01 14:14:51 +10:00
teor
de0969ef78
Merge branch 'maint-0.3.4' into maint-0.3.5 2019-02-28 10:49:33 +10:00
teor
6a61a020ee
Merge branch 'maint-0.3.3' into maint-0.3.4 2019-02-28 10:49:19 +10:00
teor
be29dfedd9
Merge branch 'maint-0.3.4' into maint-0.3.5 2019-02-28 10:45:59 +10:00
teor
524731503e
Merge branch 'maint-0.3.3' into maint-0.3.4 2019-02-28 10:45:44 +10:00
teor
3313444ef0
Merge branch 'maint-0.2.9' into maint-0.3.3 2019-02-28 10:45:30 +10:00
Nick Mathewson
761eb4cf79 Merge branch 'maint-0.4.0' 2019-02-27 09:59:42 -05:00
Nick Mathewson
56f01e58b4 Merge remote-tracking branch 'tor-github/pr/731' into maint-0.4.0 2019-02-27 09:59:33 -05:00
teor
d4b7975ce7 test/shared-random: use sr_state_free_all() rather than sr_state_free()
sr_state_free() was renamed to sr_state_free_all() between 0.2.9 and 0.3.3.

Part of 29599.
2019-02-27 15:06:53 +10:00
teor
64e082e892 Merge branch 'bug29599_029' into bug29599_033 2019-02-27 15:06:39 +10:00
teor
4d9eb4dd0e test/shared-random: Stop leaking shared random state in the unit tests
Stop leaking parts of the shared random state in the shared-random unit
tests.

Fixes bug 29599; bugfix on 0.2.9.1-alpha.
2019-02-27 15:04:40 +10:00
teor
15dc33849e
Merge branch 'maint-0.3.4' into maint-0.3.5 2019-02-27 09:38:04 +10:00
teor
1a194beb2c
Merge branch 'maint-0.3.3' into maint-0.3.4 2019-02-27 09:37:50 +10:00
teor
6c966b894c
Merge branch 'maint-0.2.9' into maint-0.3.3 2019-02-27 09:37:36 +10:00
David Goulet
b402a0887f Merge branch 'tor-github/pr/655' 2019-02-26 11:30:44 -05:00
George Kadianakis
7fbfdf2af7 Merge branch 'tor-github/pr/611' 2019-02-26 12:33:23 +02:00
Nick Mathewson
e138bb8ffc
Downgrade some LOG_ERR messages in the address/* tests to warnings
Fixes bug 29530, where the LOG_ERR messages were occurring when
we had no configured network, and so we were failing the unit tests
because of the recently-merged #28668.

Commit message edited by teor:

We backported 28668 and released it in 0.3.5.8.
This commit backports 29530 to 0.3.5.

Fixes bug 29530 in Tor 0.3.5.8.
2019-02-26 09:53:59 +10:00
Nick Mathewson
626e6d2c39 Merge remote-tracking branch 'tor-github/pr/684' 2019-02-25 13:33:39 -05:00
rl1987
d731ab4583 Check that all valid values of int and unsigned int can be put into void pointer 2019-02-25 20:04:02 +02:00
Nick Mathewson
065e7da8e6 Re-enable and fix unit test for nofork mappings
This test was previously written to use the contents of the system
headers to decide whether INHERIT_NONE or INHERIT_ZERO was going to
work.  But that won't work across different environments, such as
(for example) when the kernel doesn't match the headers.  Instead,
we add a testing-only feature to the code to track which of these
options actually worked, and verify that it behaved as we expected.

Closes ticket 29541; bugfix not on any released version of Tor.
2019-02-25 08:55:25 -05:00
George Kadianakis
331a067ae3 Fix dist_min_usec documentation and naming. 2019-02-25 13:46:58 +02:00
George Kadianakis
341cd6ea66 histogram_edges is histogram_len long 2019-02-25 13:28:35 +02:00
Nick Mathewson
34601105a3 Merge branch 'ticket29065_squashed' 2019-02-24 17:02:35 -05:00
rl1987
b7dced893a Fix shellcheck SC2006 warnings in test_switch_id.sh 2019-02-24 17:02:06 -05:00
George Kadianakis
f229a33685 Merge remote-tracking branch 'nickm/thread_rng' 2019-02-22 16:07:57 +02:00
rl1987
c346eff223 Walk back from requiring bash
Refrain from using bash array to remember $@.
2019-02-21 21:09:40 +02:00
Nick Mathewson
aa79196ee0 Merge branch 'maint-0.4.0' 2019-02-21 09:10:34 -05:00
Nick Mathewson
34183f0d71 Fix a goofy change from abcde10fce that broke test-slow linking
boklm tracked this down, and it doesn't make sense.  It caused

This change goes back to the previous LDFLAGS line.
2019-02-21 09:10:15 -05:00
David Goulet
da179088ee Merge branch 'tor-github/pr/687' 2019-02-20 12:09:02 -05:00
David Goulet
7037fe1163 Merge branch 'tor-github/pr/700' 2019-02-20 12:06:39 -05:00
rl1987
b7ad8bcaad Use setrlimit instead of ulimit -c in backtrace tests 2019-02-20 12:06:26 -05:00
Roger Dingledine
c22446e305 Merge branch 'maint-0.4.0' 2019-02-20 10:40:20 -05:00
Roger Dingledine
5ec65be8bf Merge remote-tracking branch 'nickm/ticket29530_040' into maint-0.4.0 2019-02-20 10:39:28 -05:00
Roger Dingledine
4d4eda89a1 Merge branch 'maint-0.4.0' 2019-02-20 10:36:54 -05:00
Nick Mathewson
208f04e9b8 Add a quick test for get_thread_fast_rng() 2019-02-19 15:36:11 -05:00
Nick Mathewson
d32e407976 Downgrade some LOG_ERR messages in the address/* tests to warnings
Fixes bug 29530, where the LOG_ERR messages were occurring when
we had no configured network, and so we were failing the unit tests
because of the recently-merged #28668.

Bug not in any released Tor.
2019-02-19 14:02:32 -05:00
Nick Mathewson
c9ff6a7f83 Mark map_anon_nofork test as skipped in 0.4.0
This test fails in some environments; since the code isn't used in
0.4.0, let's disable it for now.

Band-aid solution for #29534; bug not in any released Tor.
2019-02-19 13:14:26 -05:00
Nick Mathewson
6927e9a60c Merge remote-tracking branch 'tor-github/pr/665' 2019-02-19 11:56:48 -05:00
Nick Mathewson
f70929347f Merge branch 'maint-0.4.0' 2019-02-19 11:49:24 -05:00
Nick Mathewson
4bc55ed5ee Merge branch 'bug29145_029' into maint-0.4.0 2019-02-19 11:49:20 -05:00
Kris Katterjohn
4417ac880a Fix a compiler warning on OpenBSD
malloc_options needs to be declared extern (and declaring it extern
means we need to initialize it separately)

Fixes bug 29145; bugfix on 0.2.9.3-alpha

Signed-off-by: Kris Katterjohn <katterjohn@gmail.com>
2019-02-19 11:38:32 -05:00
Nick Mathewson
17e29bda5d Merge branch 'maint-0.4.0' 2019-02-19 11:34:25 -05:00
Nick Mathewson
b5f3a3d6a7 Merge remote-tracking branch 'tor-github/pr/707' into maint-0.4.0 2019-02-19 11:34:21 -05:00
Nick Mathewson
1239e411a7 Merge remote-tracking branch 'tor-github/pr/694' 2019-02-19 11:31:22 -05:00
Nick Mathewson
0db0b4769c Merge remote-tracking branch 'tor-github/pr/678' 2019-02-19 11:30:27 -05:00
Nick Mathewson
5c87add923 Merge remote-tracking branch 'tor-github/pr/701' into maint-0.4.0 2019-02-19 11:21:51 -05:00
teor
6c652eae0a fixup! test_dir: Refactor common code out of the dir_format unit tests 2019-02-20 00:40:18 +10:00
teor
39ab6c9f73 test_dir: Test descriptor variants
Including:
* relays and bridges,
* no stats, basic stats, and all stats

Part of 29017 and 29018.
2019-02-19 21:54:13 +10:00
teor
38fc52a50e test_dir: Refactor common code out of the dir_format unit tests
Also:
* delete some obsolete code that was #if 0
* improve cleanup on failure
* make the dir_format tests more consistent with each other
* construct the descriptors using smartlist chunks

This refactor is incomplete, because removing the remaining duplicate
code would be time-consuming.

Part of 29017 and 29018.
2019-02-19 21:54:13 +10:00
teor
8e5df40018 test_dir: Test rsa + ed25519 extrainfo creation and parsing
Also fix a missing mock in rsa-only parsing.
2019-02-19 21:44:41 +10:00
teor
7a2c8daded test_dir: Split test_dir_formats into separate rsa and rsa_ed25519 tests 2019-02-19 21:44:40 +10:00
teor
53b49d1a35 test_dir: Unit tests for RSA-only router and extrainfo descriptor creation
Tests 29017 and 29018.
2019-02-19 21:44:40 +10:00
teor
7c9450fb07 test_router: Add comment to explain mocking
Add comment in
test_router_dump_router_to_string_no_bridge_distribution_method to explain
the effect of a mocked function.
2019-02-19 21:43:12 +10:00
Neel Chauhan
384c5c6188 Make test-slow compile with libevent 2019-02-16 16:03:17 -05:00
George Kadianakis
3093d8afbe Fix tests to use the new design.
- All histogram tests were using start_usec/range_usec. We now manually specify
  the edges.
- Also add a test for histogram_get_bin_upper_bound().
2019-02-15 17:43:41 +02:00
George Kadianakis
98af25e013 Remove start_usec/range_usec and make equivalent fields for distributions. 2019-02-15 17:43:01 +02:00
David Goulet
6c173d00f5 Merge branch 'tor-github/pr/702' 2019-02-14 11:43:10 -05:00
George Kadianakis
9bfe4ed6dd Merge branch 'tor-github/pr/536' into maint-0.3.5 2019-02-14 17:39:34 +02:00
Nick Mathewson
6a29aa7b8c Add whitebox test for the long-output optimization of fast_rng 2019-02-14 09:26:40 -05:00
Nick Mathewson
3f28b98220 Add test for crypto_fast_rng_get_double(). 2019-02-14 09:26:40 -05:00
Nick Mathewson
acbde10fce Add a test-rng program so we can pipe to dieharder. 2019-02-14 09:26:40 -05:00
Nick Mathewson
490e187056 Add a benchmark for our several PRNGs. 2019-02-14 09:26:40 -05:00
Nick Mathewson
f3cbd6426c Implement a fast aes-ctr prng
This module is currently implemented to use the same technique as
libottery (later used by the bsds' arc4random replacement), using
AES-CTR-256 as its underlying stream cipher.  It's backtracking-
resistant immediately after each call, and prediction-resistant
after a while.

Here's how it works:

We generate psuedorandom bytes using AES-CTR-256.  We generate BUFLEN bytes
at a time.  When we do this, we keep the first SEED_LEN bytes as the key
and the IV for our next invocation of AES_CTR, and yield the remaining
BUFLEN - SEED_LEN bytes to the user as they invoke the PRNG.  As we yield
bytes to the user, we clear them from the buffer.

Every RESEED_AFTER times we refill the buffer, we mix in an additional
SEED_LEN bytes from our strong PRNG into the seed.

If the user ever asks for a huge number of bytes at once, we pull SEED_LEN
bytes from the PRNG and use them with our stream cipher to fill the user's
request.
2019-02-14 09:26:40 -05:00
Nick Mathewson
3d3578ab41 Extract RNG tests into a new test module
test_crypto.c is pretty big; it wouldn't hurt to split it up some
more before I start adding stuff to the PRNG tests.
2019-02-14 09:26:40 -05:00
George Kadianakis
f5a6d4c6ea Disable unstable circuit padding unittest.
until #29298 is implemented.
2019-02-14 12:09:41 +02:00
Nick Mathewson
5f42bc0f48 Merge remote-tracking branch 'tor-github/pr/699' 2019-02-13 15:19:59 -05:00
David Goulet
d5de1a0a55 Merge branch 'tor-github/pr/651' 2019-02-13 11:02:02 -05:00
David Goulet
6efc2a0e1f Merge branch 'tor-github/pr/650' into maint-0.3.5 2019-02-13 10:56:24 -05:00
rl1987
ad48aab056 Let's not double-quote EXTRA_CARGO_OPTIONS after all 2019-02-13 15:04:12 +02:00
rl1987
4f9061868b Use env to find bash 2019-02-13 14:51:42 +02:00
juga0
28490fa23e test: Add test to get the digest of a bw file 2019-02-13 12:26:00 +00:00
juga0
fc3e90a7b6 bwauth: Add function to get the digest of a bw file 2019-02-13 12:26:00 +00:00