41 lines
1.0 KiB
Python
Executable File
41 lines
1.0 KiB
Python
Executable File
#!/bin/python3
|
|
import os
|
|
import sys
|
|
import logging
|
|
import argparse
|
|
|
|
sys.path.append(os.path.abspath("../../"))
|
|
from lib import key_pair
|
|
|
|
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
|
logger = logging.getLogger()
|
|
logger.setLevel(logging.INFO)
|
|
|
|
BASE_DIR = os.path.join(os.path.expanduser('~'), '.sio/')
|
|
|
|
# Generate a key pair for a subject
|
|
# password - file for public key, file for private key
|
|
def generateKeyPair(args):
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument('password', nargs='?', default=None)
|
|
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:
|
|
logger.error("Need password and file to store keys")
|
|
sys.exit(1)
|
|
|
|
|
|
#Generate the key pair
|
|
key_pair.generate_key_pair(BASE_DIR + args.pubfile, BASE_DIR + args.privfile, 2048, args.password)
|
|
|
|
sys.exit(0)
|
|
|
|
if __name__ == '__main__':
|
|
generateKeyPair(sys.argv[1:])
|
|
|