1 """An extremely simple interface to the signing/verifying capabilities
4 You must already have the key in the keyring.
7 from subprocess import PIPE, Popen
8 from xmlrpclib import dumps, loads
14 """Return <data> signed with the default GPG key."""
16 p = _popen_gpg('--armor', '--sign', '--keyring', '/etc/planetlab/secring.gpg', '--no-default-keyring')
19 signed_msg = p.stdout.read()
25 def verify(signed_msg):
26 """If <signed_msg> is a valid signed document, return its contents. Otherwise, return None."""
27 p = _popen_gpg('--decrypt', '--keyring', '/usr/boot/pubring.gpg', '--no-default-keyring')
28 p.stdin.write(signed_msg)
33 if p.wait(): return None # verification failed
38 def _popen_gpg(*args):
39 """Return a Popen object to GPG."""
40 return Popen((GPG, '--batch', '--no-tty') + args, stdin=PIPE, stdout=PIPE, stderr=PIPE)