int crypt_volume_key_load_in_keyring(struct crypt_device *cd, struct volume_key *vk)
{
	int r;
	const char *type_name = key_type_name(LOGON_KEY);

	if (!vk || !cd || !type_name)
		return -EINVAL;

	if (!vk->key_description) {
		log_dbg(cd, "Invalid key description");
		return -EINVAL;
	}

	log_dbg(cd, "Loading key (%zu bytes, type %s) in thread keyring.", vk->keylength, type_name);

	r = keyring_add_key_in_thread_keyring(LOGON_KEY, vk->key_description, vk->key, vk->keylength);
	if (r) {
		log_dbg(cd, "keyring_add_key_in_thread_keyring failed (error %d)", r);
		log_err(cd, _("Failed to load key in kernel keyring."));
	} else
		crypt_set_key_in_keyring(cd, 1);

	return r;
}
int crypt_volume_key_load_in_keyring(struct crypt_device *cd, struct volume_key *vk)
{
	int r;
	const char *type_name = key_type_name(LOGON_KEY);

	if (!vk || !cd || !type_name)
		return -EINVAL;

	if (!vk->key_description) {
		log_dbg(cd, "Invalid key description");
		return -EINVAL;
	}

	log_dbg(cd, "Loading key (%zu bytes, type %s) in thread keyring.", vk->keylength, type_name);

	r = keyring_add_key_in_thread_keyring(LOGON_KEY, vk->key_description, vk->key, vk->keylength);
	if (r) {
		log_dbg(cd, "keyring_add_key_in_thread_keyring failed (error %d)", r);
		log_err(cd, _("Failed to load key in kernel keyring."));
	} else
		crypt_set_key_in_keyring(cd, 1);

	return r;
}