From f880edbeb8ebb3089bffae79a02eeba8cf75f4e1 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 20 May 2021 12:44:12 +0200 Subject: [PATCH] Store GROUP destination symmetric key as bytes instead of base64 --- RNS/Destination.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/RNS/Destination.py b/RNS/Destination.py index c0c80a1..57a345d 100755 --- a/RNS/Destination.py +++ b/RNS/Destination.py @@ -5,9 +5,6 @@ import RNS from cryptography.fernet import Fernet from cryptography.hazmat.primitives import hashes from cryptography.hazmat.backends import default_backend -from cryptography.hazmat.primitives import serialization -from cryptography.hazmat.primitives.asymmetric import rsa -from cryptography.hazmat.primitives.asymmetric import padding class Callbacks: def __init__(self): @@ -32,7 +29,6 @@ class Destination: """ KEYSIZE = RNS.Identity.KEYSIZE; - PADDINGSIZE= RNS.Identity.PADDINGSIZE; # Constants SINGLE = 0x00 @@ -245,8 +241,8 @@ class Destination: raise TypeError("A single destination holds keys through an Identity instance") if self.type == Destination.GROUP: - self.prv_bytes = Fernet.generate_key() - self.prv = Fernet(self.prv_bytes) + self.prv_bytes = base64.urlsafe_b64decode(Fernet.generate_key()) + self.prv = Fernet(base64.urlsafe_b64encode(self.prv_bytes)) def get_private_key(self): @@ -278,7 +274,7 @@ class Destination: if self.type == Destination.GROUP: self.prv_bytes = key - self.prv = Fernet(self.prv_bytes) + self.prv = Fernet(base64.urlsafe_b64encode(self.prv_bytes)) def load_public_key(self, key): if self.type != Destination.SINGLE: