コード例 #1
0
 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))
コード例 #2
0
 def test_to_json(self):
     s = PasswordSetting("unit.test")
     s.set_modification_date("2005-01-01T01:14:12")
     s.set_creation_date("2001-01-01T02:14:12")
     s.set_salt("something".encode('utf-8'))
     s.set_iterations(213)
     s.set_length(14)
     s.set_custom_character_set("XVLCWKHGFQUIAEOSNRTDYÜÖÄPZBMJ")
     s.set_notes("Some note.")
     self.assertIn("domain", s.to_dict())
     self.assertEqual("unit.test", s.to_dict()["domain"])
     self.assertIn("cDate", s.to_dict())
     self.assertEqual("2001-01-01T02:14:12", s.to_dict()["cDate"])
     self.assertIn("mDate", s.to_dict())
     self.assertEqual("2005-01-01T01:14:12", s.to_dict()["mDate"])
     self.assertIn("salt", s.to_dict())
     self.assertEqual(str(b64encode("something".encode('utf-8')), encoding='utf-8'), s.to_dict()["salt"])
     self.assertIn("iterations", s.to_dict())
     self.assertEqual(213, s.to_dict()["iterations"])
     self.assertIn("length", s.to_dict())
     self.assertEqual(14, s.to_dict()["length"])
     self.assertIn("usedCharacters", s.to_dict())
     self.assertEqual("XVLCWKHGFQUIAEOSNRTDYÜÖÄPZBMJ", s.to_dict()["usedCharacters"])
     self.assertIn("notes", s.to_dict())
     self.assertEqual("Some note.", s.to_dict()["notes"])
コード例 #3
0
 def test_to_json(self):
     s = PasswordSetting("unit.test")
     s.set_modification_date("2005-01-01T01:14:12")
     s.set_creation_date("2001-01-01T02:14:12")
     s.set_salt("something".encode('utf-8'))
     s.set_iterations(213)
     s.set_template("xxxxxxxxxxoxxx")
     s.set_extra_character_set("XVLCWKHGFQUIAEOSNRTDYÜÖÄPZBMJ")
     s.set_notes("Some note.")
     self.assertIn("domain", s.to_dict())
     self.assertEqual("unit.test", s.to_dict()["domain"])
     self.assertIn("cDate", s.to_dict())
     self.assertEqual("2001-01-01T02:14:12.000", s.to_dict()["cDate"])
     self.assertIn("mDate", s.to_dict())
     self.assertEqual("2005-01-01T01:14:12.000", s.to_dict()["mDate"])
     self.assertIn("salt", s.to_dict())
     self.assertEqual(str(b64encode("something".encode('utf-8')), encoding='utf-8'), s.to_dict()["salt"])
     self.assertIn("iterations", s.to_dict())
     self.assertEqual(213, s.to_dict()["iterations"])
     self.assertIn("passwordTemplate", s.to_dict())
     self.assertEqual("xxxxxxxxxxoxxx", s.to_dict()["passwordTemplate"])
     self.assertIn("extras", s.to_dict())
     self.assertEqual("XVLCWKHGFQUIAEOSNRTDYÜÖÄPZBMJ", s.to_dict()["extras"])
     self.assertIn("notes", s.to_dict())
     self.assertEqual("Some note.", s.to_dict()["notes"])
コード例 #4
0
 def test_salt(self):
     s = PasswordSetting("unit.test")
     self.assertEqual(32, len(s.get_salt()))
     s.set_salt("somethingelse".encode('utf-8'))
     expected = "somethingelse".encode('utf-8')
     self.assertEqual(len(expected), len(s.get_salt()))
     for i in range(len(expected)):
         self.assertEqual(expected[i], s.get_salt()[i])
コード例 #5
0
 def test_salt(self):
     s = PasswordSetting("unit.test")
     self.assertEqual(32, len(s.get_salt()))
     s.set_salt("somethingelse".encode('utf-8'))
     expected = "somethingelse".encode('utf-8')
     self.assertEqual(len(expected), len(s.get_salt()))
     for i in range(len(expected)):
         self.assertEqual(expected[i], s.get_salt()[i])
 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))
コード例 #8
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))
コード例 #9
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))
コード例 #10
0
 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))
コード例 #11
0
 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))
コード例 #12
0
 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))
コード例 #13
0
 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))
コード例 #14
0
 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))
コード例 #15
0
 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))
コード例 #16
0
 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))
コード例 #17
0
 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))
コード例 #18
0
 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))
コード例 #19
0
 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))
コード例 #20
0
 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))
コード例 #21
0
 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))
コード例 #22
0
 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))