OurNet-BBS

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

    ],
    'OurNet Client'		=> [
	recommends(
	    'Storable'		=> '1.011',
	    'RPC::PlClient'	=> '0.2013',
	    @cipher_module,
	),
    ],
    'GnuPG Encryption'		=> [ 
	-default		=> (
	    (can_run('gpg') and can_cc()) ? 1 : 0
	),
	recommends(
	    'Class::MethodMaker'=> '1.00',
	    'GnuPG::Interface'	=> '0.31',
	    'Term::ReadKey'	=> '2.13',
	),
    ],
    'Usenet News (NNTP)'	=> [
	recommends(
	    'Net::NNTP'		=> '2.19',

lib/OurNet/BBS/Authen.pm  view on Meta::CPAN

	$self->{gnupg}->options->push_recipients($who);
	$self->{gnupg}->passphrase($self->{pass} = $pass) if defined $pass;
    }

    return $self;
}

sub export_key {
    my $self = shift;

    return scalar `gpg --armor --export $self->{keyid}`;
}

sub test {
    my $self = shift;
    return ($self->{gnupg} and $self->{gnupg}->test_default_key_passphrase);
}

# query for existing BCB ciphers
sub suites {
    my ($self, @ciphers) = @_;

lib/OurNet/BBS/Authen.pm  view on Meta::CPAN

    $cipher_level ||= (CIPHER_NONE | CIPHER_BASIC | CIPHER_PGP);
    $auth_level   ||= (AUTH_NONE | AUTH_CRYPT | AUTH_PGP);

    if ($cipher_level & CIPHER_PGP or $auth_level & AUTH_PGP) {
    	if (!load_ok('GnuPG::Interface')) {
	    # pgp support broken, so...
	    $cipher_level &= ~CIPHER_PGP;
	    $auth_level   &= ~AUTH_PGP;
	}
	elsif ($keyid) {
	    unless ($Pubkey = `gpg --armor --export $keyid`) {
		$cipher_level &= ~CIPHER_PGP;
		$auth_level   &= ~AUTH_PGP;
	    }
	}
	elsif (!`gpg --version`) {
	    $cipher_level &= ~CIPHER_PGP;
	    $auth_level   &= ~AUTH_PGP;
	}
	else {
	    $cipher_level &= ~CIPHER_PGP unless $clientflag;
	    $auth_level   &= ~AUTH_PGP;
	}
    }

    if ($auth_level & AUTH_CRYPT) {

lib/OurNet/BBS/Authen.pm  view on Meta::CPAN


    return ($cipher_level, $auth_level);
}

sub setpass {
    my ($self, $pass) = @_;

    $self->{gnupg}->passphrase($self->{pass} = $pass);
}

sub gpg_setup {
    my ($input, $output, $stderr) = ( 
	IO::Handle->new(),
	IO::Handle->new(),
	IO::Handle->new(),
    );

    my $handles = GnuPG::Handles->new( 
        stdin  => $input,
        stdout => $output,
        stderr => $stderr,

lib/OurNet/BBS/Authen.pm  view on Meta::CPAN

    $subname =~ s/_keys/_key/;

    *{__PACKAGE__."::$subname"} = sub {
	my $self = shift;

	if ($method eq 'decrypt' and not defined $self->{pass}) {
	    print "error: no passphrase for $self->{who}.\n";
	    exit;
	}

	my ($i, $o, $e, $h) = gpg_setup();

	my $pid = $self->{gnupg}->$method( 
	    handles => $h,
	    command_args => (
		($method eq 'clearsign') ? (
		    ['--default-key',  $self->{keyid}],
		) : ($method eq 'sign') ? (
		    ['--default-key',  $self->{keyid}],
		) : ( '' ),
	    )

lib/OurNet/BBS/Authen.pm  view on Meta::CPAN

    *POSIX::STDOUT_FILENO = sub { 1 };
    *POSIX::STDIN_FILENO = sub { 0 };

    eval <<'.';
	
no warnings 'redefine';

sub import_key {
    my ($self, $pubkey) = @_;
    
    open my $FH, '| gpg --import --quiet --batch';
    print $FH $pubkey;
    close $FH;
    
    return $pubkey;
}

sub encrypt {
    my ($self, $message) = @_;

    open my $FH, '>', 'encrypt' or die "$!";
    print $FH $message;
    close $FH;
    
    return if system("gpg --yes --encrypt --quiet --batch --always-trust --armor -r $self->{who} -o encrypt.gpg encrypt");
    
    local $/;
    open $FH, 'encrypt.gpg' or die "$!";
    $message = <$FH>;
    close $FH;

    unlink 'encrypt';
    unlink 'encrypt.gpg';
    
    return $message;
}

sub clearsign {
    my ($self, $message) = @_;

    open my $FH, '> encrypt' or die "$!";
    print $FH $message;
    close $FH;

    return if system(
	"gpg --yes --clearsign -u $self->{keyid} -o encrypt.gpg encrypt"
    );
    
    local $/;
    open $FH, 'encrypt.gpg' or die "$!";
    $message = <$FH>;
    close $FH;

    unlink 'encrypt';
    unlink 'encrypt.gpg';
    
    return $message;
}

.
}

1;

####################################################################### {{{

lib/OurNet/BBS/Server.pm  view on Meta::CPAN


sub set_sign {
    my ($self, $signature) = @_;

    show("...setsign");

    my $response = $Auth->verify($signature);

    if (!$response or
	index($response, "key ID $Auth->{keyid}") > -1	and
	index($response, "gpg: BAD signature") == -1	and
	index($signature, "$Auth->{challenge}\n") > -1) 
    {
	show("...done!\n");
	nextstate('locate', 'relay');
	return ($OP->{STATUS_ACCEPTED}, AUTH_PGP);
    }
    else { 
	show("...failed! ($signature, $response)\n");
	nextstate();
	return $OP->{STATUS_BAD_SIGNATURE}



( run in 0.427 second using v1.01-cache-2.11-cpan-df04353d9ac )