better support human public keys, do not use forward secrecy when not signing

This commit is contained in:
Kevin Froman 2019-02-10 16:26:47 -06:00
parent 30604fa23c
commit 3cf5f4c04d
5 changed files with 9 additions and 4 deletions

View File

@ -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):

View File

@ -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

View File

@ -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):

View File

@ -48,6 +48,7 @@
<form method='post' action='/apipoints/mail/send' id='sendForm' enctype="application/x-www-form-urlencoded">
<span class='closeOverlay' overlay='sendMessage'></span>
To: <input id='draftID' type='text' name='to' placeholder='pubkey' required>
Subject: <input name='subject' id='draftSubject' maxlength=25 type='text' placeholder='message subject'>
<textarea name='message' placeholder='type your message...' id='draftText' required></textarea>
<input type='submit' value='Send' class='successBtn'>
</form>

View File

@ -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")