using gpg
Rasoul Hajikhani
rasoul@rhythm.com
Wed Apr 3 13:54:03 2002
Hello folks,
I have just hit a major malfunction and I was hoping that someone might
be able to help me. I am writing a web based interface to encrypt,
decrypt user's passphrases and save them into a database. I have no
problem generating, and encrypting a passphrase. The problem arises when
I try to decrypt a saved passphrase. Encryption of passphrase is done
like this:
--homedir $home --output $tempFile --no-comment --no-version --armor
--encrypt $recipient $phraseFile
where $recipient is : -r $user@thisCompany.com. So everyone has an
encrypted passphrase using their own uid. The result is saved into the
database.
Groups' passphrase encryption is done using the admin as --recipient
My problem arises when I try to decrypt a user's saved passphrase. Here
is the steps that I take:
1- retrieve passphrase
2- Save into .gpg file
3- call --homedir $home --decrypt $encryptFile through open3()
The code looks like this:
# This is actual code in perl
push (@$commands,"--homedir $home --decrypt $encryptFile");
# Execute user defined routine
# open3($fin, $fout, $ferr,"$self->{GPGExec} $cmd") || return
EXEC_ERROR();
my $result = $self->Execute($commands,FIN,FOUT,FERR);
# this passes in the passphrase
print FIN "$passPhrase\n";
# this closes the communication channel,
# indicating we are done
close FIN;
my @error_output = <FERR>; # reading the error
my @plaintext = <FOUT>; # reading the output
# clean up...
close FOUT;
close FERR;
If i did the same command on the command line, everything is dandy and
fine, file is actually decrypted, but when using open3() and through the
apache thread, nothing works.
The error, if that is at all error, is:
errors: gpg: Warning: using insecure memory!
I am hoping someone who has done this kind of stuff in an application,
could help me find out what I am doing wrong. I appreciate all the
comments/help that I can get.
Thanks in advance