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

Panic when decrypting

Thread Next
From:
Fisher, John
Date:
October 14, 2009 09:42
Subject:
Panic when decrypting
Message ID:
4D45CE02FC15394FA8745408A8C8A5CC7A96FE5D54@VREEXMBX01.us.ad.usa-ed.net
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   encrypt_ssn_2_live_STDIN_or_INFILE.pl 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'
);

$cipher->start('decrypting');

$cipher->setkey($skey64);

$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.

TIA,
John


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About