fixed broken forward secrecy (not sharing new keys)

This commit is contained in:
Kevin Froman 2019-01-07 16:30:47 -06:00
parent c5a0b29988
commit 8c72242eaf
2 changed files with 9 additions and 6 deletions

View File

@ -182,7 +182,7 @@ class Core:
return True
else:
logger.debug('Invalid ID: %s' % address)
#logger.debug('Invalid ID: %s' % address)
return False
def removeAddress(self, address):
@ -739,10 +739,11 @@ class Core:
data = forwardEncrypted[0]
meta['forwardEnc'] = True
except onionrexceptions.InvalidPubkey:
onionrusers.OnionrUser(self, asymPeer).generateForwardKey()
onionrusers.OnionrUser(self, asymPeer).generateForwardKey()
fsKey = onionrusers.OnionrUser(self, asymPeer).getGeneratedForwardKeys()[0]
meta['newFSKey'] = fsKey[0]
pass
#onionrusers.OnionrUser(self, asymPeer).generateForwardKey()
fsKey = onionrusers.OnionrUser(self, asymPeer).generateForwardKey()
#fsKey = onionrusers.OnionrUser(self, asymPeer).getGeneratedForwardKeys().reverse()
meta['newFSKey'] = fsKey
jsonMeta = json.dumps(meta)
if sign:
signature = self._crypto.edSign(jsonMeta.encode() + data, key=self._crypto.privKey, encodeResult=True)

View File

@ -169,7 +169,9 @@ class OnionrUser:
def addForwardKey(self, newKey, expire=604800):
if not self._core._utils.validatePubKey(newKey):
raise onionrexceptions.InvalidPubkey
raise onionrexceptions.InvalidPubkey(newKey)
if newKey in self._getForwardKeys():
return False
# Add a forward secrecy key for the peer
conn = sqlite3.connect(self._core.peerDB, timeout=10)
c = conn.cursor()