From 3cf5f4c04df2e87143fe3b398f628a7e856691f9 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sun, 10 Feb 2019 16:26:47 -0600 Subject: [PATCH] better support human public keys, do not use forward secrecy when not signing --- onionr/core.py | 6 ++++-- onionr/onionrusers.py | 3 +++ onionr/static-data/default-plugins/pms/main.py | 2 -- onionr/static-data/www/mail/index.html | 1 + onionr/static-data/www/shared/misc.js | 1 + 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/onionr/core.py b/onionr/core.py index a4852dba..6102d892 100755 --- a/onionr/core.py +++ b/onionr/core.py @@ -748,6 +748,7 @@ class Core: data = data.decode() data = str(data) plaintext = data + plaintextMeta = {} # Convert asym peer human readable key to base32 if set if ' ' in asymPeer.strip(): @@ -774,7 +775,7 @@ class Core: pass if encryptType == 'asym': - if not disableForward and asymPeer != self._crypto.pubKey: + if not disableForward and sign and asymPeer != self._crypto.pubKey: try: forwardEncrypted = onionrusers.OnionrUser(self, asymPeer).forwardEncrypt(data) data = forwardEncrypted[0] @@ -786,6 +787,7 @@ class Core: #fsKey = onionrusers.OnionrUser(self, asymPeer).getGeneratedForwardKeys().reverse() meta['newFSKey'] = fsKey jsonMeta = json.dumps(meta) + plaintextMeta = jsonMeta if sign: signature = self._crypto.edSign(jsonMeta.encode() + data, key=self._crypto.privKey, encodeResult=True) signer = self._crypto.pubKey @@ -845,7 +847,7 @@ class Core: self.daemonQueueAdd('uploadBlock', retData) if retData != False: - events.event('insertblock', {'content': plaintext, 'meta': jsonMeta, 'hash': retData, 'peer': self._utils.bytesToStr(asymPeer)}, onionr = self.onionrInst, threaded = False) + events.event('insertblock', {'content': plaintext, 'meta': plaintextMeta, 'hash': retData, 'peer': self._utils.bytesToStr(asymPeer)}, onionr = self.onionrInst, threaded = True) return retData def introduceNode(self): diff --git a/onionr/onionrusers.py b/onionr/onionrusers.py index c5bf41d1..41bc7b6e 100755 --- a/onionr/onionrusers.py +++ b/onionr/onionrusers.py @@ -40,6 +40,9 @@ class OnionrUser: Takes an instance of onionr core, a base32 encoded ed25519 public key, and a bool saveUser saveUser determines if we should add a user to our peer database or not. ''' + if ' ' in coreInst._utils.bytesToStr(publicKey).strip(): + publicKey = coreInst._utils.convertHumanReadableID(publicKey) + self.trust = 0 self._core = coreInst self.publicKey = publicKey diff --git a/onionr/static-data/default-plugins/pms/main.py b/onionr/static-data/default-plugins/pms/main.py index f2421ca5..75480ce2 100755 --- a/onionr/static-data/default-plugins/pms/main.py +++ b/onionr/static-data/default-plugins/pms/main.py @@ -290,10 +290,8 @@ class OnionrMail: return def on_insertblock(api, data={}): - print(data) sentboxTools = sentboxdb.SentBox(api.get_core()) meta = json.dumps(data['meta']) - print('on_insertblock', data) sentboxTools.addToSent(data['hash'], data['peer'], data['content']) def on_pluginrequest(api, data=None): diff --git a/onionr/static-data/www/mail/index.html b/onionr/static-data/www/mail/index.html index 99f0dba0..3ea92f1a 100755 --- a/onionr/static-data/www/mail/index.html +++ b/onionr/static-data/www/mail/index.html @@ -48,6 +48,7 @@
To: + Subject:
diff --git a/onionr/static-data/www/shared/misc.js b/onionr/static-data/www/shared/misc.js index 10c1e129..03d2f3da 100755 --- a/onionr/static-data/www/shared/misc.js +++ b/onionr/static-data/www/shared/misc.js @@ -32,6 +32,7 @@ function httpGet(theUrl) { function overlay(overlayID) { el = document.getElementById(overlayID) el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible" + scroll(0,0) } var passLinks = document.getElementsByClassName("idLink")