[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: revise recovery API
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: revise recovery API |
Date: |
Sat, 06 Feb 2021 19:24:43 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new 58fddb4 revise recovery API
58fddb4 is described below
commit 58fddb43e700e78d13d51b913155b737b81477ad
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sat Feb 6 19:24:41 2021 +0100
revise recovery API
---
src/include/anastasis.h | 19 ++++----
src/lib/anastasis_recovery.c | 77 ++++++++----------------------
src/testing/testing_cmd_challenge_answer.c | 55 +++++++++------------
3 files changed, 54 insertions(+), 97 deletions(-)
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 04ff37c..0d83f24 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -173,11 +173,11 @@ struct ANASTASIS_ChallengeAnswerOperation;
/**
* Cancel a challenge answer operation.
*
- * @param pso the challenge answer operation to cancel
+ * @param c the challenge for which to cancel the answer operation
*/
void
ANASTASIS_challenge_answer_cancel (
- struct ANASTASIS_ChallengeAnswerOperation *cao);
+ struct ANASTASIS_Challenge *c);
/**
@@ -185,16 +185,19 @@ ANASTASIS_challenge_answer_cancel (
* sends back an AnswerFeedback.
*
* @param c reference to the challenge which is answered
+ * @param payment_secret information about payment made for the recovery
* @param answer user input instruction defines which input is needed
* @param af reference to the answerfeedback which is passed back to the user
* @param af_cls handle for the challenge answer struct
- * @return handle to an challenge answer operation
+ * @return #GNUNET_OK on success
*/
-struct ANASTASIS_ChallengeAnswerOperation *
-ANASTASIS_challenge_answer (struct ANASTASIS_Challenge *c,
- const char *answer,
- ANASTASIS_AnswerFeedback af,
- void *af_cls);
+int
+ANASTASIS_challenge_answer (
+ struct ANASTASIS_Challenge *c,
+ const struct ANASTASIS_PaymentSecretP *payment_secret,
+ const char *answer,
+ ANASTASIS_AnswerFeedback af,
+ void *af_cls);
/**
diff --git a/src/lib/anastasis_recovery.c b/src/lib/anastasis_recovery.c
index 228170b..2f72c51 100644
--- a/src/lib/anastasis_recovery.c
+++ b/src/lib/anastasis_recovery.c
@@ -119,7 +119,7 @@ struct ANASTASIS_Recovery
unsigned int response_code;
/**
- * Length of available decryption policies //FIXME: Copy paste?
+ * Current offset in the @e solved_challenges array.
*/
unsigned int solved_challenge_pos;
@@ -138,11 +138,6 @@ struct ANASTASIS_Challenge
*/
struct ANASTASIS_ChallengeInformation ci;
- /**
- * Payment identifier.
- */
- struct ANASTASIS_PaymentSecretP payment_secret;
-
/**
* truth public key which identifies this challenge
*/
@@ -158,11 +153,6 @@ struct ANASTASIS_Challenge
*/
struct ANASTASIS_CRYPTO_PowSalt truth_salt;
- /**
- * Payment order ID we are to provide in the request, may be NULL.
- */
- const char *payment_order_req;
-
/**
* Callback which gives back the instructions and a status code of the
request to the user
*/
@@ -188,11 +178,6 @@ struct ANASTASIS_Challenge
*/
struct ANASTASIS_Recovery *recovery;
- /**
- * Plaintext challenge which is sent to the client???
- */
- // void *challenge;
-
/**
* keyshare lookup operation
*/
@@ -218,22 +203,6 @@ struct ANASTASIS_Challenge
*/
void *csc_cls;
- /**
- * size of the challenge???
- */
- // size_t challenge_size;
-
- /**
- * Expected http status
- */
- // unsigned int http_status;
-
-};
-
-
-struct ANASTASIS_ChallengeAnswerOperation
-{
- struct ANASTASIS_Challenge *c;
};
@@ -259,21 +228,14 @@ keyshare_lookup_cb (void *cls,
ANASTASIS_CRYPTO_keyshare_decrypt (dd->encrypted_key_share,
&id,
&c->key_share);
- c->recovery->solved_challenges[c->recovery->solved_challenge_pos] = *c;
- c->recovery->solved_challenge_pos++;
+ c->recovery->solved_challenges[c->recovery->solved_challenge_pos++] = *c;
+ c->ci.solved = true;
c->af (c->af_cls,
http_status,
TALER_EC_NONE);
- /**
- * 0 equals the challenge was not solved 1 it was solved
- */
bool missing = true;
- /**
- * Index of the policy which was completed
- */
unsigned int success = UINT_MAX;
-
for (unsigned int i = 0; i < c->recovery->ri.dps_len; i++)
{
for (unsigned int j = 0; j < c->recovery->ri.dps[i].nonces_length; j++)
@@ -347,25 +309,28 @@ keyshare_lookup_cb (void *cls,
void
-ANASTASIS_challenge_answer_cancel (
- struct ANASTASIS_ChallengeAnswerOperation *cao)
+ANASTASIS_challenge_answer_cancel (struct ANASTASIS_Challenge *c)
{
- GNUNET_free (cao->c);
- GNUNET_free (cao);
+ if (NULL == c->kslo)
+ {
+ GNUNET_break (0);
+ return;
+ }
+ ANASTASIS_keyshare_lookup_cancel (c->kslo);
+ c->kslo = NULL;
}
-struct ANASTASIS_ChallengeAnswerOperation *
-ANASTASIS_challenge_answer (struct ANASTASIS_Challenge *c,
- const char *answer_str,
- ANASTASIS_AnswerFeedback af,
- void *af_cls)
+int
+ANASTASIS_challenge_answer (
+ struct ANASTASIS_Challenge *c,
+ const struct ANASTASIS_PaymentSecretP *payment_secret,
+ const char *answer_str,
+ ANASTASIS_AnswerFeedback af,
+ void *af_cls)
{
- struct ANASTASIS_ChallengeAnswerOperation *cao;
struct GNUNET_HashCode hashed_answer;
- cao = GNUNET_new (struct ANASTASIS_ChallengeAnswerOperation);
- cao->c = c;
c->af = af;
c->af_cls = af_cls;
GNUNET_CRYPTO_hash (answer_str,
@@ -375,16 +340,16 @@ ANASTASIS_challenge_answer (struct ANASTASIS_Challenge *c,
c->ci.url,
&c->truth_public_key,
&c->truth_key,
- &c->payment_secret,
+ payment_secret,
&hashed_answer,
&keyshare_lookup_cb,
c);
if (NULL == c->kslo)
{
GNUNET_break (0);
- return NULL;
+ return GNUNET_SYSERR;
}
- return cao;
+ return GNUNET_OK;
}
diff --git a/src/testing/testing_cmd_challenge_answer.c
b/src/testing/testing_cmd_challenge_answer.c
index 1764389..c8872f9 100644
--- a/src/testing/testing_cmd_challenge_answer.c
+++ b/src/testing/testing_cmd_challenge_answer.c
@@ -42,11 +42,6 @@ struct ChallengeState
*/
struct ANASTASIS_Challenge *c;
- /**
- * Expected status code.
- */
- unsigned int http_status;
-
/**
* Answer to the challenge we are solving
*/
@@ -57,6 +52,11 @@ struct ChallengeState
*/
const char *challenge_ref;
+ /**
+ * Expected status code.
+ */
+ unsigned int http_status;
+
/**
* Index of the challenge we are solving
*/
@@ -67,10 +67,6 @@ struct ChallengeState
*/
unsigned int mode;
- /**
- * Handle for an challenge answer operation
- */
- struct ANASTASIS_ChallengeAnswerOperation *cao;
};
@@ -80,6 +76,7 @@ challenge_answer_cb (void *af_cls,
enum TALER_ErrorCode ec)
{
struct ChallengeState *cs = af_cls;
+
if (http_status_code != MHD_HTTP_OK)
{
GNUNET_break (0);
@@ -127,12 +124,12 @@ challenge_answer_run (void *cls,
return;
}
}
- if (cs->mode == 1)
+ if (1 == cs->mode)
{
const char *code;
- ref = TALER_TESTING_interpreter_lookup_command (
- is,
- cs->answer);
+
+ ref = TALER_TESTING_interpreter_lookup_command (is,
+ cs->answer);
if (NULL == ref)
{
GNUNET_break (0);
@@ -150,14 +147,16 @@ challenge_answer_run (void *cls,
}
cs->answer = code;
}
-
- cs->cao = ANASTASIS_challenge_answer ((struct ANASTASIS_Challenge *) c,
- cs->answer,
- &challenge_answer_cb,
- cs);
- if (NULL == cs->cao)
+ cs->c = (struct ANASTASIS_Challenge *) c;
+ if (GNUNET_OK !=
+ ANASTASIS_challenge_answer (cs->c,
+ NULL, /* FIXME: support payment */
+ cs->answer,
+ &challenge_answer_cb,
+ cs))
{
GNUNET_break (0);
+ cs->c = NULL;
TALER_TESTING_interpreter_fail (cs->is);
return;
}
@@ -176,29 +175,19 @@ challenge_answer_cleanup (void *cls,
const struct TALER_TESTING_Command *cmd)
{
struct ChallengeState *cs = cls;
- if (NULL != cs->cao)
+
+ if (NULL != cs->c)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Command '%s' did not complete (challenge answer)\n",
cmd->label);
- ANASTASIS_challenge_answer_cancel (cs->cao);
- cs->cao = NULL;
+ ANASTASIS_challenge_answer_cancel (cs->c);
+ cs->c = NULL;
}
GNUNET_free (cs);
}
-/**
- * Make the "challenge answer" command.
- *
- * @param label command label
- * @param http_status expected HTTP status.
- * @param challenge_ref reference to the recovery process
- * @param challenge_index defines the index of the trait to solve
- * @param answer to the challenge
- * @param answer_size size of the answer
- * @return the command
- */
struct TALER_TESTING_Command
ANASTASIS_TESTING_cmd_challenge_answer (const char *label,
unsigned int http_status,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: revise recovery API,
gnunet <=