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
This commit is contained in:
csoler 2011-10-21 21:39:36 +00:00
parent 521e9cb7c2
commit 303f6333f6

View File

@ -796,6 +796,7 @@ void p3turtle::handleSearchRequest(RsTurtleSearchRequestItem *item)
// to scramble a possible search-by-depth attack. // 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_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) if(item->depth < TURTLE_MAX_SEARCH_DEPTH || random_bypass)
{ {
@ -814,7 +815,15 @@ void p3turtle::handleSearchRequest(RsTurtleSearchRequestItem *item)
// Copy current item and modify it. // Copy current item and modify it.
RsTurtleSearchRequestItem *fwd_item = item->clone() ; 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) ; fwd_item->PeerId(*it) ;
sendItem(fwd_item) ; 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. // 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_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) if(item->depth < TURTLE_MAX_SEARCH_DEPTH || random_bypass)
{ {
@ -1730,7 +1740,15 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item)
// Copy current item and modify it. // Copy current item and modify it.
RsTurtleOpenTunnelItem *fwd_item = new RsTurtleOpenTunnelItem(*item) ; RsTurtleOpenTunnelItem *fwd_item = new RsTurtleOpenTunnelItem(*item) ;
// 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->depth) ; // increase tunnel depth
fwd_item->PeerId(*it) ; fwd_item->PeerId(*it) ;
{ {