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)
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})
def got_secret(secret): salt = urandom(16) # 16 bytes of high grade noise. digest = calculate_digest(secret, message, salt) return {"digest": digest, "salt": salt}