Decryption using GnuPG:Interface and Perl
Frank Tobin
ftobin@uiuc.edu
Mon Jun 18 22:54:02 2001
christopher.a.feathers@accenture.com, at 10:53 on Mon, 18 Jun 2001, wrote:
I am trying to wrap some of the GnuPG functions in Perl so I can enforce
some logging (an a few other reasons). l am running into a problem when I
attempt decrypt an pass in a bad passphrase - a scenario that is quite
possible. I get a "Broken pipe" printed to STDOUT and my script cannot
continue. Is there a way to catch the fact that the passphrase was bad
before attempting to print the encrypted file's contents to stdin as given
in the GnuPG::Interface examples?
Three things you can do, off of the top of my head:
1: Get the PID of the running GnuPG process (the return from "decrypt"),
and check if it's still running (send a signal of 0).
2: Read the status-fd from GnuPG; it would report a bad/good passphrase
before you had to send in the input.
3: Use the test_default_key_passphrase method of GnuPG::Interface to
pre-check the passphrase.
--
Frank Tobin http://www.uiuc.edu/~ftobin/