Commit Graph

2169 Commits

Author SHA1 Message Date
teor
e8ce57e6e8
Move a comment in test_single_onion_poisoning 2016-12-03 06:30:58 +11:00
teor
8d42aab3f6
Add a missing return value check in test_single_onion_poisoning 2016-12-03 06:30:06 +11:00
teor
fdd368d656
Remove a double-free in test_single_onion_poisoning
We were freeing both dir{1,2} directly, and service_{1,2}->directory via
rend_service_free, even though they are the same pointer.
2016-12-03 06:27:32 +11:00
teor
c100c5c69b
Refactor poison_dir allocation and free in test_single_onion_poisoning
This pattern is much less error-prone when future changes are made.
2016-12-03 06:25:46 +11:00
Nick Mathewson
6f101f96a6 Merge branch 'maint-0.2.9' 2016-12-02 07:40:53 -05:00
Nick Mathewson
1221c5aa02 test_single_onion_poisoning: Free dir[12] on all paths
Coverity doesn't like it when there are paths to the end of the
function where something doesn't get freed, even when those paths
are only reachable on unit test failure.

Fixes CID 1372899 and CID 1372900. Bug not in any released Tor.
2016-12-02 07:39:14 -05:00
Nick Mathewson
5efbd41daa Merge branch 'maint-0.2.9' 2016-12-01 09:50:17 -05:00
Nick Mathewson
f8a7972b29 Merge branch 'bug20638_029_v2_squashed' into maint-0.2.9 2016-12-01 09:45:14 -05:00
teor
f80a43d16f Stop ignoring hidden service key anonymity when first starting tor
Instead, refuse to start tor if any hidden service key has been used in
a different hidden service anonymity mode.

Fixes bug 20638; bugfix on 17178 in 0.2.9.3-alpha; reported by ahf.

The original single onion service poisoning code checked poisoning state
in options_validate, and poisoned in options_act. This was problematic,
because the global array of hidden services had not been populated in
options_validate (and there were ordrering issues with hidden service
directory creation).

This patch fixes this issue in rend_service_check_dir_and_add, which:
* creates the directory, or checks permissions on an existing directory, then
* checks the poisoning state of the directory, then
* poisons the directory.

When validating, only the permissions checks and the poisoning state checks
are perfomed (the directory is not modified).
2016-12-01 09:44:53 -05:00
teor
91abd60cad Update unit tests for 20484, 20529
Add extra logging and extra validity checks for hidden services.
2016-12-01 09:44:53 -05:00
Nick Mathewson
a7762930c3 Merge remote-tracking branch 'dgoulet/ticket20568_030_01' 2016-12-01 09:23:36 -05:00
Nick Mathewson
858c8f5593 Make new prop271 entry guards persistent
To do this, it makes sense to treat legacy guards as a separate
guard_selection_t *, and handle them separately.  This also means we
add support here for having multiple guard selections.

Note that we don't persist pathbias information yet; that will take
some refactoring.
2016-11-30 14:44:43 -05:00
Nick Mathewson
dbbaa51518 Use the new guard notification/selection APIs throughout Tor
This patch doesn't cover every case; omitted cases are marked with
"XXXX prop271", as usual.  It leaves both the old interface and the
new interface for guard status notification, since they don't
actually work in the same way: the new API wants to be told when a
circuit has failed or succeeded, whereas the old API wants to know
when a channel has failed or succeeded.

I ran into some trouble with directory guard stuff, since when we
pick the directory guard, we don't actually have a circuit to
associate it with.  I solved that by allowing guard states to be
associated with directory connections, not just circuits.
2016-11-30 14:42:53 -05:00
Nick Mathewson
8dc6048c02 Add an (as yet) unused UseDeprecatedGuardAlgorithm_ option.
I expect we'll be ripping this out somewhere in 0.3.0, but let's
keep it around for a little while in case it turns out to be the
only way to avert disaster?
2016-11-30 14:42:53 -05:00
Nick Mathewson
7bf946965b Implement most of the prop271 data structure backends.
This code handles:
  * Maintaining the sampled set, the filtered set, and the
    usable_filtered set.
  * Maintaining the confirmed and primary guard lists.
  * Picking guards for circuits, and updating guard state when
    circuit state changes.

Additionally, I've done code structure movement: even more constants
and structures from entrynodes.c have become ENTRYNODES_PRIVATE
fields of entrynodes.h.

I've also included a bunch of documentation and a bunch of unit
tests.  Coverage on the new code is pretty high.

I've noted important things to resolve before this branch is done
with the /XXXX.*prop271/ regex.
2016-11-30 14:42:52 -05:00
Nick Mathewson
21c47c4410 Add a smartlist_remove_keeporder() function, with tests. 2016-11-30 14:42:52 -05:00
Nick Mathewson
8da24c99bd Split bridge functions into a new module.
This patch is just:
   * Code movement
   * Adding headers here and there as needed
   * Adding a bridges_free_all() with a call to it.

