@@ -0,0 +1,1563 @@
+'''%0AManage backend functions of nacl and curve25519%0A'''%0A%0A# Import third party libs%0Aimport nacl.utils%0Aimport nacl.public%0Aimport nacl.encoding%0A%0A# Import python libs%0Aimport json%0Aimport datetime%0Aimport os%0A%0A%0Adef gen_keys(keydir, keyname, user=None, encoding='Hex'):%0A    '''%0A    Generate a salt manageable curve25519 key pair and save the key securely%0A    in the keydir directory under the name keyname.curve.%0A%0A    The generated keys contain both the public and private key in a json object%0A    '''%0A    curve_keys = nacl.public.PrivateKey.genrate()%0A    keypath = os.path.join(keydir, keyname)%0A    try:%0A        encoder = getattr(nacl.encoding, '%7B0%7DEncoder'.format(encoding))()%0A    except AttributeError:%0A        encoder = nacl.encoding.HexEncoder()%0A        encoding = 'Hex'%0A    store_key = %7B%7D%0A    store_key%5B'private'%5D = encoder.encode(curve_keys._private_key)%0A    store_key%5B'public'%5D = encoder.encode(curve_keys.public_key)%0A    store_key%5B'encoding'%5D = encoding%0A    store_key%5B'generation_time'%5D(datetime.datetime.now().isoformat('_'))%0A    store_key%5B'name'%5D = keyname%0A    cumask = os.umask(0577)%0A    try:%0A        with open(keypath) as fp_:%0A            fp_.write(json.dumps(store_key))%0A    except os.error:%0A        return %7B%7D%0A    os.umask(cumask)%0A    if user:%0A        try:%0A            import pwd%0A            uid = pwd.getpwnam(user).pw_uid%0A            os.chown(keypath, uid, -1)%0A        except (KeyError, ImportError, OSError):%0A            # The specified user was not found, allow the backup systems to%0A            # report the error%0A            pass%0A    return curve_keys%0A

Add routine for generating a json serialized key for curve