From f1f08852ceddea6f66627b8473f9b0177ddd8fef Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Sun, 16 Feb 2003 10:07:27 +0000 Subject: Append random garbage to pings so they have different lengths --- Echolot/Chain.pm | 5 +++-- Echolot/Config.pm | 8 ++++++-- Echolot/Pinger.pm | 5 +++-- Echolot/Tools.pm | 31 ++++++++++++++++++++++++++++++- NEWS | 8 ++++++++ 5 files changed, 50 insertions(+), 7 deletions(-) diff --git a/Echolot/Chain.pm b/Echolot/Chain.pm index 63e4a5b..2f2ca52 100644 --- a/Echolot/Chain.pm +++ b/Echolot/Chain.pm @@ -1,7 +1,7 @@ package Echolot::Chain; # (c) 2002 Peter Palfrader -# $Id: Chain.pm,v 1.5 2003/02/16 09:09:57 weasel Exp $ +# $Id: Chain.pm,v 1.6 2003/02/16 10:07:27 weasel Exp $ # =pod @@ -86,7 +86,8 @@ sub do_chainping($$$$$$$) { "type2: $type2\n". "key2: $key2\n". "sent: $now\n". - "mac: $mac\n"; + "mac: $mac\n". + Echolot::Tools::make_garbage(); $body = Echolot::Tools::crypt_symmetrically($body, 'encrypt'); my $to = Echolot::Tools::make_address('chainping'); diff --git a/Echolot/Config.pm b/Echolot/Config.pm index 5696d80..2698dd4 100644 --- a/Echolot/Config.pm +++ b/Echolot/Config.pm @@ -1,7 +1,7 @@ package Echolot::Config; # (c) 2002 Peter Palfrader -# $Id: Config.pm,v 1.54 2003/02/16 09:13:51 weasel Exp $ +# $Id: Config.pm,v 1.55 2003/02/16 10:07:27 weasel Exp $ # =pod @@ -64,6 +64,7 @@ sub init($) { # System Specific Options recipient_delimiter => '+', dev_random => '/dev/random', + dev_urandom => '/dev/urandom', sendmail => '/usr/sbin/sendmail', # Magic Numbers @@ -112,13 +113,16 @@ sub init($) { check_resurrection_ttl => 8, # check_resurrection seconds (weeks) prospective_addresses_ttl => 5*24*60*60, # 5 days reliable_auto_add_min => 3, # 3 remailes need to list new address - + expire_keys => 5*24*60*60, # 5 days expire_confs => 5*24*60*60, # 5 days expire_pings => 12*24*60*60, # 12 days expire_thesaurus => 21*24*60*60, # 21 days expire_chainpings => 12*24*60*60, # 12 days + random_garbage => 8192, + + # Directories and files mailin => 'mail', mailerrordir => 'mail-errors', diff --git a/Echolot/Pinger.pm b/Echolot/Pinger.pm index dcb03cc..792cb1d 100644 --- a/Echolot/Pinger.pm +++ b/Echolot/Pinger.pm @@ -1,7 +1,7 @@ package Echolot::Pinger; # (c) 2002 Peter Palfrader -# $Id: Pinger.pm,v 1.24 2003/02/14 04:57:45 weasel Exp $ +# $Id: Pinger.pm,v 1.25 2003/02/16 10:07:27 weasel Exp $ # =pod @@ -71,7 +71,8 @@ sub do_ping($$$) { "type: $type\n". "key: $key\n". "sent: $now\n". - "mac: $mac\n"; + "mac: $mac\n". + Echolot::Tools::make_garbage(); $body = Echolot::Tools::crypt_symmetrically($body, 'encrypt'); my $to = Echolot::Tools::make_address('ping'); diff --git a/Echolot/Tools.pm b/Echolot/Tools.pm index 86adb91..2094d5c 100644 --- a/Echolot/Tools.pm +++ b/Echolot/Tools.pm @@ -1,7 +1,7 @@ package Echolot::Tools; # (c) 2002 Peter Palfrader -# $Id: Tools.pm,v 1.15 2003/02/15 11:43:41 weasel Exp $ +# $Id: Tools.pm,v 1.16 2003/02/16 10:07:27 weasel Exp $ # =pod @@ -308,6 +308,35 @@ sub crypt_symmetrically($$) { return $result; }; +sub make_garbage() { + + my $file = Echolot::Config::get()->{'dev_urandom'}; + open(FH, $file) or + Echolot::Log::warn("Cannot open $file: $!."), + return ""; + my $random = ''; + my $want = rand(int(Echolot::Config::get()->{'random_garbage'} / 2)); + my $i = 0; + while ($want > 0) { + my $buf; + $want -= read(FH, $buf, $want); + $random .= $buf; + ($i++ > 15 && $want > 0) and + Echolot::Log::warn("Could not get enough garbage (still missing $want."), + last; + }; + close (FH) or + Echolot::Log::warn("Cannot close $file: $!."); + + $random = unpack("H*", $random); + $random = join "\n", grep { $_ ne '' } (split /(.{64})/, $random); + $random = "----- BEGIN GARBAGE' -----\n". + $random."\n". + "----- BEGIN GARBAGE' -----\n"; + + return $random; +}; + 1; # vim: set ts=4 shiftwidth=4: diff --git a/NEWS b/NEWS index 3727d5d..8183764 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,14 @@ Changes in version * Minor documentation fixes suggested by Ryan Lackey. * Removed --pgp2 in CPunk RSA pings. + * Append random garbage to pings so they have different + lengths. + new options: + - random_gabage (default: 8192) + Garbage length is chosen uniformly from 0 to random_gabage bytes. + - dev_urandom (default: /dev/urandom) + where to read garbage from (more generally: non-blocking + (low-quality) randomless source) Changes in version 2.0.10 - 2003-02-03 * Return undef rather than 0 if we cannot open a Maildir. -- cgit v1.2.3