diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-02-07 13:14:25 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-02-07 13:14:25 +0100 |
commit | b2e6fcae1a9b96f086c61f13f4c2c98338c4e414 (patch) | |
tree | 6c5c8c264ca674dd8c0e303daf3207bbaff65315 /src/exchangedb | |
parent | b9ea075d61dcd47951b2f7f962025476c045aa57 (diff) | |
download | exchange-b2e6fcae1a9b96f086c61f13f4c2c98338c4e414.tar.xz |
fix DB API for generic blinded planchet storage
Diffstat (limited to 'src/exchangedb')
-rw-r--r-- | src/exchangedb/plugin_exchangedb_postgres.c | 13 | ||||
-rw-r--r-- | src/exchangedb/test_exchangedb.c | 45 |
2 files changed, 25 insertions, 33 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c index 713e11e81..9694b73ce 100644 --- a/src/exchangedb/plugin_exchangedb_postgres.c +++ b/src/exchangedb/plugin_exchangedb_postgres.c @@ -6094,8 +6094,7 @@ postgres_insert_refresh_reveal ( GNUNET_PQ_query_param_uint32 (&i), GNUNET_PQ_query_param_auto_from_type (&rrc->orig_coin_link_sig), GNUNET_PQ_query_param_auto_from_type (&rrc->h_denom_pub), - GNUNET_PQ_query_param_fixed_size (rrc->coin_ev, - rrc->coin_ev_size), + TALER_PQ_query_param_blinded_planchet (&rrc->blinded_planchet), GNUNET_PQ_query_param_auto_from_type (&rrc->coin_envelope_hash), TALER_PQ_query_param_blinded_denom_sig (&rrc->coin_sig), GNUNET_PQ_query_param_end @@ -6202,15 +6201,14 @@ add_revealed_coins (void *cls, &rrc->orig_coin_link_sig), GNUNET_PQ_result_spec_auto_from_type ("h_coin_ev", &rrc->coin_envelope_hash), - GNUNET_PQ_result_spec_variable_size ("coin_ev", - (void **) &rrc->coin_ev, - &rrc->coin_ev_size), + TALER_PQ_result_spec_blinded_planchet ("coin_ev", + &rrc->blinded_planchet), TALER_PQ_result_spec_blinded_denom_sig ("ev_sig", &rrc->coin_sig), GNUNET_PQ_result_spec_end }; - if (NULL != rrc->coin_ev) + if (TALER_DENOMINATION_INVALID != rrc->blinded_planchet.cipher) { /* duplicate offset, not allowed */ GNUNET_break (0); @@ -6293,10 +6291,9 @@ cleanup: struct TALER_EXCHANGEDB_RefreshRevealedCoin *rrc = &grctx.rrcs[i]; TALER_blinded_denom_sig_free (&rrc->coin_sig); - GNUNET_free (rrc->coin_ev); + TALER_blinded_planchet_free (&rrc->blinded_planchet); } GNUNET_free (grctx.rrcs); - return qs; } diff --git a/src/exchangedb/test_exchangedb.c b/src/exchangedb/test_exchangedb.c index 952d329fe..f86f5451c 100644 --- a/src/exchangedb/test_exchangedb.c +++ b/src/exchangedb/test_exchangedb.c @@ -433,10 +433,9 @@ check_refresh_reveal_cb ( &revealed_coins[cnt]; const struct TALER_EXCHANGEDB_RefreshRevealedCoin *bcoin = &rrcs[cnt]; - GNUNET_assert (acoin->coin_ev_size == bcoin->coin_ev_size); GNUNET_assert (0 == - GNUNET_memcmp (acoin->coin_ev, - bcoin->coin_ev)); + TALER_blinded_planchet_cmp (&acoin->blinded_planchet, + &bcoin->blinded_planchet)); GNUNET_assert (0 == GNUNET_memcmp (&acoin->h_denom_pub, &bcoin->h_denom_pub)); @@ -1735,8 +1734,8 @@ run (void *cls) { struct TALER_EXCHANGEDB_RefreshRevealedCoin *ccoin; struct GNUNET_TIME_Timestamp now; - struct TALER_BlindedPlanchet blinded_planchet; - + struct TALER_BlindedRsaPlanchet *rp; + struct TALER_BlindedPlanchet *bp; now = GNUNET_TIME_timestamp_get (); new_dkp[cnt] = create_denom_key_pair (RSA_KEY_SIZE, @@ -1749,31 +1748,25 @@ run (void *cls) GNUNET_assert (NULL != new_dkp[cnt]); new_denom_pubs[cnt] = new_dkp[cnt]->pub; ccoin = &revealed_coins[cnt]; - ccoin->coin_ev_size = 1 + (size_t) GNUNET_CRYPTO_random_u64 ( + bp = &ccoin->blinded_planchet; + bp->cipher = TALER_DENOMINATION_RSA; + rp = &bp->details.rsa_blinded_planchet; + rp->blinded_msg_size = 1 + (size_t) GNUNET_CRYPTO_random_u64 ( GNUNET_CRYPTO_QUALITY_WEAK, (RSA_KEY_SIZE / 8) - 1); - ccoin->coin_ev = GNUNET_malloc (ccoin->coin_ev_size); + rp->blinded_msg = GNUNET_malloc (rp->blinded_msg_size); GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK, - ccoin->coin_ev, - ccoin->coin_ev_size); - - blinded_planchet.cipher = TALER_DENOMINATION_RSA; - blinded_planchet.details.rsa_blinded_planchet.blinded_msg = - ccoin->coin_ev; - blinded_planchet.details.rsa_blinded_planchet.blinded_msg_size = - ccoin->coin_ev_size; - + rp->blinded_msg, + rp->blinded_msg_size); TALER_denom_pub_hash (&new_dkp[cnt]->pub, &ccoin->h_denom_pub); - TALER_coin_ev_hash (&blinded_planchet, + TALER_coin_ev_hash (bp, &ccoin->h_denom_pub, &ccoin->coin_envelope_hash); - - GNUNET_assert (GNUNET_OK == TALER_denom_sign_blinded (&ccoin->coin_sig, &new_dkp[cnt]->priv, - &blinded_planchet)); + bp)); } RND_BLK (&tprivs); RND_BLK (&tpub); @@ -1793,11 +1786,13 @@ run (void *cls) { struct TALER_BlindedCoinHash h_coin_ev; struct TALER_CoinSpendPublicKeyP ocp; + struct TALER_DenominationHash denom_hash; - GNUNET_CRYPTO_hash (revealed_coins[0].coin_ev, - revealed_coins[0].coin_ev_size, - &h_coin_ev.hash); - + TALER_denom_pub_hash (&new_denom_pubs[0], + &denom_hash); + TALER_coin_ev_hash (&revealed_coins[0].blinded_planchet, + &denom_hash, + &h_coin_ev); FAILIF (GNUNET_DB_STATUS_SUCCESS_ONE_RESULT != plugin->get_old_coin_by_h_blind (plugin->cls, &h_coin_ev, @@ -2406,7 +2401,7 @@ drop: for (unsigned int cnt = 0; cnt < MELT_NEW_COINS; cnt++) { TALER_blinded_denom_sig_free (&revealed_coins[cnt].coin_sig); - GNUNET_free (revealed_coins[cnt].coin_ev); + TALER_blinded_planchet_free (&revealed_coins[cnt].blinded_planchet); } GNUNET_free (revealed_coins); revealed_coins = NULL; |