diff options
Diffstat (limited to 'src/include/anastasis_redux.h')
-rw-r--r-- | src/include/anastasis_redux.h | 113 |
1 files changed, 110 insertions, 3 deletions
diff --git a/src/include/anastasis_redux.h b/src/include/anastasis_redux.h index dd28174..2adb74b 100644 --- a/src/include/anastasis_redux.h +++ b/src/include/anastasis_redux.h @@ -3,14 +3,14 @@ Copyright (C) 2020, 2021 Anastasis SARL Anastasis 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 + terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. Anastasis 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 Affero General Public License for more details. + A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU Affero General Public License along with + You should have received a copy of the GNU General Public License along with Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/> */ /** @@ -111,4 +111,111 @@ void ANASTASIS_redux_action_cancel (struct ANASTASIS_ReduxAction *ra); +/** + * Handle for a policy discovery operation. + */ +struct ANASTASIS_PolicyDiscovery; + + +/** + * Function called on each discovered recovery policy. + * + * The client can then start a new policy discovery process, using the + * smallest (also most recent) @a version received per @a provider_url + * in the cursor to resume. Note that in this case, the application + * logic is responsible for de-duplication using @a hcpd, or it may show + * policies again if they are at different providers under versions not + * queried up to the cursor. + * + * @param cls closure + * @param hcpd hash of the compressed policy document (unique per policy) + * @param provider_url which provider claims to have this policy + * @param version version of the policy at this provider + * @param attribute_mask combination of optional identity attributes + * present in the state that was used to locate this version + * @param server_time when did the provider receive the upload + * @param secret_name name the user assigned to the backup + * @param providers json array of providers with this policy + */ +typedef void +(*ANASTASIS_PolicyDiscoveryCallback)(void *cls, + const struct GNUNET_HashCode *hcpd, + const char *provider_url, + uint32_t version, + json_int_t attribute_mask, + struct GNUNET_TIME_Timestamp server_time, + const char *secret_name, + const json_t *providers); + + +/** + * Start requesting providers for available policies for the + * recovery specified in @a state. + * + * @param state state to discover polices in + * @param cursor array containing "provider_url", attribute "mask", + * and "max_version" values (max_version is exclusive). + * Used for incremental discovery, NULL is allowed + * to begin from the latest version(s). + * @param cb function to call with results + * @param cb_cls closure for @a cb + * @return NULL on failure + */ +struct ANASTASIS_PolicyDiscovery * +ANASTASIS_policy_discovery_start (const json_t *state, + const json_t *cursor, + ANASTASIS_PolicyDiscoveryCallback cb, + void *cb_cls); + + +/** + * Add another provider to the list of providers to do discovery + * on. + * + * @param[in,out] pd policy discovery to expand + * @param provider_url the provider to add to the set of providers + * @param provider_state configuration state for that provider + */ +void +ANASTASIS_policy_discovery_more (struct ANASTASIS_PolicyDiscovery *pd, + const char *provider_url, + json_t *provider_state); + +/** + * Stop policy discovery. + * + * @param[in] pd operation to stop + */ +void +ANASTASIS_policy_discovery_stop (struct ANASTASIS_PolicyDiscovery *pd); + + +/** + * Compute a subset of @a master_id removing optional attributes + * based on the bits set in @a mask. + * + * @param state reducer state (tells us which attributes are optional) + * @param master_id set of identity attributes to mask + * @param mask bitmask to apply + * @return masked copy of the @a master_id + */ +json_t * +ANASTASIS_mask_id_data (const json_t *state, + const json_t *master_id, + json_int_t mask); + +/** + * 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); + + #endif /* _ANASTASIS_REDUX_H */ |