use Module::Load::Conditional qw[can_load check_install requires]; $Module::Load::Conditional::VERBOSE = 1; my $crypt_mods = {'Crypt::DH::GMP' => undef, 'Crypt::CBC' => undef, 'Crypt::Blowfish' => undef, 'Digest::SHA' => undef, 'MIME::Base64' => undef, 'Compress::Zlib' => undef}; if (can_load(modules => $crypt_mods, verbose => 1)) { $encryption_avail = 1; } my ($DH_public, $DH_public2, $DH_private, $DH_secret); [...] sub create_public_key { my $to = lc($_[0]); my $from = lc($_[1]); my $player = $_[2]; my ($DH, $p, $g, $i, $public, @chars); @chars = split(//,($player ? $to : $from)); $g = ord(shift(@chars)); while (scalar @chars) { $g += ord(shift(@chars)); } @chars = split(//, ($player ? $from : $to)); $i = ord(shift(@chars)); while (scalar @chars) { $i += ord(shift(@chars)); } $i %= scalar(@EICB_PRIMES); $p = $EICB_PRIMES[$i]; $DH = Crypt::DH::GMP->new; $DH->g($g); $DH->p($p); $DH->generate_keys; $DH_public = $DH->pub_key; $DH_private = $DH->priv_key; } sub create_secret_key { my $to = lc($_[0]); my $from = lc($_[1]); my $player = $_[2]; my ($DH, $p, $g, $i, $public, @chars); @chars = split(//,($player ? $to : $from)); $g = ord(shift(@chars)); while (scalar @chars) { $g += ord(shift(@chars)); } @chars = split(//,($player ? $from : $to)); $i = ord(shift(@chars)); while (scalar @chars) { $i += ord(shift(@chars)); } $i %= scalar(@EICB_PRIMES); $p = $EICB_PRIMES[$i]; $DH = Crypt::DH::GMP->new; $DH->g($g); $DH->p($p); $DH->priv_key($DH_private); $DH->generate_keys; $DH_secret = $DH->compute_secret($DH_public2); } [...] sub do_crypt_command { my ($who, $args, $time) = @_; my @args = split(/\s+/, $args); my $command = shift (@args); if ($command == $EICB_DH_INIT) { create_public_key($who, $cur_nick, 0); $connection->sendpriv($who, sprintf('%s%s %s', $EICB_CRYPT_PREFIX, $EICB_DH_REPLY, $DH_public)); } elsif ($command == $EICB_DH_REPLY) { $DH_public2 = shift(@args); create_public_key($who, $cur_nick, 1); $connection->sendpriv($who, sprintf('%s%s %s', $EICB_CRYPT_PREFIX, $EICB_DH_REPLY2, $DH_public)); create_secret_key($who, $cur_nick, 1); } elsif ($command == $EICB_DH_REPLY2) { $DH_public2 = shift(@args); create_secret_key($who, $cur_nick, 0); my $sha1 = Digest::SHA->new; $sha1->add($logbuffer[rand(scalar @logbuffer)]); my $key = $sha1->b64digest; $session_keys{lc($who)} = $key; encrypt(\$key, $cipher, $DH_secret); $connection->sendpriv($who, sprintf('%s%s %s', $EICB_CRYPT_PREFIX, $EICB_SESSION_KEY, $key)); timestamp($time) if ($timestamps_active); icb_print ($output_window, 'sbrkt', "%s", "[="); icb_print ($output_window, 'status', "%s", "SECURE"); icb_print ($output_window, 'sbrkt', "%s", "=]"); icb_print ($output_window, 'status', " Session key for user %s established\n", $who); $tabhist{lc($who)} = time(); } [...] #### Thread 3 terminated abnormally: Usage: Crypt::DH::GMP::priv_key(dh) at ./icbm line 2434.