Net::FCP::Key::SSK - manage SSK keys.


Net-FCP documentation Contained in the Net-FCP distribution.

Index


Code Index:

NAME

Top

Net::FCP::Key::SSK - manage SSK keys.

SYNOPSIS

Top

 use Net::FCP::Key::SSK;

 my $key = new Net::FCP::Key::SSK $public, $private[, $crypto]
 my $key = new_from_file Net::FCP::Key::SSK $path;
 my $key = new_from_fcp Net::FCP::Key::SSK $fcp;
 my $key = new_from_string Net::FCP::Key::SSK $string;

 $key->as_string;
 $key->save ($path);

 my $ssk_public_uri  = $key->gen_pub  ($name);
 my $ssk_private_uri = $key->gen_priv ($name);

DESCRIPTION

Top

THE Net::FCP::Key::SSK CLASS

my $key = new Net::FCP::Key::SSK $public, $private[, $crypto]
my $key = new_from_file Net::FCP::Key::SSK $path;
my $key = new_from_fcp Net::FCP::Key::SSK $fcp;

Various way to create a SSK key object.

$key->save ($path)

Write the key to the givne file. Unencrypted.

$key->as_string

Returns a stringified version fo the key data (in no standard format).

my $puburi = $key->gen_pub ($name)

Build a public SSK subkey with the given name and return it as a URI without freenet:-prefix.

my $privuri = $key->gen_priv ($name)

Build a private SSK subkey with the given name and return it as a URI without freenet:-prefix.

SEE ALSO

Top

Net::FCP.

BUGS

Top

Not heavily tested.

AUTHOR

Top

 Marc Lehmann <schmorp@schmorp.de>
 http://home.schmorp.de/


Net-FCP documentation Contained in the Net-FCP distribution.
package Net::FCP::Key::SSK;

use Carp;

no warnings;

sub new {
   my $class = shift;

   bless {
      pub => $_[0],
      pri => $_[1],
      ent => $_[2],
   }, $class;
}

sub new_from_fcp {
   my ($class, $fcp) = @_;

   $class->new (@{ $fcp->generate_svk_pair })
}

sub new_from_string {
   my ($class, $string) = @_;

   $class->new ((split /[\x00-\x1f,]/, $string)[0,1,2])
}

sub new_from_file {
   my ($class, $path) = @_;

   open my $fh, "<", $path
      or croak "$path: $!";

   $class->new_from_string (scalar readline $fh);
}

sub save {
   my ($self, $path) = @_;

   open my $fh, ">", $path
      or croak "$path: $!";

   print $fh $self->as_string, "\n";
}

sub as_string {
   my ($self) = @_;

   "$self->{pub},$self->{pri},$self->{ent}";
}

sub gen_pub {
   my ($self, $name) = @_;

   "SSK\@$self->{pub}PAgM,$self->{ent}/$name";
}

sub gen_priv {
   my ($self, $name) = @_;

   "SSK\@$self->{pri},$self->{ent}/$name";
}

1;