Crypt-Keys

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

0.05  2001.07.11
    - Documented data structure formats for Private key return
      values.
    - Standardized RSA-private return values. Private::RSA::SSH1 now
      calculates dp, dq, and iqmp on deserialize, and calculates u
      on serialize, in order to conform to the specification for
      RSA-private return values.

0.04  2001.07.10
    - Added test suite. Tests utilities (Util), buffer (Buffer),
      3DES inner-CBC encrypt/decrypt (DES3), all private key
      modules that are installed (Private), and all public key
      modules that are installed (Public).

0.03  2001.07.10
    - Added docs to Crypt::Keys.
    - Added bin/keydetect.
    - Added better error-handling through ErrorHandler.
    - Added Crypt::Keys::Buffer, which is a generalized
      buffer built on top of Data::Buffer that can handle
      any sort of SSH-style buffer.

Makefile.PL  view on Meta::CPAN

        'Data::Buffer'      => 0,
        'MIME::Base64'      => 0,
    },

    PEM   => {
        'Convert::PEM'      => '0.05',
        'Crypt::DES'        => 0,
    },

    SSH   => {
        'Crypt::CBC'        => '2.00',
        'Crypt::DES'        => 0,
    },
);

my %all;
for my $type (keys %PREREQS) {
    for my $mod (keys %{ $PREREQS{$type} }) {
        $all{$mod} = $PREREQS{$type}{$mod};
    }
}

README  view on Meta::CPAN

    * Data::Buffer
    * MIME::Base64

If you wish to read/write PEM-encoded files, you will also need

    * Convert::PEM (0.05 or greater)
    * Crypt::DES

And if you wish to work with SSH1 RSA files, you will need:

    * Crypt::CBC
    * Crypt::DES

INSTALLATION

Crypt::Keys installation is straightforward. If your cpan shell
is set up, you should just be able to do

    % perl -MCPAN -e 'install Crypt::Keys'

Answer the questions as to which encodings you prefer to use,

lib/Crypt/Keys/Private/RSA/SSH1.pm  view on Meta::CPAN

use strict;

use constant PRIVKEY_ID => "SSH PRIVATE KEY FILE FORMAT 1.1\n";

use vars qw( %CIPHERS );
BEGIN {
    %CIPHERS = (
        1 => undef,    ## IDEA: requires CFB
        2 => sub {     ## DES
                 require Crypt::DES;
                 Crypt::CBC->new(
                            Cipher => Crypt::DES->new(substr $_[0], 0, 8),
                            IV     => chr(0)x8,
                       );
             },
        3 => sub {     ## 3DES
                 Crypt::Keys::Private::RSA::SSH1::DES3->new($_[0]);
             },
    );
}

use Crypt::CBC;
use Digest::MD5 qw( md5 );
use Crypt::Keys::Util qw( bitsize mod_inverse );
use Crypt::Keys::Buffer;

use Crypt::Keys::ErrorHandler;
use base qw( Crypt::Keys::ErrorHandler );

sub deserialize {
    my $class = shift;
    my %param = @_;

lib/Crypt/Keys/Private/RSA/SSH1.pm  view on Meta::CPAN

    else {
        $encrypted->append($buffer->bytes);
    }
    
    $encrypted->bytes;
}

package Crypt::Keys::Private::RSA::SSH1::DES3;
use strict;

use Crypt::CBC;
use Crypt::DES;

sub new {
    my $class = shift;
    my $cipher = bless {}, $class;
    $cipher->init(@_) if @_;
    $cipher;
}

sub init {
    my $cipher = shift;
    my($key) = @_;
    for my $i (1..3) {
        my $this_key = $i == 3 && length($key) <= 16 ?
            substr $key, 0, 8 :
            substr $key, 8*($i-1), 8;
        $cipher->{"cbc$i"} = Crypt::CBC->new({
                  key => $this_key,
                  cipher => 'Crypt::DES',
                  regenerate_key => 0,
                  iv => chr(0)x8,
                  prepend_iv => 0,
             });
    }
}

sub encrypt {

t/03-3des.t  view on Meta::CPAN

# $Id: 03-3des.t,v 1.2 2002/02/16 18:29:57 btrott Exp $

use strict;

use Test;

BEGIN {
    eval "use Crypt::CBC; use Crypt::DES;";
    if ($@) {
        print "1..0 skipping\n";
        exit;
    }

    plan tests => 6;
}

use Crypt::Keys::Private::RSA::SSH1;

t/10-private.t  view on Meta::CPAN

# $Id: 10-private.t,v 1.5 2002/02/16 18:26:44 btrott Exp $

use Test;
use Crypt::Keys;

my($no_pem, $no_ssh1);
BEGIN {
    eval "use Convert::PEM;";
    $no_pem = $@;

    eval "use Crypt::CBC; use Crypt::DES;";
    $no_ssh1 = $@;
}

use File::Spec::Functions qw( catfile );

use vars qw( $SAMPLES );
my %ALG;
BEGIN {
    unshift @INC, 't/';
    require 'test-common.pl';



( run in 1.339 second using v1.01-cache-2.11-cpan-e1769b4cff6 )