+ added methods to import and select new forward secrecy keys
parent
d151e0d302
commit
c4dcd89dfe
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -60,7 +60,25 @@ 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()
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue