> [snip]
> 
> perl -V
> 
> That's lower case perl, upper case V.
> 
> [snip]

now that's funny!



ok, so I was babbling.. try this. A simple perl script useing 
Crypt::OpenPGP runs fine from the command line while the same subroutine 
used in a mod_perl module on the same machine crashes. Why? Its nothing 
to do with global variables, multiple runs, or random occurances.

I put a warn statement into Crypt::Primes to show the offending variable 
$B represented as 'B'. The only line I can find in Crypt::Primes that 
sets the value of $B is:
        my $B = floor ( $c_opt * ( $k ** 2 ) );

'floor' is imported from Math::Pari which according to the docs does not 
use any enviromental variables.

Throughout the run from the commandline $B remains an everchanging 
integer, while during the mod_perl run it suddenly becomes something 
else (37e5156f in the example below) subsequently crashing the program 
when it is involved in a numeric comparison.

and, yeh, if no one else has any suggestions this time, I'll drop it.
Thanks, Tom, for the nudge I needed to get this far..

cheers,

J


run from the commandline (test_pgp_gen.pl):

------------

my $attrib = {
        Size      => '2048',
        Identity  => 'PGP EzyDVD <[EMAIL PROTECTED]>',
        Password  => 'a new passphrase for you',
};

my $self = {
        EV_config => {
                PGPKeyLoc => 'd_main/data/.pgptest',
        },
};

# test Key Generation
($self) = pgp_keygen($self,$attrib);

exit;

sub pgp_keygen{
######################################################################################
        my ($self,$attrib) = @_;
        my $file = time;
        warn "Generating Keys";
        use Crypt::OpenPGP;
        warn "Creating Keychain";
        my $keychain = Crypt::OpenPGP->new;
        warn "Generating Keys with:\n\tType => 'RSA'\n\tSize => 
$attrib->{'Size'}\n\tIdentity => $attrib->{'Identity'}\n\tPassphrase => 
$attrib->{'Password'}";
     my ($public, $private) = $keychain->keygen (
                                                                                       
           Type => 'RSA',
                                                                                       
           Size      => $attrib->{'Size'},
                                                                                       
           Identity  => $attrib->{'Identity'},
                                                                                       
           Passphrase  => $attrib->{'Password'},
# 
                                                                                       
   Verbosity => 1,
                                                                                       
           ) or die $keychain->errstr();
        warn "Generating complete. Saving..";

        $public = $public->save;
        open(PUBLIC,'>',"$$self{'EV_config'}{'PGPKeyLoc'}/$file".'.public');
        print PUBLIC $public;
        close(PUBLIC);

        $private = $private->save;
        open(PRIVATE,'>',"$$self{'EV_config'}{'PGPKeyLoc'}/$file".'.private');
        print PRIVATE $private;
        close(PRIVATE);
        warn "Saving complete.";

        return ($self);
}
----------------
[]$ perl test_pgp_gen.pl
Generating Keys at test_pgp_gen.pl line 29.
Creating Keychain at test_pgp_gen.pl line 31.
Generating Keys with:
         Type => 'RSA'
         Size => 2048
         Identity => PGP EzyDVD <[EMAIL PROTECTED]>
Passphrase => a new passphrase for you at test_pgp_gen.pl line 33.
B = 43, r = 0.5, k = 22, q = 5347 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 151, r = 0.506631180276321, k = 41, q = 2267129 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 506, r = 0.53037992595081, k = 75, q = 2196811726937 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 1520, r = 0.562081100800386, k = 130, q = 26428241092041745277471 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 3352, r = 0.667875988226359, k = 193, q = 
688430562782715717240302427312908015051 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 9564, r = 0.588637765080919, k = 326, q = 
9655451199502028429995738816630241142900009390132769541041 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 29240, r = 0.56933184524636, k = 570, q = 
107999990085674771117533970943108471560290797135532475727108233332855637214539638256680204084416659
 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 94371, r = 0.554913243836389, k = 1024, q = 
2738877267722396215978314103886896155676111721678953257651796203192310298619466435015458288033302116849702218709734148499773910739678380930731862293431860017467060796038877
 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 60, r = 0.5, k = 26, q = 24359 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 190, r = 0.533359128724712, k = 46, q = 48084667 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 392, r = 0.674066449056276, k = 66, q = 43830135663841 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 712, r = 0.72142717088388, k = 89, q = 50528256995989181621 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 1088, r = 0.791208845615746, k = 110, q = 
364239812398539470243678957 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 1971, r = 0.731718678404107, k = 148, q = 
1161959240093706372787538778651959 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 3672, r = 0.724196026287574, k = 202, q = 
307280217785183062005469815559414190554802423 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 13548, r = 0.516487316599059, k = 388, q = 
4573246156711646201547431955375778931977675021304013322899571 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 44605, r = 0.549483445025026, k = 704, q = 
438813852077041641567647594788212444871210238760539617178735201165732467829541775227537430637306481706993845459061189
 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 94371, r = 0.68636746497564, k = 1024, q = 
80993223080358367505131642870842252036480951684884673364086759111910476071128700731354473101737997215199235595520361505554380969129822427264986371319848098818737112805371244059972125258401809403368466743517505229
 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 123, r = 0.5, k = 37, q = 654527 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 428, r = 0.509027214836461, k = 69, q = 135771153719 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 778, r = 0.72942682627937, k = 93, q = 394941117091556310137 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 2819, r = 0.515727635920378, k = 177, q = 
8004036235188785169985737349 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 10899, r = 0.504061254575025, k = 348, q = 
180188942259573961069764444265277325937384136567158231 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 28832, r = 0.611325055458173, k = 566, q = 
350298379682670231480616281730050555205183473704789598593750737572537239340220277199353725812644111344841
 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 94371, r = 0.55166370856177, k = 1024, q = 
213809062120115114391018427501298112883354222525495570595381730623361275330736153208884301264832030524901427169622407653188435165797495306139274484557627094583117307286841
 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 43, r = 0.5, k = 22, q = 6857 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 143, r = 0.5, k = 40, q = 2262811 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 323, r = 0.642240838811717, k = 60, q = 830374701427 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 795, r = 0.620170842674522, k = 94, q = 934050304398966659 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 2600, r = 0.542655948946792, k = 170, q = 
14618485825696094376760287017 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 5270, r = 0.696765591397229, k = 242, q = 
1146574020629066813182723689449453779369493447410199 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 19628, r = 0.514936333639597, k = 467, q = 
4666726133496596483757300766258393114618537437699325687728682996284875077 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 49150, r = 0.629746578600893, k = 739, q = 
247904997766713291448250396731952241613362729982386875603446336078747877306334516093985893329612926172604012456677983329603638420519442502621
 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 94371, r = 0.719770109486007, k = 1024, q = 
2166943969995365021182771678608920274939977525811785945618810839085936725332844294589763574784701247148690194245409692719959165625404775982118213147734352859742871258919573018424448305852406087924556251345731641239828395481
 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
Generating complete. Saving.. at test_pgp_gen.pl line 41.
Saving complete. at test_pgp_gen.pl line 52.
--------------




used as part of a mod_perl module:
--------------
sub pgp_keygen{
######################################################################################
        my ($self,$attrib) = @_;
        my $file = time;
        use Crypt::OpenPGP;

        warn "Creating Keychain";

        my $keychain = Crypt::OpenPGP->new;

        warn "Generating Keys with:\n\tType => 'RSA'\n\tSize => 
$attrib->{'Size'}\n\tIdentity => $attrib->{'Identity'}\n\tPassphrase => 
$attrib->{'Password'}";

     my ($public, $private) = $keychain->keygen (
                                                                                       
           Type => 'RSA',
                                                                                       
           Size      => $attrib->{'Size'},
                                                                                       
           Identity  => $attrib->{'Identity'},
                                                                                       
           Passphrase  => $attrib->{'Password'},
                                                                                       
           ) or die $keychain->errstr();

        warn "Generating complete. Saving..";

        $public = $public->save;
        open(PUBLIC,'>',"$$self{'EV_config'}{'PGPKeyLoc'}/$file".'.public');
        print PUBLIC $public;
        close(PUBLIC);

        $private = $private->save;
        open(PRIVATE,'>',"$$self{'EV_config'}{'PGPKeyLoc'}/$file".'.private');
        print PRIVATE $private;
        close(PRIVATE);

        warn "Saving complete.";

        return ($self);
}
-----------------
Creating Keychain at /usr/local/apache/lib/perl/Apache/Zeal/Subs.pm line 
1047.
Generating Keys with:
         Type => 'RSA'
         Size => 2048
         Identity => PGP EzyDVD <[EMAIL PROTECTED]>
Passphrase => a new passphrase for you at 
/usr/local/apache/lib/perl/Apache/Zeal/Subs.pm line 1051.
B = 39, r = 0.5, k = 21, q = 2789 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 129, r = 0.5, k = 38, q = 1874209 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 416, r = 0.539930321932131, k = 68, q = 241836684107 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 829, r = 0.688014823581669, k = 96, q = 171663119210245204177 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 2510, r = 0.563435999774053, k = 167, q = 
78299937754424805174510097537 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 4928, r = 0.708006452234391, k = 234, q = 
156415002296256917181266032842858760775583721180577 at 
/usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 6368, r = 0.874358499649278, k = 266, q = 
16043494810326477707784019253764776982201892927723158680518953586685433 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 20822, r = 0.549438793645733, k = 481, q = 
86687341519626380713011992462802386241360325883641886645448004662972635094467449 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 25568, r = 0.900013779508078, k = 533, q = 
3240695590176576449905067015003462210694789633470001401415510822403255873560183022734656669845588123528446844988815931430374567362118497857111131
 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 28832, r = 0.939926597249583, k = 566, q = 
21542827823661595370904702569216896167546520800006506645193021496809217040695623669378433032183609136453038523133339281904302448609886333963167380931757592935323
 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 39203, r = 0.854616066491921, k = 660, q = 
121918763141520050915466465204390434601344870212995890691355326867988970064698736813863318359386668926900792971041309778344657449137535261952363856919094845610080399745083
 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 79017, r = 0.703232932500453, k = 937, q = 
4116116331177522325424340032090836560461745087379199415482159436299126692937760111585881147858340965864471988996699515724345106231750518830248537235145426838978736285540554791383692428371789664766517
 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
B = 37e5156f  , r = 0.913143797643336, k = 1024, q = 
923333936476576873710887942587676690087519090441429097299995867179356445217226407406280526693783290358502306182206272310676638546123475192696253480973767688985572931834390260969361397809964052852427904738696328725431385803446831595933210333469028822361314430876554863201317720007857
 
at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 610.
[Tue Feb  5 23:54:34 2002] [error] PARI:   ***   incorrect type in 
comparison. at /usr/lib/perl5/site_perl/5.6.1/Crypt/Primes.pm line 690.





-- 
J
Web Developer

Eight Degrees Off Centre
http://www.eightdegrees.com.au/

Reply via email to