示例#1
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"
示例#2
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"