+ added methods to import and select new forward secrecy keys

This commit is contained in:
Kevin Froman 2018-09-11 21:58:51 -05:00
parent d151e0d302
commit c4dcd89dfe
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
3 changed files with 22 additions and 4 deletions

View File

@ -693,7 +693,7 @@ class Core:
data = data.encode()
except AttributeError:
pass
# sign before encrypt, as unauthenticated crypto should not be a problem here
if sign:
signature = self._crypto.edSign(jsonMeta.encode() + data, key=self._crypto.privKey, encodeResult=True)
signer = self._crypto.pubKey

View File

@ -50,7 +50,7 @@ class OnionrUser:
encrypted = coreInst._crypto.pubKeyEncrypt(data, self.publicKey, encodedData=True)
return encrypted
def decrypt(self, data):
def decrypt(self, data, anonymous=True):
decrypted = coreInst._crypto.pubKeyDecrypt(data, self.publicKey, encodedData=True)
return decrypted
@ -59,8 +59,26 @@ class OnionrUser:
def forwardDecrypt(self, encrypted):
return
def _getLatestForwardKey(self):
# Get the latest forward secrecy key for a peer
conn = sqlite3.connect(self._core.peerDB)
c = conn.cursor()
# Prepare the insert
time = self._core._utils.getEpoch()
key = ''
for row in c.execute("SELECT forwardKey FROM forwardKeys WHERE DATE=(SELECT max(date) FROM forwardKeys);"):
key = row[0]
break
conn.commit()
conn.close()
return key
def addForwardKey(self, newKey):
if not self._core._utils.validatePubKey(newKey):
raise onionrexceptions.InvalidPubkey
# Add a forward secrecy key for the peer
conn = sqlite3.connect(self._core.peerDB)
c = conn.cursor()

View File

@ -54,7 +54,7 @@ def _processForwardKey(api, myBlock):
def on_processBlocks(api):
myBlock = api.data['block']
blockType = api.data['type']
print('blockType is ' + blockType)
logger.info('blockType is ' + blockType)
# Process specific block types