File Coverage

blib/lib/Crypt/RSA/Key/Public/SSH.pm
Criterion Covered Total %
statement 31 31 100.0
branch 2 4 50.0
condition n/a
subroutine 8 8 100.0
pod 2 2 100.0
total 43 45 95.5


line stmt bran cond sub pod time code
1             package Crypt::RSA::Key::Public::SSH;
2 2     2   1508 use strict;
  2         6  
  2         60  
3 2     2   10 use warnings;
  2         5  
  2         78  
4              
5             ## Crypt::RSA::Key::Private::SSH
6             ##
7             ## Copyright (c) 2001, Vipul Ved Prakash. All rights reserved.
8             ## This code is free software; you can redistribute it and/or modify
9             ## it under the same terms as Perl itself.
10              
11 2     2   10 use Carp qw/croak/;
  2         5  
  2         132  
12 2     2   12 use Crypt::RSA::DataFormat qw(bitsize);
  2         5  
  2         76  
13 2     2   10 use Crypt::RSA::Key::Public;
  2         5  
  2         57  
14 2     2   10 use base qw( Crypt::RSA::Key::Public );
  2         5  
  2         549  
15              
16             sub deserialize {
17 1     1 1 981 my ($self, %params) = @_;
18 1         3 my $string = $params{String};
19 1 50       4 croak "Must supply String=>'blob' to deserialize" unless defined $string;
20 1 50       3 $string = join('', @$string) if ref($string) eq 'ARRAY';
21 1         9 my ($bitsize, $e, $n, $ident) = split /\s/, $string, 4;
22 1         8 $self->n ($n);
23 1         6 $self->e ($e);
24 1         6 $self->Identity ($ident);
25 1         4 return $self;
26             }
27              
28             sub serialize {
29 1     1 1 8 my ($self, %params) = @_;
30 1         7 my $bitsize = bitsize ($self->n);
31 1         7 my $string = join ' ', $bitsize, $self->e, $self->n, $self->Identity;
32 1         85 return $string;
33             }
34              
35             1;
36              
37             =head1 NAME
38              
39             Crypt::RSA::Key::Public::SSH - SSH Public Key Import
40              
41             =head1 SYNOPSIS
42              
43             Crypt::RSA::Key::Public::SSH is a class derived from
44             Crypt::RSA::Key::Public that provides serialize() and
45             deserialze() methods for SSH 2.x keys.
46              
47             =head1 AUTHOR
48              
49             Vipul Ved Prakash, Email@vipul.netE
50              
51             =cut
52              
53