def test_custom_character_set(self):
     setting = PasswordSetting('some.domain')
     setting.set_salt('pepper'.encode('utf-8'))
     setting.set_custom_character_set(
         'abcdefghijklmnopqrstuvwxyzABCDUFGHJKLMNPQRTEVWXYZ0123456789#!"§$%&/()[]{}=-_+*<>;:.')
     manager = CtSesam(domain=setting.get_domain(), username=setting.get_username(), kgk='foo'.encode('utf-8'))
     self.assertEqual("5#%KiEvUU7", manager.generate(setting))
Example #2
0
 def generate_password(self):
     if not self.kgk_manager.has_kgk():
         self.kgk_manager.create_new_kgk()
         self.kgk_manager.create_and_save_new_kgk_block()
     if not self.kgk_manager.kgk_crypter or not self.kgk_manager.salt:
         self.kgk_manager.get_kgk_crypter(self.master_password_edit.text().encode('utf-8'),
                                          self.kgk_manager.get_kgk_crypter_salt())
     if self.setting_dirty:
         self.setting.new_salt()
         self.setting.calculate_template()
     self.settings_manager.set_setting(self.setting)
     if not self.setting.get_legacy_password():
         generator = CtSesam(self.setting.get_domain(),
                             self.setting.get_username(),
                             self.kgk_manager.get_kgk(),
                             self.setting.get_salt(),
                             self.setting.get_iterations())
         password = generator.generate(self.setting)
     else:
         password = self.setting.get_legacy_password()
     self.password.setText(password)
     self.password.setTextInteractionFlags(Qt.TextSelectableByMouse | Qt.TextSelectableByKeyboard)
     self.clipboard_button.setVisible(True)
     self.settings_manager.store_local_settings(self.kgk_manager)
     self.setting_dirty = False
 def test_custom_salt(self):
     setting = PasswordSetting('some.domain')
     setting.set_salt(b'qanisaoerna56745678eornsiarteonstiaroenstiaeroh')
     setting.set_template("oxAxxaxxnx")
     manager = CtSesam(domain=setting.get_domain(),
                       username=setting.get_username(),
                       kgk='foo'.encode('utf-8'))
     self.assertEqual(")hN8ol<;6<", manager.generate(setting))
 def test_default(self):
     setting = PasswordSetting('some.domain')
     setting.set_salt('pepper'.encode('utf-8'))
     setting.set_template("xaxnxxAoxx")
     manager = CtSesam(domain=setting.get_domain(),
                       username=setting.get_username(),
                       kgk='foo'.encode('utf-8'))
     self.assertEqual("]ew26XW.X<", manager.generate(setting))
