int crypt_activate_by_token_pin(struct crypt_device *cd, const char *name,
	const char *type, int token, const char *pin, size_t pin_size,
	void *usrptr, uint32_t flags)
{
	int r;

	log_dbg(cd, "%s volume %s using token (%s type) %d.",
		name ? "Activating" : "Checking", name ?: "passphrase",
		type ?: "any", token);

	if ((r = _onlyLUKS2(cd, CRYPT_CD_QUIET | CRYPT_CD_UNRESTRICTED, 0)))
		return r;

	if ((flags & CRYPT_ACTIVATE_KEYRING_KEY) && !crypt_use_keyring_for_vk(cd))
		return -EINVAL;

	if ((flags & CRYPT_ACTIVATE_ALLOW_UNBOUND_KEY) && name)
		return -EINVAL;

	r = _activate_check_status(cd, name, flags & CRYPT_ACTIVATE_REFRESH);
	if (r < 0)
		return r;

	return LUKS2_token_open_and_activate(cd, &cd->u.luks2.hdr, token, name, type, pin, pin_size, flags, usrptr);
}
int crypt_activate_by_token_pin(struct crypt_device *cd, const char *name,
	const char *type, int token, const char *pin, size_t pin_size,
	void *usrptr, uint32_t flags)
{
	int r;

	log_dbg(cd, "%s volume %s using token (%s type) %d.",
		name ? "Activating" : "Checking", name ?: "passphrase",
		type ?: "any", token);

	if ((r = _onlyLUKS2(cd, CRYPT_CD_QUIET | CRYPT_CD_UNRESTRICTED, 0)))
		return r;

	if ((flags & CRYPT_ACTIVATE_KEYRING_KEY) && !crypt_use_keyring_for_vk(cd))
		return -EINVAL;

	if ((flags & CRYPT_ACTIVATE_ALLOW_UNBOUND_KEY) && name)
		return -EINVAL;

	r = _activate_check_status(cd, name, flags & CRYPT_ACTIVATE_REFRESH);
	if (r < 0)
		return r;

	return LUKS2_token_open_and_activate(cd, &cd->u.luks2.hdr, token, name, type, pin, pin_size, flags, usrptr);
}