[tor-commits] [bridgedb/develop] Make publicKey and secretKey attributes of the ICaptcha interface.

isis at torproject.org isis at torproject.org
Wed May 14 22:41:20 UTC 2014


commit a8f35253e47bc47f0f3ca763f29a51224da47d55
Author: Isis Lovecruft <isis at torproject.org>
Date:   Wed May 14 20:45:09 2014 +0000

    Make publicKey and secretKey attributes of the ICaptcha interface.
    
    Both the reCaptcha and GimpCaptcha subclasses of the generic base
    implementation, bridgedb.captcha.Captcha, of the ICaptcha interface have
    publicKey and secretKey attributes. In fact, it would be hard to
    generate a secret CAPTCHA challenge_string which was retrievable later
    if there weren't any keypairs involved. Ergo, the keypair should be part
    of the interface specification.
---
 lib/bridgedb/captcha.py |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/lib/bridgedb/captcha.py b/lib/bridgedb/captcha.py
index 8a76198..f5674c4 100644
--- a/lib/bridgedb/captcha.py
+++ b/lib/bridgedb/captcha.py
@@ -82,6 +82,11 @@ class ICaptcha(Interface):
         "A string containing the contents of a CAPTCHA image file.")
     challenge = Attribute(
         "A unique string associated with the dispursal of this CAPTCHA.")
+    publicKey = Attribute(
+        "A public key used for encrypting CAPTCHA challenge strings.")
+    secretKey = Attribute(
+        "A private key used for decrypting challenge strings during CAPTCHA"
+        "solution verification.")
 
     def get():
         """Retrieve a new CAPTCHA image."""
@@ -92,15 +97,21 @@ class Captcha(object):
 
     :ivar str image: The CAPTCHA image.
     :ivar str challenge: A challenge string which should permit checking of
-        the client's CAPTCHA solution in some manner. This should be passed
-        along to the client with the CAPTCHA image.
+        the client's CAPTCHA solution in some manner. In stateless protocols
+        such as HTTP, this should be passed along to the client with the
+        CAPTCHA image.
+    :ivar publicKey: A public key used for encrypting CAPTCHA challenge strings.
+    :ivar secretKey: A private key used for decrypting challenge strings during
+        CAPTCHA solution verification.
     """
     implements(ICaptcha)
 
-    def __init__(self):
+    def __init__(self, publicKey=None, secretKey=None):
         """Obtain a new CAPTCHA for a client."""
         self.image = None
         self.challenge = None
+        self.publicKey = publicKey
+        self.secretKey = secretKey
 
     def get(self):
         return self.image





More information about the tor-commits mailing list