summaryrefslogtreecommitdiff
path: root/Echolot
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2003-02-16 10:07:27 +0000
committerPeter Palfrader <peter@palfrader.org>2003-02-16 10:07:27 +0000
commitf1f08852ceddea6f66627b8473f9b0177ddd8fef (patch)
tree70c079112017bf8bb97b2de505d3685383934473 /Echolot
parent18c647bc293990fd8471d7d6fdb902315359dcfd (diff)
Append random garbage to pings so they have different lengths
Diffstat (limited to 'Echolot')
-rw-r--r--Echolot/Chain.pm5
-rw-r--r--Echolot/Config.pm8
-rw-r--r--Echolot/Pinger.pm5
-rw-r--r--Echolot/Tools.pm31
4 files changed, 42 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 <peter@palfrader.org>
-# $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 <peter@palfrader.org>
-# $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 <peter@palfrader.org>
-# $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 <peter@palfrader.org>
-# $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: