diff options
author | Özgür Kesim <oec-taler@kesim.org> | 2021-12-27 23:24:48 +0100 |
---|---|---|
committer | Özgür Kesim <oec-taler@kesim.org> | 2021-12-27 23:24:48 +0100 |
commit | ef4238874f6628a9ee4464ad3b70a7fde96d518b (patch) | |
tree | 27ba7f32c4d32bce4c821ba6c6a2ed8791d2c30b /src/util | |
parent | 070f442a1182c7c2a09c42e94ce202509ade1b77 (diff) |
[age restriction] progress 9/n
More worke towards support for extensions and age restriction:
- taler-exchange-httpd_management_extensions.c almost completed
- handling of request implemented
- stub "set_extensions" for database transaction added
- utility functions added
- TALER_exchange_offline_extension_agemask_{sign,verify}
- TALER_agemask_parse_json
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/extension_age_restriction.c | 12 | ||||
-rw-r--r-- | src/util/offline_signatures.c | 63 |
2 files changed, 69 insertions, 6 deletions
diff --git a/src/util/extension_age_restriction.c b/src/util/extension_age_restriction.c index fbdb796f2..c0efd7cd1 100644 --- a/src/util/extension_age_restriction.c +++ b/src/util/extension_age_restriction.c @@ -38,12 +38,12 @@ TALER_get_age_mask (const struct GNUNET_CONFIGURATION_Handle *cfg, char *groups; enum TALER_Extension_ReturnValue ret = TALER_Extension_ERROR_SYS; - if ((GNUNET_NO == GNUNET_CONFIGURATION_have_value (cfg, - TALER_EXTENSION_SECTION_AGE_RESTRICTION, - "ENABLED")) || - (GNUNET_NO == GNUNET_CONFIGURATION_get_value_yesno (cfg, - TALER_EXTENSION_SECTION_AGE_RESTRICTION, - "ENABLED"))) + if ((GNUNET_YES != GNUNET_CONFIGURATION_have_value (cfg, + TALER_EXTENSION_SECTION_AGE_RESTRICTION, + "ENABLED")) || + (GNUNET_YES != GNUNET_CONFIGURATION_get_value_yesno (cfg, + TALER_EXTENSION_SECTION_AGE_RESTRICTION, + "ENABLED"))) { /* Age restriction is not enabled */ mask->mask = 0; diff --git a/src/util/offline_signatures.c b/src/util/offline_signatures.c index cd9dceca5..7fbec826b 100644 --- a/src/util/offline_signatures.c +++ b/src/util/offline_signatures.c @@ -490,4 +490,67 @@ TALER_exchange_offline_wire_fee_verify ( } +void +TALER_exchange_offline_extension_agemask_sign ( + const struct TALER_AgeMask mask, + const struct TALER_MasterPrivateKeyP *master_priv, + struct TALER_MasterSignatureP *master_sig) +{ + struct TALER_MasterExtensionAgeRestrictionPS ar = { + .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_EXTENSION), + .purpose.size = htonl (sizeof(ar)), + .mask = mask + }; + GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv, + &ar, + &master_sig->eddsa_signature); +} + + +enum GNUNET_GenericReturnValue +TALER_exchange_offline_extension_agemask_verify ( + const struct TALER_AgeMask mask, + const struct TALER_MasterPublicKeyP *master_pub, + const struct TALER_MasterSignatureP *master_sig + ) +{ + struct TALER_MasterExtensionAgeRestrictionPS ar = { + .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_EXTENSION), + .purpose.size = htonl (sizeof(ar)), + .mask = mask + }; + 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; +} + + +#endif + /* end of offline_signatures.c */ |