From c1c40eaa24926273a6aa688e92e99d832aa1501e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 16 Aug 2021 11:01:38 +0200 Subject: -preparations for sepa auth plugin --- src/stasis/plugin_anastasis_postgres.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/stasis') diff --git a/src/stasis/plugin_anastasis_postgres.c b/src/stasis/plugin_anastasis_postgres.c index 9d206c7..325bae8 100644 --- a/src/stasis/plugin_anastasis_postgres.c +++ b/src/stasis/plugin_anastasis_postgres.c @@ -1758,6 +1758,11 @@ struct CheckValidityContext */ bool valid; + /** + * Set to true if a code matching @e hashed_code was set to 'satisfied' by the plugin. + */ + bool satisfied; + /** * Set to true if we had a database failure. */ @@ -1786,9 +1791,12 @@ check_valid_code (void *cls, for (unsigned int i = 0; i < num_results; i++) { uint64_t server_code; + uint8_t sat; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("code", &server_code), + GNUNET_PQ_result_spec_auto_from_type ("satisfied", + &sat), GNUNET_PQ_result_spec_end }; @@ -1811,6 +1819,7 @@ check_valid_code (void *cls, cvc->hashed_code)) { cvc->valid = true; + cvc->satisfied = (0 != sat); } else { @@ -1844,13 +1853,15 @@ check_valid_code (void *cls, * @param cls closure * @param truth_uuid identification of the challenge which the code corresponds to * @param hashed_code code which the user provided and wants to verify + * @param[out] satisfied set to true if the challenge is set to satisfied * @return code validity status */ enum ANASTASIS_DB_CodeStatus postgres_verify_challenge_code ( void *cls, const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid, - const struct GNUNET_HashCode *hashed_code) + const struct GNUNET_HashCode *hashed_code, + bool *satisfied) { struct PostgresClosure *pg = cls; struct CheckValidityContext cvc = { @@ -1866,6 +1877,7 @@ postgres_verify_challenge_code ( }; enum GNUNET_DB_QueryStatus qs; + *satisfied = false; check_connection (pg); GNUNET_TIME_round_abs (&now); qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn, @@ -1877,7 +1889,10 @@ postgres_verify_challenge_code ( (cvc.db_failure) ) return ANASTASIS_DB_CODE_STATUS_HARD_ERROR; if (cvc.valid) + { + *satisfied = cvc.satisfied; return ANASTASIS_DB_CODE_STATUS_VALID_CODE_STORED; + } if (0 == qs) return ANASTASIS_DB_CODE_STATUS_NO_RESULTS; return ANASTASIS_DB_CODE_STATUS_CHALLENGE_CODE_MISMATCH; @@ -2523,6 +2538,7 @@ libanastasis_plugin_db_postgres_init (void *cls) GNUNET_PQ_make_prepare ("challengecode_select", "SELECT " " code" + ",satisfied" " FROM anastasis_challengecode" " WHERE truth_uuid=$1" " AND expiration_date > $2" -- cgit v1.2.3