Crypt-Keys

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


0.06  2002.02.16
    - First public release.
    - Added Filename argument to Crypt::Keys->detect.
    - Got rid of reliance upon File::Type; don't really need that much
      overhead, just a couple of regular expressions will do.
    - Added tests for Crypt::Keys->detect, for return value format
      and contents ('Format' and 'Description' of keyfiles).
    - Incorporated changes to Util::mp2bin and Util::bin2mp from
      Crypt::OpenPGP::Util.
    - Moved Crypt::DES3 code into Crypt::Keys::Private::RSA::SSH1, because
      that's the only place it is used.

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.

Makefile.PL  view on Meta::CPAN

my %PREREQS = (
    _base => {
        'Digest::MD5'       => 0,
        'Math::Pari'        => '2.001804',
        '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};
    }
}
$PREREQS{_all} = \%all;

README  view on Meta::CPAN

The base prereqs are these:

    * Digest::MD5
    * Math::Pari (2.001804 or greater)
    * 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,
and you'll be on your way.

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

package Crypt::Keys::Private::RSA::SSH1;
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;

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

        $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 {
    my($cipher, $text) = @_;
    $cipher->{cbc3}->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 0.313 second using v1.01-cache-2.11-cpan-9a3d99fc6dc )