mirror of
https://github.com/kevinveenbirkenbach/splitted-secret.git
synced 2025-09-09 19:57:17 +02:00
Implemented further decription steps
This commit is contained in:
@@ -32,6 +32,19 @@ class Decryption(AbstractSplittedSecret):
|
||||
def resetDecrypterIds(self):
|
||||
self.decrypter_ids = []
|
||||
self.addDecrypterId(self.user_id)
|
||||
|
||||
def resetPasswordShare(self):
|
||||
self.password_parts = {}
|
||||
self.addPasswordShare(self.user_id,self.getPasswordShare())
|
||||
|
||||
def addPasswordShare(self,user_id,password_share):
|
||||
self.password_parts[str(user_id)] = password_share
|
||||
|
||||
def getSharedPassword(self):
|
||||
shared_password = ''
|
||||
for password_share_index in sorted(self.password_parts):
|
||||
shared_password += str(self.password_parts[password_share_index])
|
||||
return shared_password
|
||||
|
||||
def addDecrypterId(self,decrypter_id):
|
||||
decrypter_id = int(decrypter_id)
|
||||
@@ -42,9 +55,24 @@ class Decryption(AbstractSplittedSecret):
|
||||
if decrypter_id in self.decrypter_ids:
|
||||
raise Exception("The decrypter is already in the list.")
|
||||
self.decrypter_ids.append(decrypter_id)
|
||||
|
||||
def getDecryptersIds(self):
|
||||
|
||||
def getUserId(self):
|
||||
return self.user_id
|
||||
|
||||
def getCoDecrypterIds(self):
|
||||
co_decrypter_ids = self.decrypter_ids[:]
|
||||
co_decrypter_ids.remove(int(self.user_id))
|
||||
return co_decrypter_ids
|
||||
|
||||
def getDecrypterIds(self):
|
||||
return self.decrypter_ids
|
||||
|
||||
def getDecryptersGroupName(self):
|
||||
self.decrypter_ids.sort()
|
||||
return ''.join(str(x) for x in self.decrypter_ids)
|
||||
|
||||
def getPasswordShare(self):
|
||||
return self.user_data['groups'][str(self.getDecryptersGroupName())]
|
||||
|
||||
def getNeededCoDecryptersAmount(self):
|
||||
return self.needed_decrypters_amount -1
|
||||
|
@@ -51,11 +51,11 @@ class Encryption(AbstractSplittedSecret):
|
||||
characters = string.ascii_letters + string.digits
|
||||
return (''.join(random.choice(characters) for i in range(length)).upper())
|
||||
|
||||
def isGroupValid(self,password_group_index_str):
|
||||
def isGroupValid(self,password_group_name):
|
||||
secret_stakeholders_range=range(1,(self.amount_of_secret_holders+1))
|
||||
valid_numbers = re.compile("([" + ','.join([str(x) for x in secret_stakeholders_range]) + "]{" + str(self.group_members_amount) + "})")
|
||||
unvalid_sequenz = re.compile("(.)\\1+")
|
||||
return re.search(valid_numbers, password_group_index_str) and not re.search(unvalid_sequenz, password_group_index_str)
|
||||
return re.search(valid_numbers, password_group_name) and not re.search(unvalid_sequenz, password_group_name)
|
||||
|
||||
def compileContacts(self):
|
||||
contacts = {}
|
||||
@@ -71,21 +71,21 @@ class Encryption(AbstractSplittedSecret):
|
||||
self.compileContacts()
|
||||
index = self.getStartnumber()
|
||||
while index < self.getEndnumber():
|
||||
password_group_index_str = ''.join(sorted(str(index)))
|
||||
if self.isGroupValid(password_group_index_str):
|
||||
password_group_index_int = int(password_group_index_str)
|
||||
password_group_name = ''.join(sorted(str(index)))
|
||||
if self.isGroupValid(password_group_name):
|
||||
password_group_index_int = int(password_group_name)
|
||||
if not password_group_index_int in self.group_mapped_data:
|
||||
self.group_mapped_data[password_group_index_int] = {}
|
||||
self.group_mapped_data[password_group_index_int]['members'] = {}
|
||||
self.group_mapped_data[password_group_index_int]['password'] = ''
|
||||
password = ''
|
||||
for secret_holder_index in password_group_index_str:
|
||||
for secret_holder_index in password_group_name:
|
||||
self.group_mapped_data[password_group_index_int]['members'][secret_holder_index]={}
|
||||
particial_password_length= int(self.OVERALL_PASSWORD_LENGTHS*self.quota_factor);
|
||||
password_part = self.createPassword(particial_password_length)
|
||||
self.group_mapped_data[password_group_index_int]['members'][secret_holder_index] = password_part
|
||||
password += password_part
|
||||
self.user_mapped_data[secret_holder_index]['groups'][password_group_index_str] = password_part
|
||||
self.user_mapped_data[secret_holder_index]['groups'][password_group_name] = password_part
|
||||
self.group_mapped_data[password_group_index_int]['password'] += password
|
||||
index += 1
|
||||
|
||||
|
Reference in New Issue
Block a user