From: <ope...@li...> - 2005-08-29 18:31:56
|
Update of /cvsroot/openca/openca-0.9/src/modules/openca-crypto/Token In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7348/src/modules/openca-crypto/Token Modified Files: Tag: openca_0_9_2 LunaCA3.pm Log Message: * Fixed HSM login and logout commands so now they use the token's login and logout functions instead of direct command line execution Author of changes: balamood2 Index: LunaCA3.pm =================================================================== RCS file: /cvsroot/openca/openca-0.9/src/modules/openca-crypto/Token/LunaCA3.pm,v retrieving revision 1.7.2.6 retrieving revision 1.7.2.7 diff -C2 -d -r1.7.2.6 -r1.7.2.7 *** LunaCA3.pm 17 Feb 2005 09:12:50 -0000 1.7.2.6 --- LunaCA3.pm 29 Aug 2005 18:31:48 -0000 1.7.2.7 *************** *** 42,45 **** --- 42,47 ---- ## create a new LunaCA3 token sub new { + + $ENV{'LD_LIBRARY_PATH'}=$ENV{'LD_LIBRARY_PATH'}.":/apps/usr/luna/lib"; my $that = shift; my $class = ref($that) || $that; *************** *** 66,69 **** --- 68,99 ---- return undef if (not $self->{CRYPTO}); return undef if (not $self->{NAME}); + + $keys->{ENGINE} = "LunaCA3"; + + if ($self->{MODE}=~ /^(SESSION|DAEMON)$/i) + { + my $lower=1000; + my $upper=50000; + my $HiRandom = int(rand( $upper-$lower + 10000 ) ) + $lower; + my $LoRandom = int(rand ($upper -$lower + 1)) + $lower ; + + my $AppID = "$HiRandom:$LoRandom"; + #print "\n AppID = $HiRandom:$LoRandom\n"; + #$self->{APPID} = $AppID; + $self->{APPID} = $keys->{APPID};; + if (not $self->login()){ + $errno = 7134014; + $errval = i18nGettext ("Cannot use the private key of the CA (__ERRNO__). __ERRVAL__", + "__ERRNO__", $self->errno(), + "__ERRVAL__", $self->errval()); + return undef; + } + print " OK"; + $keys->{PRE_ENGINE} = " ENGINE_INIT:". $self->{SLOT}.":".$self->{APPID}; + + + } + + ## create openssl object *************** *** 72,76 **** #$keys->{ENGINE} = "LunaCA3 -enginearg ". # $self->{SLOT}.":".$self->{APPID}; - $keys->{ENGINE} = "LunaCA3"; $keys->{KEYFORM} = "PEM"; $self->debug ("initing OpenSSL"); --- 102,105 ---- *************** *** 146,149 **** --- 175,183 ---- my $keys = { @_ }; + if ( -e $self->{LOCK_FILE}) { + return 1; + } + + my $command = $self->{UTILITY}; $command .= " -o "; *************** *** 151,154 **** --- 185,189 ---- $command .= " -i ".$self->{APPID}; + $self->debug ("executing login"); my $ret = `$command`; |