Crypt-RSA

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


  * ::Key::Private::read() will call reveal() if the password is provided
    at construction. 

  * Added support for unencrypted keys to ::Key::Private.

  * ::Key::Private does not convert pari2pv at every STORE().
    Tie::EncryptedHash is created explicitely at hide().
    
  * Put together ::Key::Private::SSH from Benjamin Trott's patches and
    wrote ::Key::Public::SSH. ::Key::Private::SSH's CBC encryption is 
    not compatible with SSH yet.

  * Documented the Crypt::RSA error handling mechanism in
    Crypt::RSA::Errorhandler.

  * Encryption schemes, signature schemes and post processors are now
    loaded at runtime in Crypt::RSA. Suitable values for these can be
    specified at object construction. Primary reason for this is to
    interface with modules not included in the Crypt::RSA bundle.

META.yml  view on Meta::CPAN

  version: 1.3
name: Crypt-RSA
no_index:
  directory:
    - inc
    - t
requires:
  Class::Loader: 2.00
  Convert::ASCII::Armour: 0
  Crypt::Blowfish: 0
  Crypt::CBC: 0
  Crypt::Primes: 0.38
  Crypt::Random: 0.34
  Data::Buffer: 0
  Data::Dumper: 0
  Digest::MD2: 0
  Digest::MD5: 0
  Digest::SHA1: 0
  Math::Pari: 2.001804
  Sort::Versions: 0
  Tie::EncryptedHash: 0

Makefile.PL  view on Meta::CPAN

name            'Crypt-RSA';
abstract_from   'lib/Crypt/RSA.pm';
author          'Vipul Ved Prakash <mail@vipul.net>';
license         'perl';
version_from    'lib/Crypt/RSA.pm';
perl_version    '5.006';

requires        'Math::Pari'            => '2.001804';
requires        'Crypt::Random'         => '0.34';
requires        'Crypt::Primes'         => '0.38';
requires        'Crypt::CBC'            => 0;
requires        'Crypt::Blowfish'       => 0;
requires        'Data::Dumper'          => 0; 
requires        'Tie::EncryptedHash'    => 0;
requires        'Convert::ASCII::Armour'=> 0;
requires        'Sort::Versions'        => 0;
requires        'Digest::SHA1'          => 0;
requires        'Digest::MD5'           => 0;
requires        'Digest::MD2'           => 0;
requires        'Class::Loader'         => '2.00';
requires        'Data::Buffer'          => 0; 

lib/Crypt/RSA.pm  view on Meta::CPAN

indemnification. I'd be happy to provide a commercial license
if you need one. Please send me mail at C<mail@vipul.net> with
the subject "Crypt::RSA license". Please don't send me mail
asking if you need a commercial license. You don't, if
Artistic of GPL suit you fine.

=head1 SEE ALSO

Crypt::RSA::Primitives(3), Crypt::RSA::DataFormat(3),
Crypt::RSA::Errorhandler(3), Crypt::RSA::Debug(3), Crypt::Primes(3),
Crypt::Random(3), Crypt::CBC(3), Crypt::Blowfish(3),
Tie::EncryptedHash(3), Convert::ASCII::Armour(3), Math::Pari(3),
Class::Loader(3), crypt-rsa-interoperability(3),
crypt-rsa-interoperability-table(3).

=head1 REPORTING BUGS

All bug reports related to Crypt::RSA should go to rt.cpan.org 
at C<http://rt.cpan.org/Dist/Display.html?Queue=Crypt-RSA>

Crypt::RSA is considered to be stable. If you are running into a

lib/Crypt/RSA/Key.pm  view on Meta::CPAN

=item B<Identity>

A string that identifies the owner of the key. This string usually takes
the form of a name and an email address. The identity is not bound to the
key with a signature. However, a future release or another module will
provide this facility. 

=item B<Cipher>

The block cipher which is used for encrypting the private key. Defaults to
`Blowfish'. Cipher could be set to any value that works with Crypt::CBC(3)
and Tie::EncryptedHash(3).

=item B<Verbosity> 

When set to 1, generate() will draw a progress display on STDOUT.

=item B<Filename>

The generated key pair will be written to disk, in $Filename.public and
$Filename.private files, if this argument is provided. Disk writes can be

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


=item Password

Password with which the private key is encrypted, or should be encrypted
(in case of a new key).

=item Cipher 

Name of the symmetric cipher in which the private key is encrypted (or
should be encrypted). The default is "Blowfish" and possible values
include DES, IDEA, Twofish and other ciphers supported by Crypt::CBC.

=back

=item B<reveal()>

If the key is not decrypted at C<new()>, it can be decrypted by
calling C<reveal()> with a C<Password> argument.

=item B<hide()>

lib/Crypt/RSA/Key/Private/SSH.pm  view on Meta::CPAN

        1 => 'IDEA',
        2 => 'DES',
        3 => 'DES3',
        4 => 'ARCFOUR',
        6 => 'Blowfish',
    );
}

use Carp qw( croak );
use Data::Buffer;
use Crypt::CBC;
use Crypt::RSA::Key::Private;
use base qw( Crypt::RSA::Key::Private );

sub deserialize {
    my($key, %params) = @_;
    my $blob = join '', @{$params{String}};
    my $passphrase = $params{Passphrase} || '';

    my $buffer = new Crypt::RSA::Key::Private::SSH::Buffer;
    $buffer->append($blob);

lib/Crypt/RSA/Key/Private/SSH.pm  view on Meta::CPAN


    $key->Identity( $buffer->get_str );     ## Comment.

    if ($cipher_type != 0) {
        my $cipher_name = $CIPHERS{$cipher_type} or
            croak "Unknown cipher '$cipher_type' used in key file";
        my $class = 'Crypt::' . $cipher_name;
        eval { require $class };
        if ($@) { croak "Unsupported cipher '$cipher_name': $@" }

        my $cipher = Crypt::CBC->new($passphrase, $cipher_name);
        my $decrypted =
            $cipher->decrypt($buffer->bytes($buffer->offset));
        $buffer->empty;
        $buffer->append($decrypted);
    }

    my $check1 = $buffer->get_int8;
    my $check2 = $buffer->get_int8;
    unless ($check1 == $buffer->get_int8 &&
            $check2 == $buffer->get_int8) {

lib/Crypt/RSA/Key/Private/SSH.pm  view on Meta::CPAN

    $encrypted->put_mp_int($key->n);
    $encrypted->put_mp_int($key->e);
    $encrypted->put_str($key->Identity || '');

    if ($cipher_type) {
        my $cipher_name = $CIPHERS{$cipher_type};
        my $class = 'Crypt::' . $cipher_name;
        eval { require $class };
        if ($@) { croak "Unsupported cipher '$cipher_name': $@" }
    
        my $cipher = Crypt::CBC->new($passphrase, $cipher_name);
        $encrypted->append( $cipher->encrypt($buffer->bytes) );
    }
    else {
        $encrypted->append($buffer->bytes);
    }
    
    $encrypted->bytes;
}




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