It breaks compilation, since the bridge code needed to make exactly
2 calls into entrynodes.c internals.  I'll fix those in the next
commit.
2016-11-30 14:42:52 -05:00
Nick Mathewson
dd6def5daf Initial code to parse/encode/sample prop271 guards
The encoding code is very straightforward.  The decoding code is a
bit tricky, but clean-ish.  The sampling code is untested and
probably needs more work.
2016-11-30 14:42:52 -05:00
Nick Mathewson
539eba0a4b Teach parse_iso_time about the spaceless variant.
(We previously added support for generating the spaceless
2016-11-14T19:58:12 variant, but not for actually parsing it.)
2016-11-30 14:42:52 -05:00
Nick Mathewson
823357dbe4 Add an entry_guard_describe() function
This function helpfully removes all but one remaining use of
an entry_guard_t private field in pathbias.c
2016-11-30 14:42:52 -05:00
Nick Mathewson
be447bc770 Move path-bias fields into a separate structure
(Other than the field movement, the code changes here are just
search-and-replace)
2016-11-30 14:42:52 -05:00
Chelsea H. Komlo
c86bbdd3ae
adding documentation to extracted unit test helper 2016-11-24 08:12:36 -05:00
Chelsea H. Komlo
118bba7622
Refactor to remove unnecessary check in circuit_is_available_for_use 2016-11-24 08:12:33 -05:00
Chelsea H. Komlo
afb6ae7b0f
Refactor circuit_predict_and_launch_new 2016-11-24 08:12:30 -05:00
Chelsea H. Komlo
b95998ef0c
moving useful test helper to test_helpers.h 2016-11-24 08:12:27 -05:00
Nick Mathewson
c35d481f56 Merge branch 'maint-0.2.9' 2016-11-21 12:44:21 -05:00
Nick Mathewson
e2c881487c Merge remote-tracking branch 'arma/bug20423' into maint-0.2.9 2016-11-21 12:40:08 -05:00
Nick Mathewson
427dcb29b5 Merge branch 'maint-0.2.9' 2016-11-17 20:08:15 -05:00
Roger Dingledine
3bb40b213b refactor router_pick_published_address to have another arg
no change in behavior except fewer log entries in the case where we use
a cached result.
2016-11-16 16:13:03 -05:00
teor
150a2b39b0
fixup! Add expect_log_msg_containing_either3() and expect_log_msg_containing_either4()
Fix typos:
    * extra '('
    * use assert_log_predicate (without 3 or 4 at the end)

Tidy whitespace.
Wrap long lines.
2016-11-16 13:14:00 +11:00
Neel Chauhan
0825fc6af9
Add all four error messages to test_address_get_if_addrs6_list_no_internal() 2016-11-16 12:57:13 +11:00
Neel Chauhan
01492d3869
Add all four error messages to test_address_get_if_addrs6_list_internal() 2016-11-16 12:57:09 +11:00
Neel Chauhan
cccc08ad56
Add expect_log_msg_containing_either3() and expect_log_msg_containing_either4() 2016-11-16 12:57:05 +11:00
Neel Chauhan
9f74f8f732 Move encode_cert to torcert.c and rename it to tor_cert_encode_ed22519()
Signed-off-by: David Goulet <dgoulet@torproject.org>
2016-11-10 11:00:50 -05:00
Nick Mathewson
0980787f91 Merge remote-tracking branch 'dgoulet/bug20570_030_01' 2016-11-10 09:28:31 -05:00
Nick Mathewson
217b895831 Merge remote-tracking branch 'dgoulet/ticket19642_030_01' 2016-11-10 09:16:00 -05:00
rubiate
d46c1b49a4 Do not serve a consensus if it is too old
Closes ticket 20511.
2016-11-10 10:16:18 +13:00
Nick Mathewson
c58592e658 Merge branch 'maint-0.2.9' 2016-11-08 18:51:19 -05:00
Nick Mathewson
89ec191b68 Merge remote-tracking branch 'public/bug20306_029' into maint-0.2.9 2016-11-08 18:51:07 -05:00
David Goulet
34f14a35b6 hs: Add single-onion-service line to v3 descriptor
This field indicates if the service is a Single Onion Service if present in
the descriptor.

Closes #19642

Signed-off-by: David Goulet <dgoulet@torproject.org>
2016-11-08 13:22:42 -05:00
Nick Mathewson
3e3040a5d9 Merge branch 'maint-0.2.9'
Conflicts:
	src/or/rendservice.c
2016-11-07 16:31:40 -05:00
Nick Mathewson
c2fc0941a5 Merge remote-tracking branch 'teor/bug20484_029_v2' into maint-0.2.9 2016-11-07 16:12:13 -05:00
Nick Mathewson
7236e42684 Merge branch 'maint-0.2.9' 2016-11-07 16:10:55 -05:00
Nick Mathewson
e482541cfb Fix another 20499-broken test 2016-11-07 16:10:42 -05:00
Nick Mathewson
d2071c36f6 Fix a unit test (broken by recent 20499 hacking) 2016-11-07 16:02:55 -05:00
David Goulet
18e0a0b70d test: Remove useless HS decode multiple intro points
The test was broken and skipped because the hardcoded cross certificate didn't
include the dynamically generated signing key generated by the test. The only
way we could have fixed that is extracting the signing key from the hardcoded
string and put it in the descriptor object or dynamically generate the cross
certificate.

In the end, all this was kind of pointless as we already test the decoding of
multiple introduction points elsewhere and we don't gain anything with that
specific test thus the removal.

Fixes #20570

Signed-off-by: David Goulet <dgoulet@torproject.org>
2016-11-07 10:59:30 -05:00
Nick Mathewson
61612f980d Merge branch 'maint-0.2.9' 2016-11-06 20:24:29 -05:00
Nick Mathewson
def41e93bd In test_tortls_classify_client_ciphers(), s/ECDH/ECDHE/
(We weren't actually using these ciphers; we were just requing that
ciphers of that name existed.)

