diff options
author | Özgür Kesim <oec-taler@kesim.org> | 2022-01-08 14:40:20 +0100 |
---|---|---|
committer | Özgür Kesim <oec-taler@kesim.org> | 2022-01-08 14:40:20 +0100 |
commit | cc7d7707ab2bd43bc9e95c0eeec9ce95cdc0c523 (patch) | |
tree | 472e895b321e539f4675f016a285d6f6e6436b76 /src/util | |
parent | b49fac3d5892f75a2eb7fbfbca0056965c6967c7 (diff) |
[age restriction] progress 10/n
More work towards support for extensions:
- Prepared statements and DB-plugin-functions for setting and retrieving
configurations from the database added.
- primitive "registry" of extensions for age restrictions and peer2peer
(stub)
- TALER_Extensions now with FP for parsing, setting and converting a
configuration.
- /management/extensions handler now verifies signature of the (opaque)
json object for all extensions.
- /management/extensions handler calls the FP in the corrensponding
TALER_Extension for parsing and setting the configuration of a
particular extension
More work towards age restriction:
- TALER_Extensions interfaces for config-parser, -setter and converter
implemented for age restriction
- DB event handler now retrieves config from database, parses it and
sets it (the age mask) in the global extension.
- load_age_mask now loads age mask from the global extension (and not
from the config file)
- add age_restricted_denoms to /keys response
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/Makefile.am | 1 | ||||
-rw-r--r-- | src/util/extension_age_restriction.c | 5 | ||||
-rw-r--r-- | src/util/extensions.c | 49 | ||||
-rw-r--r-- | src/util/offline_signatures.c | 56 |
4 files changed, 68 insertions, 43 deletions
diff --git a/src/util/Makefile.am b/src/util/Makefile.am index cae1a205e..55ebb4dff 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -72,6 +72,7 @@ libtalerutil_la_SOURCES = \ crypto_wire.c \ denom.c \ exchange_signatures.c \ + extensions.c \ extension_age_restriction.c \ getopt.c \ lang.c \ diff --git a/src/util/extension_age_restriction.c b/src/util/extension_age_restriction.c index c0efd7cd1..42a58b2e9 100644 --- a/src/util/extension_age_restriction.c +++ b/src/util/extension_age_restriction.c @@ -23,7 +23,6 @@ #include "taler_extensions.h" #include "stdint.h" - /** * * @param cfg Handle to the GNUNET configuration @@ -137,12 +136,14 @@ TALER_parse_age_group_string (char *groups, /** + * Encodes the age mask into a string, like "8:10:12:14:16:18:21" + * * @param mask Age mask * @return String representation of the age mask, allocated by GNUNET_malloc. * Can be used as value in the TALER config. */ char * -TALER_age_mask_to_string (struct TALER_AgeMask *m) +TALER_age_mask_to_string (const struct TALER_AgeMask *m) { uint32_t mask = m->mask; unsigned int n = 0; diff --git a/src/util/extensions.c b/src/util/extensions.c new file mode 100644 index 000000000..87dd16b4d --- /dev/null +++ b/src/util/extensions.c @@ -0,0 +1,49 @@ +/* + This file is part of TALER + Copyright (C) 2014-2021 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 extensions.c + * @brief Utility functions for extensions + * @author Özgür Kesim + */ +#include "platform.h" +#include "taler_util.h" +#include "taler_extensions.h" +#include "stdint.h" + +enum GNUNET_GenericReturnValue +TALER_extension_get_by_name (const char *name, + const struct TALER_Extension **extensions, + const struct TALER_Extension **ext) +{ + + const struct TALER_Extension *it = *extensions; + + for (; NULL != it; it++) + { + if (0 == strncmp (name, + it->name, + strlen (it->name))) + { + *ext = it; + return GNUNET_OK; + } + } + + return GNUNET_NO; +} + + +/* end of extensions.c */ diff --git a/src/util/offline_signatures.c b/src/util/offline_signatures.c index 7fbec826b..1240a8bc5 100644 --- a/src/util/offline_signatures.c +++ b/src/util/offline_signatures.c @@ -491,66 +491,40 @@ TALER_exchange_offline_wire_fee_verify ( void -TALER_exchange_offline_extension_agemask_sign ( - const struct TALER_AgeMask mask, +TALER_exchange_offline_extension_config_hash_sign ( + const struct TALER_ExtensionConfigHash h_config, const struct TALER_MasterPrivateKeyP *master_priv, struct TALER_MasterSignatureP *master_sig) { - struct TALER_MasterExtensionAgeRestrictionPS ar = { + struct TALER_MasterExtensionConfigurationPS ec = { .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_EXTENSION), - .purpose.size = htonl (sizeof(ar)), - .mask = mask + .purpose.size = htonl (sizeof(ec)), + .h_config = h_config }; GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv, - &ar, + &ec, &master_sig->eddsa_signature); } enum GNUNET_GenericReturnValue -TALER_exchange_offline_extension_agemask_verify ( - const struct TALER_AgeMask mask, +TALER_exchange_offline_extension_config_hash_verify ( + const struct TALER_ExtensionConfigHash h_config, const struct TALER_MasterPublicKeyP *master_pub, const struct TALER_MasterSignatureP *master_sig ) { - struct TALER_MasterExtensionAgeRestrictionPS ar = { + struct TALER_MasterExtensionConfigurationPS ec = { .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_EXTENSION), - .purpose.size = htonl (sizeof(ar)), - .mask = mask + .purpose.size = htonl (sizeof(ec)), + .h_config = h_config }; - return - GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_EXTENSION, - &ar, - &master_sig->eddsa_signature, - &master_pub->eddsa_pub); -} - -#if 0 -/* TODO peer2peer */ -void -TALER_exchange_offline_extension_p2p_sign ( - // TODO - const struct TALER_MasterPrivateKeyP *master_priv, - struct TALER_MasterSignatureP *master_sig) -{ - // TODO -} - - -enum GNUNET_GenericReturnValue -TALER_exchange_offline_extension_p2p_verify ( - // TODO - const struct TALER_MasterPublicKeyP *master_pub, - const struct TALER_MasterSignatureP *master_sig, - ) -{ - // TODO - return GNUNET_FALSE; + return GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_EXTENSION, + &ec, + &master_sig->eddsa_signature, + &master_pub->eddsa_pub); } -#endif - /* end of offline_signatures.c */ |