+ added methods to import and select new forward secrecy keys
This commit is contained in:
parent
d151e0d302
commit
c4dcd89dfe
@ -693,7 +693,7 @@ class Core:
|
|||||||
data = data.encode()
|
data = data.encode()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
# sign before encrypt, as unauthenticated crypto should not be a problem here
|
|
||||||
if sign:
|
if sign:
|
||||||
signature = self._crypto.edSign(jsonMeta.encode() + data, key=self._crypto.privKey, encodeResult=True)
|
signature = self._crypto.edSign(jsonMeta.encode() + data, key=self._crypto.privKey, encodeResult=True)
|
||||||
signer = self._crypto.pubKey
|
signer = self._crypto.pubKey
|
||||||
|
@ -50,7 +50,7 @@ class OnionrUser:
|
|||||||
encrypted = coreInst._crypto.pubKeyEncrypt(data, self.publicKey, encodedData=True)
|
encrypted = coreInst._crypto.pubKeyEncrypt(data, self.publicKey, encodedData=True)
|
||||||
return encrypted
|
return encrypted
|
||||||
|
|
||||||
def decrypt(self, data):
|
def decrypt(self, data, anonymous=True):
|
||||||
decrypted = coreInst._crypto.pubKeyDecrypt(data, self.publicKey, encodedData=True)
|
decrypted = coreInst._crypto.pubKeyDecrypt(data, self.publicKey, encodedData=True)
|
||||||
return decrypted
|
return decrypted
|
||||||
|
|
||||||
@ -60,7 +60,25 @@ class OnionrUser:
|
|||||||
def forwardDecrypt(self, encrypted):
|
def forwardDecrypt(self, encrypted):
|
||||||
return
|
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):
|
def addForwardKey(self, newKey):
|
||||||
|
if not self._core._utils.validatePubKey(newKey):
|
||||||
|
raise onionrexceptions.InvalidPubkey
|
||||||
# Add a forward secrecy key for the peer
|
# Add a forward secrecy key for the peer
|
||||||
conn = sqlite3.connect(self._core.peerDB)
|
conn = sqlite3.connect(self._core.peerDB)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
|
@ -54,7 +54,7 @@ def _processForwardKey(api, myBlock):
|
|||||||
def on_processBlocks(api):
|
def on_processBlocks(api):
|
||||||
myBlock = api.data['block']
|
myBlock = api.data['block']
|
||||||
blockType = api.data['type']
|
blockType = api.data['type']
|
||||||
print('blockType is ' + blockType)
|
logger.info('blockType is ' + blockType)
|
||||||
|
|
||||||
# Process specific block types
|
# Process specific block types
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user