sio-2425/delivery1/client/bin/rep_subject_credentials

41 lines
1.0 KiB
Plaintext
Raw Normal View History

2024-11-12 10:26:56 +00:00
#!/bin/python3
2024-11-19 19:06:54 +00:00
import os
2024-11-12 10:26:56 +00:00
import sys
import logging
import argparse
sys.path.append(os.path.abspath("../../"))
2024-11-17 20:18:02 +00:00
from lib import key_pair
2024-11-12 10:26:56 +00:00
logging.basicConfig(format='%(levelname)s\t- %(message)s')
logger = logging.getLogger()
logger.setLevel(logging.INFO)
2024-11-20 22:03:50 +00:00
BASE_DIR = os.path.join(os.path.expanduser('~'), '.sio/')
2024-11-12 10:26:56 +00:00
# Generate a key pair for a subject
2024-11-17 20:18:02 +00:00
# password - file for public key, file for private key
2024-11-12 10:26:56 +00:00
def generateKeyPair(args):
parser = argparse.ArgumentParser()
parser.add_argument('password', nargs='?', default=None)
2024-11-17 20:18:02 +00:00
parser.add_argument('pubfile', nargs='?', default=None)
parser.add_argument('privfile', nargs='?', default=None)
args = parser.parse_args()
if not args.password or not args.pubfile or not args.privfile:
2024-11-12 10:26:56 +00:00
logger.error("Need password and file to store keys")
2024-11-20 20:49:40 +00:00
sys.exit(1)
2024-11-12 10:26:56 +00:00
#Generate the key pair
key_pair.generate_key_pair(BASE_DIR + args.pubfile, BASE_DIR + args.privfile, 2048, args.password)
2024-11-19 19:06:54 +00:00
2024-11-20 20:49:40 +00:00
sys.exit(0)
2024-11-12 10:26:56 +00:00
if __name__ == '__main__':
2024-11-17 20:18:02 +00:00
generateKeyPair(sys.argv[1:])
2024-11-12 10:26:56 +00:00