[tor-commits] [bridgedb/master] Fix GPGME 'invalid argument' error while signing.

isis at torproject.org isis at torproject.org
Fri May 16 18:52:51 UTC 2014


commit fafbdc77a2656185740790e688ced745518c72c7
Author: Isis Lovecruft <isis at torproject.org>
Date:   Wed Apr 23 01:38:31 2014 +0000

    Fix GPGME 'invalid argument' error while signing.
    
     * FIX error introduced in commit b2c7a2a2 in branch for #11522
       fixes. The in-memory files for the message and the signature file for
       libgpgme need to be type io.BytesIO(buffer(message)), not
       io.StringIO(unicode()) like the rest of the email body files.
---
 lib/bridgedb/crypto.py |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/bridgedb/crypto.py b/lib/bridgedb/crypto.py
index b70069d..4ce30b2 100644
--- a/lib/bridgedb/crypto.py
+++ b/lib/bridgedb/crypto.py
@@ -343,8 +343,7 @@ def getGPGContext(cfg):
         ctx.signers = (bridgedbKey,)
 
         logging.debug("Testing signature created with GnuPG key...")
-        testMessage = "Testing 1 2 3"
-        signatureText, sigs = gpgSignMessage(ctx, testMessage)
+        signatureText, sigs = gpgSignMessage(ctx, "Testing 1 2 3")
 
         if not len(sigs) == 1:
             raise PythonicGpgmeError("Testing couldn't produce a signature "\
@@ -396,8 +395,8 @@ def gpgSignMessage(gpgmeCtx, messageString, mode=None):
     if not mode:
         mode = gpgme.SIG_MODE_CLEAR
 
-    msgFile = io.StringIO(unicode(messageString))
-    sigFile = io.StringIO()
+    msgFile = io.BytesIO(buffer(messageString))
+    sigFile = io.BytesIO()
     sigList = gpgmeCtx.sign(msgFile, sigFile, mode)
     sigFile.seek(0)
     signature = sigFile.read()





More information about the tor-commits mailing list