X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=userdir_gpg.py;h=f594cea574ede7ae13cbc57048479a9a180eafbf;hb=refs%2Fheads%2Fsalsa;hp=93292611e72894dac76d66d92be24baf7c10744d;hpb=4eaa444b9eb4c9d24cd2790f99a690054bf2f806;p=mirror%2Fuserdir-ldap.git diff --git a/userdir_gpg.py b/userdir_gpg.py index 9329261..f594cea 100644 --- a/userdir_gpg.py +++ b/userdir_gpg.py @@ -244,12 +244,14 @@ def GPGWriteFilter(Program,Options,Message): Output.close(); GPGText.close(); + + # This takes a text passage, a destination and a flag indicating the # compatibility to use and returns an encrypted message to the recipient. # It is best if the recipient is specified using the hex key fingerprint # of the target, ie 0x64BE1319CCF6D393BF87FF9358A6D4EE def GPGEncrypt(Message,To,PGP2): - Error = "KeyringError" + class KeyringError(Exception): pass # Encrypt using the PGP5 block encoding and with the PGP5 option set. # This will handle either RSA or DSA/DH asymetric keys. # In PGP2 compatible mode IDEA and rfc1991 encoding are used so that @@ -257,11 +259,11 @@ def GPGEncrypt(Message,To,PGP2): # can read a message encrypted with blowfish and RSA. searchkey = GPGKeySearch(To); if len(searchkey) == 0: - raise Error, "No key found matching %s"%(To); + raise KeyringError("No key found matching %s"%(To)) elif len(searchkey) > 1: - raise Error, "Multiple keys found matching %s"%(To); + raise KeyringError("Multiple keys found matching %s"%(To)) if searchkey[0][4].find("E") < 0: - raise Error, "Key %s has no encryption capability - are all encryption subkeys expired or revoked? Are there any encryption subkeys?"%(To); + raise KeyringError("Key %s has no encryption capability - are all encryption subkeys expired or revoked? Are there any encryption subkeys?"%(To)) if PGP2 == 0: try: