in fxa/core.py [0:0]
def change_password(self, email, oldpwd=None, newpwd=None,
oldstretchpwd=None, newstretchpwd=None):
exactly_one_of(oldpwd, "oldpwd", oldstretchpwd, "oldstretchpwd")
exactly_one_of(newpwd, "newpwd", newstretchpwd, "newstretchpwd")
if self.key_stretch_version == 2:
version, salt = self.get_key_stretch_version(email)
old_spwd = StretchedPassword(version, email, salt, oldpwd, oldstretchpwd)
new_spwd = StretchedPassword(2, email, salt, newpwd, newstretchpwd)
if version == 2:
resp = self.start_password_change(email, old_spwd.v2)
kb = self.fetch_keys(resp["keyFetchToken2"], old_spwd.v2)[1]
else:
resp = self.start_password_change(email, old_spwd.v1)["passwordChangeToken"]
kb = self.fetch_keys(resp["keyFetchToken"], old_spwd.v1)[1]
self.finish_password_change_v2(
resp["passwordChangeToken"],
new_spwd,
kb)
else:
if oldpwd:
oldstretchpwd = quick_stretch_password(email, oldpwd)
if newpwd:
newstretchpwd = quick_stretch_password(email, newpwd)
resp = self.start_password_change(email, oldstretchpwd)
kb = self.fetch_keys(resp["keyFetchToken"], oldstretchpwd)[1]
new_wrapkb = derive_wrap_kb(kb, newstretchpwd)
self.finish_password_change(resp["passwordChangeToken"], newstretchpwd, new_wrapkb)