diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-11-17 22:02:08 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-11-17 22:02:08 +0100 |
commit | 3ccacbd78bf720294363648a496b635abe072408 (patch) | |
tree | d03414707aebbaaffa7add6a7ca0ea02be1b6ca7 /src/include | |
parent | 36e8be14334cd619d2847e3e8c1ecc136f402d71 (diff) | |
download | anastasis-3ccacbd78bf720294363648a496b635abe072408.tar.gz anastasis-3ccacbd78bf720294363648a496b635abe072408.tar.bz2 anastasis-3ccacbd78bf720294363648a496b635abe072408.zip |
make anastasis build against latest Exchange
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/anastasis_testing_lib.h | 467 |
1 files changed, 117 insertions, 350 deletions
diff --git a/src/include/anastasis_testing_lib.h b/src/include/anastasis_testing_lib.h index a4807a1..ba1b8a3 100644 --- a/src/include/anastasis_testing_lib.h +++ b/src/include/anastasis_testing_lib.h @@ -32,231 +32,125 @@ #define ANASTASIS_FAIL() \ do {GNUNET_break (0); return NULL; } while (0) -/** - * Index used in #ANASTASIS_TESTING_get_trait_hash() for the current hash. - */ -#define ANASTASIS_TESTING_TRAIT_HASH_CURRENT 0 - -/** - * Obtain a hash from @a cmd. - * - * @param cmd command to extract the number from. - * @param index the number's index number, use #ANASTASIS_TESTING_TRAIT_HASH_CURRENT - * @param[out] h set to the hash coming from @a cmd. - * @return #GNUNET_OK on success. - */ -int -ANASTASIS_TESTING_get_trait_hash (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct GNUNET_HashCode **h); - - -/** - * Offer a hash. - * - * @param index the number's index number. - * @param h the hash to offer. - * @return trait on success. - */ -struct TALER_TESTING_Trait -ANASTASIS_TESTING_make_trait_hash (unsigned int index, - const struct GNUNET_HashCode *h); - - -/** - * Obtain a truth decryption key from @a cmd. - * - * @param cmd command to extract the public key from. - * @param index usually 0 - * @param[out] key set to the account public key used in @a cmd. - * @return #GNUNET_OK on success. - */ -int -ANASTASIS_TESTING_get_trait_truth_key ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct ANASTASIS_CRYPTO_TruthKeyP **key); - - -/** - * Offer an truth decryption key. - * - * @param index usually zero - * @param h the account_pub to offer. - * @return trait on success. - */ -struct TALER_TESTING_Trait -ANASTASIS_TESTING_make_trait_truth_key ( - unsigned int index, - const struct ANASTASIS_CRYPTO_TruthKeyP *h); - - -/** - * Obtain an account public key from @a cmd. - * - * @param cmd command to extract the public key from. - * @param index usually 0 - * @param[out] pub set to the account public key used in @a cmd. - * @return #GNUNET_OK on success. - */ -int -ANASTASIS_TESTING_get_trait_account_pub ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct ANASTASIS_CRYPTO_AccountPublicKeyP **pub); - - -/** - * Offer an account public key. - * - * @param index usually zero - * @param h the account_pub to offer. - * @return trait on success - */ -struct TALER_TESTING_Trait -ANASTASIS_TESTING_make_trait_account_pub ( - unsigned int index, - const struct ANASTASIS_CRYPTO_AccountPublicKeyP *h); - - -/** - * Obtain an account private key from @a cmd. - * - * @param cmd command to extract the number from. - * @param index must be 0 - * @param[out] priv set to the account private key used in @a cmd. - * @return #GNUNET_OK on success. - */ -int -ANASTASIS_TESTING_get_trait_account_priv ( - const struct - TALER_TESTING_Command *cmd, - unsigned int index, - const struct ANASTASIS_CRYPTO_AccountPrivateKeyP **priv); - - -/** - * Offer an account private key. - * - * @param index usually zero - * @param priv the account_priv to offer. - * @return trait on success - */ -struct TALER_TESTING_Trait -ANASTASIS_TESTING_make_trait_account_priv ( - unsigned int index, - const struct - ANASTASIS_CRYPTO_AccountPrivateKeyP *priv); - -/** - * Obtain an account public key from @a cmd. - * - * @param cmd command to extract the payment identifier from. - * @param index the payment identifier's index number. - * @param[out] payment_secret set to the payment secret coming from @a cmd. - * @return #GNUNET_OK on success. - */ -int -ANASTASIS_TESTING_get_trait_payment_secret ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct ANASTASIS_PaymentSecretP **payment_secret); - - -/** - * Offer a payment secret. - * - * @param index usually zero - * @param h the payment secret to offer. - * @return trait on success - */ -struct TALER_TESTING_Trait -ANASTASIS_TESTING_make_trait_payment_secret ( - unsigned int index, - const struct ANASTASIS_PaymentSecretP *h); - - -/** - * Obtain an truth UUID from @a cmd. - * - * @param cmd command to extract the number from. - * @param index the number's index number. - * @param[out] tpk set to the number coming from @a cmd. - * @return #GNUNET_OK on success. - */ -int -ANASTASIS_TESTING_get_trait_truth_uuid ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct ANASTASIS_CRYPTO_TruthUUIDP **tpk); - - -/** - * Offer a truth UUID. - * - * @param index the number's index number. - * @param tpk the UUID to offer. - * @return trait on success - */ -struct TALER_TESTING_Trait -ANASTASIS_TESTING_make_trait_truth_uuid ( - unsigned int index, - const struct ANASTASIS_CRYPTO_TruthUUIDP *tpk); - /** - * Obtain an encrypted key share from @a cmd. - * - * @param cmd command to extract the number from. - * @param index the number's index number. - * @param[out] eks set to the key share coming from @a cmd. - * @return #GNUNET_OK on success. - */ -int -ANASTASIS_TESTING_get_trait_eks ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct ANASTASIS_CRYPTO_EncryptedKeyShareP **eks); - - -/** - * Offer an encrypted key share. - * - * @param index the number's index number. - * @param eks the encrypted key share to offer. - * @return trait on success - */ -struct TALER_TESTING_Trait -ANASTASIS_TESTING_make_trait_eks ( - unsigned int index, - const struct ANASTASIS_CRYPTO_EncryptedKeyShareP *eks); - - -/** - * Obtain a code from @a cmd. - * - * @param cmd command to extract the number from. - * @param index the number's index number. - * @param[out] code set to the number coming from @a cmd. - * @return #GNUNET_OK on success. - */ -int -ANASTASIS_TESTING_get_trait_code ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const char **code); - - -/** - * Offer an authentication code. - * - * @param index the number's index number. - * @param code the code to offer. - * @return trait on success - */ -struct TALER_TESTING_Trait -ANASTASIS_TESTING_make_trait_code (unsigned int index, - const char *code); + * Create headers for a trait with name @a name for + * statically allocated data of type @a type. + */ +#define ANASTASIS_TESTING_MAKE_DECL_SIMPLE_TRAIT(name,type) \ + enum GNUNET_GenericReturnValue \ + ANASTASIS_TESTING_get_trait_ ## name ( \ + const struct TALER_TESTING_Command *cmd, \ + type **ret); \ + struct TALER_TESTING_Trait \ + ANASTASIS_TESTING_make_trait_ ## name ( \ + type * value); + + +/** + * Create C implementation for a trait with name @a name for statically + * allocated data of type @a type. + */ +#define ANASTASIS_TESTING_MAKE_IMPL_SIMPLE_TRAIT(name,type) \ + enum GNUNET_GenericReturnValue \ + ANASTASIS_TESTING_get_trait_ ## name ( \ + const struct TALER_TESTING_Command *cmd, \ + type **ret) \ + { \ + if (NULL == cmd->traits) return GNUNET_SYSERR; \ + return cmd->traits (cmd->cls, \ + (const void **) ret, \ + TALER_S (name), \ + 0); \ + } \ + struct TALER_TESTING_Trait \ + ANASTASIS_TESTING_make_trait_ ## name ( \ + type * value) \ + { \ + struct TALER_TESTING_Trait ret = { \ + .trait_name = TALER_S (name), \ + .ptr = (const void *) value \ + }; \ + return ret; \ + } + + +/** + * Create headers for a trait with name @a name for + * statically allocated data of type @a type. + */ +#define ANASTASIS_TESTING_MAKE_DECL_INDEXED_TRAIT(name,type) \ + enum GNUNET_GenericReturnValue \ + ANASTASIS_TESTING_get_trait_ ## name ( \ + const struct TALER_TESTING_Command *cmd, \ + unsigned int index, \ + type **ret); \ + struct TALER_TESTING_Trait \ + ANASTASIS_TESTING_make_trait_ ## name ( \ + unsigned int index, \ + type * value); + + +/** + * Create C implementation for a trait with name @a name for statically + * allocated data of type @a type. + */ +#define ANASTASIS_TESTING_MAKE_IMPL_INDEXED_TRAIT(name,type) \ + enum GNUNET_GenericReturnValue \ + ANASTASIS_TESTING_get_trait_ ## name ( \ + const struct TALER_TESTING_Command *cmd, \ + unsigned int index, \ + type **ret) \ + { \ + if (NULL == cmd->traits) return GNUNET_SYSERR; \ + return cmd->traits (cmd->cls, \ + (const void **) ret, \ + TALER_S (name), \ + index); \ + } \ + struct TALER_TESTING_Trait \ + ANASTASIS_TESTING_make_trait_ ## name ( \ + unsigned int index, \ + type * value) \ + { \ + struct TALER_TESTING_Trait ret = { \ + .index = index, \ + .trait_name = TALER_S (name), \ + .ptr = (const void *) value \ + }; \ + return ret; \ + } + + +/** + * Call #op on all simple traits. + */ +#define ANASTASIS_TESTING_SIMPLE_TRAITS(op) \ + op (hash, const struct GNUNET_HashCode) \ + op (truth, const struct ANASTASIS_Truth *) \ + op (policy, const struct ANASTASIS_Policy *) \ + op (salt, const struct ANASTASIS_CRYPTO_ProviderSaltP) \ + op (core_secret, const void *) \ + op (truth_key, const struct ANASTASIS_CRYPTO_TruthKeyP) \ + op (account_pub, const struct ANASTASIS_CRYPTO_AccountPublicKeyP) \ + op (account_priv, const struct ANASTASIS_CRYPTO_AccountPrivateKeyP) \ + op (payment_secret, const struct ANASTASIS_PaymentSecretP) \ + op (truth_uuid, const struct ANASTASIS_CRYPTO_TruthUUIDP) \ + op (eks, const struct ANASTASIS_CRYPTO_EncryptedKeyShareP) \ + op (code, const char *) \ + op (filename, const char *) + + +/** + * Call #op on all indexed traits. + */ +#define ANASTASIS_TESTING_INDEXED_TRAITS(op) \ + op (challenges, const struct ANASTASIS_Challenge *) + + +ANASTASIS_TESTING_SIMPLE_TRAITS (ANASTASIS_TESTING_MAKE_DECL_SIMPLE_TRAIT) + +ANASTASIS_TESTING_INDEXED_TRAITS (ANASTASIS_TESTING_MAKE_DECL_INDEXED_TRAIT) /** @@ -505,34 +399,6 @@ ANASTASIS_TESTING_cmd_keyshare_lookup ( /** - * Obtain a salt from @a cmd. - * - * @param cmd command to extract the salt from. - * @param index the salt's index number. - * @param[out] s set to the salt coming from @a cmd. - * @return #GNUNET_OK on success. - */ -int -ANASTASIS_TESTING_get_trait_salt ( - const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct ANASTASIS_CRYPTO_ProviderSaltP **s); - - -/** - * Offer an salt. - * - * @param index the salt's index number. - * @param s the salt to offer. - * @return trait on success - */ -struct TALER_TESTING_Trait -ANASTASIS_TESTING_make_trait_salt ( - unsigned int index, - const struct ANASTASIS_CRYPTO_ProviderSaltP *s); - - -/** * Make the "/config" command. * * @param label command label @@ -549,31 +415,6 @@ ANASTASIS_TESTING_cmd_config (const char *label, /* ********************* test truth upload ********************* */ /** - * Obtain a truth from @a cmd. - * - * @param cmd command to extract the truth from. - * @param index the index of the truth - * @param[out] t set to the truth coming from @a cmd. - * @return #GNUNET_OK on success. - */ -int -ANASTASIS_TESTING_get_trait_truth (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct ANASTASIS_Truth **t); - - -/** - * Offer a truth. - * - * @param index the truth's index number. - * @param t the truth to offer. - * @return trait on success - */ -struct TALER_TESTING_Trait -ANASTASIS_TESTING_make_trait_truth (unsigned int index, - const struct ANASTASIS_Truth *t); - -/** * Creates a sample of id_data. * * @param id_data some sample data (e.g. AHV, name, surname, ...) @@ -642,31 +483,6 @@ ANASTASIS_TESTING_cmd_truth_upload_question ( /* ********************* test policy create ********************* */ -/** - * Obtain a policy from @a cmd. - * - * @param cmd command to extract the policy from. - * @param index the index of the policy - * @param[out] p set to the policy coming from @a cmd. - * @return #GNUNET_OK on success. - */ -int -ANASTASIS_TESTING_get_trait_policy (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct ANASTASIS_Policy **p); - - -/** - * Offer a policy. - * - * @param index the policy's index number. - * @param p the policy to offer. - * @return trait on success - */ -struct TALER_TESTING_Trait -ANASTASIS_TESTING_make_trait_policy (unsigned int index, - const struct ANASTASIS_Policy *p); - /** * Make the "policy create" command. @@ -682,31 +498,6 @@ ANASTASIS_TESTING_cmd_policy_create (const char *label, /* ********************* test secret share ********************* */ -/** - * Obtain the core secret from @a cmd. - * - * @param cmd command to extract the core secret from. - * @param index the index of the core secret (usually 0) - * @param[out] s set to the core secret coming from @a cmd. - * @return #GNUNET_OK on success. - */ -int -ANASTASIS_TESTING_get_trait_core_secret (const struct - TALER_TESTING_Command *cmd, - unsigned int index, - const void **s); - - -/** - * Offer the core secret. - * - * @param index the core secret's index number (usually 0). - * @param s the core secret to offer. - * @return trait on success - */ -struct TALER_TESTING_Trait -ANASTASIS_TESTING_make_trait_core_secret (unsigned int index, - const void *s); /** * Types of options for performing the secret sharing. Used as a bitmask. @@ -824,30 +615,6 @@ ANASTASIS_TESTING_cmd_recover_secret_finish ( /* ********************* test challenge answer ********************* */ -/** - * Obtain a challenge from @a cmd. - * - * @param cmd command to extract the challenge from. - * @param index the index of the challenge - * @param[out] c set to the challenge coming from @a cmd. - * @return #GNUNET_OK on success. - */ -int -ANASTASIS_TESTING_get_trait_challenge (const struct TALER_TESTING_Command *cmd, - unsigned int index, - const struct ANASTASIS_Challenge **c); - -/** - * Offer a challenge. - * - * @param index the challenge index number. - * @param r the challenge to offer. - * @return trait on success - */ -struct TALER_TESTING_Trait -ANASTASIS_TESTING_make_trait_challenge (unsigned int index, - const struct ANASTASIS_Challenge *r); - /** * Create a "challenge start" command. Suitable for the "file" |