Ejemplo n.º 1
0
def temp_client():
    """
    :return:
    """
    longterm = identity.genkey()
    longterm_pub = longterm.get_verifying_key()

    session = identity.genkey()
    session_pub = session.get_verifying_key()

    return {"longterm": longterm,
            "longterm_pub": longterm_pub,
            "session": session,
            "session_pub": session_pub}
Ejemplo n.º 2
0
def test_handshake(temp_client):
    """
    Test the handshake
    :return:
    """
    serverpriv = identity.genkey()
    serverpub = serverpriv.get_verifying_key()

    secret, message = null_proto.client_handshake_begin(temp_client["longterm"],
                                                        temp_client["session"],
                                                        serverpub)

    assert secret
    assert message

    server_secret, gotpub, challenge, challenge_plain = null_proto.server_handshake_begin(serverpriv, message)

    assert secret == server_secret

    response = null_proto.client_handshake_finish(temp_client["longterm"],
                                                  server_secret, challenge)

    complete = null_proto.server_handshake_finish(gotpub,
                                                  challenge_plain, response)

    assert "status" in complete
    assert complete["status"] == "complete"
Ejemplo n.º 3
0
def test_client_handshake(run_server):
    """
    Connect to the server and do a handshake
    :param run_server:
    :return:
    """
    proc, serverpub = run_server
    assert proc
    assert serverpub
    privkey = identity.genkey()
    client = null_client.Client(privkey, "http://{}:8080".format(MYIP), serverpub)

    client.connect()

    client.submit_location("Ian Norton", "Lave", "Open")
Ejemplo n.º 4
0
    def connect(self):
        """
        Handshake with the server
        :return:
        """
        self.ecdhkey = identity.genkey()
        self.sessionkey, send = null_proto.client_handshake_begin(self.signer, self.ecdhkey, self.serverpub)
        response = self.post("/handshake_begin", json.dumps(send))
        response = json.loads(response)

        send = null_proto.client_handshake_finish(self.signer, self.sessionkey, response)

        response = self.post("/handshake_finish", json.dumps(send))
        response = json.loads(response)

        assert "status" in response, "expected status in response"
        assert response["status"] == "complete", "expected status == complete"