Mailing List Archive

Looking for a decrypting script
I'm fairly new to gpg, but I would like to be able to append to a file, encrypted
messages, like so:
I can generate the files without much problem, but don't know how to decrypt it.

Encrypted File would look like something like this:

-----BEGIN PGP MESSAGE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: For info see http://www.gnupg.org

/iNNQl3grM515suFqcnXghGMunsgit3Zjpr+WWwoLhSiA9X2FCJiAtcsjLofTN5l
AlA6zNrusB+GSMOeYpeTfcYZB97aOSoVF9OjYtkVfTjcS+LBIx2xoFQgp1+/i2z6
cWq1QXKG5+zlzsqu7DyAoplkYCsH0+nCis8bwTywjTKSySoKLMHOTAG0e347Ij1d
Atw1aceB2M4yDA28PEFeI9ZAaQ9P66bA8UFIwAY=
=gYTc
-----END PGP MESSAGE-----
-----BEGIN PGP MESSAGE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: For info see http://www.gnupg.org

hQEOA/cVrW7P7/adEAP/VXN1sTR0KJhq4sYVwvwwkBcqlG611AZgETzTdtsL+aER
1MaAIY8w4a/J3H4gMX5pAB8A/DhQYFIRAd17PT6Tkj3dOXbcdpluCq00XpYCG+WE
Atw1aceB2M4yDA28PEFeI9ZAaQ9P66bA8UFIwAY=
=gYTc
-----END PGP MESSAGE-----

I would like some type of script where I could read this file in and output each record
that was encrypted, the decryption will be in a secure place, but I don't know of anyway
to accomplish this. I would like to write the output to a file or stdout for final
processing.

Anyone have any suggestions on how this could be done, or is it even feasible?

thanks
Kelley
Re: Looking for a decrypting script [ In reply to ]
Kelley Lingerfelt, at 23:11 -0400 on Thu, 27 Jul 2000, wrote:

> I would like some type of script where I could read this file in and
> output each record that was encrypted, the decryption will be in a
> secure place, but I don't know of anyway to accomplish this. I would
> like to write the output to a file or stdout for final processing.

Since you're dealing with successive encrypted messages, you could
actually very likely process the file using pgpenvelope's
(http://pgpenvelope.sourceforge.net/) pgpenvelope_decrypt program, even
though you aren't using Pine or such things.

pgpenvelope_decrypt is flexible and can correctly handle multiple OpenPGP
blocks in messages; this is ideal for your task. It reads from stdin, and
writes to stdout, and was designed for handling the bodies mail messages
which contain OpenPGP blocks. The only modification that would be made
would be to made off the top of my head would be to pass in the passphrase
directly to GnuPG instead of having the user enter it.

As sen_ml stated in a different reply, this entire thing is fairly trivial
to accomplish with a Perl module, and this is exactly what
pgpenvelope_decrypt does, using GnuPG::Interface.

--
Frank Tobin http://www.uiuc.edu/~ftobin/
Re: Looking for a decrypting script [ In reply to ]
Thanks for the replies, I've got all the modules downloaded and installed, the
pgpenvelope_decrypt works great. But for the life of me I can't figure out how
to pass the passphrase in, I'm prompted for the passphrase at every encrypted
message.

Any help would be appreciated, even if it's embedded in the program would be
ok for now, I would really like to enter it for the first time and it be
remembered from that point on, but either way would be ok for now. Sorry I'm
such a dunce, but believe me I have tried, but it's just not working for me.

thanks
Kelley


Frank Tobin wrote:

> Kelley Lingerfelt, at 23:11 -0400 on Thu, 27 Jul 2000, wrote:
>
> > I would like some type of script where I could read this file in and
> > output each record that was encrypted, the decryption will be in a
> > secure place, but I don't know of anyway to accomplish this. I would
> > like to write the output to a file or stdout for final processing.
>
> Since you're dealing with successive encrypted messages, you could
> actually very likely process the file using pgpenvelope's
> (http://pgpenvelope.sourceforge.net/) pgpenvelope_decrypt program, even
> though you aren't using Pine or such things.
>
> pgpenvelope_decrypt is flexible and can correctly handle multiple OpenPGP
> blocks in messages; this is ideal for your task. It reads from stdin, and
> writes to stdout, and was designed for handling the bodies mail messages
> which contain OpenPGP blocks. The only modification that would be made
> would be to made off the top of my head would be to pass in the passphrase
> directly to GnuPG instead of having the user enter it.
>
> As sen_ml stated in a different reply, this entire thing is fairly trivial
> to accomplish with a Perl module, and this is exactly what
> pgpenvelope_decrypt does, using GnuPG::Interface.
>
> --
> Frank Tobin http://www.uiuc.edu/~ftobin/
Re: Looking for a decrypting script [ In reply to ]
Kelley Lingerfelt, at 23:27 -0400 on Fri, 28 Jul 2000, wrote:

> Thanks for the replies, I've got all the modules downloaded and
> installed, the pgpenvelope_decrypt works great. But for the life of me
> I can't figure out how to pass the passphrase in, I'm prompted for the
> passphrase at every encrypted message.

You have two solutions you could use.

1) Use a passphrase-caching wrapper for GnuPG, such as secret-agent,
available at:

http://www.vibe.at/tools/secret-agent/

2) To have pgpenvelope_decrypt remember and enter your passphrase for you,
you could apply this patch to it:

