work on offline decryption and fixed pubkey encrypt bug
parent
2c4d086316
commit
b8644c0441
|
@ -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:
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue