37 lines
869 B
Python
Executable File
37 lines
869 B
Python
Executable File
#!/bin/python3
|
|
import sys
|
|
import logging
|
|
import argparse
|
|
|
|
from lib import key_pair
|
|
|
|
logging.basicConfig(format='%(levelname)s\t- %(message)s')
|
|
logger = logging.getLogger()
|
|
logger.setLevel(logging.INFO)
|
|
|
|
# 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 len(args) != 3:
|
|
logger.error("Need password and file to store keys")
|
|
sys.exit(-1)
|
|
|
|
|
|
#Generate the key pair
|
|
key_pair.generate_key_pair(args.pubfile, args.privfile, 2048, args.password)
|
|
|
|
return 0
|
|
|
|
if __name__ == '__main__':
|
|
generateKeyPair(sys.argv[1:])
|
|
|