commit 4865637d8b7cb6bf6321dda192716d0f701f288b
parent 49393f576924e89adff368e5bbc3a9f8458c4f7c
Author: Matyja Lukas Adam <lukas.matyja@students.bfh.ch>
Date: Mon, 1 Jan 2024 22:52:38 +0100
solve merge conflict
Diffstat:
10 files changed, 122 insertions(+), 620 deletions(-)
diff --git a/src/donau-tools/Makefile.am b/src/donau-tools/Makefile.am
@@ -4,7 +4,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/include
pkgcfgdir = $(prefix)/share/taler/config.d/
pkgcfg_DATA = \
- coins.conf \
+ coins.conf
if USE_COVERAGE
AM_CFLAGS = --coverage -O0
diff --git a/src/donau/donau-httpd.c b/src/donau/donau-httpd.c
@@ -32,7 +32,6 @@
#include "donau-httpd_terms.h"
#include "donaudb_lib.h"
#include "donaudb_plugin.h"
-#include "taler/taler_extensions.h"
#include <gnunet/gnunet_mhd_compat.h>
#include "donau_util.h"
@@ -50,7 +49,7 @@
* Above what request latency do we start to log?
*/
#define WARN_LATENCY GNUNET_TIME_relative_multiply ( \
- GNUNET_TIME_UNIT_MILLISECONDS, 500)
+ GNUNET_TIME_UNIT_MILLISECONDS, 500)
/**
* Are clients allowed to request /keys for times other than the
@@ -171,14 +170,6 @@ int DH_check_invariants_flag;
bool DH_suicide;
/**
- * Signature of the configuration of all enabled extensions,
- * signed by the donau's offline master key with purpose
- * TALER_SIGNATURE_MASTER_EXTENSION.
- */
-struct TALER_MasterSignatureP DH_extensions_sig;
-bool DH_extensions_signed = false;
-
-/**
* Value to return from main()
*/
static int global_ret;
@@ -191,7 +182,7 @@ static uint16_t serve_port;
/**
* Counter for the number of requests this HTTP has processed so far.
*/
-//static unsigned long long req_count;
+// static unsigned long long req_count;
/**
* Counter for the number of open connections.
@@ -276,11 +267,11 @@ handle_mhd_completion_callback (void *cls,
return;
GNUNET_async_scope_enter (&rc->async_scope_id,
&old_scope);
- //check_suicide ();
- //DH_check_invariants ();
+ // check_suicide ();
+ // DH_check_invariants ();
if (NULL != rc->rh_cleaner)
rc->rh_cleaner (rc);
- //DH_check_invariants ();
+ // DH_check_invariants ();
{
#if MHD_VERSION >= 0x00097304
const union MHD_ConnectionInfo *ci;
@@ -307,7 +298,7 @@ handle_mhd_completion_callback (void *cls,
TALER_MHD_parse_post_cleanup_callback (rc->opaque_post_parsing_context);
/* Sanity-check that we didn't leave any transactions hanging */
GNUNET_break (GNUNET_OK ==
- DH_plugin->preflight (DH_plugin->cls));
+ DH_plugin->preflight (DH_plugin->cls));
{
struct GNUNET_TIME_Relative latency;
@@ -512,75 +503,75 @@ handle_mhd_request (void *cls,
{
static struct DH_RequestHandler handlers[] = {
/* /robots.txt: disallow everything */
-{
- .url = "robots.txt",
- .method = MHD_HTTP_METHOD_GET,
- //.handler.get = &DH_handler_static_response,
- .mime_type = "text/plain",
- .data = "User-agent: *\nDisallow: /\n",
- .response_code = MHD_HTTP_OK
-},
+ {
+ .url = "robots.txt",
+ .method = MHD_HTTP_METHOD_GET,
+ // .handler.get = &DH_handler_static_response,
+ .mime_type = "text/plain",
+ .data = "User-agent: *\nDisallow: /\n",
+ .response_code = MHD_HTTP_OK
+ },
/* Landing page, tell humans to go away. */
-{
- .url = "",
- .method = MHD_HTTP_METHOD_GET,
- //.handler.get = DH_handler_static_response,
- .mime_type = "text/plain",
- .data =
- "Hello, I'm the Taler donau. This HTTP server is not for humans.\n",
- .response_code = MHD_HTTP_OK
-},
+ {
+ .url = "",
+ .method = MHD_HTTP_METHOD_GET,
+ // .handler.get = DH_handler_static_response,
+ .mime_type = "text/plain",
+ .data =
+ "Hello, I'm the Taler donau. This HTTP server is not for humans.\n",
+ .response_code = MHD_HTTP_OK
+ },
/* AGPL licensing page, redirect to source. As per the AGPL-license, every
deployment is required to offer the user a download of the source of
the actual deployment. We make this easy by including a redirect to the
source here. */
-{
- .url = "agpl",
- .method = MHD_HTTP_METHOD_GET,
- //.handler.get = &DH_handler_agpl_redirect
-},
-{
- .url = "seed",
- .method = MHD_HTTP_METHOD_GET,
- .handler.get = &handler_seed
-},
+ {
+ .url = "agpl",
+ .method = MHD_HTTP_METHOD_GET,
+ // .handler.get = &DH_handler_agpl_redirect
+ },
+ {
+ .url = "seed",
+ .method = MHD_HTTP_METHOD_GET,
+ .handler.get = &handler_seed
+ },
/* Configuration */
-{
- .url = "config",
- .method = MHD_HTTP_METHOD_GET,
- //.handler.get = &DH_handler_config
-},
+ {
+ .url = "config",
+ .method = MHD_HTTP_METHOD_GET,
+ // .handler.get = &DH_handler_config
+ },
/* Performance metrics */
-{
- .url = "metrics",
- .method = MHD_HTTP_METHOD_GET,
- //.handler.get = &DH_handler_metrics
-},
+ {
+ .url = "metrics",
+ .method = MHD_HTTP_METHOD_GET,
+ // .handler.get = &DH_handler_metrics
+ },
/* Terms of service */
-{
- .url = "terms",
- .method = MHD_HTTP_METHOD_GET,
- //.handler.get = &DH_handler_terms
-},
+ {
+ .url = "terms",
+ .method = MHD_HTTP_METHOD_GET,
+ // .handler.get = &DH_handler_terms
+ },
/* Privacy policy */
-{
- .url = "privacy",
- .method = MHD_HTTP_METHOD_GET,
- //.handler.get = &DH_handler_privacy
-},
+ {
+ .url = "privacy",
+ .method = MHD_HTTP_METHOD_GET,
+ // .handler.get = &DH_handler_privacy
+ },
/* Return key material and fundamental properties for this donau */
-{
- .url = "keys",
- .method = MHD_HTTP_METHOD_GET,
- //.handler.get = &DH_keys_get_handler,
-},
+ {
+ .url = "keys",
+ .method = MHD_HTTP_METHOD_GET,
+ // .handler.get = &DH_keys_get_handler,
+ },
/* request R, used in clause schnorr withdraw and refresh */
-{
- .url = "csr-melt",
- .method = MHD_HTTP_METHOD_POST,
- //.handler.post = &DH_handler_csr_melt,
- .nargs = 0
-},
+ {
+ .url = "csr-melt",
+ .method = MHD_HTTP_METHOD_POST,
+ // .handler.post = &DH_handler_csr_melt,
+ .nargs = 0
+ },
/* mark end of list */
@@ -603,7 +594,7 @@ handle_mhd_request (void *cls,
rc = *con_cls = GNUNET_new (struct DH_RequestContext);
rc->start_time = GNUNET_TIME_absolute_get ();
GNUNET_async_scope_fresh (&rc->async_scope_id);
- //DH_check_invariants ();
+ // DH_check_invariants ();
rc->url = url;
rc->connection = connection;
/* We only read the correlation ID on the first callback for every client */
@@ -630,7 +621,7 @@ handle_mhd_request (void *cls,
GNUNET_async_scope_enter (&rc->async_scope_id,
&old_scope);
- //DH_check_invariants ();
+ // DH_check_invariants ();
if (NULL != correlation_id)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Handling request (%s) for URL '%s', correlation_id=%s\n",
@@ -1202,11 +1193,11 @@ run_single_request (void)
}
}
+
#endif
/* end of HAVE_DEVELOPER */
-
/**
* Signature of the callback used by MHD to notify the application
* about completed connections. If we are running in test-mode with
@@ -1262,21 +1253,11 @@ do_shutdown (void *cls)
(void) cls;
mhd = TALER_MHD_daemon_stop ();
- // DH_resume_keys_requests (true);
- // DH_deposits_get_cleanup ();
- // DH_reserves_get_cleanup ();
- // DH_purses_get_cleanup ();
- // DH_kyc_check_cleanup ();
- // DH_kyc_proof_cleanup ();
- // TALER_KYCLOGIC_kyc_done ();
if (NULL != mhd)
{
MHD_stop_daemon (mhd);
mhd = NULL;
}
- // DH_wire_done ();
- // DH_extensions_done ();
- // DH_keys_finished ();
if (NULL != DH_plugin)
{
DONAUDB_plugin_unload (DH_plugin);
@@ -1344,29 +1325,8 @@ run (void *cls,
GNUNET_SCHEDULER_shutdown ();
return;
}
- // if (GNUNET_OK !=
- // DH_extensions_init ())
- // {
- // global_ret = EXIT_FAILURE;
- // GNUNET_SCHEDULER_shutdown ();
- // return;
- // }
- // if (GNUNET_OK !=
- // DH_keys_init ())
- // {
- // global_ret = EXIT_FAILURE;
- // GNUNET_SCHEDULER_shutdown ();
- // return;
- // }
- // if (GNUNET_OK !=
- // DH_wire_init ())
- // {
- // global_ret = EXIT_FAILURE;
- // GNUNET_SCHEDULER_shutdown ();
- // return;
- // }
-
- //DH_load_terms (DH_cfg);
+
+ // DH_load_terms (DH_cfg);
DH_curl_ctx
= GNUNET_CURL_init (&GNUNET_CURL_gnunet_scheduler_reschedule,
&donau_curl_rc);
@@ -1433,6 +1393,7 @@ run (void *cls,
#endif
}
+
/**
* The main function of the taler-donau-httpd server ("the donau").
*
@@ -1485,4 +1446,5 @@ main (int argc,
return global_ret;
}
+
/* end of taler-donau-httpd.c */
\ No newline at end of file
diff --git a/src/donau/donau-httpd.h b/src/donau/donau-httpd.h
@@ -26,7 +26,6 @@
#include <microhttpd.h>
#include "taler/taler_json_lib.h"
#include <taler/taler_util.h>
-#include "taler/taler_extensions.h"
#include <gnunet/gnunet_mhd_compat.h>
@@ -56,12 +55,12 @@ extern int DH_check_invariants_flag;
* as building new /keys responses is expensive. Should only be
* enabled for testcases, development and test systems.
*/
-//extern int DH_allow_keys_timetravel;
+// extern int DH_allow_keys_timetravel;
/**
* Main directory with data.
*/
-//extern char *DH_revocation_directory;
+// extern char *DH_revocation_directory;
/**
* True if we should commit suicide once all active
diff --git a/src/donau/donau-httpd_keys.c b/src/donau/donau-httpd_keys.c
@@ -23,11 +23,10 @@
#include "taler/taler_json_lib.h"
#include "taler/taler_mhd_lib.h"
#include "donau-httpd.h"
-//#include "donau-httpd_config.h"
+// #include "donau-httpd_config.h"
#include "donau-httpd_keys.h"
#include "donau-httpd_responses.h"
#include "donaudb_plugin.h"
-#include "taler/taler_extensions.h"
/**
@@ -55,12 +54,14 @@ struct HelperDenomination
*/
struct GNUNET_TIME_Timestamp start_time;
+
/**
* For how long will the helper allow signing? 0 if
* the key was revoked or purged.
*/
struct GNUNET_TIME_Relative validity_duration;
+
/**
* Hash of the full denomination key.
*/
@@ -111,13 +112,13 @@ struct HelperSignkey
/**
* When will the helper start to use this key for signing?
*/
- //struct GNUNET_TIME_Timestamp start_time;
+ // struct GNUNET_TIME_Timestamp start_time;
/**
* For how long will the helper allow signing? 0 if
* the key was revoked or purged.
*/
- //struct GNUNET_TIME_Relative validity_duration;
+ // struct GNUNET_TIME_Relative validity_duration;
/**
* The public key.
@@ -209,7 +210,7 @@ struct KeysResponseData
* The client's request must include this date or a higher one
* for this response to be applicable.
*/
- struct GNUNET_TIME_Timestamp cherry_pick_date;
+ struct GNUNET_TIME_Timestamp cherry_pick_date;
};
@@ -231,12 +232,6 @@ struct SigningKey
*/
struct DONAUDB_SignkeyMetaData meta;
- /**
- * The long-term offline master key's signature for this signing key.
- * Signs over @e donau_pub and @e meta.
- */
- //struct TALER_MasterSignatureP master_sig;
-
};
struct DH_KeyStateHandle
@@ -287,19 +282,19 @@ struct DH_KeyStateHandle
/**
* When did we initiate the key reloading?
*/
- //struct GNUNET_TIME_Timestamp reload_time;
+ // struct GNUNET_TIME_Timestamp reload_time;
/**
* What is the period at which we rotate keys
* (signing or denomination keys)?
*/
- //struct GNUNET_TIME_Relative rekey_frequency;
+ // struct GNUNET_TIME_Relative rekey_frequency;
/**
* When does our online signing key expire and we
* thus need to re-generate this response?
*/
- //struct GNUNET_TIME_Timestamp signature_expires;
+ // struct GNUNET_TIME_Timestamp signature_expires;
/**
* True if #finish_keys_response() was not yet run and this key state
@@ -1211,10 +1206,10 @@ DH_keys_init ()
asset_type = GNUNET_strdup ("fiat");
}
keys_eh = DH_plugin->event_listen (DH_plugin->cls,
- GNUNET_TIME_UNIT_FOREVER_REL,
- &es,
- &keys_update_event_cb,
- NULL);
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &es,
+ &keys_update_event_cb,
+ NULL);
if (NULL == keys_eh)
{
GNUNET_break (0);
@@ -1241,7 +1236,7 @@ DH_keys_finished ()
if (NULL != keys_eh)
{
DH_plugin->event_listen_cancel (DH_plugin->cls,
- keys_eh);
+ keys_eh);
keys_eh = NULL;
}
}
@@ -1868,69 +1863,6 @@ create_krd (struct DH_KeyStateHandle *ksh,
&grouped_donau_sig));
GNUNET_assert (NULL != keys);
- /* Signal support for the configured, enabled extensions. */
- {
- json_t *extensions = json_object ();
- bool has_extensions = false;
-
- GNUNET_assert (NULL != extensions);
- /* Fill in the configurations of the enabled extensions */
- for (const struct TALER_Extensions *iter = TALER_extensions_get_head ();
- NULL != iter && NULL != iter->extension;
- iter = iter->next)
- {
- const struct TALER_Extension *extension = iter->extension;
- json_t *manifest;
- int r;
-
- /* skip if not enabled */
- if (! extension->enabled)
- continue;
-
- /* flag our findings so far */
- has_extensions = true;
-
-
- manifest = extension->manifest (extension);
- GNUNET_assert (manifest);
-
- r = json_object_set_new (
- extensions,
- extension->name,
- manifest);
- GNUNET_assert (0 == r);
- }
-
- /* Update the keys object with the extensions and its signature */
- if (has_extensions)
- {
- json_t *sig;
- int r;
-
- r = json_object_set_new (
- keys,
- "extensions",
- extensions);
- GNUNET_assert (0 == r);
-
- /* Add the signature of the extensions, if it is not zero */
- if (DH_extensions_signed)
- {
- sig = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_data_auto ("extensions_sig",
- &DH_extensions_sig));
-
- r = json_object_update (keys, sig);
- GNUNET_assert (0 == r);
- }
- }
- else
- {
- json_decref (extensions);
- }
- }
-
-
{
char *keys_json;
void *keys_jsonz;
@@ -2096,7 +2028,8 @@ finish_keys_response (struct DH_KeyStateHandle *ksh)
denominations_by_group =
GNUNET_CONTAINER_multihashmap_create (1024,
- GNUNET_NO /* NO, because keys are only on the stack */);
+ GNUNET_NO /* NO, because keys are only on the stack */
+ );
/* heap = min heap, sorted by start time */
@@ -2426,7 +2359,8 @@ build_key_state (struct HelperState *hs,
ksh->denomkey_map = GNUNET_CONTAINER_multihashmap_create (1024,
true);
ksh->signkey_map = GNUNET_CONTAINER_multipeermap_create (32,
- false /* MUST be false! */);
+ false /* MUST be false! */
+ );
/* NOTE: fetches master-signed signkeys, but ALSO those that were revoked! */
GNUNET_break (GNUNET_OK ==
DH_plugin->preflight (DH_plugin->cls));
@@ -2439,8 +2373,8 @@ build_key_state (struct HelperState *hs,
return NULL;
}
qs = DH_plugin->iterate_denominations (DH_plugin->cls,
- &denomination_info_cb,
- ksh);
+ &denomination_info_cb,
+ ksh);
if (qs < 0)
{
GNUNET_break (GNUNET_DB_STATUS_SOFT_ERROR != qs);
@@ -2451,8 +2385,8 @@ build_key_state (struct HelperState *hs,
}
/* NOTE: ONLY fetches non-revoked AND master-signed signkeys! */
qs = DH_plugin->iterate_active_signkeys (DH_plugin->cls,
- &signkey_info_cb,
- ksh);
+ &signkey_info_cb,
+ ksh);
if (qs < 0)
{
GNUNET_break (0);
@@ -2461,8 +2395,8 @@ build_key_state (struct HelperState *hs,
return NULL;
}
qs = DH_plugin->iterate_auditor_denominations (DH_plugin->cls,
- &auditor_denom_cb,
- ksh);
+ &auditor_denom_cb,
+ ksh);
if (qs < 0)
{
GNUNET_break (0);
@@ -2471,8 +2405,8 @@ build_key_state (struct HelperState *hs,
return NULL;
}
qs = DH_plugin->iterate_active_auditors (DH_plugin->cls,
- &auditor_info_cb,
- ksh);
+ &auditor_info_cb,
+ ksh);
if (qs < 0)
{
GNUNET_break (0);
@@ -2510,9 +2444,9 @@ DH_keys_update_states ()
};
DH_plugin->event_notify (DH_plugin->cls,
- &es,
- NULL,
- 0);
+ &es,
+ NULL,
+ 0);
key_generation++;
DH_resume_keys_requests (false);
}
@@ -2600,9 +2534,9 @@ DH_keys_denomination_by_hash (
}
return DH_keys_denomination_by_hash_from_state (ksh,
- h_denom_pub,
- conn,
- mret);
+ h_denom_pub,
+ conn,
+ mret);
}
@@ -2622,7 +2556,7 @@ DH_keys_denomination_by_hash_from_state (
if (NULL == conn)
return NULL;
*mret = DH_RESPONSE_reply_unknown_denom_pub_hash (conn,
- h_denom_pub);
+ h_denom_pub);
return NULL;
}
return dk;
@@ -2945,9 +2879,9 @@ DH_keys_donau_sign_ (
return TALER_EC_DONAU_GENERIC_KEYS_MISSING;
}
return DH_keys_donau_sign2_ (ksh,
- purpose,
- pub,
- sig);
+ purpose,
+ pub,
+ sig);
}
@@ -3041,7 +2975,7 @@ krd_search_comparator (const void *key,
MHD_RESULT
DH_keys_get_handler (struct DH_RequestContext *rc,
- const char *const args[])
+ const char *const args[])
{
struct GNUNET_TIME_Timestamp last_issue_date;
const char *etag;
@@ -3301,7 +3235,7 @@ add_future_signkey_cb (void *cls,
MHD_RESULT
DH_keys_management_get_keys_handler (const struct DH_RequestHandler *rh,
- struct MHD_Connection *connection)
+ struct MHD_Connection *connection)
{
struct DH_KeyStateHandle *ksh;
json_t *reply;
diff --git a/src/donaudb/test_donaudb.c b/src/donaudb/test_donaudb.c
@@ -34,24 +34,25 @@ static int result;
* Report line of error if @a cond is true, and jump to label "drop".
*/
#define FAILIF(cond) \
- do { \
- if (! (cond)) { break;} \
- GNUNET_break (0); \
- goto drop; \
- } while (0)
+ do { \
+ if (! (cond)) { break;} \
+ GNUNET_break (0); \
+ goto drop; \
+ } while (0)
/**
* Initializes @a ptr with random data.
*/
#define RND_BLK(ptr) \
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, sizeof (*ptr))
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, ptr, sizeof (* \
+ ptr))
/**
* Initializes @a ptr with zeros.
*/
#define ZR_BLK(ptr) \
- memset (ptr, 0, sizeof (*ptr))
+ memset (ptr, 0, sizeof (*ptr))
/**
@@ -108,63 +109,6 @@ mark_prepare_cb (void *cls,
}
-/**
- * Simple check that config retrieval and setting for extensions work
- */
-static enum GNUNET_GenericReturnValue
-test_extension_manifest (void)
-{
- char *manifest;
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS !=
- plugin->get_extension_manifest (plugin->cls,
- "fnord",
- &manifest));
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->set_extension_manifest (plugin->cls,
- "fnord",
- "bar"));
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->get_extension_manifest (plugin->cls,
- "fnord",
- &manifest));
-
- FAILIF (0 != strcmp ("bar", manifest));
- GNUNET_free (manifest);
-
- /* let's do this again! */
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->set_extension_manifest (plugin->cls,
- "fnord",
- "buzz"));
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->get_extension_manifest (plugin->cls,
- "fnord",
- &manifest));
-
- FAILIF (0 != strcmp ("buzz", manifest));
- GNUNET_free (manifest);
-
- /* let's do this again, with NULL */
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->set_extension_manifest (plugin->cls,
- "fnord",
- NULL));
-
- FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT !=
- plugin->get_extension_manifest (plugin->cls,
- "fnord",
- &manifest));
-
- FAILIF (NULL != manifest);
-
- return GNUNET_OK;
-drop:
- return GNUNET_SYSERR;
-}
-
int
main (int argc,
char *const argv[])
diff --git a/src/include/donaudb_plugin.h b/src/include/donaudb_plugin.h
@@ -20,12 +20,11 @@
*/
#ifndef DONAUDB_PLUGIN_H
#define DONAUDB_PLUGIN_H
-//#include <jansson.h>
+// #include <jansson.h>
#include <gnunet/gnunet_db_lib.h>
#include "taler/taler_json_lib.h"
#include "donau_signatures.h"
#include "donau_util.h"
-//#include "taler/taler_extensions_policy.h"
/**
* Meta data about a donation unit key.
@@ -45,7 +44,7 @@ struct DONAUDB_DonationUnitKeyMetaData
/**
* Hash code of the donation unit public key.
*/
- struct DONAU_DonationUnitHashP donation_unit_hash; //already in GNUNET_CRYPTO_BlindSignPublicKey -> part of every public donation unit
+ struct DONAU_DonationUnitHashP donation_unit_hash; // already in GNUNET_CRYPTO_BlindSignPublicKey -> part of every public donation unit
};
diff --git a/src/lib/donau_api_batch_submit_receipts.c b/src/lib/donau_api_batch_submit_receipts.c
@@ -135,11 +135,6 @@ struct DONAU_BatchDepositHandle
struct TALER_CharityWireHashP h_wire;
/**
- * Hash over the extensions, or all zero.
- */
- struct TALER_ExtensionPolicyHashP h_policy;
-
- /**
* Time when this confirmation was generated / when the donau received
* the deposit request.
*/
diff --git a/src/pq/pq_common.h b/src/pq/pq_common.h
@@ -1,48 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2023 Taler Systems SA
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-*/
-/**
- * @file pq/pq_common.h
- * @brief common defines for the pq functions
- * @author Johannes Casaburi
- */
-#ifndef DONAU_PQ_COMMON_H_
-#define DONAU_PQ_COMMON_H_
-
-#include "taler/taler_util.h"
-
-/**
- * Internal types that are supported as DONAU-specific array types.
- *
- * To support a new type,
- * 1. add a new entry into this list,
- * 2. for query-support, implement the size calculation and memory copying in
- * qconv_array() accordingly, in pq_query_helper.c
- * 3. provide a query-API for arrays of the type, by calling
- * query_param_array_generic with the appropriate parameters,
- * in pq_query_helper.c
- * 4. for result-support, implement memory copying by adding another case
- * to extract_array_generic, in pq_result_helper.c
- * 5. provide a result-spec-API for arrays of the type,
- * in pq_result_helper.c
- * 6. expose the API's in taler_pq_lib.h
- */
-enum DONAU_PQ_ArrayType
-{
- DONAU_PQ_array_of_blinded_donation_id_kps,
-};
-
-#endif /* TALER_PQ_COMMON_H_ */
-/* end of pg/pq_common.h */
diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c
@@ -23,7 +23,6 @@
#include <gnunet/gnunet_pq_lib.h>
#include <taler/taler_pq_lib.h>
#include "donau_util.h"
-#include "pq_common.h"
/**
@@ -123,285 +122,4 @@ TALER_PQ_query_param_donation_unit_pub (
}
-/** ------------------- Array support -----------------------------------**/
-
-/**
- * Closure for the array type handlers.
- *
- * May contain sizes information for the data, given (and handled) by the
- * caller.
- */
-struct qconv_array_cls
-{
- /**
- * If not null, contains the array of sizes (the size of the array is the
- * .size field in the ambient GNUNET_PQ_QueryParam struct). We do not free
- * this memory.
- *
- * If not null, this value has precedence over @a sizes, which MUST be NULL */
- const size_t *sizes;
-
- /**
- * If @a size and @a c_sizes are NULL, this field defines the same size
- * for each element in the array.
- */
- size_t same_size;
-
- /**
- * If true, the array parameter to the data pointer to the qconv_array is a
- * continuous byte array of data, either with @a same_size each or sizes
- * provided bytes by @a sizes;
- */
- bool continuous;
-
- /**
- * Type of the array elements
- */
- enum DONAU_PQ_ArrayType typ;
-
- /**
- * Oid of the array elements
- */
- Oid oid;
-
- /**
- * db context, needed for OID-lookup of basis-types
- */
- struct GNUNET_PQ_Context *db;
-};
-
-/**
- * Callback to cleanup a qconv_array_cls to be used during
- * GNUNET_PQ_cleanup_query_params_closures
- */
-static void
-qconv_array_cls_cleanup (void *cls)
-{
- GNUNET_free (cls);
-}
-
-
-/**
- * Function called to convert input argument into SQL parameters for arrays
- *
- * Note: the format for the encoding of arrays for libpq is not very well
- * documented. We peeked into various sources (postgresql and libpqtypes) for
- * guidance.
- *
- * @param cls Closure of type struct qconv_array_cls*
- * @param data Pointer to first element in the array
- * @param data_len Number of _elements_ in array @a data (if applicable)
- * @param[out] param_values SQL data to set
- * @param[out] param_lengths SQL length data to set
- * @param[out] param_formats SQL format data to set
- * @param param_length number of entries available in the @a param_values, @a param_lengths and @a param_formats arrays
- * @param[out] scratch buffer for dynamic allocations (to be done via #GNUNET_malloc()
- * @param scratch_length number of entries left in @a scratch
- * @return -1 on error, number of offsets used in @a scratch otherwise
- */
-static int
-qconv_array (
- void *cls,
- const void *data,
- size_t data_len,
- void *param_values[],
- int param_lengths[],
- int param_formats[],
- unsigned int param_length,
- void *scratch[],
- unsigned int scratch_length)
-{
- struct qconv_array_cls *meta = cls;
- size_t num = data_len;
- size_t tlen;
- size_t total_size;
- const size_t *sizes;
- bool same_sized;
- void *elements = NULL;
- bool noerror = true;
- /* needed to capture the encoded rsa signatures */
- void **buffers = NULL;
- size_t *buffer_lengths = NULL;
-
- (void) (param_length);
- (void) (scratch_length);
-
- GNUNET_assert (NULL != meta);
- GNUNET_assert (num < INT_MAX);
-
- sizes = meta->sizes;
- same_sized = (0 != meta->same_size);
-
-#define RETURN_UNLESS(cond) \
- do { \
- if (! (cond)) \
- { \
- GNUNET_break ((cond)); \
- noerror = false; \
- goto DONE; \
- } \
- } while (0)
-
- /* Calculate sizes and check bounds */
- {
- /* num * length-field */
- size_t x = sizeof(uint32_t);
- size_t y = x * num;
- RETURN_UNLESS ((0 == num) || (y / num == x));
-
- /* size of header */
- total_size = x = sizeof(struct GNUNET_PQ_ArrayHeader_P);
- total_size += y;
- RETURN_UNLESS (total_size >= x);
-
- /* sizes of elements */
- if (same_sized)
- {
- x = num * meta->same_size;
- RETURN_UNLESS ((0 == num) || (x / num == meta->same_size));
-
- y = total_size;
- total_size += x;
- RETURN_UNLESS (total_size >= y);
- }
- else /* sizes are different per element */
- {
- switch (meta->typ)
- {
- case DONAU_PQ_array_of_blinded_donation_id_kps:
- {
- const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *budi_kps =
- data;
- size_t len;
-
- buffers = GNUNET_new_array (num, void *);
- buffer_lengths = GNUNET_new_array (num, size_t);
-
- for (size_t i = 0; i<num; i++)
- {
- const struct GNUNET_CRYPTO_BlindedMessage *bm = &budi_kps[i].
- blinded_udi;
-
- switch (bm->cipher) // ?
- {
- case GNUNET_CRYPTO_BSA_RSA:
- tlen = bm->details.rsa_blinded_message.blinded_msg_size;
- break;
- case GNUNET_CRYPTO_BSA_CS:
- tlen = sizeof (bm->details.cs_blinded_message);
- break;
- default:
- GNUNET_assert (0);
- }
-
- len = tlen + sizeof (bm);
- buffer_lengths[i] = len;
-
- y = total_size;
- total_size += len;
- RETURN_UNLESS (total_size >= y);
- }
- sizes = buffer_lengths;
- break;
- }
- default:
- GNUNET_assert (0);
- }
- }
-
- RETURN_UNLESS (INT_MAX > total_size);
- RETURN_UNLESS (0 != total_size);
-
- elements = GNUNET_malloc (total_size);
- }
-
- /* Write data */
- {
- char *out = elements;
- struct GNUNET_PQ_ArrayHeader_P h = {
- .ndim = htonl (1), /* We only support one-dimensional arrays */
- .has_null = htonl (0), /* We do not support NULL entries in arrays */
- .lbound = htonl (1), /* Default start index value */
- .dim = htonl (num),
- .oid = htonl (meta->oid),
- };
-
- /* Write header */
- GNUNET_memcpy (out,
- &h,
- sizeof(h));
- out += sizeof(h);
-
- /* Write elements */
- for (size_t i = 0; i < num; i++)
- {
- size_t sz = same_sized ? meta->same_size : sizes[i];
-
- *(uint32_t *) out = htonl (sz);
- out += sizeof(uint32_t);
- switch (meta->typ)
- {
- case DONAU_PQ_array_of_blinded_donation_id_kps:
- {
- const struct DONAU_BlindedUniqueDonationIdentifierKeyPair *budi_kps =
- data;
- const struct GNUNET_CRYPTO_BlindedMessage *bm = &budi_kps[i].
- blinded_udi;
- uint32_t be[2];
-
- be[0] = htonl ((uint32_t) bm->cipher);
- be[1] = htonl (0x01); /* magic margker: blinded */
- GNUNET_memcpy (out,
- &be,
- sizeof(be));
- out += sizeof(be);
- sz -= sizeof(be);
-
- switch (bm->cipher)
- {
- case GNUNET_CRYPTO_BSA_RSA:
- /* For RSA, 'same_sized' must have been false */
- GNUNET_assert (NULL != buffers);
- GNUNET_memcpy (out,
- buffers[i],
- sz);
- break;
- case GNUNET_CRYPTO_BSA_CS:
- GNUNET_memcpy (out,
- &bm->details.cs_blinded_message,
- sz);
- break;
- default:
- GNUNET_assert (0);
- }
- break;
- }
- default:
- {
- GNUNET_assert (0);
- break;
- }
- }
- out += sz;
- }
- }
- param_values[0] = elements;
- param_lengths[0] = total_size;
- param_formats[0] = 1;
- scratch[0] = elements;
-
-DONE:
- if (NULL != buffers)
- {
- for (size_t i = 0; i<num; i++)
- GNUNET_free (buffers[i]);
- GNUNET_free (buffers);
- }
- GNUNET_free (buffer_lengths);
- if (noerror)
- return 1;
- return -1;
-}
-
-
/* end of pq/pq_query_helper.c */
diff --git a/src/testing/test_donau_api.c b/src/testing/test_donau_api.c
@@ -34,7 +34,6 @@
#include "taler_bank_service.h"
#include "taler_fakebank_lib.h"
#include "taler_testing_lib.h"
-#include "taler/taler_extensions.h"
/**
* Configuration file we use. One (big) configuration is used