Ignore:
Timestamp:
04/01/15 18:41:36 (9 years ago)
Author:
nanardon
Message:

Don't use SSH storage form

After several hour to try to figure out it seems Crypt::RSA::Key::Private::SSH
is unable to properly encrypt the private, making everything readable.

This patch replace the SSH form by the native one.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql.pm

    r1286 r1309  
    1212use Crypt::RSA::Key::Public::SSH; 
    1313use Crypt::RSA::Key::Private::SSH; 
     14use Crypt::RSA::Key::Public; 
     15use Crypt::RSA::Key::Private; 
    1416use MIME::Base64; 
    1517 
     
    225227    my ($public, $private) = $rsa->keygen ( 
    226228        Identity  => 'LATMOS-Accounts', 
    227         Size      => 768, 
     229        Size      => 2048, 
    228230        Password  => $password, 
    229231        Verbosity => 0, 
    230         KF=>'SSH', 
    231232    ) or die $rsa->errstr(); # TODO avoid die 
    232233    return ($public, $private); 
     
    243244    my $base = $self; 
    244245    my $serialize = $base->get_global_value('rsa_private_key') or return; 
    245     my $privkey = Crypt::RSA::Key::Private::SSH->new; 
    246     $privkey->deserialize(String => [ decode_base64($serialize) ], 
    247         Passphrase => $password); 
    248     $privkey 
     246    my $string = decode_base64($serialize); 
     247    my $privkey = $string =~ /^SSH PRIVATE KEY FILE/ 
     248        ? Crypt::RSA::Key::Private::SSH->new 
     249        : Crypt::RSA::Key::Private->new; 
     250    $privkey = $privkey->deserialize( 
     251        String => [ $string ], 
     252        Password => $password 
     253    ); 
     254    $privkey->reveal( Password => $password ); 
     255    $privkey; 
    249256} 
    250257 
     
    280287    my ($self, $public, $private) = @_; 
    281288    my $base = $self; 
     289    $private->hide; 
    282290    $base->set_global_value('rsa_private_key', 
    283291        encode_base64($private->serialize)); 
Note: See TracChangeset for help on using the changeset viewer.