mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-22 21:50:18 +00:00
Compare commits
1 Commits
e0d00c278f
...
600923b2da
Author | SHA1 | Date | |
---|---|---|---|
|
600923b2da |
@ -269,7 +269,6 @@ class Destination:
|
|||||||
if self.ratchets != None:
|
if self.ratchets != None:
|
||||||
self.rotate_ratchets()
|
self.rotate_ratchets()
|
||||||
ratchet = RNS.Identity._ratchet_public_bytes(self.ratchets[0])
|
ratchet = RNS.Identity._ratchet_public_bytes(self.ratchets[0])
|
||||||
RNS.Identity._remember_ratchet(self.hash, ratchet)
|
|
||||||
|
|
||||||
if app_data == None and self.default_app_data != None:
|
if app_data == None and self.default_app_data != None:
|
||||||
if isinstance(self.default_app_data, bytes):
|
if isinstance(self.default_app_data, bytes):
|
||||||
@ -574,7 +573,7 @@ class Destination:
|
|||||||
if self.type == Destination.SINGLE and self.identity != None:
|
if self.type == Destination.SINGLE and self.identity != None:
|
||||||
selected_ratchet = RNS.Identity.get_ratchet(self.hash)
|
selected_ratchet = RNS.Identity.get_ratchet(self.hash)
|
||||||
if selected_ratchet:
|
if selected_ratchet:
|
||||||
self.latest_ratchet_id = RNS.Identity._get_ratchet_id(selected_ratchet)
|
self.latest_ratchet_id = RNS.Identity.truncated_hash(selected_ratchet)
|
||||||
return self.identity.encrypt(plaintext, ratchet=selected_ratchet)
|
return self.identity.encrypt(plaintext, ratchet=selected_ratchet)
|
||||||
|
|
||||||
if self.type == Destination.GROUP:
|
if self.type == Destination.GROUP:
|
||||||
|
@ -249,11 +249,7 @@ class Identity:
|
|||||||
if ratchet == None:
|
if ratchet == None:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
return Identity._get_ratchet_id(ratchet)
|
return Identity.truncated_hash(ratchet)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _get_ratchet_id(ratchet_pub_bytes):
|
|
||||||
return Identity.full_hash(ratchet_pub_bytes)[:Identity.NAME_HASH_LENGTH//8]
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _ratchet_public_bytes(ratchet):
|
def _ratchet_public_bytes(ratchet):
|
||||||
@ -268,7 +264,7 @@ class Identity:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _remember_ratchet(destination_hash, ratchet):
|
def _remember_ratchet(destination_hash, ratchet):
|
||||||
# TODO: Remove at some point, and only log new ratchets
|
# TODO: Remove at some point, and only log new ratchets
|
||||||
RNS.log(f"Remembering ratchet {RNS.prettyhexrep(Identity._get_ratchet_id(ratchet))} for {RNS.prettyhexrep(destination_hash)}", RNS.LOG_EXTREME)
|
RNS.log(f"Remembering ratchet {RNS.prettyhexrep(Identity.truncated_hash(ratchet))} for {RNS.prettyhexrep(destination_hash)}", RNS.LOG_EXTREME)
|
||||||
try:
|
try:
|
||||||
Identity.known_ratchets[destination_hash] = ratchet
|
Identity.known_ratchets[destination_hash] = ratchet
|
||||||
|
|
||||||
@ -288,7 +284,7 @@ class Identity:
|
|||||||
ratchet_file = open(outpath, "wb")
|
ratchet_file = open(outpath, "wb")
|
||||||
ratchet_file.write(umsgpack.packb(ratchet_data))
|
ratchet_file.write(umsgpack.packb(ratchet_data))
|
||||||
ratchet_file.close()
|
ratchet_file.close()
|
||||||
os.replace(outpath, finalpath)
|
os.rename(outpath, finalpath)
|
||||||
|
|
||||||
|
|
||||||
threading.Thread(target=persist_job, daemon=True).start()
|
threading.Thread(target=persist_job, daemon=True).start()
|
||||||
@ -677,7 +673,7 @@ class Identity:
|
|||||||
for ratchet in ratchets:
|
for ratchet in ratchets:
|
||||||
try:
|
try:
|
||||||
ratchet_prv = X25519PrivateKey.from_private_bytes(ratchet)
|
ratchet_prv = X25519PrivateKey.from_private_bytes(ratchet)
|
||||||
ratchet_id = Identity._get_ratchet_id(ratchet_prv.public_key().public_bytes())
|
ratchet_id = Identity.truncated_hash(ratchet_prv.public_key().public_bytes())
|
||||||
shared_key = ratchet_prv.exchange(peer_pub)
|
shared_key = ratchet_prv.exchange(peer_pub)
|
||||||
derived_key = RNS.Cryptography.hkdf(
|
derived_key = RNS.Cryptography.hkdf(
|
||||||
length=32,
|
length=32,
|
||||||
|
Loading…
Reference in New Issue
Block a user