comparison src/memory/memory.py @ 1652:fd7f41d8cbdf

memory: fixes asyncCreateProfile to not overwrite the personal key
author souliane <souliane@mailoo.org>
date Mon, 23 Nov 2015 18:51:15 +0100
parents a3d0cfa5b7a6
children 61391d863709
comparison
equal deleted inserted replaced
1651:5c1d6efd6936 1652:fd7f41d8cbdf
451 """ 451 """
452 if not name: 452 if not name:
453 raise ValueError("Empty profile name") 453 raise ValueError("Empty profile name")
454 if name[0] == '@': 454 if name[0] == '@':
455 raise ValueError("A profile name can't start with a '@'") 455 raise ValueError("A profile name can't start with a '@'")
456 personal_key = BlockCipher.getRandomKey(base64=True) # generated once for all and saved in a PersistentDict 456
457 self.auth_sessions.newSession({C.MEMORY_CRYPTO_KEY: personal_key}, profile=name) # will be encrypted by setParam
458 d = self.params.asyncCreateProfile(name) 457 d = self.params.asyncCreateProfile(name)
458
459 def initPersonalKey(dummy):
460 # be sure to call this after checking that the profile doesn't exist yet
461 personal_key = BlockCipher.getRandomKey(base64=True) # generated once for all and saved in a PersistentDict
462 self.auth_sessions.newSession({C.MEMORY_CRYPTO_KEY: personal_key}, profile=name) # will be encrypted by setParam
463
464 d.addCallback(initPersonalKey)
459 d.addCallback(lambda dummy: self.setParam(C.PROFILE_PASS_PATH[1], password, C.PROFILE_PASS_PATH[0], profile_key=name)) 465 d.addCallback(lambda dummy: self.setParam(C.PROFILE_PASS_PATH[1], password, C.PROFILE_PASS_PATH[0], profile_key=name))
460 return d 466 return d
461 467
462 def asyncDeleteProfile(self, name, force=False): 468 def asyncDeleteProfile(self, name, force=False):
463 """Delete an existing profile 469 """Delete an existing profile