int LUKS2_find_keyslot(struct luks2_hdr *hdr, const char *type)
{
	int i;
	json_object *jobj_keyslot, *jobj_type;

	if (!type)
		return -EINVAL;

	for (i = 0; i < LUKS2_KEYSLOTS_MAX; i++) {
		jobj_keyslot = LUKS2_get_keyslot_jobj(hdr, i);
		if (!jobj_keyslot)
			continue;

		json_object_object_get_ex(jobj_keyslot, "type", &jobj_type);
		if (!strcmp(json_object_get_string(jobj_type), type))
			return i;
	}

	return -ENOENT;
}
int LUKS2_find_keyslot(struct luks2_hdr *hdr, const char *type)
{
	int i;
	json_object *jobj_keyslot, *jobj_type;

	if (!type)
		return -EINVAL;

	for (i = 0; i < LUKS2_KEYSLOTS_MAX; i++) {
		jobj_keyslot = LUKS2_get_keyslot_jobj(hdr, i);
		if (!jobj_keyslot)
			continue;

		json_object_object_get_ex(jobj_keyslot, "type", &jobj_type);
		if (!strcmp(json_object_get_string(jobj_type), type))
			return i;
	}

	return -ENOENT;
}