summaryrefslogtreecommitdiff
path: root/src/exchange/taler-exchange-httpd_keys.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-11-25 13:37:47 +0100
committerChristian Grothoff <christian@grothoff.org>2021-11-25 13:37:47 +0100
commit94012d011c3b2c3b3dcc9527d56d1814f42fcdc7 (patch)
tree8b82cb011155f7a131ecaeb05301dfe8a1c718b7 /src/exchange/taler-exchange-httpd_keys.c
parent98549cdc5aff7081f20ccc53b566802020f6fdd9 (diff)
downloadexchange-94012d011c3b2c3b3dcc9527d56d1814f42fcdc7.tar.gz
exchange-94012d011c3b2c3b3dcc9527d56d1814f42fcdc7.tar.bz2
exchange-94012d011c3b2c3b3dcc9527d56d1814f42fcdc7.zip
add invariant checks
Diffstat (limited to 'src/exchange/taler-exchange-httpd_keys.c')
-rw-r--r--src/exchange/taler-exchange-httpd_keys.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/exchange/taler-exchange-httpd_keys.c b/src/exchange/taler-exchange-httpd_keys.c
index 1fb58fc8c..bca1b644b 100644
--- a/src/exchange/taler-exchange-httpd_keys.c
+++ b/src/exchange/taler-exchange-httpd_keys.c
@@ -461,6 +461,52 @@ suspend_request (struct MHD_Connection *connection)
}
+/**
+ * Called on each denomination key. Checks that the key still works.
+ *
+ * @param cls NULL
+ * @param hc denomination hash (unused)
+ * @param value a `struct TEH_DenominationKey`
+ * @return #GNUNET_OK
+ */
+static int
+check_dk (void *cls,
+ const struct GNUNET_HashCode *hc,
+ void *value)
+{
+ struct TEH_DenominationKey *dk = value;
+ struct TALER_PlanchetSecretsP ps;
+ struct TALER_PlanchetDetail pd;
+ struct TALER_CoinPubHash c_hash;
+
+ (void) hc;
+ (void) value;
+ GNUNET_assert (TALER_DENOMINATION_INVALID != dk->denom_pub.cipher);
+ memset (&ps,
+ 42,
+ sizeof (ps));
+ GNUNET_assert (GNUNET_OK ==
+ TALER_planchet_prepare (&dk->denom_pub,
+ &ps,
+ &c_hash,
+ &pd));
+ GNUNET_free (pd.coin_ev);
+ return GNUNET_OK;
+}
+
+
+void
+TEH_check_invariants ()
+{
+ struct TEH_KeyStateHandle *ksh;
+
+ ksh = TEH_keys_get_state ();
+ GNUNET_CONTAINER_multihashmap_iterate (ksh->denomkey_map,
+ &check_dk,
+ NULL);
+}
+
+
void
TEH_resume_keys_requests (bool do_shutdown)
{
@@ -935,8 +981,12 @@ keys_update_event_cb (void *cls,
(void) cls;
(void) extra;
(void) extra_size;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Received /keys update event\n");
+ TEH_check_invariants ();
key_generation++;
TEH_resume_keys_requests (false);
+ TEH_check_invariants ();
}