From 247ae540f9d5b143560aab939502f57d01754ee7 Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sun, 21 Oct 2018 00:07:35 -0500 Subject: [PATCH] reworked offline encryption --- onionr/core.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/onionr/core.py b/onionr/core.py index 65f9f26a..296fec88 100644 --- a/onionr/core.py +++ b/onionr/core.py @@ -724,17 +724,18 @@ class Core: except AttributeError: pass - try: - forwardEncrypted = onionrusers.OnionrUser(self, asymPeer).forwardEncrypt(data) - data = forwardEncrypted[0] - meta['forwardEnc'] = True - except onionrexceptions.InvalidPubkey: + if encryptType == 'sym': + try: + forwardEncrypted = onionrusers.OnionrUser(self, asymPeer).forwardEncrypt(data) + data = forwardEncrypted[0] + meta['forwardEnc'] = True + except onionrexceptions.InvalidPubkey: + onionrusers.OnionrUser(self, asymPeer).generateForwardKey() + else: + logger.info(forwardEncrypted) onionrusers.OnionrUser(self, asymPeer).generateForwardKey() - else: - logger.info(forwardEncrypted) - onionrusers.OnionrUser(self, asymPeer).generateForwardKey() - fsKey = onionrusers.OnionrUser(self, asymPeer).getGeneratedForwardKeys()[0] - meta['newFSKey'] = fsKey[0] + fsKey = onionrusers.OnionrUser(self, asymPeer).getGeneratedForwardKeys()[0] + meta['newFSKey'] = fsKey[0] jsonMeta = json.dumps(meta) if sign: signature = self._crypto.edSign(jsonMeta.encode() + data, key=self._crypto.privKey, encodeResult=True)