Re: Private/Public keys over the network

[email protected] (Dave Paris) Fri, 03 Aug 2001 02:22:59 -0400
Newsgroups perl.crypto
Organization W3Works, LLC
Message-ID <[email protected]>
Serializing the object using Storable's nstore method works quite well.

## start example.pl ##
#!/usr/local/bin/perl

package Foo;

use Storable qw(nstore retrieve);
use Data::Dumper;

sub new {
    my ($self, $args) = @_;
    bless {
        one => $args->{one},
        two => $args->{two},
    }, $self;
}

if($ARGV[0] eq 'write') {
    my $args = {
        one => $ARGV[1],
        two => $ARGV[2],
    };
    my $obj = new Foo ($args);
    nstore $obj, './foo.store';
}

if($ARGV[0] eq 'read') {
    my $obj = retrieve('./foo.store');
    print Dumper($obj);
}

exit 0;
## end example.pl

Using a network transport produces the same result as storing to a file,
provided the network byte order format is used (nstore, in this case).

usage:
]$ ./example.pl write biz baz
]$ ./example.pl read
$VAR1 = bless( {
                 'one' => 'biz',
                 'two' => 'baz'
               }, 'Foo' );

Oh, and do lose the idea of transporting private keys over unsecured
public network links - that's just asking for trouble.

Best~
d.

Ramkumar Chinchani wrote:
> 
> I dont know if this is the right list for this question. However, here goes.
> 
> I wrote up a small server client setup, where the server generates
> public/private key pairs using Crypt::RSA written by Vipul Ved Prakash, and I
> send the public key over from the server to the client.
> 
> The other end receives it correctly, but isn't able to locate a method for the
> object. Apparently, the entire object tree doesn't get sent over. Is there any
> way around this? What would be the proper way to reinitialize the key object
> once it is received at the client end?
> 
> Thanks.
> 
> BTW, the error verbatim is:
> 
> Can't locate object method "check" via package
> "Crypt::RSA::Key::Public=HASH(0x81c7c0c)" (perhaps you forgot to load
> "Crypt::RSA::Key::Public=HASH(0x81c7c0c)"?) at
> /usr/local/lib/perl5/site_perl/5.6.1/Crypt/RSA.pm line 95, <GEN0> line 1.