def status2str(num):
    """ Return YubiHSM response status code as string. """
    known = {0x80: 'YSM_STATUS_OK',
             0x81: 'YSM_KEY_HANDLE_INVALID',
             0x82: 'YSM_AEAD_INVALID',
             0x83: 'YSM_OTP_INVALID',
             0x84: 'YSM_OTP_REPLAY',
             0x85: 'YSM_ID_DUPLICATE',
             0x86: 'YSM_ID_NOT_FOUND',
             0x87: 'YSM_DB_FULL',
             0x88: 'YSM_MEMORY_ERROR',
             0x89: 'YSM_FUNCTION_DISABLED',
             0x8a: 'YSM_KEY_STORAGE_LOCKED',
             0x8b: 'YSM_MISMATCH',
             0x8c: 'YSM_INVALID_PARAMETER',
             }

    if num in known:
        return known[num]
    return "0x%02x" % (num)