diff options
author | Özgür Kesim <oec-taler@kesim.org> | 2022-01-11 15:24:43 +0100 |
---|---|---|
committer | Özgür Kesim <oec-taler@kesim.org> | 2022-01-21 15:41:02 +0100 |
commit | 0b56de6c994d3e525aa2d0195ff4607db3f14715 (patch) | |
tree | 9f34c40155dd5538841497c9f6a151deb2305a8d /src/util | |
parent | 0b6ebc6160f1fd1f6db7c433f0912b5d2845a59c (diff) | |
download | exchange-0b56de6c994d3e525aa2d0195ff4607db3f14715.tar.xz |
[age restriction] progress 12/n
- taler-offline-tool now handles extensions
- command "extensions" added with subcommands "show" and "sign"
- parses extensions from taler config
- shows and signs of extensions and their configurations
- creates signed set of configurations for upload
- added test for retrieval of extension config
- simplified signature verification for extensions
- remove per-extension signatures, also from DB schema
- adjust prepared statements accordingly
- adjust DB event handler for extensions
- allow NULL for config for extension in DB schema
- handler for /management/extensions adjusted to new datastructures
- changed test for TALER_denom_blind/TALER_denom_sign_blinded with and
without TALER_AgeHash
- minor updates and various fixes
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/extension_age_restriction.c | 75 | ||||
-rw-r--r-- | src/util/offline_signatures.c | 8 |
2 files changed, 35 insertions, 48 deletions
diff --git a/src/util/extension_age_restriction.c b/src/util/extension_age_restriction.c index b29a8ca88..0b04c7d7b 100644 --- a/src/util/extension_age_restriction.c +++ b/src/util/extension_age_restriction.c @@ -30,12 +30,12 @@ * @return Error if extension for age restriction was set, but age groups were * invalid, OK otherwise. */ -enum TALER_Extension_ReturnValue +enum GNUNET_GenericReturnValue TALER_get_age_mask (const struct GNUNET_CONFIGURATION_Handle *cfg, struct TALER_AgeMask *mask) { char *groups; - enum TALER_Extension_ReturnValue ret = TALER_Extension_ERROR_SYS; + enum GNUNET_GenericReturnValue ret = GNUNET_SYSERR; if ((GNUNET_YES != GNUNET_CONFIGURATION_have_value (cfg, TALER_EXTENSION_SECTION_AGE_RESTRICTION, @@ -46,7 +46,7 @@ TALER_get_age_mask (const struct GNUNET_CONFIGURATION_Handle *cfg, { /* Age restriction is not enabled */ mask->mask = 0; - return TALER_Extension_OK; + return GNUNET_OK; } /* Age restriction is enabled, extract age groups */ @@ -56,13 +56,13 @@ TALER_get_age_mask (const struct GNUNET_CONFIGURATION_Handle *cfg, &groups)) { /* FIXME: log error? */ - return TALER_Extension_ERROR_SYS; + return GNUNET_SYSERR; } if (groups == NULL) { /* No groups defined in config, return default_age_mask */ mask->mask = TALER_EXTENSION_DEFAULT_AGE_MASK; - return TALER_Extension_OK; + return GNUNET_OK; } ret = TALER_parse_age_group_string (groups, mask); @@ -79,59 +79,46 @@ TALER_get_age_mask (const struct GNUNET_CONFIGURATION_Handle *cfg, * @param[out] mask Bit representation of the age groups. * @return Error if string was invalid, OK otherwise. */ -enum TALER_Extension_ReturnValue +enum GNUNET_GenericReturnValue TALER_parse_age_group_string (const char *groups, struct TALER_AgeMask *mask) { - enum TALER_Extension_ReturnValue ret = TALER_Extension_ERROR_SYS; - char *pos; + + const char *pos = groups; unsigned int prev = 0; - unsigned int val; - char dummy; + unsigned int val = 0; + char c; - while (1) + while (*pos) { - pos = strchr (groups, ':'); - if (NULL != pos) + c = *pos++; + if (':' == c) { - *pos = 0; - } + if (prev >= val) + return GNUNET_SYSERR; - if (1 != sscanf (groups, - "%u%c", - &val, - &dummy)) - { - /* Invalid input */ - mask->mask = 0; - ret = TALER_Extension_ERROR_PARSING; - break; - } - else if ((0 >= val) || (32 <= val) || (prev >= val)) - { - /* Invalid value */ - mask->mask = 0; - ret = TALER_Extension_ERROR_INVALID; - break; + mask->mask |= 1 << val; + prev = val; + val = 0; + continue; } - /* Set the corresponding bit in the mask */ - mask->mask |= 1 << val; + if ('0'>c || '9'<c) + return GNUNET_SYSERR; - if (NULL == pos) - { - /* We reached the end. Mark zeroth age-group and exit. */ - mask->mask |= 1; - ret = TALER_Extension_OK; - break; - } + val = 10 * val + c - '0'; - prev = val; - *pos = ':'; - groups = pos + 1; + if (0>=val || 32<=val) + return GNUNET_SYSERR; } - return ret; + if (0>val || 32<=val || prev>=val) + return GNUNET_SYSERR; + + mask->mask |= (1 << val); + mask->mask |= 1; // mark zeroth group, too + + return GNUNET_OK; } diff --git a/src/util/offline_signatures.c b/src/util/offline_signatures.c index 1240a8bc5..ab2988349 100644 --- a/src/util/offline_signatures.c +++ b/src/util/offline_signatures.c @@ -492,14 +492,14 @@ TALER_exchange_offline_wire_fee_verify ( void TALER_exchange_offline_extension_config_hash_sign ( - const struct TALER_ExtensionConfigHash h_config, + const struct TALER_ExtensionConfigHash *h_config, const struct TALER_MasterPrivateKeyP *master_priv, struct TALER_MasterSignatureP *master_sig) { struct TALER_MasterExtensionConfigurationPS ec = { .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_EXTENSION), .purpose.size = htonl (sizeof(ec)), - .h_config = h_config + .h_config = *h_config }; GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv, &ec, @@ -509,7 +509,7 @@ TALER_exchange_offline_extension_config_hash_sign ( enum GNUNET_GenericReturnValue TALER_exchange_offline_extension_config_hash_verify ( - const struct TALER_ExtensionConfigHash h_config, + const struct TALER_ExtensionConfigHash *h_config, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_MasterSignatureP *master_sig ) @@ -517,7 +517,7 @@ TALER_exchange_offline_extension_config_hash_verify ( struct TALER_MasterExtensionConfigurationPS ec = { .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_EXTENSION), .purpose.size = htonl (sizeof(ec)), - .h_config = h_config + .h_config = *h_config }; return GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_EXTENSION, |