Patch from rubiate.  Fixes 20460
2016-11-06 20:23:40 -05:00
Nick Mathewson
0fed324c2c Would you believe me if I said there were more 32-bit and clang warnings? 2016-11-04 15:47:28 -04:00
Nick Mathewson
f45a581486 Fix some 32-bit warnings and clang warnings 2016-11-04 15:24:30 -04:00
David Goulet
c1bbc8405b prop224: Fix memleaks in hs descriptor unit test
Signed-off-by: David Goulet <dgoulet@torproject.org>
2016-11-04 14:47:09 -04:00
Nick Mathewson
7a78a37f1d Fix memory leaks in test_hs_cache.c 2016-11-04 14:39:35 -04:00
Nick Mathewson
ed4aebcd97 Fix more unit test leaks. 2016-11-04 14:35:15 -04:00
David Goulet
791625750e prop224: Remove pointless unit test
Signed-off-by: David Goulet <dgoulet@torproject.org>
2016-11-04 14:31:28 -04:00
Nick Mathewson
1a03edefba Fix a heap overrun in test_decode_plaintext 2016-11-04 14:28:19 -04:00
Nick Mathewson
d16b4b3e48 Fix memory leaks in hs_descriptor/decode_descriptor and in encode_enc_key() 2016-11-04 14:27:45 -04:00
Nick Mathewson
a4291eef5a Expose desc_intro_point_free to the tests, and use it.
Also fix another couple of leaks.
2016-11-04 14:22:04 -04:00
Nick Mathewson
29ae8dcf96 Fix a bunch of leaks in hs_cache/upload_and_download_hs_desc 2016-11-04 14:13:30 -04:00
Nick Mathewson
6847b9f6af Fix make check-spaces 2016-11-04 14:00:08 -04:00
Nick Mathewson
0e2df2b653 Tell a broken test to skip itself 2016-11-04 13:57:07 -04:00
David Goulet
b876e5128a prop224: fix unit test to actually initialize a connection object
Signed-off-by: David Goulet <dgoulet@torproject.org>
2016-11-04 13:53:20 -04:00
Nick Mathewson
c35c43d7d9 Merge branch 'ticket17238_029_02-resquash'
Conflicts:
	src/or/rendclient.c
	src/or/rendcommon.c
	src/or/routerparse.c
	src/test/test_dir.c
	src/trunnel/ed25519_cert.h
2016-11-04 13:26:37 -04:00
David Goulet
3f29688bdf prop224: Use a const pointer for the cache lookup entry
Signed-off-by: David Goulet <dgoulet@torproject.org>
2016-11-04 10:32:50 -04:00
David Goulet
1263f74a12 prop224: Rename cert type to follow naming convention
Signed-off-by: David Goulet <dgoulet@torproject.org>
2016-11-04 10:32:50 -04:00
George Kadianakis
d795ed5871 Make check-spaces happy :)
Signed-off-by: David Goulet <dgoulet@torproject.org>
Signed-off-by: George Kadianakis <desnacked@riseup.net>
2016-11-04 10:32:50 -04:00
George Kadianakis
a8efd087bd test: Add prop224 directory fetch/upload unit tests
Signed-off-by: David Goulet <dgoulet@torproject.org>
Signed-off-by: George Kadianakis <desnacked@riseup.net>
2016-11-04 10:32:50 -04:00
David Goulet
45a72356cb prop224: Directory support for v3 descriptor publishing
Closes #19205

Signed-off-by: David Goulet <dgoulet@torproject.org>
Signed-off-by: George Kadianakis <desnacked@riseup.net>
2016-11-04 10:32:49 -04:00
David Goulet
1aeaba4906 test: Add prop224 directory cache unit tests
Signed-off-by: David Goulet <dgoulet@torproject.org>
Signed-off-by: George Kadianakis <desnacked@riseup.net>
2016-11-04 10:32:49 -04:00
David Goulet
025610612d prop224: Directory cache support
This implements the proposal 224 directory descriptor cache store and lookup
functionalities. Furthermore, it merges the OOM call for the HSDir cache with
current protocol v2 and the new upcoming v3.

Add hs_cache.{c|h} with store/lookup API.

Closes #18572

Signed-off-by: David Goulet <dgoulet@torproject.org>
Signed-off-by: George Kadianakis <desnacked@riseup.net>
2016-11-04 10:31:35 -04:00
David Goulet
473f99bf7b test: Add prop224 descriptor unit tests
Signed-off-by: David Goulet <dgoulet@torproject.org>
Signed-off-by: George Kadianakis <desnacked@riseup.net>
2016-11-04 10:29:28 -04:00
David Goulet
8293356ad9 hs: Refactor rend_data_t for multi version support
In order to implement proposal 224, we need the data structure rend_data_t to
be able to accomodate versionning that is the current version of hidden
service (2) and the new version (3) and future version.

For that, we implement a series of accessors and a downcast function to get
the v2 data structure. rend_data_t becomes a top level generic place holder.

The entire rend_data_t API has been moved to hs_common.{c|h} in order to
seperate code that is shared from between HS versions and unshared code (in
rendcommon.c).

Closes #19024

