int crypt_token_luks2_keyring_set(struct crypt_device *cd,
	int token,
	const struct crypt_token_params_luks2_keyring *params)
{
	int r;
	char json[4096];

	if (!params)
		return -EINVAL;

	log_dbg(cd, "Creating new LUKS2 keyring token (%d).", token);

	if ((r = onlyLUKS2(cd)))
		return r;

	r = LUKS2_token_keyring_json(json, sizeof(json), params);
	if (r < 0)
		return r;

	return LUKS2_token_create(cd, &cd->u.luks2.hdr, token, json, 1);
}
int crypt_token_luks2_keyring_set(struct crypt_device *cd,
	int token,
	const struct crypt_token_params_luks2_keyring *params)
{
	int r;
	char json[4096];

	if (!params)
		return -EINVAL;

	log_dbg(cd, "Creating new LUKS2 keyring token (%d).", token);

	if ((r = onlyLUKS2(cd)))
		return r;

	r = LUKS2_token_keyring_json(json, sizeof(json), params);
	if (r < 0)
		return r;

	return LUKS2_token_create(cd, &cd->u.luks2.hdr, token, json, 1);
}