diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-01-19 17:30:07 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-01-19 17:30:07 +0100 |
commit | 285e1ab3bd2754598da2bae802e8482c3f8b4f24 (patch) | |
tree | 7e897bd03a896223c0f8ed22e3061b10b854bec1 /src/reducer/anastasis_api_redux.c | |
parent | 21e28d6d049a948fe71817da7cb3e3b0f1639eb6 (diff) | |
download | anastasis-285e1ab3bd2754598da2bae802e8482c3f8b4f24.tar.gz anastasis-285e1ab3bd2754598da2bae802e8482c3f8b4f24.tar.bz2 anastasis-285e1ab3bd2754598da2bae802e8482c3f8b4f24.zip |
implement parallel deduplicating optional attribute brute-forcing discovery process on top of reducer state, but as a side-activity
Diffstat (limited to 'src/reducer/anastasis_api_redux.c')
-rw-r--r-- | src/reducer/anastasis_api_redux.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/reducer/anastasis_api_redux.c b/src/reducer/anastasis_api_redux.c index 66aabe1..a83b86b 100644 --- a/src/reducer/anastasis_api_redux.c +++ b/src/reducer/anastasis_api_redux.c @@ -2004,3 +2004,66 @@ ANASTASIS_REDUX_load_continents_ () GNUNET_JSON_pack_array_steal ("continents", continents)); } + + +/** + * Lookup @a salt of @a provider_url in @a state. + * + * @param state the state to inspect + * @param provider_url provider to look into + * @param[out] salt value to extract + * @return #GNUNET_OK on success + */ +enum GNUNET_GenericReturnValue +ANASTASIS_reducer_lookup_salt_ (const json_t *state, + const char *provider_url, + struct ANASTASIS_CRYPTO_ProviderSaltP *salt) +{ + const json_t *aps; + const json_t *cfg; + uint32_t http_status = 0; + bool disabled = false; + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_bool ("disabled", + &disabled)), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_uint32 ("http_status", + &http_status)), + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_fixed_auto ("salt", + salt)), + GNUNET_JSON_spec_end () + }; + + aps = json_object_get (state, + "authentication_providers"); + if (NULL == aps) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + cfg = json_object_get (aps, + provider_url); + if (NULL == cfg) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + if (GNUNET_OK != + GNUNET_JSON_parse (cfg, + spec, + NULL, NULL)) + { + /* provider not working */ + GNUNET_break_op (0); + return GNUNET_NO; + } + if (disabled) + return GNUNET_NO; + if (NULL == + json_object_get (cfg, + "salt")) + return GNUNET_NO; + return GNUNET_OK; +} |