-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
34 lines (25 loc) · 1.15 KB
/
client.py
File metadata and controls
34 lines (25 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
import controlFunctions as cf
"""
Implementation of a simple client for the key-exchange.
Supports both Elliptic Curve (ECDH) and Ordinary Diffie-Hellman (DH).
The client should connect to the server and perform the key-exchange.
The client writes the used keys to specific files:
- private key to "client.priv"
- public key to "client.pub"
- shared key (the SHA-256 hash) to "client.shared"
The shared key is the *SHA-256 hash of the shared value*:
- In case of ECDH: Hash of the x-coordinate (first coord.) of the shared point
- In case of DH: Hash of the hexadecimal notation (without the '0x' prefix!) of shared value
The client accepts the following command-line arguments:
- --ec: Use Elliptic Curve Diffie-Hellman (ECDH) instead of Ordinary Diffie-Hellman (DH).
- --port: The port to connect to the server.
Example:
$ python3 client.py --ec --port 12345
The client should *not* output anything to the standard output, only to the aforementioned files.
"""
def main():
args = cf.runScript() # Parse program arguments
cf.startClient(args.get('port'), args.get('use_ecdh')) # Start client side
if __name__ == "__main__":
main()