reworked offline encryption

master
Kevin Froman 2018-10-21 00:07:35 -05:00
parent 220fda02ce
commit 247ae540f9
1 changed files with 11 additions and 10 deletions

View File

@ -724,17 +724,18 @@ class Core:
except AttributeError: except AttributeError:
pass pass
try: if encryptType == 'sym':
forwardEncrypted = onionrusers.OnionrUser(self, asymPeer).forwardEncrypt(data) try:
data = forwardEncrypted[0] forwardEncrypted = onionrusers.OnionrUser(self, asymPeer).forwardEncrypt(data)
meta['forwardEnc'] = True data = forwardEncrypted[0]
except onionrexceptions.InvalidPubkey: meta['forwardEnc'] = True
except onionrexceptions.InvalidPubkey:
onionrusers.OnionrUser(self, asymPeer).generateForwardKey()
else:
logger.info(forwardEncrypted)
onionrusers.OnionrUser(self, asymPeer).generateForwardKey() onionrusers.OnionrUser(self, asymPeer).generateForwardKey()
else: fsKey = onionrusers.OnionrUser(self, asymPeer).getGeneratedForwardKeys()[0]
logger.info(forwardEncrypted) meta['newFSKey'] = fsKey[0]
onionrusers.OnionrUser(self, asymPeer).generateForwardKey()
fsKey = onionrusers.OnionrUser(self, asymPeer).getGeneratedForwardKeys()[0]
meta['newFSKey'] = fsKey[0]
jsonMeta = json.dumps(meta) jsonMeta = json.dumps(meta)
if sign: if sign:
signature = self._crypto.edSign(jsonMeta.encode() + data, key=self._crypto.privKey, encodeResult=True) signature = self._crypto.edSign(jsonMeta.encode() + data, key=self._crypto.privKey, encodeResult=True)