From 85aae3723d754dcc7a3d60edab666591ecbddd5b Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Wed, 30 Oct 2013 12:26:00 -0300 Subject: Fix non-ascii password change problem. [Closes #4003] --- changes/bug-4003_fix-non-ascii-password-change | 1 + src/leap/bitmask/crypto/srpauth.py | 14 +++++++------- src/leap/bitmask/gui/mainwindow.py | 4 ++-- src/leap/bitmask/gui/preferenceswindow.py | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 changes/bug-4003_fix-non-ascii-password-change diff --git a/changes/bug-4003_fix-non-ascii-password-change b/changes/bug-4003_fix-non-ascii-password-change new file mode 100644 index 00000000..2d6a0ed8 --- /dev/null +++ b/changes/bug-4003_fix-non-ascii-password-change @@ -0,0 +1 @@ + - Fix problem changing a non-ascii password. Closes #4003. diff --git a/src/leap/bitmask/crypto/srpauth.py b/src/leap/bitmask/crypto/srpauth.py index 93fb740f..ab98850d 100644 --- a/src/leap/bitmask/crypto/srpauth.py +++ b/src/leap/bitmask/crypto/srpauth.py @@ -217,10 +217,9 @@ class SRPAuth(QtCore.QObject): """ logger.debug("Authentication preprocessing...") - self._srp_user = self._srp.User(username, - password, - self._hashfun, - self._ng) + self._srp_user = self._srp.User(username.encode('utf-8'), + password.encode('utf-8'), + self._hashfun, self._ng) _, A = self._srp_user.start_authentication() self._srp_a = A @@ -487,7 +486,8 @@ class SRPAuth(QtCore.QObject): self.get_uid()) salt, verifier = self._srp.create_salted_verification_key( - self._username, new_password, self._hashfun, self._ng) + self._username.encode('utf-8'), new_password.encode('utf-8'), + self._hashfun, self._ng) cookies = {self.SESSION_ID_KEY: self.get_session_id()} headers = { @@ -518,9 +518,9 @@ class SRPAuth(QtCore.QObject): Might raise SRPAuthenticationError :param username: username for this session - :type username: str + :type username: unicode :param password: password for this user - :type password: str + :type password: unicode :returns: A defer on a different thread :rtype: twisted.internet.defer.Deferred diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py index dddd53da..fa1a82f8 100644 --- a/src/leap/bitmask/gui/mainwindow.py +++ b/src/leap/bitmask/gui/mainwindow.py @@ -880,8 +880,8 @@ class MainWindow(QtGui.QMainWindow): leap_assert(self._provider_config, "We need a provider config!") if data[self._provider_bootstrapper.PASSED_KEY]: - username = self._login_widget.get_user().encode("utf8") - password = self._login_widget.get_password().encode("utf8") + username = self._login_widget.get_user() + password = self._login_widget.get_password() if self._srp_auth is None: self._srp_auth = SRPAuth(self._provider_config) diff --git a/src/leap/bitmask/gui/preferenceswindow.py b/src/leap/bitmask/gui/preferenceswindow.py index 58cb05ba..b043afe6 100644 --- a/src/leap/bitmask/gui/preferenceswindow.py +++ b/src/leap/bitmask/gui/preferenceswindow.py @@ -156,7 +156,7 @@ class PreferencesWindow(QtGui.QDialog): """ logger.debug("SRP password changed successfully.") try: - self._soledad.change_passphrase(str(new_password)) + self._soledad.change_passphrase(new_password) logger.debug("Soledad password changed successfully.") except NoStorageSecret: logger.debug( -- cgit v1.2.3 From 1198f8484f0a6c89a610cd9aabcf30d2f43c832e Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Wed, 30 Oct 2013 12:31:14 -0300 Subject: Fix pep8 indent issue. And better operator usage. - E128: continuation line under-indented for visual indent. - Don't use identity operator to compare boolean. --- src/leap/bitmask/services/soledad/soledadbootstrapper.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/leap/bitmask/services/soledad/soledadbootstrapper.py b/src/leap/bitmask/services/soledad/soledadbootstrapper.py index d06cc910..79bec1eb 100644 --- a/src/leap/bitmask/services/soledad/soledadbootstrapper.py +++ b/src/leap/bitmask/services/soledad/soledadbootstrapper.py @@ -192,9 +192,8 @@ class SoledadBootstrapper(AbstractBootstrapper): # soledad-launcher in the gui. raise - leap_assert(sameProxiedObjects(self._soledad, None) - is not True, - "Null soledad, error while initializing") + leap_assert(not sameProxiedObjects(self._soledad, None), + "Null soledad, error while initializing") # and now, let's sync sync_tries = self.MAX_SYNC_RETRIES -- cgit v1.2.3