summaryrefslogtreecommitdiff
path: root/src/or/rendservice.c
AgeCommit message (Collapse)Author
2017-12-08Switch to a safer FREE_AND_NULL implementationNick Mathewson
This one only evaluates the input once, so it cannot mess up even if there are side effects.
2017-12-08Change the free macro convention in the rest of src/or/*.hNick Mathewson
2017-10-25hs-v2: Copy needed information between service on prunningDavid Goulet
Turns out that when reloading a tor configured with hidden service(s), we weren't copying all the needed information between the old service object to the new one. For instance, the desc_is_dirty timestamp wasn't which could lead to the service uploading its desriptor much later than it would need to. The replaycache wasn't also moved over and some intro point information as well. Fixes #23790 Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-19hs: Pad RENDEZVOUS1 v3 cell to match length of v2David Goulet
RENDEZVOUS1 cell is 84 bytes long in v3 and 168 bytes long in v2 so this commit pads with random bytes the v3 cells up to 168 bytes so they all look alike at the rendezvous point. Closes #23420 Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-18Merge branch 'maint-0.3.1'Nick Mathewson
2017-09-18Merge branch 'maint-0.3.0' into maint-0.3.1Nick Mathewson
2017-09-18Fix log-uninitialized-stack bug in rend_service_intro_established.Nick Mathewson
Fixes bug 23490; bugfix on 0.2.7.2-alpha. TROVE-2017-008 CVE-2017-0380
2017-09-15Merge branch 'scan-build-032'Nick Mathewson
2017-09-15Run our #else/#endif annotator on our source code.Nick Mathewson
2017-09-12Clear up dead-assignment warnings from scan-buildNick Mathewson
2017-09-08Merge branch 'ed25519_lookup'Nick Mathewson
2017-09-07hs: Do not assert on rend_data while iterating over circuitsDavid Goulet
The pruning process and the deleting ephemeral service function iterates over all circuits and were asserting on rend_data for a matching circuit. This is not good because now we have v3 circuits without a rend_data. Fixes #23429 Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-31hs: Set rendezvous circuit timestamp_dirty all the timeDavid Goulet
We used to check if it was set to 0 which is what unused circuit have but when the rendezvous circuit was cannibalized, the timestamp_dirty is not 0 but we still need to reset it so we can actually use it without having the chance of expiring the next second (or very soon). Fixes #23123 Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-29Merge branch 'maint-0.3.1'Nick Mathewson
2017-08-28hs: Fix the intro circuit max retryDavid Goulet
Some parentheses were missing making the rend_max_intro_circs_per_period() return a lower value than it was suppose to. The calculation is that a service at most will open a number of intro points that it wants which is 3 by default or HiddenServiceNumIntroductionPoints. Two extra are launched for performance reason. Finally, this can happen twice for two descriptors for the current and next time period. From: 2 * n_intro_wanted + 2 ...which resulted in 8 for 3 intro points, this commit fixes it to: (n_intro_wanted + 2) * 2 ... resulting in 12 possible intro point circuit which is the correct maximum intro circuit allowed per period. Last, this commit rate limits the the log message if we ever go above that limit else over a INTRO_CIRC_RETRY_PERIOD, we can print it often! Fixes #22159 Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-25Merge branch 'maint-0.3.1'Nick Mathewson
2017-08-25Merge branch 'bug19418_029' into maint-0.3.1Nick Mathewson
2017-08-22Refactor node lookup APIs to take flagsNick Mathewson
Right now there's a single warn_if_unnamed flag for router_get_consensus_status_by_nickname() and node_get_by_nickname(), that is nearly always 1. I've turned it into an 'unsigned' bitfield, and inverted its sense. I've added the flags argument to node_get_by_hex_id() too, though it does nothing there right now. I've removed the router_get_consensus_status_by_nickname() function, since it was only used in once place. This patch changes the warning behavior of GETINFO ns/name/<name>, since all other name lookups from the controller currently warn. Later I'm going to add more flags, for ed25519 support.
2017-08-19prop224: Refactor parse_extended_hostname() to parse v3 addrs.George Kadianakis
We need this func so that we recognize SOCKS conns to v3 addresses. - Also rename rend_valid_service_id() to rend_valid_v2_service_id() - Also move parse_extended_hostname() tests to their own unittest, and add a v3 address to the test as well. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-09Make sure we always wind up checking i2d_*'s output.Nick Mathewson
The biggest offender here was sometimes not checking the output of crypto_pk_get_digest. Fixes bug 19418. Reported by Guido Vranken.
2017-08-08prop224: Add service rendezvous circuit relaunchDavid Goulet
This introduces a callback to relaunch a service rendezvous circuit when a previous one failed to build or expired. It unifies the legacy function rend_service_relaunch_rendezvous() with one for specific to prop224. There is now only one entry point for that which is hs_circ_retry_service_rendezvous_point() supporting both legacy and prop224 circuits. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08hs: Rename num_rend_services()David Goulet
Renamed to rend_num_services() so it is consistent with the legacy naming. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Link rendezvous circuit to edge connectionDavid Goulet
This commit refactors the handle_hs_exit_conn() function introduced at a prior commit that connects the rendezvous circuit to the edge connection used to connect to the service virtual port requested in a BEGIN cell. The refactor adds the support for prop224 adding the hs_service_set_conn_addr_port() function that has the same purpose has rend_service_set_connection_addr_port() from the legacy code. The rend_service_set_connection_addr_port() has also been a bit refactored so the common code can be shared between the two HS subsystems (legacy and prop224). In terms of functionallity, nothing has changed, we still close the circuits in case of failure for the same reasons as the legacy system currently does. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Establish rendezvous circuit for serviceDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Circuit has opened and ESTABLISH_INTRO cellDavid Goulet
Add the entry point from the circuit subsystem of "circuit has opened" which is for all type of hidden service circuits. For the introduction point, this commit actually adds the support for handling those circuits when opened and sending ESTABLISH_INTRO on a circuit. Rendevzou point circuit aren't supported yet at this commit. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Service v3 descriptor creation and logicDavid Goulet
This commit adds the functionality for a service to build its descriptor. Also, a global call to build all descriptors for all services is added to the service scheduled events. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-07-24Rename the hybrid_encrypt/decrypt functions; label them as dangerousNick Mathewson
We need to keep these around for TAP and old-style hidden services, but they're obsolete, and we shouldn't encourage anyone to use them. So I've added "obsolete" to their names, and a comment explaining what the problem is. Closes ticket 23026.
2017-07-13Merge remote-tracking branch 'dgoulet/ticket21979_032_04'Nick Mathewson
2017-07-13prop224: Fix clang warningsDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-07-13prop224: Use the service config object when configuringDavid Goulet
Both configuration function now takes the service config object instead of the service itself. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-07-13hs: Add rend_service_init()David Goulet
Initialize both the global and staging service lists. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-07-13prop224: Load and/or generate v3 service keysDavid Goulet
Try to load or/and generate service keys for v3. This write both the public and private key file to disk along with the hostname file containing the onion address. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-07-13prop224: Configure v3 service from optionsDavid Goulet
This commit adds the support in the HS subsystem for loading a service from a set of or_options_t and put them in a staging list. To achieve this, service accessors have been created and a global hash map containing service object indexed by master public key. However, this is not used for now. It's ground work for registration process. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-07-13prop224: Add hs_config.{c|h} with a refactoringDavid Goulet
Add the hs_config.{c|h} files contains everything that the HS subsystem needs to load and configure services. Ultimately, it should also contain client functions such as client authorization. This comes with a big refactoring of rend_config_services() which has now changed to only configure a single service and it is stripped down of the common directives which are now part of the generic handler. This is ground work for prop224 of course but only touches version 2 services and add XXX note for version 3. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-07-13rephist: Remove unused crypto_pk statistics.Isis Lovecruft
These statistics were largely ununsed, and kept track of statistical information on things like how many time we had done TLS or how many signatures we had verified. This information is largely not useful, and would only be logged after receiving a SIGUSR1 signal (but only if the logging severity level was less than LOG_INFO). * FIXES #19871. * REMOVES note_crypto_pk_op(), dump_pk_op(), and pk_op_counts from src/or/rephist.c. * REMOVES every external call to these functions.
2017-07-07Explicit length checks in circuit_init_cpath_crypto().George Kadianakis
2017-07-07Refactor circuit_init_cpath_crypto() to do prop224 rend circuits.George Kadianakis
circuit_init_cpath_crypto() is responsible for creating the cpath of legacy SHA1/AES128 circuits currently. We want to use it for prop224 circuits, so we refactor it to create circuits with SHA3-256 and AES256 as well. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-05-09Merge branch 'dgoulet_ticket22060_031_01_squashed'Nick Mathewson
2017-05-09config: Remove AllowInvalidNodes optionDavid Goulet
Deprecated in 0.2.9.2-alpha, this commits changes it as OBSOLETE() and cleans up the code associated with it. Partially fixes #22060 Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-05-05Merge remote-tracking branch 'dgoulet/ticket21978_031_02'Nick Mathewson
2017-04-27Merge branch 'dirreq'Nick Mathewson
2017-04-24hs: Refactor rend_add_service()David Goulet
Remove duplicate code that validates a service object which is now in rend_validate_service(). Add some comments on why we nullify a service in the code path of rend_config_services(). Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-04-24hs: Add rend_validate_service() functionDavid Goulet
This new function validates a service object and is used everytime a service is successfully loaded from the configuration file. It is currently copying the validation that rend_add_service() also does which means both functions validate. It will be decoupled in the next commit. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-04-21Replace remaining directory_initiate_command_* instancesNick Mathewson
2017-04-21hs: Fix a spurious warn in rend_log_intro_limitDavid Goulet
We do dump HS stats now at log info everytime the intro circuit creation retry period limit has been reached. However, the log was upgraded to warning if we actually were over the elapsed time (plus an extra slop). It is actually something that will happen in tor in normal case. For instance, if the network goes down for 10 minutes then back up again making have_completed_a_circuit() return false which results in never updating that retry period marker for a service. Fixes #22032 Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-04-13hs: Make the service list pruning function publicDavid Goulet
The reason for making the temporary list public is to keep it encapsulated in the rendservice subsystem so the prop224 code does not have direct access to it and can only affect it through the rendservice pruning function. It also has been modified to not take list as arguments but rather use the global lists (main and temporary ones) because prop224 code will call it to actually prune the rendservice's lists. The function does the needed rotation of pointers between those lists and then prune if needed. In order to make the unit test work and not completely horrible, there is a "impl_" version of the function that doesn't free memory, it simply moves pointers around. It is directly used in the unit test and two setter functions for those lists' pointer have been added only for unit test. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-04-07hs: Move common defines to hs_common.hDavid Goulet
Some of those defines will be used by the v3 HS protocol so move them to a common header out of rendservice.c. This is also ground work for prop224 service implementation. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-04-07hs: Move service check private dir to hs_common.cDavid Goulet
Another building blocks for prop224 service work. This also makes the function takes specific argument instead of the or_option_t object. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-04-03Merge remote-tracking branch 'teor/bug21596_030' into maint-0.3.0Nick Mathewson
2017-03-15Run the copyright update script.Nick Mathewson