Ejemplo n.º 1
0
    def test_password_to_key_utf8(self):
        self.assertEqual((a2b_hex('f320972c667ba5cd4d35119a6b0271a1'),
                          a2b_hex('f10050ca688e5a6ce62b1ffb0f6f6869')),
                         password_to_key('κόσμε'))

        self.assertEqual((a2b_hex('f320972c667ba5cd4d35119a6b0271a1'),
                          a2b_hex('f10050ca688e5a6ce62b1ffb0f6f6869')),
                         password_to_key(a2b_hex('cebae1bdb9cf83cebcceb5')))
Ejemplo n.º 2
0
    def test_password_to_key(self):
        self.assertEqual((a2b_hex('090b47dbed595654901dee1cc655e420'),
                          a2b_hex('592fd483f759e29909a04c4505d2ce0a')),
                         password_to_key('password'))

        self.assertEqual((a2b_hex('090b47dbed595654901dee1cc655e420'),
                          a2b_hex('592fd483f759e29909a04c4505d2ce0a')),
                         password_to_key(b'password'))
Ejemplo n.º 3
0
    def test_change_raw_keys(self):
        self.require_version((2, 1, 0), "Change authentication key")

        key_enc = a2b_hex("090b47dbed595654901dee1cc655e420")
        key_mac = a2b_hex("592fd483f759e29909a04c4505d2ce0a")

        # Create an auth key with the capability to change
        authkey = AuthenticationKey.put(
            self.session,
            0,
            "Test CHANGE authkey",
            1,
            CAPABILITY.CHANGE_AUTHENTICATION_KEY,
            CAPABILITY.NONE,
            key_enc,
            key_mac,
        )

        with self.hsm.create_session_derived(authkey.id,
                                             "password") as session:
            key_enc, key_mac = password_to_key("second_password")
            authkey.with_session(session).change_key(key_enc, key_mac)

        with self.hsm.create_session_derived(authkey.id, "second_password"):
            pass

        authkey.delete()
Ejemplo n.º 4
0
    def test_password_to_key_utf8(self):
        self.assertEqual(
            (
                a2b_hex("f320972c667ba5cd4d35119a6b0271a1"),
                a2b_hex("f10050ca688e5a6ce62b1ffb0f6f6869"),
            ),
            password_to_key("κόσμε"),
        )

        self.assertEqual(
            (
                a2b_hex("f320972c667ba5cd4d35119a6b0271a1"),
                a2b_hex("f10050ca688e5a6ce62b1ffb0f6f6869"),
            ),
            password_to_key(a2b_hex("cebae1bdb9cf83cebcceb5")),
        )
Ejemplo n.º 5
0
    def test_password_to_key(self):
        self.assertEqual(
            (
                a2b_hex("090b47dbed595654901dee1cc655e420"),
                a2b_hex("592fd483f759e29909a04c4505d2ce0a"),
            ),
            password_to_key("password"),
        )

        self.assertEqual(
            (
                a2b_hex("090b47dbed595654901dee1cc655e420"),
                a2b_hex("592fd483f759e29909a04c4505d2ce0a"),
            ),
            password_to_key(b"password"),
        )
Ejemplo n.º 6
0
    def test_change_raw_keys(self):
        self.require_version((2, 1, 0), 'Change authentication key')

        key_enc = a2b_hex('090b47dbed595654901dee1cc655e420')
        key_mac = a2b_hex('592fd483f759e29909a04c4505d2ce0a')

        # Create an auth key with the capability to change
        authkey = AuthenticationKey.put(self.session, 0, 'Test CHANGE authkey',
                                        1,
                                        CAPABILITY.CHANGE_AUTHENTICATION_KEY,
                                        CAPABILITY.NONE, key_enc, key_mac)

        session = self.hsm.create_session_derived(authkey.id, 'password')
        authkey2 = session.get_object(authkey.id, OBJECT.AUTHENTICATION_KEY)

        key_enc, key_mac = password_to_key('second_password')

        authkey2.change_key(key_enc, key_mac)
        session.close()

        self.hsm.create_session_derived(authkey.id, 'second_password').close()

        authkey.delete()