diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2022-03-21 03:59:31 +0100 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2022-03-21 03:59:31 +0100 |
commit | c7e2d206bab7f06375be2154b323ad429d13a9e7 (patch) | |
tree | 969cc459e34e9cc88074269e272fd27be38f01f5 /src/exchange/taler-exchange-httpd_reserves_status.c | |
parent | 1f86b02ffa60e3817f6a7d70a654f02759e793f3 (diff) |
add logic to check timestamp, revise history balance calculation logic in client
Diffstat (limited to 'src/exchange/taler-exchange-httpd_reserves_status.c')
-rw-r--r-- | src/exchange/taler-exchange-httpd_reserves_status.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/exchange/taler-exchange-httpd_reserves_status.c b/src/exchange/taler-exchange-httpd_reserves_status.c index 0b6ee2d3..6a3260d1 100644 --- a/src/exchange/taler-exchange-httpd_reserves_status.c +++ b/src/exchange/taler-exchange-httpd_reserves_status.c @@ -30,6 +30,13 @@ #include "taler-exchange-httpd_reserves_status.h" #include "taler-exchange-httpd_responses.h" +/** + * How far do we allow a client's time to be off when + * checking the request timestamp? + */ +#define TIMESTAMP_TOLERANCE \ + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 15) + /** * Closure for #reserve_status_transaction. @@ -140,6 +147,7 @@ TEH_handler_reserves_status (struct TEH_RequestContext *rc, &reserve_sig), GNUNET_JSON_spec_end () }; + struct GNUNET_TIME_Timestamp now; rsc.reserve_pub = reserve_pub; { @@ -159,6 +167,17 @@ TEH_handler_reserves_status (struct TEH_RequestContext *rc, return MHD_YES; /* failure */ } } + now = GNUNET_TIME_timestamp_get (); + if (! GNUNET_TIME_absolute_approx_eq (now.abs_time, + timestamp.abs_time, + TIMESTAMP_TOLERANCE)) + { + GNUNET_break_op (0); + return TALER_MHD_reply_with_error (rc->connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_EXCHANGE_GENERIC_CLOCK_SKEW, + NULL); + } if (GNUNET_OK != TALER_wallet_reserve_status_verify (timestamp, reserve_pub, |