akonsu said:
a> hello,
a> i am looking for a module with functionality similar to that of the
a> Perl's Mail::GPG package. I need to verify multipart emails that are
a> PGP-signed.
I don't know Perl's GPG package, but to verify PGP-signed stuff you can
use gnupg. It doesn't have special code for mail messages, however. It
is just a Pythonic wrapper facade around the gpg program.
However, it doesn't do the PGP/MIME stuff, so you will have to transform
the MIME messages into something that GPG understands. This isn't hard
and you can find a short python script that does it on
http://domnit.org/2008/03/clearmime. It describes how you can use it as
a program and pipe the message through it into gpg --verify. You can
also use it as a module if you rename it to clearmime.py, and use it
with the recently released gnupg module. It is released under GPL.
However it wouldn't be hard to write something similar yourself, for
example if you want to feed it existing Message objects rather than strings.
Example:
import os
from gnupg import GPG
from clearmime import clarify
msgtxt = open('testgpg.msg').read()
cl = clarify(msgtxt)
gpg=GPG(gnupghome = os.path.join(os.environ['HOME'], '.gnupg'))
if gpg.verify(cl):
print "Signature correct"
else:
print "Signature incorrect"