From 0fd6cf19afc8091494ba1b2adcf2b4b2c7bcadcb Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 7 Aug 2016 23:21:49 +0200 Subject: mostly working migration of the DH-seeded refresh variant --- src/exchange-lib/exchange_api_refresh_link.c | 6 +- src/exchange/taler-exchange-httpd_refresh.c | 5 +- src/exchangedb/perf_taler_exchangedb_init.c | 3 - src/exchangedb/plugin_exchangedb_postgres.c | 6 +- src/exchangedb/test_exchangedb.c | 104 ++++++++------------------- src/include/taler_crypto_lib.h | 20 ------ 6 files changed, 39 insertions(+), 105 deletions(-) (limited to 'src') diff --git a/src/exchange-lib/exchange_api_refresh_link.c b/src/exchange-lib/exchange_api_refresh_link.c index 31c27fe98..a1dba9938 100644 --- a/src/exchange-lib/exchange_api_refresh_link.c +++ b/src/exchange-lib/exchange_api_refresh_link.c @@ -209,8 +209,10 @@ parse_refresh_link_ok (struct TALER_EXCHANGE_RefreshLinkHandle *rlh, json_t *jsona; struct TALER_TransferPublicKeyP trans_pub; struct GNUNET_JSON_Specification spec[] = { - GNUNET_JSON_spec_json ("new_coins", &jsona), - GNUNET_JSON_spec_fixed_auto ("transfer_pub", &trans_pub), + GNUNET_JSON_spec_json ("new_coins", + &jsona), + GNUNET_JSON_spec_fixed_auto ("transfer_pub", + &trans_pub), GNUNET_JSON_spec_end() }; diff --git a/src/exchange/taler-exchange-httpd_refresh.c b/src/exchange/taler-exchange-httpd_refresh.c index 3dbffe511..655749eb0 100644 --- a/src/exchange/taler-exchange-httpd_refresh.c +++ b/src/exchange/taler-exchange-httpd_refresh.c @@ -425,7 +425,9 @@ handle_refresh_melt_json (struct MHD_Connection *connection, /* parse JSON arrays into binary arrays and hash everything together for the signature check */ - memset (commit_coin, 0, sizeof (commit_coin)); + memset (commit_coin, + 0, + sizeof (commit_coin)); for (i = 0; i < TALER_CNC_KAPPA; i++) { commit_coin[i] = GNUNET_new_array (num_newcoins, @@ -454,7 +456,6 @@ handle_refresh_melt_json (struct MHD_Connection *connection, GNUNET_CRYPTO_hash_context_read (hash_context, rcc->coin_ev, rcc->coin_ev_size); - GNUNET_JSON_parse_free (coin_spec); } } diff --git a/src/exchangedb/perf_taler_exchangedb_init.c b/src/exchangedb/perf_taler_exchangedb_init.c index 3b14a19ce..1694dc06b 100644 --- a/src/exchangedb/perf_taler_exchangedb_init.c +++ b/src/exchangedb/perf_taler_exchangedb_init.c @@ -575,9 +575,6 @@ PERF_TALER_EXCHANGEDB_refresh_commit_coin_init () struct TALER_EXCHANGEDB_RefreshCommitCoin *commit_coin; commit_coin = GNUNET_new (struct TALER_EXCHANGEDB_RefreshCommitCoin); - GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, - &commit_coin->refresh_link, - sizeof(struct TALER_RefreshLinkEncryptedP)); commit_coin->coin_ev = "coin_ev"; commit_coin->coin_ev_size = 8; return commit_coin; diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 47d59c862..0c4f908c3 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -3464,7 +3464,7 @@ postgres_get_link_data_list (void *cls, return NULL; } - for (i = 0; i < nrows; i++) + for (i = nrows-1; i >= 0; i--) { struct GNUNET_CRYPTO_RsaPublicKey *denom_pub; struct GNUNET_CRYPTO_RsaSignature *sig; @@ -3481,7 +3481,9 @@ postgres_get_link_data_list (void *cls, }; if (GNUNET_OK != - GNUNET_PQ_extract_result (result, rs, i)) + GNUNET_PQ_extract_result (result, + rs, + i)) { PQclear (result); GNUNET_break (0); diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 61972d2de..a053c87f4 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -297,26 +297,6 @@ static struct TALER_Amount fee_refund; static struct TALER_Amount amount_with_fee; -/** - * Compare two coin encrypted refresh links. - * - * @param rc1 first commitment - * @param rc2 second commitment - * @return 0 if they are equal - */ -static int -refresh_link_encrypted_cmp (struct TALER_RefreshLinkEncryptedP *rl1, - struct TALER_RefreshLinkEncryptedP *rl2) -{ - if (0 == - memcmp (rl1, - rl2, - sizeof (struct TALER_RefreshLinkEncryptedP))) - return 0; - return 1; -} - - /** * Compare two coin commitments. * @@ -332,11 +312,9 @@ commit_coin_cmp (struct TALER_EXCHANGEDB_RefreshCommitCoin *rc1, FAILIF (0 != memcmp (rc1->coin_ev, rc2->coin_ev, rc2->coin_ev_size)); - FAILIF (0 != - refresh_link_encrypted_cmp (&rc1->refresh_link, - &rc2->refresh_link)); return 0; drop: + GNUNET_break (0); return 1; } @@ -369,9 +347,7 @@ test_refresh_commit_coins (struct TALER_EXCHANGEDB_Session *session, { struct TALER_EXCHANGEDB_RefreshCommitCoin *ret_commit_coins; struct TALER_EXCHANGEDB_RefreshCommitCoin *a_ccoin; - struct TALER_RefreshLinkEncryptedP a_rlink; struct TALER_EXCHANGEDB_RefreshCommitCoin *b_ccoin; - struct TALER_RefreshLinkEncryptedP b_rlink; unsigned int cnt; uint16_t cnc_index; int ret; @@ -387,13 +363,8 @@ test_refresh_commit_coins (struct TALER_EXCHANGEDB_Session *session, for (cnt=0; cnt < MELT_NEW_COINS; cnt++) { struct TALER_EXCHANGEDB_RefreshCommitCoin *ccoin; - struct TALER_RefreshLinkEncryptedP rlink; ccoin = &commit_coins[cnc_index][cnt]; - GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, - &rlink, - sizeof (rlink)); - ccoin->refresh_link = rlink; ccoin->coin_ev_size = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, COIN_ENC_MAX_SIZE); ccoin->coin_ev = GNUNET_malloc (ccoin->coin_ev_size); @@ -426,14 +397,6 @@ test_refresh_commit_coins (struct TALER_EXCHANGEDB_Session *session, FAILIF (0 != memcmp (a_ccoin->coin_ev, a_ccoin->coin_ev, a_ccoin->coin_ev_size)); - a_rlink = a_ccoin->refresh_link; - b_rlink = b_ccoin->refresh_link; - FAILIF (0 != memcmp (a_rlink.blinding_key_enc, - b_rlink.blinding_key_enc, - sizeof (a_rlink.blinding_key_enc))); - FAILIF (0 != memcmp (a_rlink.coin_priv_enc, - b_rlink.coin_priv_enc, - sizeof (a_rlink.coin_priv_enc))); GNUNET_free (ret_commit_coins[cnt].coin_ev); } GNUNET_free (ret_commit_coins); @@ -453,7 +416,7 @@ test_refresh_commit_coins (struct TALER_EXCHANGEDB_Session *session, } -static struct TALER_RefreshCommitLinkP rclp[TALER_CNC_KAPPA]; +static struct TALER_TransferPublicKeyP rctp[TALER_CNC_KAPPA]; /** @@ -469,37 +432,37 @@ test_refresh_commit_links (struct TALER_EXCHANGEDB_Session *session, const struct TALER_EXCHANGEDB_RefreshSession *refresh_session, const struct GNUNET_HashCode *session_hash) { - struct TALER_RefreshCommitLinkP cl2; int ret; unsigned int i; + struct TALER_TransferPublicKeyP tp; ret = GNUNET_SYSERR; FAILIF (GNUNET_NO != - plugin->get_refresh_commit_link (plugin->cls, - session, - session_hash, - MELT_NOREVEAL_INDEX, - &cl2)); + plugin->get_refresh_transfer_public_key (plugin->cls, + session, + session_hash, + MELT_NOREVEAL_INDEX, + &tp)); for (i=0;iinsert_refresh_commit_link (plugin->cls, - session, - session_hash, - i, - &rclp[i])); + plugin->insert_refresh_transfer_public_key (plugin->cls, + session, + session_hash, + i, + &rctp[i])); FAILIF (GNUNET_OK != - plugin->get_refresh_commit_link (plugin->cls, - session, - session_hash, - i, - &cl2)); + plugin->get_refresh_transfer_public_key (plugin->cls, + session, + session_hash, + i, + &tp)); FAILIF (0 != - memcmp (&rclp[i], - &cl2, - sizeof (struct TALER_RefreshCommitLinkP))); + memcmp (&rctp[i], + &tp, + sizeof (struct TALER_TransferPublicKeyP))); } ret = GNUNET_OK; drop: @@ -517,22 +480,17 @@ static struct GNUNET_HashCode session_hash; * @param cls closure * @param sh a session the coin was melted in * @param transfer_pub public transfer key for the session - * @param shared_secret_enc set to shared secret for the session */ static void check_transfer_data (void *cls, const struct GNUNET_HashCode *sh, - const struct TALER_TransferPublicKeyP *transfer_pub, - const struct TALER_EncryptedLinkSecretP *shared_secret_enc) + const struct TALER_TransferPublicKeyP *transfer_pub) { int *ok = cls; - FAILIF (0 != memcmp (&rclp[MELT_NOREVEAL_INDEX].transfer_pub, + FAILIF (0 != memcmp (&rctp[MELT_NOREVEAL_INDEX], transfer_pub, sizeof (struct TALER_TransferPublicKeyP))); - FAILIF (0 != memcmp (&rclp[MELT_NOREVEAL_INDEX].shared_secret_enc, - shared_secret_enc, - sizeof (struct TALER_EncryptedLinkSecretP))); FAILIF (0 != memcmp (&session_hash, sh, sizeof (struct GNUNET_HashCode))); @@ -711,9 +669,9 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) for (i=0;icommit_links[i], - sizeof (struct TALER_RefreshCommitLinkP))); + memcmp (&rctp[i], + &mc->transfer_pubs[i], + sizeof (struct TALER_TransferPublicKeyP))); } plugin->free_melt_commitment (plugin->cls, mc); @@ -741,24 +699,18 @@ test_melting (struct TALER_EXCHANGEDB_Session *session) FAILIF (NULL == ldl); for (ldlp = ldl; NULL != ldlp; ldlp = ldlp->next) { - struct TALER_RefreshLinkEncryptedP r1; - struct TALER_RefreshLinkEncryptedP r2; int found; found = GNUNET_NO; for (cnt=0;cnt < MELT_NEW_COINS;cnt++) { - r1 = commit_coins[MELT_NOREVEAL_INDEX][cnt].refresh_link; - r2 = ldlp->link_data_enc; FAILIF (NULL == ldlp->ev_sig.rsa_signature); if ( (0 == GNUNET_CRYPTO_rsa_public_key_cmp (ldlp->denom_pub.rsa_public_key, new_dkp[cnt]->pub.rsa_public_key)) && (0 == GNUNET_CRYPTO_rsa_signature_cmp (ldlp->ev_sig.rsa_signature, - ev_sigs[cnt].rsa_signature)) && - (0 == - refresh_link_encrypted_cmp (&r1, &r2)) ) + ev_sigs[cnt].rsa_signature)) ) { found = GNUNET_YES; break; diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h index e8e8f3a03..269c1c62c 100644 --- a/src/include/taler_crypto_lib.h +++ b/src/include/taler_crypto_lib.h @@ -475,26 +475,6 @@ struct TALER_WireTransferIdentifierP }; -/** - * @brief Representation of an encrypted refresh link. - */ -struct TALER_RefreshLinkEncryptedP -{ - - /** - * Encrypted blinding key with @e blinding_key_enc_size bytes, - * must be allocated at the end of this struct. - */ - char blinding_key_enc[sizeof (struct TALER_DenominationBlindingKeyP)]; - - /** - * Encrypted private key of the coin. - */ - char coin_priv_enc[sizeof (struct TALER_CoinSpendPrivateKeyP)]; - -}; - - GNUNET_NETWORK_STRUCT_END /** -- cgit v1.2.3