static void test_jwt_rs_token(void)
{
	const char *error;

	if (skip_dcrypt)
		return;

	test_begin("JWT RSA token");
	/* write public key to file */
	oauth2_validation_key_cache_evict(key_cache, "default");
	save_key("RS256", rsa_public_key);

	buffer_t *tokenbuf = create_jwt_token("RS256");

	/* sign token */
	buffer_t *sig = t_buffer_create(64);
	struct dcrypt_private_key *key;
	if (!dcrypt_key_load_private(&key, rsa_private_key, NULL, NULL,
				     &error) ||
	    !dcrypt_sign(key, "sha256", DCRYPT_SIGNATURE_FORMAT_DSS,
			 tokenbuf->data, tokenbuf->used, sig,
			 DCRYPT_PADDING_RSA_PKCS1, &error)) {
		i_error("dcrypt signing failed: %s", error);
		lib_exit(1);
	}
	dcrypt_key_unref_private(&key);

	/* convert to base64 */
	buffer_append(tokenbuf, ".", 1);
	base64url_encode(BASE64_ENCODE_FLAG_NO_PADDING, SIZE_MAX,
			 sig->data, sig->used, tokenbuf);

	test_jwt_token(str_c(tokenbuf));

	test_end();
}
static void test_jwt_rs_token(void)
{
	const char *error;

	if (skip_dcrypt)
		return;

	test_begin("JWT RSA token");
	 
	oauth2_validation_key_cache_evict(key_cache, "default");
	save_key("RS256", rsa_public_key);

	buffer_t *tokenbuf = create_jwt_token("RS256");

	 
	buffer_t *sig = t_buffer_create(64);
	struct dcrypt_private_key *key;
	if (!dcrypt_key_load_private(&key, rsa_private_key, NULL, NULL,
				     &error) ||
	    !dcrypt_sign(key, "sha256", DCRYPT_SIGNATURE_FORMAT_DSS,
			 tokenbuf->data, tokenbuf->used, sig,
			 DCRYPT_PADDING_RSA_PKCS1, &error)) {
		i_error("dcrypt signing failed: %s", error);
		lib_exit(1);
	}
	dcrypt_key_unref_private(&key);

	 
	buffer_append(tokenbuf, ".", 1);
	base64url_encode(BASE64_ENCODE_FLAG_NO_PADDING, SIZE_MAX,
			 sig->data, sig->used, tokenbuf);

	test_jwt_token(str_c(tokenbuf));

	test_end();
}