Example #5
0
 def test_custom_character_set(self):
     setting = PasswordSetting('some.domain')
     setting.set_salt('pepper'.encode('utf-8'))
     setting.set_extra_character_set(
         'abcdefghijklmnopqrstuvwxyzABCDUFGHJKLMNPQRTEVWXYZ0123456789#!"§$%&/()[]{}=-_+*<>;:.')
     setting.set_template("oxxxxxxxxx")
     manager = CtSesam(domain=setting.get_domain(), username=setting.get_username(), kgk='foo'.encode('utf-8'))
     self.assertEqual("5#%KiEvUU7", manager.generate(setting))
 def test_custom_character_set(self):
     setting = PasswordSetting("some.domain")
     setting.set_salt("pepper".encode("utf-8"))
     setting.set_extra_character_set(
         'abcdefghijklmnopqrstuvwxyzABCDUFGHJKLMNPQRTEVWXYZ0123456789#!"§$%&/()[]{}=-_+*<>;:.'
     )
     setting.set_template("oxxxxxxxxx")
     manager = CtSesam(domain=setting.get_domain(), username=setting.get_username(), kgk="foo".encode("utf-8"))
     self.assertEqual("5#%KiEvUU7", manager.generate(setting))
 def test_long(self):
     setting = PasswordSetting('some.domain')
     setting.set_salt('pepper'.encode('utf-8'))
     setting.set_template("Aanoxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
     manager = CtSesam(domain=setting.get_domain(),
                       username=setting.get_username(),
                       kgk='foo'.encode('utf-8'))
     self.assertEqual("Ba0=}#K.X<$/eS0AuGjRm>(\"dnDnvZCx",
                      manager.generate(setting))
def print_generated_password(password_setting, kgk, quiet):
    sesam = CtSesam(password_setting.get_domain(),
                    password_setting.get_username(), kgk,
                    password_setting.get_salt(),
                    password_setting.get_iterations())
    password = sesam.generate(password_setting)
    if quiet:
        print(password)
    else:
        print('Passwort: ' + password)
def print_generated_password(password_setting, kgk, quiet):
    sesam = CtSesam(password_setting.get_domain(),
                    password_setting.get_username(),
                    kgk,
                    password_setting.get_salt(),
                    password_setting.get_iterations())
    password = sesam.generate(password_setting)
    if quiet:
        print(password)
    else:
        print('Passwort: ' + password)
Example #10
0
 def migrate_local_domains(self, new_kgk_manager):
     for domain in self.settings_manager.get_domain_list():
         setting = self.settings_manager.get_setting(domain)
         generator = CtSesam(setting.get_domain(),
                             setting.get_username(),
                             self.kgk_manager.get_kgk(),
                             setting.get_salt(),
                             setting.get_iterations())
         setting.set_legacy_password(generator.generate(setting))
         self.settings_manager.set_setting(setting)
     self.kgk_manager = new_kgk_manager
     self.settings_manager.store_local_settings(self.kgk_manager)
 def test_simple_password_3_tpl(self):
     setting = PasswordSetting('FooBar')
     setting.set_iterations(8192)
     setting.set_template("xxAxxx")
     setting.set_salt('blahfasel'.encode('utf-8'))
     kgk = 'test'.encode('utf-8')
     manager = CtSesam(domain=setting.get_domain(),
                       username=setting.get_username(),
                       kgk=kgk,
                       salt=setting.get_salt(),
                       iterations=setting.get_iterations())
     self.assertEqual(
         unhexlify(
             "309d504d68dc921dcece9d10c14b406673715f15782032d64229b4b42336c8ec860cd9b9451048"
             + "24ce43720b3a088828843df4029fdb8b2314f8b5129c815949"),
         manager.hash_value)
     self.assertEqual("BAELOH", manager.generate(setting))
 def test_simple_password_1_tpl(self):
     setting = PasswordSetting('FooBar')
     setting.set_extra_character_set("#!\"$%&/()[]{}=-_+*<>;:.")
     setting.set_iterations(4096)
     setting.set_template("xxoxAxxxxxxxxxaxx")
     setting.set_salt('blahfasel'.encode('utf-8'))
     kgk = 'test'.encode('utf-8')
     manager = CtSesam(domain=setting.get_domain(),
                       username=setting.get_username(),
                       kgk=kgk,
                       salt=setting.get_salt(),
                       iterations=setting.get_iterations())
     self.assertEqual(
         unhexlify(
             "4e9e2503556bda7ad06cf45cab4490213becd3473845a868900fb61fa17d1c448496d11987c4"
             + "446d8007562029cce7f176eda4157604012a44e42add594a524e"),
         manager.hash_value)
     self.assertEqual("pU)VUfgJ-Ws*wgzzE", manager.generate(setting))
 def test_pin(self):
     setting = PasswordSetting('Bank')
     setting.set_iterations(1)
     setting.set_extra_character_set("0123456789")
     setting.set_template("oxxx")
     setting.set_salt('pepper'.encode('utf-8'))
     kgk = 'reallysafe'.encode('utf-8')
     manager = CtSesam(domain=setting.get_domain(),
                       username=setting.get_username(),
                       kgk=kgk,
                       salt=setting.get_salt(),
                       iterations=setting.get_iterations())
     self.assertEqual(
         unhexlify(
             "55b5f5cdd9bf2845e339650b4f6e1398cf7fe9ceed087eb5f5bc059882723579fc8ec27443417"
             + "cf33c9763bafac6277fbe991bf27dd0206e78f7d9dfd574167f"),
         manager.hash_value)
     self.assertEqual("7809", manager.generate(setting))
 def test_simple_password_2(self):
     setting = PasswordSetting('MyFavoriteDomain')
     setting.set_extra_character_set(
         "abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNPQRTUVWXYZ")
     setting.set_iterations(8192)
     setting.set_template("oxxxxxxxxxxxxxxx")
     setting.set_salt('pepper'.encode('utf-8'))
     kgk = 'foobar'.encode('utf-8')
     manager = CtSesam(domain=setting.get_domain(),
                       username=setting.get_username(),
                       kgk=kgk,
                       salt=setting.get_salt(),
                       iterations=setting.get_iterations())
     self.assertEqual(
         unhexlify(
             "cb0ae7b2b7fc969770a9bfc1eef3a9afd02d2b28d6d8e9cb324f41a31392a0f800ea7e2e43"
             + "e847537ceb863a16a869d5e4dd6822cf3be0206440eff97dc2001c"),
         manager.hash_value)
     self.assertEqual("wLUwoQvKzBaYXbme", manager.generate(setting))
 def test_simple_password_4_tpl(self):
     setting = PasswordSetting('FooBar')
     setting.set_iterations(8192)
     setting.set_extra_character_set("0123456789abcdef")
     setting.set_template("xxxxxxxxxxxxxxxxxxxxxxxoxxxx")
     setting.set_salt('SALT'.encode('utf-8'))
     kgk = 'MY_T0P_5ecr57_PA55W0RD ;-)'.encode('utf-8')
     manager = CtSesam(domain=setting.get_domain(),
                       username=setting.get_username(),
                       kgk=kgk,
                       salt=setting.get_salt(),
                       iterations=setting.get_iterations())
     self.assertEqual(
         unhexlify(
             "4993fd21600977c6f56b833eed223dda9b1bd34294afd1db4925553099cce402abda7000a22d2c"
             + "fda152afcf8a3a142e55ce57a9597434a39d05ccd93a853626"),
         manager.hash_value)
     self.assertEqual("626358a39dcc50d93a4347959a75",
                      manager.generate(setting))
 def test_simple_password_1(self):
     setting = PasswordSetting('ct.de')
     setting.set_extra_character_set(
         "abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNPQRTUVWXYZ0123456789" +
         "#!\"§$%&/()[]{}=-_+*<>;:.")
     setting.set_iterations(4096)
     setting.set_template("oxxxxxxxxx")
     setting.set_salt('pepper'.encode('utf-8'))
     kgk = 'test'.encode('utf-8')
     manager = CtSesam(domain=setting.get_domain(),
                       username=setting.get_username(),
                       kgk=kgk,
                       salt=setting.get_salt(),
                       iterations=setting.get_iterations())
     self.assertEqual(
         unhexlify(
             "f4d54b303b21ee3d8bff9c1eae6f66d90db58c0a5cc770eee322cc59d4dec65793bf8f5dec"
             + "717fd1404bbfacf59befa68c4ad9168bfeaa6a9e28b326a76a82bb"),
         manager.hash_value)
     self.assertEqual("YBVUH=sN/3", manager.generate(setting))
 def test_long(self):
     setting = PasswordSetting('some.domain')
     setting.set_salt('pepper'.encode('utf-8'))
     setting.set_length(32)
     manager = CtSesam(domain=setting.get_domain(), username=setting.get_username(), kgk='foo'.encode('utf-8'))
     self.assertEqual("]#]Y6Q-+)TCus§&8[kEw5O.pJsTjOC#}", manager.generate(setting))
 def test_custom_salt(self):
     setting = PasswordSetting('some.domain')
     setting.set_salt(b'qanisaoerna56745678eornsiarteonstiaroenstiaeroh')
     manager = CtSesam(domain=setting.get_domain(), username=setting.get_username(), kgk='foo'.encode('utf-8'))
     self.assertEqual("]#]Y6Q-+)T", manager.generate(setting))
 def test_default(self):
     setting = PasswordSetting('some.domain')
     setting.set_salt('pepper'.encode('utf-8'))
     manager = CtSesam(domain=setting.get_domain(), username=setting.get_username(), kgk='foo'.encode('utf-8'))
     self.assertEqual("]#]Y6Q-+)T", manager.generate(setting))
 def test_long(self):
     setting = PasswordSetting("some.domain")
     setting.set_salt("pepper".encode("utf-8"))
     setting.set_template("Aanoxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
     manager = CtSesam(domain=setting.get_domain(), username=setting.get_username(), kgk="foo".encode("utf-8"))
     self.assertEqual('Ba0=}#K.X<$/eS0AuGjRm>("dnDnvZCx', manager.generate(setting))
 def test_custom_salt(self):
     setting = PasswordSetting("some.domain")
     setting.set_salt(b"qanisaoerna56745678eornsiarteonstiaroenstiaeroh")
     setting.set_template("oxAxxaxxnx")
     manager = CtSesam(domain=setting.get_domain(), username=setting.get_username(), kgk="foo".encode("utf-8"))
     self.assertEqual(")hN8ol<;6<", manager.generate(setting))
 def test_default(self):
     setting = PasswordSetting("some.domain")
     setting.set_salt("pepper".encode("utf-8"))
     setting.set_template("xaxnxxAoxx")
     manager = CtSesam(domain=setting.get_domain(), username=setting.get_username(), kgk="foo".encode("utf-8"))
     self.assertEqual("]ew26XW.X<", manager.generate(setting))