*** pgpenvelope_decrypt Sun Jul 23 22:19:49 2000
--- pgpenvelope_decrypt.new Sat Jul 29 11:39:31 2000
***************
*** 34,39 ****
--- 34,40 ----
use FindBin;
use sigtrap 'handler' => 'die_signal_handler', 'normal-signals';

+ use Term::ReadKey;
use GnuPG::Interface 0.10;

use PGPEnvelope::Common;
***************
*** 95,100 ****
--- 96,107 ----
my $gnupg = GnuPG::Interface->new();
$gnupg->options->meta_interactive( not $is_filter );
$gnupg->gnupg_call( $program_call );
+
+ print "Please enter a passphrase: ";
+ ReadMode 'noecho', $terminal->input_handle();
+ my $passphrase = ReadLine 0, $terminal->input_handle();
+ ReadMode 'restore', $terminal->input_handle();
+ $gnupg->passphrase( $passphrase );

PGP_MESSAGE: while ( <STDIN> )
{
Re: Looking for a decrypting script [ In reply to ]
Thanks for the patch, it works great. Appreciate all the time you spent
helping me. I'm just decrypting away. :)

thanks
Kelley



Frank Tobin wrote:

> Kelley Lingerfelt, at 23:27 -0400 on Fri, 28 Jul 2000, wrote:
>
> > Thanks for the replies, I've got all the modules downloaded and
> > installed, the pgpenvelope_decrypt works great. But for the life of me
> > I can't figure out how to pass the passphrase in, I'm prompted for the
> > passphrase at every encrypted message.
>
> You have two solutions you could use.
>
> 1) Use a passphrase-caching wrapper for GnuPG, such as secret-agent,
> available at:
>
> http://www.vibe.at/tools/secret-agent/
>
> 2) To have pgpenvelope_decrypt remember and enter your passphrase for you,
> you could apply this patch to it:
>
> *** pgpenvelope_decrypt Sun Jul 23 22:19:49 2000
> --- pgpenvelope_decrypt.new Sat Jul 29 11:39:31 2000
> ***************
> *** 34,39 ****
> --- 34,40 ----
> use FindBin;
> use sigtrap 'handler' => 'die_signal_handler', 'normal-signals';
>
> + use Term::ReadKey;
> use GnuPG::Interface 0.10;
>
> use PGPEnvelope::Common;
> ***************
> *** 95,100 ****
> --- 96,107 ----
> my $gnupg = GnuPG::Interface->new();
> $gnupg->options->meta_interactive( not $is_filter );
> $gnupg->gnupg_call( $program_call );
> +
> + print "Please enter a passphrase: ";
> + ReadMode 'noecho', $terminal->input_handle();
> + my $passphrase = ReadLine 0, $terminal->input_handle();
> + ReadMode 'restore', $terminal->input_handle();
> + $gnupg->passphrase( $passphrase );
>
> PGP_MESSAGE: while ( <STDIN> )
> {