Signed-off-by: David Goulet <dgoulet@torproject.org>
Signed-off-by: George Kadianakis <desnacked@riseup.net>
2016-11-04 10:29:26 -04:00
Nick Mathewson
80a5091e4f Merge remote-tracking branch 'mintytoast/bug_19563' 2016-11-03 18:40:41 -04:00
Nick Mathewson
63c94954b1 Fix BUG message in channel/queue_impossible 2016-11-03 18:34:44 -04:00
overcaffeinated
dce4603d9b Use tor_htonll in test_util_format_unaligned_accessors
Remove the inline htonll, switch to tor_htonll for
test_util_format_unaligned_accessors.
2016-11-03 21:18:02 +00:00
overcaffeinated
c613446ca2 Refactor tests for tor_htonll and tor_ntohll
Following kind feedback from dgoulet: add tests for min (0) and
max (UINT64_MAX) values. Rename expected results to something more
sensible than 'n'.
2016-11-03 20:52:11 +00:00
overcaffeinated
c4603233db Add unit test for tor_htonll and tor_ntohll
Add tests for tor_htonll and tor_ntohll - fixes bug 19563.
2016-11-03 19:37:59 +00:00
Nick Mathewson
409984c6ae Fix two warnings in test_link_handshake.c
One is fixed by disabling the -Wredundant-decls warnings around
openssl headers here, because of the old double-declaration of
SSL_get_selected_srtp_profile().

One is fixed by including compat.h before or.h so that we get the
winsock2.h include before the windows.h include.
2016-11-03 11:16:06 -04:00
Nick Mathewson
32854aef28 whitespace fixes 2016-11-03 08:55:54 -04:00
Nick Mathewson
d9ca4e20bd Merge branch 'feature_15055_v2' 2016-11-03 08:44:46 -04:00
Nick Mathewson
805e97a433 Drop support for AUTHTYPE_RSA_SHA256_RFC5705 authentication.
This was a stopgap method, designed on the theory that some routers
might support it before they could support Ed25519.  But it looks
like everybody who supports RFC5705 will also have an Ed25519 key,
so there's not a lot of reason to have this even supported.
2016-11-03 08:40:10 -04:00
Nick Mathewson
d4c57909f8 Test failing cases of ed25519 authentication. 2016-11-03 08:40:10 -04:00
Nick Mathewson
acbb60cd63 Move unittests' RSA pregen code into a new file, and improve.
This patch moves the pregenerated RSA key logic into a new
testing_rsakeys.c.

Also, it adds support for RSA2048, since the link handshake tests
want that.

Also, it includes pregenerated keys, rather than trying to actually
generate the keys at startup, since generating even a small handful
of RSA2048 keys makes for an annoying delay.
2016-11-03 08:40:10 -04:00
Nick Mathewson
af2459f09e Unit tests for cert-chain-processing, including failed cases
Check out the coverage!
2016-11-03 08:40:10 -04:00
Nick Mathewson
672fe4bee4 Extend link handshake tests to handle successful Ed25519 handshakes.
Success cases only. Failure cases to come.
2016-11-03 08:40:09 -04:00
Nick Mathewson
88c2a6b936 Send and receive AUTHENTICATE cells correctly with ED keys.
Includes updated test for authchallenge cells
2016-11-03 08:39:31 -04:00
Nick Mathewson
e64bac6eb4 Increase TLS RSA link key length to 2048 bits
Oddly, nothing broke.

Closes ticket 13752.
2016-11-03 08:39:30 -04:00
Nick Mathewson
99b3e54691 Add "Ed ID" arguments to a bunch of connection-ID-related fns.
In particular, these functions are the ones that set the identity of
a given connection or channel, and/or confirm that we have learned
said IDs.

There's a lot of stub code here: we don't actually need to use the
new keys till we start looking up connections/channels by Ed25519
IDs.  Still, we want to start passing the Ed25519 IDs in now, so it
makes sense to add these stubs as part of 15055.
2016-11-03 08:37:22 -04:00
Nick Mathewson
0b4221f98d Make the current time an argument to x509 cert-checking functions
This makes the code a bit cleaner by having more of the functions be
pure functions that don't depend on the current time.
2016-11-03 08:37:22 -04:00
Nick Mathewson
e3c8253721 Add function to check RSA->Ed cross-certifications
Also, adjust signing approach to more closely match the signing
scheme in the proposal.

