summaryrefslogtreecommitdiff
path: root/src/or/hs_common.h
AgeCommit message (Collapse)Author
2018-01-19Merge branch 'maint-0.3.2'Nick Mathewson
2018-01-19Merge branch 'bug24895_031_02' into bug24895_032_02David Goulet
2018-01-19Merge branch 'bug24895_029_02' into bug24895_031_02David Goulet
2017-12-20Merge branch 'maint-0.3.2'Nick Mathewson
2017-12-20Merge remote-tracking branch 'dgoulet/ticket24425_032_01' into maint-0.3.2Nick Mathewson
2017-12-11Merge branch 'maint-0.3.2'Nick Mathewson
2017-12-08Merge branch 'macro_free_v2_squashed'Nick Mathewson
2017-12-08Fix wide lines introduced by previous patch.Nick Mathewson
2017-12-08Replace all FREE_AND_NULL* uses to take a type and a free function.Nick Mathewson
This commit was made mechanically by this perl script: \#!/usr/bin/perl -w -i -p next if /^#define FREE_AND_NULL/; s/\bFREE_AND_NULL\((\w+),/FREE_AND_NULL\(${1}_t, ${1}_free_,/; s/\bFREE_AND_NULL_UNMATCHED\(/FREE_AND_NULL\(/;
2017-12-08Change the free macro convention in the rest of src/or/*.hNick Mathewson
2017-12-05hs-v3: Cleanup HS circuits when marking as closedDavid Goulet
First, hs_service_intro_circ_has_closed() is now called in circuit_mark_for close() because the HS subsystem needs to learn when an intro point is actually not established anymore as soon as possible. There is a time window between a close and a free. Second, when we mark for close, we also remove it from the circuitmap because between the close and the free, a service can launch an new circuit to that same intro point and thus register it which only succeeds if the intro point authentication key is not already in the map. However, we still do a remove from the circuitmap in circuit_free() in order to also cleanup the circuit if it wasn't marked for close prior to the free. Fixes #23603 Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-11-29hs-v3: Bump hsdir_spread_store from 3 to 4David Goulet
Per the analysis in https://trac.torproject.org/projects/tor/ticket/23170#comment:17, this will greatly improve service reachability. Closes #24425 Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-11-20hs: Rename rend_service_add_ephemeral_status_tDavid Goulet
Move it to hs_common.h and rename it "hs_service_add_ephemeral_status_t". It will be shared between v2 and v3 services. Part of #20699 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-15Run our #else/#endif annotator on our source code.Nick Mathewson
2017-09-08prop224: Pick the right hsdir index based on descriptor.George Kadianakis
There was a bug in upload_descriptor_to_all() where we picked between first and second hsdir index based on which time segment we are. That's not right and instead we should be uploading our two descriptors using a different hsdir index every time. That is, upload first descriptor using first hsdir index, and upload second descriptor using second hdsir index. Also simplify stuff in pick_hdsir_v3() since that's only used to fetch descriptors and hence we can just always use the fetch hsdir index.
2017-09-08prop224: hs_time_between_tp_and_srv() -> hs_in_period_between_tp_and_srv()George Kadianakis
Conflicts: src/or/nodelist.c
2017-09-08prop224: 'is_new_tp' -> 'use_second_hdsir_index' in hs_get_responsible_hsdirs()George Kadianakis
2017-09-08prop224: Make client and service pick same HSDirDavid Goulet
With the latest change on how we use the HSDir index, the client and service need to pick their responsible HSDir differently that is depending on if they are before or after a new time period. The overlap mode is active function has been renamed for this and test added. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-08prop224: Expand the overlap period concept to be a full SRV protocol runDavid Goulet
Because of #23387, we've realized that there is one scenario that makes the client unable to reach the service because of a desynch in the time period used. The scenario is as follows: +------------------------------------------------------------------+ | | | 00:00 12:00 00:00 12:00 00:00 12:00 | | SRV#1 TP#1 SRV#2 TP#2 SRV#3 TP#3 | | | | $==========|-----------$===========|-----------$===========| | | ^ ^ | | C S | +------------------------------------------------------------------+ In this scenario the HS has a newer consensus than the client, and the HS just moved to the next TP but the client is still stuck on the old one. However, the service is not in any sort of overlap mode so it doesn't cover the old TP anymore, so the client is unable to fetch a descriptor. We've decided to solve this by extending the concept of overlap period to be permanent so that the service always publishes two descriptors and aims to cover clients with both older and newer consensuses. See the spec patch in #23387 for more details.
2017-09-08prop224: Use fetch and store HSDir indexes.David Goulet
Based on our #23387 findings, it seems like to maintain 24/7 reachability we need to employ different logic when computing hsdir indices for fetching vs storing. That's to guarantee that the client will always fetch the current descriptor, while the service will always publish two descriptors aiming to cover all possible edge cases. For more details see the next commit and the spec branch. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24prop224: Make lspecs to extend info publicDavid Goulet
The hs circuit file had this function that takes a list of link specifiers and return a newly allocated extend info object. Make it public so the client side can also use it to be able to extend to introduction point. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24prop224: Refactor pick_hsdir() to be used by both v2 and v3.George Kadianakis
Also refactor rendclient.c to use the new hs_pick_hdsir() func. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24prop224: Fix hidserv request code to work for both v2 and v3.George Kadianakis
See documentation of `last_hid_serv_requests_` for how it works. strmaps are cool! Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-24prop224: Move some rendclient.c code to hs_common.cGeorge Kadianakis
Specifically move the pick_hsdir() function and all the HSDir request tracking code. We plan to use all that code both for v2 and v3. This commit only moves code. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Function to inc/decrement num rendezvous streamGeorge Kadianakis
Add a common function for both legacy and prop224 hidden service to increment and decrement the rendezvous stream counter on an origin circuit. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08Start caching disaster SRV values.George Kadianakis
Also add some unittests.
2017-08-08Don't set HSDir index if we don't have a live consensus.George Kadianakis
We also had to alter the SRV functions to take a consensus as optional input, since we might be setting our HSDir index using a consensus that is currently being processed and won't be returned by the networkstatus_get_live_consensus() function. This change has two results: a) It makes sure we are using a fresh consensus with the right SRV value when we are calculating the HSDir hash ring. b) It ensures that we will not use the sr_get_current/previous() functions when we don't have a consensus which would have falsely triggered the disaster SRV logic.
2017-08-08prop224: Refactor hs_get_time_period_num() to not use absolute time.George Kadianakis
Instead use the SRV protocol duration to calculate the rotation offset that was previously hardcoded to 12 hours.
2017-08-08prop224: Compute start time of next time period.George Kadianakis
2017-08-08test: Add unit test coverage of hs_service.cDavid Goulet
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: Add a responsible HSDir functionDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Add hsdir consensus parametersDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Build hsdir index for node_tDavid Goulet
This hsdir index value is used to give an index value to all node_t (relays) that supports HSDir v3. An index value is then computed using the blinded key to know where to fetch/upload the service descriptor from/to. To avoid computing that index value everytime the client/service needs it, we do that everytime we get a new consensus which then doesn't change until the next one. The downside is that we need to sort them once we need to compute the set of responsible HSDir. Finally, the "hs_index" function is also added but not used. It will be used in later commits to compute which node_t is a responsible HSDir for the service we want to fetch/upload the descriptor. 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: Implement subcredential creationDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Add descriptor overlap mode functionGeorge Kadianakis
The function has been added but not used except for the unit tests. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: API for the creation of blinded keysDavid Goulet
Add a function for both the client and service side that is building a blinded key from a keypair (service) and from a public key (client). Those two functions uses the current time period information to build the key. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-07-25prop224: Helper to dup a link_specifier_t objectDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-07-13prop224: Don't use char * for binary dataDavid Goulet
It turns out that some char * sneaked in our hs_common.c code. Replace those by uint8_t *. 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: Service address creation/validationDavid Goulet
This also adds unit test and a small python script generating a deterministic test vector that a unit test tries to match. 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 a init/free_all function for the whole subsystemDavid Goulet
Introduces hs_init() located in hs_common.c which initialize the entire HS v3 subsystem. This is done _prior_ to the options being loaded because we need to allocate global data structure before we load the configuration. The hs_free_all() is added to release everything from tor_free_all(). Note that both functions do NOT handle v2 service subsystem but does handle the common interface that both v2 and v3 needs such as the cache and circuitmap. 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-07prop224: Add connection and circuit identifier objectDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-04-18prop224: Add time period functions and unittestsGeorge Kadianakis
This will be used by the build blinded key functions. 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: Remove redundant define of ed25519 auth key typeDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>