half way done with encryption plugin, fixed encryption bug in onionrcrypto when using non anonymous encryption
parent
fbd82d38fe
commit
220fda02ce
|
@ -732,6 +732,7 @@ class Core:
|
|||
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]
|
||||
jsonMeta = json.dumps(meta)
|
||||
|
|
|
@ -128,7 +128,7 @@ class OnionrCrypto:
|
|||
encoding = nacl.encoding.RawEncoder
|
||||
|
||||
if self.privKey != None and not anonymous:
|
||||
ownKey = nacl.signing.SigningKey(seed=self.privKey, encoder=nacl.encoding.Base32Encoder)
|
||||
ownKey = nacl.signing.SigningKey(seed=self.privKey, encoder=nacl.encoding.Base32Encoder).to_curve25519_private_key()
|
||||
key = nacl.signing.VerifyKey(key=pubkey, encoder=nacl.encoding.Base32Encoder).to_curve25519_public_key()
|
||||
ourBox = nacl.public.Box(ownKey, key)
|
||||
retVal = ourBox.encrypt(data.encode(), encoder=encoding)
|
||||
|
|
|
@ -58,6 +58,7 @@ class OnionrUser:
|
|||
def forwardEncrypt(self, data):
|
||||
retData = ''
|
||||
forwardKey = self._getLatestForwardKey()
|
||||
logger.info('using ' + forwardKey)
|
||||
if self._core._utils.validatePubKey(forwardKey):
|
||||
retData = self._core._crypto.pubKeyEncrypt(data, forwardKey, encodedData=True, anonymous=True)
|
||||
else:
|
||||
|
@ -87,7 +88,7 @@ class OnionrUser:
|
|||
conn = sqlite3.connect(self._core.peerDB, timeout=10)
|
||||
c = conn.cursor()
|
||||
|
||||
for row in c.execute("SELECT forwardKey FROM forwardKeys WHERE peerKey = ? AND date=(SELECT max(date) FROM forwardKeys)", (self.publicKey,)):
|
||||
for row in c.execute("SELECT forwardKey FROM forwardKeys WHERE peerKey = ? order by date desc", (self.publicKey,)):
|
||||
key = row[0]
|
||||
break
|
||||
|
||||
|
@ -99,7 +100,7 @@ class OnionrUser:
|
|||
conn = sqlite3.connect(self._core.peerDB, timeout=10)
|
||||
c = conn.cursor()
|
||||
keyList = []
|
||||
for row in c.execute("SELECT forwardKey FROM forwardKeys WHERE peerKey = ?", (self.publicKey,)):
|
||||
for row in c.execute("SELECT forwardKey FROM forwardKeys WHERE peerKey = ? order by date desc", (self.publicKey,)):
|
||||
key = row[0]
|
||||
keyList.append(key)
|
||||
|
||||
|
|
Loading…
Reference in New Issue