コード例 #1
0
 def authenticateCluster(self):
     """Authenticate the cluster."""
     secret = yield get_shared_secret()
     message = urandom(16)  # 16 bytes of the finest.
     response = yield self.callRemote(cluster.Authenticate, message=message)
     salt, digest = response["salt"], response["digest"]
     digest_local = calculate_digest(secret, message, salt)
     returnValue(digest == digest_local)
コード例 #2
0
def authenticate_with_secret(secret, message):
    """Patch-in for `Authenticate` calls.

    This ought to always return the correct digest because it'll be using
    the same shared-secret as the region.
    """
    salt = urandom(16)  # 16 bytes of high grade noise.
    digest = calculate_digest(secret, message, salt)
    return defer.succeed({"digest": digest, "salt": salt})
コード例 #3
0
 def got_secret(secret):
     salt = urandom(16)  # 16 bytes of high grade noise.
     digest = calculate_digest(secret, message, salt)
     return {"digest": digest, "salt": salt}