using verify over stdin

Justin Karneges justin-psi at affinix.com
Mon Nov 4 15:16:01 CET 2002


Hello everyone,

I'm trying to write a program to interface with gpg.  I'm really only 
interested in some basic stuff (encrypt, decrypt, sign, verify), and I've got 
it all working except for 'verify'.  It seems 'verify' is tricky since it has 
to read two blocks of information.  I don't want to use files, I want to stay 
with stdin/stdout, so I run this:

  gpg --armor --verify - -

The above command will try to verify a detached sig and then the original data 
that was used to make the sig.  What is interesting about this command is 
that it reads from stdin _twice_.  The first read is for the sig, the second 
is for the original data.

In a shell, I would run the command then:
 - paste the sig
 - press ^D
 - paste the data
 - press ^D

And gpg reports a successful verification.  It is the same on Windows, just 
with ^Z instead of ^D.  So whatever this double-stdin thing is, it does work 
everywhere.

The problem is that I cannot replicate this procedure in my program.  I 
figured that ^D just does a close() on stdin, but when I do so it causes gpg 
to exit unsuccesfully.  How can my program use the stdin of gpg twice?

-Justin





More information about the Gnupg-devel mailing list