diff --git a/onionr/onionrcrypto.py b/onionr/onionrcrypto.py index d93d7c90..678a4457 100644 --- a/onionr/onionrcrypto.py +++ b/onionr/onionrcrypto.py @@ -144,7 +144,7 @@ class OnionrCrypto: def pubKeyDecrypt(self, data, pubkey='', privkey='', anonymous=False, encodedData=False): '''pubkey decrypt (Curve25519, taken from Ed25519 pubkey)''' - retVal = False + decrypted = False if encodedData: encoding = nacl.encoding.Base64Encoder else: diff --git a/onionr/static-data/default-plugins/encrypt/main.py b/onionr/static-data/default-plugins/encrypt/main.py index 48508e79..d4d9306a 100644 --- a/onionr/static-data/default-plugins/encrypt/main.py +++ b/onionr/static-data/default-plugins/encrypt/main.py @@ -74,8 +74,16 @@ class PlainEncryption: print('ONIONR ENCRYPTED DATA %s END ENCRYPTED DATA' % (encrypted,)) def decrypt(self, data): plaintext = "" - encrypted = data - + encrypted = data.replace('ONIONR ENCRYPTED DATA ', '').replace('END ENCRYPTED DATA', '') + myPub = self.api.get_core()._crypto.pubKey + decrypted = self.api.get_core()._crypto.pubKeyDecrypt(encrypted, pubkey, anonymous=True, encodedData=True) + if decrypted == False: + print("Decryption failed") + else: + data = json.loads(decrypted) + if not self.api.get_core()._crypto.edVerify(data['data'], data['signer'], data['sig']): + print("WARNING: THIS MESSAGE HAS AN INVALID SIGNATURE") + print(self.api.get_core()._utils.escapeAnsi(data['data'])) return