def test_keystore_unlock(self):
        if self.hsm.version.ver <= (0, 9, 8,):
            print ("Test for known bug in 0.9.8 disabled.")
            return None
        cleartext = "reference"
        nonce = '010203040506'.decode('hex')
        res_before = self.hsm.generate_aead_simple(nonce, 0x2000, cleartext)
        # lock key store
        try:
            res = self.hsm.key_storage_unlock("A" * 8)
            self.fail("Expected YSM_MISMATCH/YSM_KEY_STORAGE_LOCKED, got %s" % (res))
        except pyhsm.exception.YHSM_CommandFailed, e:
            if self.hsm.version.have_key_store_decrypt():
                self.assertEquals(e.status, pyhsm.defines.YSM_MISMATCH)
            else:
                self.assertEquals(e.status, pyhsm.defines.YSM_KEY_STORAGE_LOCKED)
        # make sure we can't generate AEADs when keystore is locked
        try:
            res = self.hsm.generate_aead_simple(nonce, 0x2000, cleartext)
            self.fail("Expected YSM_KEY_STORAGE_LOCKED, got %s (before lock: %s)" \
                          % (res.data.encode('hex'), res_before.data.encode('hex')))
        except pyhsm.exception.YHSM_CommandFailed, e:
            self.assertEquals(e.status, pyhsm.defines.YSM_KEY_STORAGE_LOCKED)
        # unlock key store with correct passphrase
        self.assertTrue(self.hsm.key_storage_unlock(test_common.HsmPassphrase.decode("hex")))
        # make sure it is properly unlocked
        res_after = self.hsm.generate_aead_simple(nonce, 0x2000, cleartext)
        self.assertEquals(res_before.data, res_after.data)
Compare two messages, and assert that the expected annotations are
dataset/ETHPy150Open Yubico/python-pyhsm/test/test_misc.py/TestUtil.test_keystore_unlock--crossover with--dataset/ETHPy150Open mozilla/addons-server/src/olympia/devhub/tests/test_utils.py/TestValidationComparator.compare