From 3fa1ea0376b7a195a3f2eeb497a67eff470ca75d Mon Sep 17 00:00:00 2001 From: souliane Date: Mon, 23 Nov 2015 18:51:15 +0100 Subject: [PATCH] memory: fixes asyncCreateProfile to not overwrite the personal key --- src/memory/memory.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/memory/memory.py b/src/memory/memory.py index 560d24c9..2f8664ca 100644 --- a/src/memory/memory.py +++ b/src/memory/memory.py @@ -453,9 +453,15 @@ class Memory(object): raise ValueError("Empty profile name") if name[0] == '@': raise ValueError("A profile name can't start with a '@'") - personal_key = BlockCipher.getRandomKey(base64=True) # generated once for all and saved in a PersistentDict - self.auth_sessions.newSession({C.MEMORY_CRYPTO_KEY: personal_key}, profile=name) # will be encrypted by setParam + d = self.params.asyncCreateProfile(name) + + def initPersonalKey(dummy): + # be sure to call this after checking that the profile doesn't exist yet + personal_key = BlockCipher.getRandomKey(base64=True) # generated once for all and saved in a PersistentDict + self.auth_sessions.newSession({C.MEMORY_CRYPTO_KEY: personal_key}, profile=name) # will be encrypted by setParam + + d.addCallback(initPersonalKey) d.addCallback(lambda dummy: self.setParam(C.PROFILE_PASS_PATH[1], password, C.PROFILE_PASS_PATH[0], profile_key=name)) return d