| Net-FCP documentation | Contained in the Net-FCP distribution. |
Net::FCP::Key::SSK - manage SSK keys.
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);
Various way to create a SSK key object.
Write the key to the givne file. Unencrypted.
Returns a stringified version fo the key data (in no standard format).
Build a public SSK subkey with the given name and return it as a URI without
freenet:-prefix.
Build a private SSK subkey with the given name and return it as a URI without
freenet:-prefix.
Not heavily tested.
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;