(The format doesn't quite match the format in the proposal, since
RSA signatures aren't fixed-length.)

Closes 19020.
2016-11-03 08:37:22 -04:00
Nick Mathewson
348b90a915 Refactor RSA certificate checking into its own function. 2016-11-03 08:37:22 -04:00
Nick Mathewson
e23389841c Migrate certificates into a sub-structure of or_handshake_state
This will help us do cert-checking in the background in the future,
perhaps.
2016-11-03 08:37:21 -04:00
teor
01fe039b78
Test single onion service configs where the directory does not exist
Runs a test for each combination of create/don't create directories.

Tests #20484.
2016-11-02 14:17:52 +11:00
teor
13fbbe9cce
Make sure passthrough_test_setup doesn't inadvertently fail or skip tests
passthrough_test_setup doesn't pass through arguments if the argument
is equal to 0 or TT_SKIP. Instead, it fails or skips the test.

Assert on this, so we don't accidentally fail or skip tests.
2016-11-02 14:16:14 +11:00
teor
77e1d660ee
Add get_fname_rnd for unit tests that want a unique path every time 2016-11-02 14:14:19 +11:00
teor
d7634dc519
Create get_fname_suffix, and refactor get_fname to use it 2016-11-02 14:13:34 +11:00
teor
fedafe7c0e
Use check_private_dir in test_single_onion_poisoning
This avoids Win32 conditionals for mkdir.
2016-11-02 11:37:11 +11:00
Nick Mathewson
25f53955f6 Merge branch 'maint-0.2.9' 2016-11-01 13:32:29 -04:00
Nick Mathewson
ff3e08f2af Attempt to fix unit tests on netbsd 2016-11-01 13:32:21 -04:00
Nick Mathewson
d73c671d6d policy_is_reject_star():
ome policies are default-reject, some default-accept.  But
policy_is_reject_star() assumed they were all default_reject.  Fix
that!

Also, document that policy_is_reject_star() treats a NULL policy as
empty. This allows us to simplify the checks in
parse_reachable_addresses() by quite a bit.

Fxes bug 20306; bugfix on 0.2.8.2-alpha.
2016-10-31 15:05:56 -04:00
Matt Traudt
183fbc4137 Hopefully fix int64 comparisons in test_dir_networkstatus_compute_bw_weights_v10 2016-10-28 11:37:28 -04:00
Nick Mathewson
172b124006 Resolve memory leaks in test_dir_networkstatus_compute_bw_weights_v10 2016-10-27 09:41:19 -04:00
overcaffeinated
e2577cce0c Convert remaining files to smartlist_add_strdup
The coccinelle script produced errors with these test files so
convert the remaining cases of smartlist_add to
smartlist_add_strdup by hand.
2016-10-27 11:15:57 +01:00
overcaffeinated
265d5446fa Automated change to use smartlist_add_strdup
Use the following coccinelle script to change uses of
smartlist_add(sl, tor_strdup(str)) to
smartlist_add_strdup(sl, string) (coccinelle script from nickm
via bug 20048):

@@
expression a;
expression b;
@@
- smartlist_add
+ smartlist_add_strdup
   (a,
- tor_strdup(
   b
- )
  )
2016-10-27 10:26:06 +01:00
Matt Traudt
6629c5c3fe Add historic bwweight tests, comments, line len fixes 2016-10-26 16:37:16 -04:00
Matt Traudt
7ba0ae9426 Add consensus weight calculation tests 2016-10-26 16:37:16 -04:00
Nick Mathewson
8cc528c750 Allow asking a bridge's own descriptor over one-hop connection
When we refactored purpose_needs_anonymity(), we made it so _all_
bridge requests required anonymity.  But that missed the case
that we are allowed to ask a bridge for its own descriptor.

With this patch, we consider the resource, and allow "authority.z"
("your own descriptor, compressed") for a bridge's server descriptor
to be non-anonymous.

Fix for bug 20410; bug not in any released Tor.
2016-10-26 08:32:48 -04:00
Nick Mathewson
c87d9b13a4 BUG in purpose_needs_anonymity if switch not matched.
I believe that this should never trigger, but if it does, it
suggests that there was a gap between is_sensitive_dir_purpose and
purpose_needs_anonymity that we need to fill.  Related to 20077.
2016-10-19 18:04:47 -04:00
Nick Mathewson
df387b94e8 Merge remote-tracking branch 'chelseakomlo/master' 2016-10-19 17:17:12 -04:00
Nick Mathewson
9f6bb29b05 Compilation fix. (function pointer implicit cast in tests.) 2016-10-19 17:15:42 -04:00
Nick Mathewson
12cf73c451 Merge remote-tracking branch 'andrea/ticket19858_v2'
Conflict in entrynodes.c: any_bridge_supports_microdescriptors was
removed in master, and modified in 19858_v2
2016-10-19 17:11:47 -04:00
Chelsea H. Komlo
471b0c5175
Refactor purpose_needs_anonymity to use switch statement 2016-10-19 12:25:50 -05:00
Chelsea H. Komlo
195ccce94e
Refactor to use purpose_needs_anonymity and remove is_sensitive_dir_purpose 2016-10-18 18:40:50 -05:00
Nick Mathewson
55c468c521 Whitespace cleaning 2016-10-14 10:40:31 -04:00
Nick Mathewson
af70e43131 Merge remote-tracking branch 'public/spaces_in_unix_addrs' 2016-10-14 10:21:41 -04:00
Nick Mathewson
9615ad338f Make the FreeBSD ersatz_socketpair test even more skippable.
(This is safe, since only windows actually -uses- erstaz_socketpair.)
2016-10-14 09:14:07 -04:00
Nick Mathewson
07f2e5748e ersatz socketpair tests: work around freebsd jails. 2016-10-13 09:47:28 -04:00
Nick Mathewson
0e1b228aa6 Fix a bug in displaying IPv6 addrs in test_op_ipv6_ with --verbose
The test code, if it failed, or if it was run in verbose mode, would
use the wrong variable for its loop.  Patch from rubiate uploaded to
19999.
2016-10-11 20:09:24 -04:00
paolo.ingls@gmail.com
ab78a4df93 torrc parsing b0rks on carriage-return
(Specifically, carriage return after a quoted value in a config
line. Fixes bug 19167; bugfix on 0.2.0.16-alpha when we introduced
support for quoted values. Unit tests, changes file, and this
parenthetical by nickm.)
2016-10-11 09:25:22 -04:00
Nick Mathewson
05aed5b635 Allow a unix: address to contain a C-style quoted string.
Feature 18753 -- all this to allow spaces.
2016-10-04 15:43:20 -04:00
Nick Mathewson
ed5d2daba1 Merge remote-tracking branch 'public/ticket20001_v2' 2016-09-26 11:01:10 -07:00
Nick Mathewson
97337844b7 Merge branch 'protover_v2_squashed' 2016-09-26 11:00:08 -07:00
Nick Mathewson
3a3120819c Rename compute_protover_vote to protover_compute_vote 2016-09-26 10:56:53 -07:00
Nick Mathewson
e402cddefe Clean whitespace, add missing documentation 2016-09-26 10:56:52 -07:00
Nick Mathewson
a232161f7b Cover the error cases of parsing protocol versions
Also, detect an additional failure type. Thanks, tests!

(How distinctly I recall thee)
2016-09-26 10:56:50 -07:00
Nick Mathewson
0697e413ef Unit tests for protover_all_supported 2016-09-26 10:56:49 -07:00
Nick Mathewson
c1be8f9d57 Basic backend for the protocol-versions voting algorithm.
[This is a brute-force method that potentially uses way too much
RAM. Need to rethink this a little. Right now you can DOS an
authority by saying "Foo=1-4294967295".]
2016-09-26 10:56:49 -07:00
Nick Mathewson
4df12239f6 Emit and parse protocol lists in router descriptors 2016-09-26 10:56:49 -07:00
Nick Mathewson
b2b2e1c7f2 checkpoint basic protover backend 2016-09-26 10:56:48 -07:00
Andrea Shepard
006c26f54f Abolish globals in entrynodes.c; relativize guard context to new guard_selection_t structure 2016-09-25 02:11:44 +00:00
Nick Mathewson
0baa276ea9 Coverity warning fix: let coverity tell we're closing sockets
Our use of the (mockable) tor_close_socket() in the util/socket_..
tests confused coverity, which could no longer tell that we were
actually closing the sockets.
2016-09-22 09:24:56 -04:00
Nick Mathewson
6cb9c2cf77 Add support for AES256 and AES192
(This will be used by prop224)
2016-09-16 11:21:33 -04:00
Nick Mathewson
ff116b7808 Simplify the crypto_cipher_t interface and structure
Previously, the IV and key were stored in the structure, even though
they mostly weren't needed.  The only purpose they had was to
support a seldom-used API where you could pass NULL when creating
a cipher in order to get a random key/IV, and then pull that key/IV
back out.

This saves 32 bytes per AES instance, and makes it easier to support
different key lengths.
2016-09-16 10:12:30 -04:00
Nick Mathewson
b08ddb60c9 Ensure that dir1 and dir2 are freed at the end of poisoning test
Found by coverity.
2016-09-14 11:01:21 -04:00
Nick Mathewson
8b7922b282 Merge remote-tracking branch 'teor/feature20072' 2016-09-14 10:18:41 -04:00
Nick Mathewson
4f4e995d42 Merge branch 'bug20081' 2016-09-14 10:17:04 -04:00
teor
16085a8421
Add some chutney single onion networks to make test-network-all
This requires a recent version of chutney, with the single onion
network flavours (git c72a652 or later).

Closes ticket #20072.
2016-09-14 12:17:10 +10:00
Nick Mathewson
831649f56e Fix a memory leak in options/validate__single_onion 2016-09-13 10:40:42 -04:00
Nick Mathewson
2237478045 options/validate__single_onion test: use new log capture api
I changed the API here in deb294ff53, to be less annoying
to use.
2016-09-13 10:22:34 -04:00
Nick Mathewson
9f0cb5af15 Merge branch 'feature-17178-v7-squashed-v2' 2016-09-13 10:20:08 -04:00
teor
f311c9ffa2 Replace OnionService* with HiddenService* in option names
And make consequential line-length adjustments.
2016-09-13 10:13:57 -04:00
teor
365ca3ca0f Refactor Single Onion code to improve consistency
* Check consistency between the two single onion torrc options
* Use the more relevant option each time we check for single onion mode
* Clarify log messages
* Clarify comments
* Otherwise, no behaviour change
2016-09-13 10:13:57 -04:00
teor (Tim Wilson-Brown)
b560f852f2 Implement Prop #260: Single Onion Services
Add experimental OnionServiceSingleHopMode and
OnionServiceNonAnonymousMode options. When both are set to 1, every
hidden service on a tor instance becomes a non-anonymous Single Onion
Service. Single Onions make one-hop (direct) connections to their
introduction and renzedvous points. One-hop circuits make Single Onion
servers easily locatable, but clients remain location-anonymous.
This is compatible with the existing hidden service implementation, and
works on the current tor network without any changes to older relays or
clients.

Implements proposal #260, completes ticket #17178. Patch by teor & asn.

squash! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Implement Prop #260: Single Onion Services

Redesign single onion service poisoning.

When in OnionServiceSingleHopMode, each hidden service key is poisoned
(marked as non-anonymous) on creation by creating a poison file in the
hidden service directory.

Existing keys are considered non-anonymous if this file exists, and
anonymous if it does not.

Tor refuses to launch in OnionServiceSingleHopMode if any existing keys
are anonymous. Similarly, it refuses to launch in anonymous client mode
if any existing keys are non-anonymous.

Rewrite the unit tests to match and be more comprehensive.
Adds a bonus unit test for rend_service_load_all_keys().
2016-09-13 10:10:54 -04:00
Nick Mathewson
8fdf2f583c Unit tests for proposal 271 client-side implementation 2016-09-13 09:45:55 -04:00
Nick Mathewson
20c4b01694 Make preferred_chunk_size avoid overflow, handle big inputs better
Also, add tests for the function.

Closes 20081; bugfix on 0.2.0.16-alpha. This is a Guido Vranken
issue. Thanks, Guido!
2016-09-13 09:07:12 -04:00
Nick Mathewson
d5d29cd5a2 Whoops. Cant call sockaddr_in a "sin", since sin() is a thing. 2016-09-11 17:59:25 -04:00
Nick Mathewson
ccea2a5aa9 Fix gmtime unit test on openbsd
openbsd helpfully handles gmtime() of INT64_MIN.  Good job!

Our tests didn't handle that so well.
2016-09-11 17:43:20 -04:00
Nick Mathewson
c6e70dacb8 Try to make our ersatz-socketpair test work better on FreeBSD jails 2016-09-11 17:28:29 -04:00
Nick Mathewson
a671a1c9d6 Tweak tor_gmtime_r test.
On openbsd64, I'm seeing a warning that the log isn't saying what
I'd expect, but I'm not seeing what the answer actually _is_ here.
2016-09-11 17:13:51 -04:00
Nick Mathewson
64521a9d35 Merge remote-tracking branch 'public/solaris_warnings_028' 2016-09-11 16:52:24 -04:00
Nick Mathewson
77e2be06f6 make check-spaces 2016-09-09 15:38:46 -04:00
Nick Mathewson
75a7997148 Fix a coupole of coverity complaints. 2016-09-09 15:29:57 -04:00
Nick Mathewson
4c55e8a58f Fix cases where the tests were doing closesocket() on a non-socket
These seem to have caused warnings on windows. Hmmm.
2016-09-09 10:28:12 -04:00
Nick Mathewson
2fe7e3d9d2 Oh dear, I was missing an extern. 2016-09-09 10:20:34 -04:00
Nick Mathewson
373bfd9630 Make a couple more tests run faster.
The point of diminishing returns has been reached.
2016-09-09 10:08:27 -04:00
Nick Mathewson
7c52109641 Disable a single pbkdf2 test vector
The other test vectors are pretty complete, and get full coverage, I
believe.

This one test vector accounted for half the time spent in
test-slow.  "Now that's slow!"
2016-09-09 09:57:15 -04:00
Nick Mathewson
5e30e26c6d Chop another ~93 RSA key generations out of the unit tests
We have a mock for our RSA key generation function, so we now wire
it to pk_generate(). This covers all the cases that were not using
pk_generate() before -- all ~93 of them.
2016-09-09 09:45:50 -04:00
Nick Mathewson
05110c9294 Move the donna-fuzzing tests into test_slow.
This shaves another 3-4 seconds off the main-path tests for me,
which is again worth it, according to XKCD#1204.
2016-09-09 08:58:42 -04:00
Nick Mathewson
5ec395b27f Re-enable RSA cacheing in tests, with a better design.
This makes tests faster and saves about 6 seconds for me, which
makes it worth it, according to https://xkcd.com/1205.
2016-09-09 08:58:42 -04:00
Nick Mathewson
63e34e9e49 Reinstate a couple of teardown_capture_of_logs that I missed
Patch from rubiate. See #19999
2016-09-08 19:49:21 -04:00
Nick Mathewson
55713f0d79 Placate "make check-spaces" 2016-09-08 15:43:56 -04:00
Nick Mathewson
d860b99dbf Fix remaining test warnings. (in test_relay.c) 2016-09-08 15:25:56 -04:00
Nick Mathewson
e9fdec2b1d capture and detect expected BUG messages in shared-random tests 2016-09-08 15:13:53 -04:00
Nick Mathewson
deb294ff53 Simplify log_test_helpers interface
Previously, you needed to store the previous log severity in a local
variable, and it wasn't clear if you were allowed to call these
functions more than once.
2016-09-08 15:03:11 -04:00
Nick Mathewson
b0a9e54705 Resolve more BUG warnings in the unit tests 2016-09-08 14:39:20 -04:00
Nick Mathewson
d0fe86f39e Fix bug warnings in test_circuitlist. 2016-09-08 14:04:55 -04:00
Nick Mathewson
3269307daf Treat all nonfatal assertion failures as unit test failures.
Part of 19999.
2016-09-08 13:27:30 -04:00
Nick Mathewson
6a1454aa46 Tolerate another failure mode of get_if_addres6_list in tests 2016-09-08 11:47:16 -04:00
Nick Mathewson
f9cb9d8990 more consistent use of expect_log_msg_containing 2016-09-08 11:16:09 -04:00
Nick Mathewson
f64f293c48 Suppress a really impressive pile of warnings in conection/.. tests 2016-09-08 10:56:51 -04:00
Nick Mathewson
d626ffe29c Fix a bug in connection/download_status.. tests 2016-09-08 10:48:22 -04:00
Nick Mathewson
3705ee8fe4 Revise log-testing macros to dump the actual log contents on failure 2016-09-08 10:33:01 -04:00
Nick Mathewson
ae3ea9a7a1 Remove redundant definitions of expect_{no_,}log_msg() 2016-09-08 10:32:59 -04:00
Nick Mathewson
8acb951fc8 Unit test fix: windows should be able to handle DNSPort just fine. 2016-09-08 09:23:20 -04:00
Nick Mathewson
08d1ac4f2a Patch from rubiate: disable openbsd memory protections in test-memwipe
Test-memwipe is *supposed* to invoke undefined behavior, alas.

Closes 20066.
2016-09-08 09:00:24 -04:00
Nick Mathewson
bee5f38e39 set the "addr" field in the dir_handle_get tests, to resolve bug warnings. 2016-09-07 14:30:51 -04:00
Nick Mathewson
ab4485e281 Remove the useless (and uninitialized) MOCK_TOR_ADDR in test_dir_handle_get.c 2016-09-07 14:26:43 -04:00
Nick Mathewson
9d933bbacf Capture and enforce BUG warnings in dir/param_voting_lookup 2016-09-07 13:49:18 -04:00
Nick Mathewson
075c52084d Fix unit test failure introduced by #20002
Updating the consensus algorithm made a non-valid node never get
listed, which messed up some other tests.
2016-09-07 13:40:38 -04:00
Nick Mathewson
a49fee1c29 Capture and enforce bug warnings in util/time test 2016-09-07 12:15:46 -04:00
Nick Mathewson
e9b1d0619f Merge remote-tracking branch 'dgoulet/ticket18693_029_01' 2016-09-07 11:46:00 -04:00
Nick Mathewson
3823d0aa7d Capture and detect the BUG() warnings in test_util_parse_integer. 2016-09-06 21:01:52 -04:00
Nick Mathewson
2a4a815f58 Fix a unit test bug for passing arguments to tor_parse_ulong.
We wanted to make sure -50 was a bad input, but instead we were
passing a 'min' that was greater than 'max'.
2016-09-06 20:29:55 -04:00
Nick Mathewson
7ba47ca1fd Split tor_parse_{some_int} testing into separate fn. Code movement only. 2016-09-06 20:25:54 -04:00
Nick Mathewson
43092e21c1 Merge remote-tracking branch 'teor/feature20069' 2016-09-06 19:06:32 -04:00
Nick Mathewson
5927ed8d33 checkSpace.pl now forbids more identifiers.
The functions it warns about are:
  assert, memcmp, strcat, strcpy, sprintf, malloc, free, realloc,
  strdup, strndup, calloc.

Also, fix a few lingering instances of these in the code. Use other
conventions to indicate _intended_ use of assert and
malloc/realloc/etc.
2016-09-06 12:35:37 -04:00
teor
26b47f80dd
Add hs-ipv6 to the chutney IPv6 tests
Requires a recent version of chutney.

Also remove bridges+hs, as it's somewhat redundant.
2016-09-06 13:45:09 +10:00
Andrea Shepard
341a159ab4 Appease make check-spaces 2016-09-05 17:47:39 +00:00
Nick Mathewson
6abce601f2 Fix BUG warning with stack trace from config/parse_port_config__listenaddress 2016-09-05 13:30:50 -04:00
Nick Mathewson
6c1d1127a8 Fix memory leaks in the shared random tests.
Please remember to test your code with
--enable-expensive-hardening. :)
2016-09-01 09:10:27 -04:00
Nick Mathewson
7ef4eef764 Actually, always monotime_init() in the unit tests. 2016-08-31 14:38:17 -04:00
Nick Mathewson
cfc62e2374 Initialize monotonic timer code before using it in the tests 2016-08-31 14:34:49 -04:00
Nick Mathewson
d4f05dcd0e Detect and suppress bug message from zlib compression bomb test 2016-08-31 14:30:34 -04:00
Nick Mathewson
d299c043d4 Require specific messages for remaining link-handshake failure cases 2016-08-31 14:10:15 -04:00
Nick Mathewson
273290d4fe Always log [bug] warnings from the unit tests.
We should consider them bugs.  If they are happening intentionally,
we should use the log_test_helpers code to capture and suppress
them.  But having them off-by-default has potential to cause
programming errors.
2016-08-31 13:22:07 -04:00
Nick Mathewson
69dce09031 Do not call tor_tls_server_info_callback(NULL) from tests.
This isn't valid behavior, and it causes a crash when you run
the unit tests at --debug.

