Esempio n. 1
0
    def check_private_key(self, secret_key, password):
        if detect_non_printable(secret_key):
            self.view.error(self.tr("Non printable characters in secret key"))
            return False

        if detect_non_printable(password):
            self.view.error(self.tr("Non printable characters in password"))
            return False

        if SigningKey(secret_key, password,
                      self.connection.scrypt_params).pubkey != self.connection.pubkey:
            self.view.error(self.tr("Wrong secret key or password. Cannot open the private key"))
            return False
        return True
Esempio n. 2
0
    def check_key(self):
        if self.mode == ConnectionConfigController.PUBKEY:
            if len(self.view.edit_pubkey.text()) < 42:
                self.view.label_info.setText(
                    self.tr("Forbidden : pubkey is too short"))
                return False
            if len(self.view.edit_pubkey.text()) > 45:
                self.view.label_info.setText(
                    self.tr("Forbidden : pubkey is too long"))
                return False
        else:
            if self.view.edit_password.text() != \
                    self.view.edit_password_repeat.text():
                self.view.label_info.setText(
                    self.tr("Error : passwords are different"))
                return False

            if self.view.edit_salt.text() != \
                    self.view.edit_salt_bis.text():
                self.view.label_info.setText(
                    self.tr("Error : secret keys are different"))
                return False

            if detect_non_printable(self.view.edit_salt.text()):
                self.view.label_info.setText(
                    self.tr("Forbidden : Invalid characters in salt field"))
                return False

            if detect_non_printable(self.view.edit_password.text()):
                self.view.label_info.setText(
                    self.tr(
                        "Forbidden : Invalid characters in password field"))
                return False

            if self.model.app.parameters.expert_mode:
                self.view.label_info.setText(self.tr(""))
                return True

            if len(self.view.edit_salt.text()) < 6:
                self.view.label_info.setText(
                    self.tr("Forbidden : salt is too short"))
                return False

            if len(self.view.edit_password.text()) < 6:
                self.view.label_info.setText(
                    self.tr("Forbidden : password is too short"))
                return False

        self.view.label_info.setText("")
        return True
Esempio n. 3
0
    def check_private_key(self, secret_key, password):
        if detect_non_printable(secret_key):
            self.view.error(self.tr("Non printable characters in secret key"))
            return False

        if detect_non_printable(password):
            self.view.error(self.tr("Non printable characters in password"))
            return False

        if SigningKey(secret_key, password, self.connection.scrypt_params
                      ).pubkey != self.connection.pubkey:
            self.view.error(
                self.tr(
                    "Wrong secret key or password. Cannot open the private key"
                ))
            return False
        return True