diff --git a/client/python/client.py b/client/python/client.py index 15f13e5b573b013fca79937d431559a331a2504b..109822c1fb2acb5df104146b3c88eb78373d38df 100644 --- a/client/python/client.py +++ b/client/python/client.py @@ -5,7 +5,7 @@ sys.path.insert(0, '../../shared/netcode') import queue import grpc from shared.netcode.netcode_pb2 import * -from shared.netcode.netcode_pb2_grpc import NotifierComStub +from shared.netcode.netcode_pb2_grpc import NotifierCommunicationStub usage = "Usage:\n- Sender:\n ./client.py 1\n- Receiver:\n ./client.py 0" @@ -38,10 +38,10 @@ if __name__ == "__main__": print("Error: Connection to server failed.") exit(1) - stub = NotifierComStub(channel) + stub = NotifierCommunicationStub(channel) if is_sender: - response = stub.OpenComm(OpenCommRequest(challenge=1)) + response = stub.Open(OpenRequest(id_code=1)) print(response) sendQueue = queue.SimpleQueue() @@ -58,7 +58,7 @@ if __name__ == "__main__": sendQueue.put_nowait(Message(content=text)) else: - response = stub.AnswerComm(AnswerCommRequest(challenge=1)) + response = stub.Answer(AnswerRequest(challenge=1)) print(response) for message in stub.ReceiveMessage(Nothing()): diff --git a/protocol.md b/protocol.md index 6b5bd20b13d25c588ea9efc8d35013886bb51bbc..dbe5fac7409bf6189c9dda00306baaf99388ab6a 100644 --- a/protocol.md +++ b/protocol.md @@ -7,12 +7,12 @@ 1. Authenticate to the server and establish communication. 1. A tells the server to open a communication. 2. A sends an id_code to the server. - 3. A gets a comm_id from the server. + 3. If someone answered with the same id_code, A gets a comm_id from the server. 2. B tells the server to answer A's communication request. - 1. B receives A's challenge. - 2. B answers the solution to the server. - 3. The server checks the solution and accepts the communication establishment. + 2. B sends A's id_code to the server. + 3. The server checks if it matches and returns a comm_id to B. 2. Generate and exchange an ephemeral key. + 1. A and B generate a RSA key-pair. 3. Instantiate symmetric encryption using the ephemeral key. 4. Authenticate each other directly. -5. (?) Check communication transcript (avoid malicious server). \ No newline at end of file +5. (?) Check communication transcript (avoid malicious server). diff --git a/server/server.py b/server/server.py index b04427aacfd38f3811eb6a272161300eb1065b02..f95e0fd0f512494943ad5897fc566fa37b55e762 100644 --- a/server/server.py +++ b/server/server.py @@ -7,32 +7,33 @@ from shared.netcode.netcode_pb2 import * from shared.netcode.netcode_pb2_grpc import * -class NotifierService(NotifierComServicer): - def OpenComm(self, request, context): +class NotifierService(NotifierCommunicationServicer): + def Open(self, request, context): # TODO: append id_code to list # TODO: wait for id_code answered # TODO: return comm_id return CommResponse() - def AnswerComm(self, request, context): + def Answer(self, request, context): # TODO: check if if_code can be answered # TODO: return comm_id return CommResponse() def ReceiveMessage(self, request, context): # TODO: read comm_id and wait for messages - yield Message(content="test") + yield Message(comm_id=-1, content="test") def SendMessage(self, request_iterator, context): for msg in request_iterator: # TODO: read comm_id and route message + print(msg.comm_id) print(msg.content) return Nothing() if __name__ == "__main__": server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) - add_NotifierComServicer_to_server( + add_NotifierCommunicationServicer_to_server( NotifierService(), server) server.add_insecure_port('[::]:8080') server.start()