I've added an IF_BUG_ONCE() check for this case.
2016-08-31 13:18:13 -04:00
Nick Mathewson
871b711f10 Work even harder not to suppress logging messages unless we mean to. 2016-08-31 13:12:36 -04:00
Nick Mathewson
2df6cdc9f9 Document and clean log_test_helpers.c a bit
In addition to documentation, this commit makes a function static,
and removes a weird single-point-of-return-ism, and notes a thing I
should fix.
2016-08-31 13:11:26 -04:00
Nick Mathewson
d5614b2102 Use setup_full_capture_of_logs() where appropriate. 2016-08-31 12:53:18 -04:00
Nick Mathewson
f74916a98f setup_capture_of_logs: no longer suppress log messages
Previously setup_capture_of_logs would prevent log messages from
going to the console entirely.  That's a problem, since sometimes
log messages are bugs!  Now setup_capture_of_logs() acts sensibly.

If you really do need to keep a message from going to the console
entirely, there is setup_full_capture_of_logs().  But only use that
if you're prepared to make sure that there are no extraneous
messages generated at all.
2016-08-31 12:51:22 -04:00
Nick Mathewson
1f7dc823c5 Improvements to test_link_handshake: check specific error messages
Otherwise it's too easy to lose our test coverage.
2016-08-31 12:11:01 -04:00