Commit e5d34093 authored by Pascal Engélibert's avatar Pascal Engélibert

Server: random keys generation

parent bfaf1bee
......@@ -21,7 +21,7 @@ Sources:
https://www.ietf.org/rfc/rfc3092.txt <- Very important RFC, please read it
"""
import asyncio, getpass, secrets, random
import asyncio, getpass, random
import ubjson
import libnacl.sign
from utils import *
......@@ -45,9 +45,6 @@ class Confirmation():
self.out_amount = int(data["out_amount"])
self.out_base = int(data["out_base"])
def genKeys():
return secrets.token_urlsafe(), secrets.token_urlsafe()
def get_peers(host, proxy=None, proxy_onion_only=False):
header, content = sdata(host, "GET", "/pubkey/list", proxy=proxy, proxy_onion_only=proxy_onion_only)
......
......@@ -17,7 +17,7 @@
along with ĞMixer-py. If not, see <https://www.gnu.org/licenses/>.
"""
import json, asyncio, getpass, secrets, random
import json, asyncio, getpass, random
from threading import Thread
import ubjson
import plyvel
......@@ -42,6 +42,8 @@ BIND_HOST = socket.gethostname()
BIND_PORT = 10951
PUBLIC_HOST = BIND_HOST
PUBLIC_PORT = BIND_PORT
ID_SALT = ""
ID_PASSWORD = ""
BMA_HOSTS = ["g1.duniter.fr 443", "g1.duniter.org 443", "g1.presles.fr 443", "g1.cgeek.fr 443", "ts.g1.librelois.fr 443"]
MIX_INTERVAL = 60
MIX_MIN_TXS = 5 # minimum amount of txs to mix
......@@ -169,8 +171,8 @@ def readConfig(cdir):
conf["client"].setdefault("proxy", None)
conf["client"].setdefault("proxy_onion_only", False)
conf.setdefault("crypto", {})
conf["crypto"].setdefault("id_salt", "")
conf["crypto"].setdefault("id_password", "")
conf["crypto"].setdefault("id_salt", ID_SALT)
conf["crypto"].setdefault("id_password", ID_PASSWORD)
conf.setdefault("mix", {})
conf["mix"].setdefault("mix_interval", MIX_INTERVAL)
conf["mix"].setdefault("mix_req_age_max", MIX_REQ_AGE_MAX)
......@@ -737,6 +739,11 @@ if __name__ == "__main__":
conf = readConfig(DIR)
readPeers(DIR)
elif "-I" in sys.argv:
ID_SALT, ID_PASSWORD = genKeys()
conf = readConfig(DIR)
readPeers(DIR)
elif "-k" in sys.argv:
conf = readConfig(DIR)
salt, password = getCredentials(conf)
......@@ -755,6 +762,7 @@ Options:\n\
default: ~/.gmixer\n\
-s Start server\n\
-i Init config\n\
-I Init config (generate random keys)\n\
-k Display public key\n\
-v Display version\n\
")
......@@ -16,7 +16,7 @@
along with ĞMixer-py. If not, see <https://www.gnu.org/licenses/>.
"""
import sys, os, re, socket, time
import sys, os, re, socket, time, secrets
import socks
from duniterpy.key import SigningKey, PublicKey
_argv = sys.argv # silkaj reads sys.argv!
......@@ -44,6 +44,9 @@ def normalize_pubkey(pubkey):
def clean_pubkey(pubkey):
return pubkey.replace(" ", "")
def genKeys():
return secrets.token_urlsafe(), secrets.token_urlsafe()
#-------- NETWORK
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment