diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/exchange/taler-exchange-httpd.c | 4 | ||||
| -rw-r--r-- | src/exchange/taler-exchange-httpd_management.h | 2 | ||||
| -rw-r--r-- | src/exchange/taler-exchange-httpd_management_denominations_HDP_revoke.c | 2 | ||||
| -rw-r--r-- | src/exchange/taler-exchange-httpd_management_post_keys.c | 14 | ||||
| -rw-r--r-- | src/exchange/taler-exchange-httpd_refreshes_reveal.c | 19 | ||||
| -rw-r--r-- | src/exchange/taler-exchange-httpd_refund.c | 2 | ||||
| -rw-r--r-- | src/exchange/taler-exchange-httpd_responses.c | 5 | ||||
| -rw-r--r-- | src/exchange/taler-exchange-httpd_withdraw.c | 30 | ||||
| -rw-r--r-- | src/include/taler_crypto_lib.h | 12 | ||||
| -rw-r--r-- | src/util/denom.c | 19 | 
10 files changed, 69 insertions, 40 deletions
| diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index 1feede1a..0f9ab769 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -540,7 +540,7 @@ handle_post_management (struct TEH_RequestContext *rc,    if (0 == strcmp (args[0],                     "denominations"))    { -    struct GNUNET_HashCode h_denom_pub; +    struct TALER_DenominationHash h_denom_pub;      if ( (NULL == args[0]) ||           (NULL == args[1]) || @@ -681,7 +681,7 @@ handle_post_auditors (struct TEH_RequestContext *rc,                        const char *const args[])  {    struct TALER_AuditorPublicKeyP auditor_pub; -  struct GNUNET_HashCode h_denom_pub; +  struct TALER_DenominationHash h_denom_pub;    if ( (NULL == args[0]) ||         (NULL == args[1]) || diff --git a/src/exchange/taler-exchange-httpd_management.h b/src/exchange/taler-exchange-httpd_management.h index 3f58083e..d46aad9e 100644 --- a/src/exchange/taler-exchange-httpd_management.h +++ b/src/exchange/taler-exchange-httpd_management.h @@ -64,7 +64,7 @@ TEH_handler_management_auditors_AP_disable (  MHD_RESULT  TEH_handler_management_denominations_HDP_revoke (    struct MHD_Connection *connection, -  const struct GNUNET_HashCode *h_denom_pub, +  const struct TALER_DenominationHash *h_denom_pub,    const json_t *root); diff --git a/src/exchange/taler-exchange-httpd_management_denominations_HDP_revoke.c b/src/exchange/taler-exchange-httpd_management_denominations_HDP_revoke.c index 6519404d..a8acf2f7 100644 --- a/src/exchange/taler-exchange-httpd_management_denominations_HDP_revoke.c +++ b/src/exchange/taler-exchange-httpd_management_denominations_HDP_revoke.c @@ -34,7 +34,7 @@  MHD_RESULT  TEH_handler_management_denominations_HDP_revoke (    struct MHD_Connection *connection, -  const struct GNUNET_HashCode *h_denom_pub, +  const struct TALER_DenominationHash *h_denom_pub,    const json_t *root)  {    struct TALER_MasterSignatureP master_sig; diff --git a/src/exchange/taler-exchange-httpd_management_post_keys.c b/src/exchange/taler-exchange-httpd_management_post_keys.c index 311fff78..b8f8922f 100644 --- a/src/exchange/taler-exchange-httpd_management_post_keys.c +++ b/src/exchange/taler-exchange-httpd_management_post_keys.c @@ -40,7 +40,7 @@ struct DenomSig    /**     * Hash of a denomination public key.     */ -  struct GNUNET_HashCode h_denom_pub; +  struct TALER_DenominationHash h_denom_pub;    /**     * Master signature for the @e h_denom_pub. @@ -156,14 +156,14 @@ add_keys (void *cls,            connection,            MHD_HTTP_INTERNAL_SERVER_ERROR,            TALER_EC_EXCHANGE_GENERIC_BAD_CONFIGURATION, -          GNUNET_h2s (&akc->d_sigs[i].h_denom_pub)); +          GNUNET_h2s (&akc->d_sigs[i].h_denom_pub.hash));          return GNUNET_DB_STATUS_HARD_ERROR;        case GNUNET_NO:          *mhd_ret = TALER_MHD_reply_with_error (            connection,            MHD_HTTP_NOT_FOUND,            TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN, -          GNUNET_h2s (&akc->d_sigs[i].h_denom_pub)); +          GNUNET_h2s (&akc->d_sigs[i].h_denom_pub.hash));          return GNUNET_DB_STATUS_HARD_ERROR;        case GNUNET_OK:          break; @@ -196,7 +196,7 @@ add_keys (void *cls,            connection,            MHD_HTTP_FORBIDDEN,            TALER_EC_EXCHANGE_MANAGEMENT_KEYS_DENOMKEY_ADD_SIGNATURE_INVALID, -          GNUNET_h2s (&akc->d_sigs[i].h_denom_pub)); +          GNUNET_h2s (&akc->d_sigs[i].h_denom_pub.hash));          return GNUNET_DB_STATUS_HARD_ERROR;        }      } @@ -208,7 +208,7 @@ add_keys (void *cls,        &denom_pub,        &meta,        &akc->d_sigs[i].master_sig); -    GNUNET_CRYPTO_rsa_public_key_free (denom_pub.rsa_public_key); +    TALER_denom_pub_free (&denom_pub);      if (qs < 0)      {        if (GNUNET_DB_STATUS_SOFT_ERROR == qs) @@ -222,7 +222,7 @@ add_keys (void *cls,      }      GNUNET_log (GNUNET_ERROR_TYPE_INFO,                  "Added offline signature for denomination `%s'\n", -                GNUNET_h2s (&akc->d_sigs[i].h_denom_pub)); +                GNUNET_h2s (&akc->d_sigs[i].h_denom_pub.hash));      GNUNET_assert (0 != qs);    } @@ -284,7 +284,7 @@ add_keys (void *cls,            connection,            MHD_HTTP_FORBIDDEN,            TALER_EC_EXCHANGE_MANAGEMENT_KEYS_SIGNKEY_ADD_SIGNATURE_INVALID, -          GNUNET_h2s (&akc->d_sigs[i].h_denom_pub)); +          GNUNET_h2s (&akc->d_sigs[i].h_denom_pub.hash));          return GNUNET_DB_STATUS_HARD_ERROR;        }      } diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.c b/src/exchange/taler-exchange-httpd_refreshes_reveal.c index 4ca6bd15..7c891bf3 100644 --- a/src/exchange/taler-exchange-httpd_refreshes_reveal.c +++ b/src/exchange/taler-exchange-httpd_refreshes_reveal.c @@ -68,8 +68,8 @@ reply_refreshes_reveal_success (struct MHD_Connection *connection,      json_t *obj;      obj = GNUNET_JSON_PACK ( -      GNUNET_JSON_pack_rsa_signature ("ev_sig", -                                      sigs[freshcoin_index].rsa_signature)); +      TALER_JSON_pack_denomination_signature ("ev_sig", +                                              &sigs[freshcoin_index]));      GNUNET_assert (0 ==                     json_array_append_new (list,                                            obj)); @@ -189,8 +189,8 @@ check_exists_cb (void *cls,      rctx->ev_sigs = GNUNET_new_array (num_freshcoins,                                        struct TALER_DenominationSignature);      for (unsigned int i = 0; i<num_freshcoins; i++) -      rctx->ev_sigs[i].rsa_signature -        = GNUNET_CRYPTO_rsa_signature_dup (rrcs[i].coin_sig.rsa_signature); +      TALER_denom_sig_deep_copy (&rctx->ev_sigs[i], +                                 &rrcs[i].coin_sig);    }  } @@ -334,7 +334,7 @@ refreshes_reveal_transaction (void *cls,            struct TALER_RefreshCoinData *rcd = &rce->new_coins[j];            struct TALER_PlanchetSecretsP ps;            struct TALER_PlanchetDetail pd; -          struct GNUNET_HashCode c_hash; +          struct TALER_CoinPubHash c_hash;            rcd->dk = &rctx->dks[j]->denom_pub;            TALER_planchet_setup_refresh (&ts, @@ -500,7 +500,7 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection,    unsigned int num_fresh_coins = json_array_size (new_denoms_h_json);    /* We know num_fresh_coins is bounded by #MAX_FRESH_COINS, so this is safe */    const struct TEH_DenominationKey *dks[num_fresh_coins]; -  struct GNUNET_HashCode dk_h[num_fresh_coins]; +  struct TALER_DenominationHash dk_h[num_fresh_coins];    struct TALER_RefreshCoinData rcds[num_fresh_coins];    struct TALER_CoinSpendSignatureP link_sigs[num_fresh_coins];    struct TALER_EXCHANGEDB_Melt melt; @@ -686,7 +686,7 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection,                                      struct TALER_DenominationSignature);    for (unsigned int i = 0; i<rctx->num_fresh_coins; i++)    { -    enum TALER_ErrorCode ec; +    enum TALER_ErrorCode ec = TALER_EC_NONE;      rctx->ev_sigs[i]        = TEH_keys_denomination_sign ( @@ -694,7 +694,7 @@ resolve_refreshes_reveal_denominations (struct MHD_Connection *connection,            rctx->rcds[i].coin_ev,            rctx->rcds[i].coin_ev_size,            &ec); -    if (NULL == rctx->ev_sigs[i].rsa_signature) +    if (TALER_EC_NONE != ec)      {        GNUNET_break (0);        ret = TALER_MHD_reply_with_ec (connection, @@ -769,8 +769,7 @@ cleanup:    if (NULL != rctx->ev_sigs)    {      for (unsigned int i = 0; i<num_fresh_coins; i++) -      if (NULL != rctx->ev_sigs[i].rsa_signature) -        GNUNET_CRYPTO_rsa_signature_free (rctx->ev_sigs[i].rsa_signature); +      TALER_denom_sig_free (&rctx->ev_sigs[i]);      GNUNET_free (rctx->ev_sigs);      rctx->ev_sigs = NULL; /* just to be safe... */    } diff --git a/src/exchange/taler-exchange-httpd_refund.c b/src/exchange/taler-exchange-httpd_refund.c index 73b4b251..be8a88df 100644 --- a/src/exchange/taler-exchange-httpd_refund.c +++ b/src/exchange/taler-exchange-httpd_refund.c @@ -370,7 +370,7 @@ static MHD_RESULT  verify_and_execute_refund (struct MHD_Connection *connection,                             struct TALER_EXCHANGEDB_Refund *refund)  { -  struct GNUNET_HashCode denom_hash; +  struct TALER_DenominationHash denom_hash;    {      struct TALER_RefundRequestPS rr = { diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c index 8fc21731..6747e3bf 100644 --- a/src/exchange/taler-exchange-httpd_responses.c +++ b/src/exchange/taler-exchange-httpd_responses.c @@ -779,9 +779,8 @@ TEH_RESPONSE_compile_reserve_history (                               &value);            TALER_amount_hton (&rcc.closing_fee,                               &closing->closing_fee); -          GNUNET_CRYPTO_hash (closing->receiver_account_details, -                              strlen (closing->receiver_account_details) + 1, -                              &rcc.h_wire); +          TALER_payto_hash (closing->receiver_account_details, +                            &rcc.h_payto);            if (TALER_EC_NONE !=                TEH_keys_exchange_sign (&rcc,                                        &pub, diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c index 4839ec97..e5ba2b2e 100644 --- a/src/exchange/taler-exchange-httpd_withdraw.c +++ b/src/exchange/taler-exchange-httpd_withdraw.c @@ -107,7 +107,7 @@ struct WithdrawContext    /**     * Hash of the denomination public key.     */ -  struct GNUNET_HashCode denom_pub_hash; +  struct TALER_DenominationHash denom_pub_hash;    /**     * Signature over the request. @@ -205,7 +205,9 @@ withdraw_transaction (void *cls,    /* store away optimistic signature to protect       it from being overwritten by get_withdraw_info */    denom_sig = wc->collectable.sig; -  wc->collectable.sig.rsa_signature = NULL; +  memset (&wc->collectable.sig, +          0, +          sizeof (wc->collectable.sig));  #endif    qs = TEH_plugin->get_withdraw_info (TEH_plugin->cls,                                        &wc->wsrd.h_coin_envelope, @@ -229,7 +231,7 @@ withdraw_transaction (void *cls,         optimization trade-off loses in this case: we unnecessarily computed         a signature :-( */  #if OPTIMISTIC_SIGN -    GNUNET_CRYPTO_rsa_signature_free (denom_sig.rsa_signature); +    TALER_denom_sig_free (&denom_sig);  #endif      return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;    } @@ -364,14 +366,14 @@ withdraw_transaction (void *cls,  #if ! OPTIMISTIC_SIGN    if (NULL == wc->collectable.sig.rsa_signature)    { -    enum TALER_ErrorCode ec; +    enum TALER_ErrorCode ec = TALER_EC_NONE;      wc->collectable.sig        = TEH_keys_denomination_sign (&wc->denom_pub_hash,                                      wc->blinded_msg,                                      wc->blinded_msg_len,                                      &ec); -    if (NULL == wc->collectable.sig.rsa_signature) +    if (TALER_EC_NONE != ec)      {        GNUNET_break (0);        *mhd_ret = TALER_MHD_reply_with_ec (connection, @@ -530,7 +532,7 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,      = htonl (TALER_SIGNATURE_WALLET_RESERVE_WITHDRAW);    wc.wsrd.h_denomination_pub      = wc.denom_pub_hash; -  GNUNET_CRYPTO_hash (wc.blinded_msg, +  TALER_coin_ev_hash (wc.blinded_msg,                        wc.blinded_msg_len,                        &wc.wsrd.h_coin_envelope);    if (GNUNET_OK != @@ -550,12 +552,13 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,  #if OPTIMISTIC_SIGN    /* Sign before transaction! */ +  ec = TALER_EC_NONE;    wc.collectable.sig      = TEH_keys_denomination_sign (&wc.denom_pub_hash,                                    wc.blinded_msg,                                    wc.blinded_msg_len,                                    &ec); -  if (NULL == wc.collectable.sig.rsa_signature) +  if (TALER_EC_NONE != ec)    {      GNUNET_break (0);      GNUNET_JSON_parse_free (spec); @@ -579,8 +582,7 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,      {        /* Even if #withdraw_transaction() failed, it may have created a signature           (or we might have done it optimistically above). */ -      if (NULL != wc.collectable.sig.rsa_signature) -        GNUNET_CRYPTO_rsa_signature_free (wc.collectable.sig.rsa_signature); +      TALER_denom_sig_free (&wc.collectable.sig);        GNUNET_JSON_parse_free (spec);        return mhd_ret;      } @@ -591,9 +593,7 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,    if (wc.kyc_denied)    { -    if (NULL != wc.collectable.sig.rsa_signature) -      GNUNET_CRYPTO_rsa_signature_free (wc.collectable.sig.rsa_signature); - +    TALER_denom_sig_free (&wc.collectable.sig);      return TALER_MHD_REPLY_JSON_PACK (        rc->connection,        MHD_HTTP_ACCEPTED, @@ -607,9 +607,9 @@ TEH_handler_withdraw (struct TEH_RequestContext *rc,      ret = TALER_MHD_REPLY_JSON_PACK (        rc->connection,        MHD_HTTP_OK, -      GNUNET_JSON_pack_rsa_signature ("ev_sig", -                                      wc.collectable.sig.rsa_signature)); -    GNUNET_CRYPTO_rsa_signature_free (wc.collectable.sig.rsa_signature); +      TALER_JSON_pack_denomination_signature ("ev_sig", +                                              &wc.collectable.sig)); +    TALER_denom_sig_free (&wc.collectable.sig);      return ret;    }  } diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h index f3f48c04..3b0c8750 100644 --- a/src/include/taler_crypto_lib.h +++ b/src/include/taler_crypto_lib.h @@ -674,6 +674,18 @@ TALER_denom_pub_deep_copy (struct TALER_DenominationPublicKey *denom_dst,  /** + * Make a (deep) copy of the given @a denom_src to + * @a denom_dst. + * + * @param[out] denom_dst target to copy to + * @param denom_str public key to copy + */ +void +TALER_denom_sig_deep_copy (struct TALER_DenominationSignature *denom_dst, +                           const struct TALER_DenominationSignature *denom_src); + + +/**   * Compare two denomination public keys.   *   * @param denom1 first key diff --git a/src/util/denom.c b/src/util/denom.c index 5ea4aca2..407ade38 100644 --- a/src/util/denom.c +++ b/src/util/denom.c @@ -195,6 +195,25 @@ TALER_denom_pub_deep_copy (struct TALER_DenominationPublicKey *denom_dst,  } +void +TALER_denom_sig_deep_copy (struct TALER_DenominationSignature *denom_dst, +                           const struct TALER_DenominationSignature *denom_src) +{ +  *denom_dst = *denom_src; /* shallow copy */ +  switch (denom_src->cipher) +  { +  case TALER_DENOMINATION_RSA: +    denom_dst->details.rsa_signature +      = GNUNET_CRYPTO_rsa_signature_dup ( +          denom_src->details.rsa_signature); +    return; +  // TODO: add case for Clause-Schnorr +  default: +    GNUNET_assert (0); +  } +} + +  /**   * Compare two denomination public keys.   * | 
