develooper Front page | perl.beginners | Postings from October 2009

Panic when decrypting

Thread Next
Fisher, John
October 14, 2009 09:42
Panic when decrypting
Message ID:
I have written a Perl script which I have used for years to decrypt at the field level in a file. Occasionally I get a problem file.
It throws out this message like this and stops -
    "panic: sv_setpvn called with negative strlen  at line 108, <STDIN> line 1249."

It hits a specific record. So, I look at that record and there is nothing special about it. I cut the file down so that record is no longer at the same record count. Say I now make it record 10 of a 20 record file. It decrypts it fine and may fail elsewhere. It is so bizarre.

Here is the key lines of code.

#!/usr/bin/perl -w
use Crypt::GCrypt;
use MIME::Base64;

$skey = <<< a salt key >>>;
$skey64 = MIME::Base64::decode($skey);

$cipher = Crypt::GCrypt->new(
  type => 'cipher',
  algorithm => 'aes',
  mode => 'ecb'



$decodecipher = MIME::Base64::decode($encrypted_ssn);
$orig_key = $cipher->decrypt($decodecipher);           <<= it fails on this line.

Googling has come up empty handed. Any thoughts, recommendations or experience would be appreciated.
I have tried to run the command line of OPENSSL which I think it what Perl is interacting with. I can figure out how to do a file, but not a field with OPENSSL.


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About