From 303f6333f64497a9c5b09708a449cedafd07e135 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 21 Oct 2011 21:39:36 +0000 Subject: [PATCH] obfuscation of TR and SR by random rare non-increase of length 1 requests (original idea by Costa) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4647 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/turtle/p3turtle.cc | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/turtle/p3turtle.cc b/libretroshare/src/turtle/p3turtle.cc index 5e90a4222..79f5a7970 100644 --- a/libretroshare/src/turtle/p3turtle.cc +++ b/libretroshare/src/turtle/p3turtle.cc @@ -796,6 +796,7 @@ void p3turtle::handleSearchRequest(RsTurtleSearchRequestItem *item) // to scramble a possible search-by-depth attack. // bool random_bypass = (item->depth == TURTLE_MAX_SEARCH_DEPTH && (((_random_bias ^ item->request_id)&0x7)==2)) ; + bool random_dshift = (item->depth == 1 && (((_random_bias ^ item->request_id)&0x7)==6)) ; if(item->depth < TURTLE_MAX_SEARCH_DEPTH || random_bypass) { @@ -814,7 +815,15 @@ void p3turtle::handleSearchRequest(RsTurtleSearchRequestItem *item) // Copy current item and modify it. RsTurtleSearchRequestItem *fwd_item = item->clone() ; - ++(fwd_item->depth) ; // increase search depth + // increase search depth, except in some rare cases, to prevent correlation between + // TR sniffing and friend names. The strategy is to not increase depth if the depth + // is 1: + // If B receives a TR of depth 1 from A, B cannot deduice that A is downloading the + // file, since A might have shifted the depth. + // + if(!random_dshift) + ++(fwd_item->depth) ; + fwd_item->PeerId(*it) ; sendItem(fwd_item) ; @@ -1712,6 +1721,7 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item) // If search depth not too large, also forward this search request to all other peers. // bool random_bypass = (item->depth >= TURTLE_MAX_SEARCH_DEPTH && (((_random_bias ^ item->partial_tunnel_id)&0x7)==2)) ; + bool random_dshift = (item->depth == 1 && (((_random_bias ^ item->partial_tunnel_id)&0x7)==6)) ; if(item->depth < TURTLE_MAX_SEARCH_DEPTH || random_bypass) { @@ -1730,7 +1740,15 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item) // Copy current item and modify it. RsTurtleOpenTunnelItem *fwd_item = new RsTurtleOpenTunnelItem(*item) ; - ++(fwd_item->depth) ; // increase tunnel depth + // increase search depth, except in some rare cases, to prevent correlation between + // TR sniffing and friend names. The strategy is to not increase depth if the depth + // is 1: + // If B receives a TR of depth 1 from A, B cannot deduice that A is downloading the + // file, since A might have shifted the depth. + // + if(!random_dshift) + ++(fwd_item->depth) ; // increase tunnel depth + fwd_item->PeerId(*it) ; {