Newer
Older
# App name
appName = "MyAuth"
jsonCfg = MyAuthConf.getJsonString(appName, "CRITICAL")
except json.decoder.JSONDecodeError as jex:
sys.stderr.write("load_json_config JSONdecode :%s" % jex)
exit(-1)
def randomString(stringLength=10):
"""Generate a random string of fixed length """
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringLength))
# Action Help
def help():
print("CA managment script usage: ")
print("")
print("To get this help")
print("\t"+cmdName+" [help]")
print("")
print("Generate <Root nodes number> certificates (5 by default)" +
"for selected <Algorythm> (\"sig_dil\" by default)")
print("\t"+cmdName+" init_root_ca [<Root nodes number>] [<Algorythm>] [<Restore string>]")
print("")
counter = 0
# Parse input arguments
# Extract command name
# Extract subcommand
if counter == 2:
action = arg
elif counter > 2:
# Process actions
if action == "help":
help()
# Action init root CAs
elif action == "init_root_ca":
# Default params
rootCaNumber = 5
rootCaAlgoName = "sig_dil"
# Set default algo Dilithium
# Read action args
if len(action_arg) > 0:
rootCaNumber = action_arg[1]
if len(action_arg) > 1:
rootCaAlgoName = action_arg[2]
# Parse algo name
if rootCaAlgoName == "sig_bliss":
elif rootCaAlgoName == "sig_tesla":
elif rootCaAlgoName == "sig_picnic":
elif rootCaAlgoName == "sig_dil":
else:
# Process error case
print("(!) Wrong algo name \""+rootCaAlgoName+"\", possible names: sig_bliss, sig_tesla, sig_picnic, sig_dil")
help()
exit(-1)
# Create certs
print("Init root "+str(rootCaNumber)+" certificates with algo "
+ rootCaAlgoName)
print("Record somewhere the restore string(without braces): \""
+ restoreString+"\"")
for cur in range(int(rootCaNumber)):
cname = MyAuthConf.getNetworkName(appName, "_") + "_root_" + str(cur)
cert = Cert.generate(cname, rootCaAlgo, restoreString)
cert.save()