work on offline decryption and fixed pubkey encrypt bug

This commit is contained in:
Kevin Froman 2018-10-23 23:54:28 -05:00
parent 2c4d086316
commit b8644c0441
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
2 changed files with 11 additions and 3 deletions

View File

@ -144,7 +144,7 @@ class OnionrCrypto:
def pubKeyDecrypt(self, data, pubkey='', privkey='', anonymous=False, encodedData=False): def pubKeyDecrypt(self, data, pubkey='', privkey='', anonymous=False, encodedData=False):
'''pubkey decrypt (Curve25519, taken from Ed25519 pubkey)''' '''pubkey decrypt (Curve25519, taken from Ed25519 pubkey)'''
retVal = False decrypted = False
if encodedData: if encodedData:
encoding = nacl.encoding.Base64Encoder encoding = nacl.encoding.Base64Encoder
else: else:

View File

@ -74,8 +74,16 @@ class PlainEncryption:
print('ONIONR ENCRYPTED DATA %s END ENCRYPTED DATA' % (encrypted,)) print('ONIONR ENCRYPTED DATA %s END ENCRYPTED DATA' % (encrypted,))
def decrypt(self, data): def decrypt(self, data):
plaintext = "" 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 return