added compute_hash() method
[sfa.git] / sfa / trust / certificate.py
index 9480f7a..54d98eb 100644 (file)
@@ -203,6 +203,9 @@ class Keypair:
       k.verify_update(data)
       return M2Crypto.m2.verify_final(k.ctx, base64.b64decode(sig), k.pkey)
 
+   def compute_hash(self, value):
+      return self.sign_string(str(value))      
+
 ##
 # The certificate class implements a general purpose X509 certificate, making
 # use of the appropriate pyOpenSSL or M2Crypto abstractions. It also adds
@@ -516,14 +519,14 @@ class Certificate:
         # until a certificate is found that is signed by a trusted root.
 
         # TODO: verify expiration time
-        print "====Verify Chain====="
+        #print "====Verify Chain====="
         # if this cert is signed by a trusted_cert, then we are set
         for trusted_cert in trusted_certs:
-            print "***************"
+            #print "***************"
             # TODO: verify expiration of trusted_cert ?
-            print "CLIENT CERT", self.dump()
-            print "TRUSTED CERT", trusted_cert.dump()
-            print "Client is signed by Trusted?", self.is_signed_by_cert(trusted_cert)
+            #print "CLIENT CERT", self.dump()
+            #print "TRUSTED CERT", trusted_cert.dump()
+            #print "Client is signed by Trusted?", self.is_signed_by_cert(trusted_cert)
             if self.is_signed_by_cert(trusted_cert):
                 #print self.get_subject(), "is signed by a root"
                 return