diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-01 11:42:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-01 11:43:16 +0200 |
commit | 42d323d4344c748e1e793a606646c932d998cb47 (patch) | |
tree | 555a858ae9be73da5a0421c5af8926fb2b9d1735 /src/backend | |
parent | 9b6cc730772c7b1c193236cf809f63d908237447 (diff) | |
download | merchant-42d323d4344c748e1e793a606646c932d998cb47.tar.gz merchant-42d323d4344c748e1e793a606646c932d998cb47.tar.bz2 merchant-42d323d4344c748e1e793a606646c932d998cb47.zip |
implement #6942: switch UUIDs to strings
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/taler-merchant-httpd_helper.c | 24 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_helper.h | 11 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-orders.c | 7 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-products-ID-lock.c | 10 |
4 files changed, 45 insertions, 7 deletions
diff --git a/src/backend/taler-merchant-httpd_helper.c b/src/backend/taler-merchant-httpd_helper.c index 0120b7b3..cc6288f9 100644 --- a/src/backend/taler-merchant-httpd_helper.c +++ b/src/backend/taler-merchant-httpd_helper.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2014--2020 Taler Systems SA + (C) 2014--2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software @@ -224,3 +224,25 @@ TMH_check_auth_config (struct MHD_Connection *connection, } return GNUNET_OK; } + + +/** + * Generate binary UUID from client-provided UUID-string. + * + * @param uuids string intpu + * @param[out] uuid set to binary UUID + */ +void +TMH_uuid_from_string (const char *uuids, + struct GNUNET_Uuid *uuid) +{ + struct GNUNET_HashCode hc; + + GNUNET_CRYPTO_hash (uuids, + strlen (uuids), + &hc); + GNUNET_static_assert (sizeof (hc) > sizeof (*uuid)); + memcpy (uuid, + &hc, + sizeof (*uuid)); +} diff --git a/src/backend/taler-merchant-httpd_helper.h b/src/backend/taler-merchant-httpd_helper.h index 0460665b..cc5b3013 100644 --- a/src/backend/taler-merchant-httpd_helper.h +++ b/src/backend/taler-merchant-httpd_helper.h @@ -76,4 +76,15 @@ TMH_check_auth_config (struct MHD_Connection *connection, const char **auth_token); +/** + * Generate binary UUID from client-provided UUID-string. + * + * @param uuids string intpu + * @param[out] uuid set to binary UUID + */ +void +TMH_uuid_from_string (const char *uuids, + struct GNUNET_Uuid *uuid); + + #endif diff --git a/src/backend/taler-merchant-httpd_private-post-orders.c b/src/backend/taler-merchant-httpd_private-post-orders.c index 8a0ca347..22e6327f 100644 --- a/src/backend/taler-merchant-httpd_private-post-orders.c +++ b/src/backend/taler-merchant-httpd_private-post-orders.c @@ -1443,9 +1443,10 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh, { const char *error_name; unsigned int error_line; + const char *uuidsi; struct GNUNET_JSON_Specification ispec[] = { - GNUNET_JSON_spec_fixed_auto ("uuid", - &uuids[i]), + GNUNET_JSON_spec_string ("uuid", + &uuidsi), GNUNET_JSON_spec_end () }; @@ -1474,6 +1475,8 @@ TMH_private_post_orders (const struct TMH_RequestHandler *rh, TALER_EC_GENERIC_PARAMETER_MALFORMED, "lock_uuids"); } + TMH_uuid_from_string (uuidsi, + &uuids[i]); } } diff --git a/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c b/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c index 0fae6023..7fc7b0ac 100644 --- a/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c +++ b/src/backend/taler-merchant-httpd_private-post-products-ID-lock.c @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2020 Taler Systems SA + (C) 2020, 2021 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as @@ -35,12 +35,13 @@ TMH_private_post_products_ID_lock (const struct TMH_RequestHandler *rh, struct TMH_MerchantInstance *mi = hc->instance; const char *product_id = hc->infix; enum GNUNET_DB_QueryStatus qs; + const char *uuids; struct GNUNET_Uuid uuid; uint32_t quantity; struct GNUNET_TIME_Relative duration; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_fixed_auto ("lock_uuid", - &uuid), // FIXME: use string? + GNUNET_JSON_spec_string ("lock_uuid", + &uuids), TALER_JSON_spec_relative_time ("duration", &duration), GNUNET_JSON_spec_uint32 ("quantity", @@ -61,7 +62,8 @@ TMH_private_post_products_ID_lock (const struct TMH_RequestHandler *rh, ? MHD_YES : MHD_NO; } - + TMH_uuid_from_string (uuids, + &uuid); qs = TMH_db->lock_product (TMH_db->cls, mi->settings.id, product_id, |