diff options
Diffstat (limited to 'src/mint/taler-mint-httpd_refresh.c')
-rw-r--r-- | src/mint/taler-mint-httpd_refresh.c | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/src/mint/taler-mint-httpd_refresh.c b/src/mint/taler-mint-httpd_refresh.c index 913f40fa2..5a9cf1eac 100644 --- a/src/mint/taler-mint-httpd_refresh.c +++ b/src/mint/taler-mint-httpd_refresh.c | |||
@@ -118,7 +118,7 @@ refresh_accept_denoms (struct MHD_Connection *connection, | |||
118 | const struct MintKeyState *key_state, | 118 | const struct MintKeyState *key_state, |
119 | const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub, | 119 | const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub, |
120 | const json_t *root, | 120 | const json_t *root, |
121 | struct TALER_HashContext *hash_context, | 121 | struct GNUNET_HashContext *hash_context, |
122 | struct TALER_Amount *r_amount) | 122 | struct TALER_Amount *r_amount) |
123 | { | 123 | { |
124 | unsigned i; | 124 | unsigned i; |
@@ -154,7 +154,7 @@ refresh_accept_denoms (struct MHD_Connection *connection, | |||
154 | 154 | ||
155 | dki = TALER_MINT_get_denom_key (key_state, &denom_pub); | 155 | dki = TALER_MINT_get_denom_key (key_state, &denom_pub); |
156 | 156 | ||
157 | TALER_hash_context_read (hash_context, | 157 | GNUNET_CRYPTO_hash_context_read (hash_context, |
158 | &denom_pub, sizeof (struct TALER_RSA_PublicKeyBinaryEncoded)); | 158 | &denom_pub, sizeof (struct TALER_RSA_PublicKeyBinaryEncoded)); |
159 | 159 | ||
160 | cost = TALER_amount_add (TALER_amount_ntoh (dki->value), | 160 | cost = TALER_amount_add (TALER_amount_ntoh (dki->value), |
@@ -307,7 +307,7 @@ refresh_accept_melts (struct MHD_Connection *connection, | |||
307 | const struct MintKeyState *key_state, | 307 | const struct MintKeyState *key_state, |
308 | const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub, | 308 | const struct GNUNET_CRYPTO_EddsaPublicKey *session_pub, |
309 | json_t *root, | 309 | json_t *root, |
310 | struct TALER_HashContext *hash_context, | 310 | struct GNUNET_HashContext *hash_context, |
311 | struct TALER_Amount *r_melt_balance) | 311 | struct TALER_Amount *r_melt_balance) |
312 | { | 312 | { |
313 | size_t i; | 313 | size_t i; |
@@ -350,7 +350,7 @@ refresh_accept_melts (struct MHD_Connection *connection, | |||
350 | return res; | 350 | return res; |
351 | } | 351 | } |
352 | 352 | ||
353 | TALER_hash_context_read (hash_context, | 353 | GNUNET_CRYPTO_hash_context_read (hash_context, |
354 | &coin_public_info.coin_pub, sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)); | 354 | &coin_public_info.coin_pub, sizeof (struct GNUNET_CRYPTO_EddsaPublicKey)); |
355 | 355 | ||
356 | dki = TALER_MINT_get_denom_key (key_state, &coin_public_info.denom_pub); | 356 | dki = TALER_MINT_get_denom_key (key_state, &coin_public_info.denom_pub); |
@@ -442,7 +442,7 @@ helper_refresh_send_melt_response (struct MHD_Connection *connection, | |||
442 | int res; | 442 | int res; |
443 | json_t *root; | 443 | json_t *root; |
444 | json_t *list; | 444 | json_t *list; |
445 | struct TALER_HashContext hash_context; | 445 | struct GNUNET_HashContext *hash_context; |
446 | 446 | ||
447 | if (GNUNET_OK != | 447 | if (GNUNET_OK != |
448 | (res = TALER_MINT_DB_get_refresh_session (db_conn, | 448 | (res = TALER_MINT_DB_get_refresh_session (db_conn, |
@@ -458,7 +458,7 @@ helper_refresh_send_melt_response (struct MHD_Connection *connection, | |||
458 | list = json_array (); | 458 | list = json_array (); |
459 | json_object_set_new (root, "blind_session_pubs", list); | 459 | json_object_set_new (root, "blind_session_pubs", list); |
460 | 460 | ||
461 | TALER_hash_context_start (&hash_context); | 461 | hash_context = GNUNET_CRYPTO_hash_context_start (); |
462 | 462 | ||
463 | { | 463 | { |
464 | struct RefreshMeltResponseSignatureBody body; | 464 | struct RefreshMeltResponseSignatureBody body; |
@@ -466,7 +466,7 @@ helper_refresh_send_melt_response (struct MHD_Connection *connection, | |||
466 | 466 | ||
467 | body.purpose.size = htonl (sizeof (struct RefreshMeltResponseSignatureBody)); | 467 | body.purpose.size = htonl (sizeof (struct RefreshMeltResponseSignatureBody)); |
468 | body.purpose.purpose = htonl (TALER_SIGNATURE_REFRESH_MELT_RESPONSE); | 468 | body.purpose.purpose = htonl (TALER_SIGNATURE_REFRESH_MELT_RESPONSE); |
469 | TALER_hash_context_finish (&hash_context, &body.melt_response_hash); | 469 | GNUNET_CRYPTO_hash_context_finish (hash_context, &body.melt_response_hash); |
470 | sig_json = sign_as_json (&body.purpose); | 470 | sig_json = sign_as_json (&body.purpose); |
471 | GNUNET_assert (NULL != sig_json); | 471 | GNUNET_assert (NULL != sig_json); |
472 | json_object_set (root, "signature", sig_json); | 472 | json_object_set (root, "signature", sig_json); |
@@ -588,7 +588,7 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh, | |||
588 | struct MintKeyState *key_state; | 588 | struct MintKeyState *key_state; |
589 | struct TALER_Amount requested_cost; | 589 | struct TALER_Amount requested_cost; |
590 | struct TALER_Amount melt_balance; | 590 | struct TALER_Amount melt_balance; |
591 | struct TALER_HashContext hash_context; | 591 | struct GNUNET_HashContext *hash_context; |
592 | struct GNUNET_HashCode melt_hash; | 592 | struct GNUNET_HashCode melt_hash; |
593 | 593 | ||
594 | res = process_post_json (connection, | 594 | res = process_post_json (connection, |
@@ -666,16 +666,16 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh, | |||
666 | /* Write requested denominations to the DB, | 666 | /* Write requested denominations to the DB, |
667 | * and sum the costs (value plus fees) */ | 667 | * and sum the costs (value plus fees) */ |
668 | 668 | ||
669 | TALER_hash_context_start (&hash_context); | 669 | hash_context = GNUNET_CRYPTO_hash_context_start (); |
670 | 670 | ||
671 | if (GNUNET_OK != (res = refresh_accept_denoms (connection, db_conn, key_state, | 671 | if (GNUNET_OK != (res = refresh_accept_denoms (connection, db_conn, key_state, |
672 | &refresh_session_pub, root, | 672 | &refresh_session_pub, root, |
673 | &hash_context, | 673 | hash_context, |
674 | &requested_cost))) | 674 | &requested_cost))) |
675 | { | 675 | { |
676 | TALER_MINT_key_state_release (key_state); | 676 | TALER_MINT_key_state_release (key_state); |
677 | TALER_MINT_DB_rollback (db_conn); | 677 | TALER_MINT_DB_rollback (db_conn); |
678 | // FIXME: hash_context_end? | 678 | GNUNET_CRYPTO_hash_context_abort (hash_context); |
679 | return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; | 679 | return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; |
680 | } | 680 | } |
681 | 681 | ||
@@ -683,15 +683,16 @@ TALER_MINT_handler_refresh_melt (struct RequestHandler *rh, | |||
683 | 683 | ||
684 | if (GNUNET_OK != (res = refresh_accept_melts (connection, db_conn, key_state, | 684 | if (GNUNET_OK != (res = refresh_accept_melts (connection, db_conn, key_state, |
685 | &refresh_session_pub, root, | 685 | &refresh_session_pub, root, |
686 | &hash_context, | 686 | hash_context, |
687 | &melt_balance))) | 687 | &melt_balance))) |
688 | { | 688 | { |
689 | TALER_MINT_key_state_release (key_state); | 689 | TALER_MINT_key_state_release (key_state); |
690 | GNUNET_break (GNUNET_OK == TALER_MINT_DB_rollback (db_conn)); | 690 | GNUNET_break (GNUNET_OK == TALER_MINT_DB_rollback (db_conn)); |
691 | GNUNET_CRYPTO_hash_context_abort (hash_context); | ||
691 | return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; | 692 | return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; |
692 | } | 693 | } |
693 | 694 | ||
694 | TALER_hash_context_finish (&hash_context, &melt_hash); | 695 | GNUNET_CRYPTO_hash_context_finish (hash_context, &melt_hash); |
695 | 696 | ||
696 | TALER_MINT_key_state_release (key_state); | 697 | TALER_MINT_key_state_release (key_state); |
697 | 698 | ||
@@ -800,7 +801,7 @@ TALER_MINT_handler_refresh_commit (struct RequestHandler *rh, | |||
800 | struct RefreshSession refresh_session; | 801 | struct RefreshSession refresh_session; |
801 | int i; | 802 | int i; |
802 | struct GNUNET_HashCode commit_hash; | 803 | struct GNUNET_HashCode commit_hash; |
803 | struct TALER_HashContext hash_context; | 804 | struct GNUNET_HashContext *hash_context; |
804 | json_t *root; | 805 | json_t *root; |
805 | 806 | ||
806 | res = process_post_json (connection, | 807 | res = process_post_json (connection, |
@@ -880,7 +881,7 @@ TALER_MINT_handler_refresh_commit (struct RequestHandler *rh, | |||
880 | return MHD_NO; | 881 | return MHD_NO; |
881 | } | 882 | } |
882 | 883 | ||
883 | TALER_hash_context_start (&hash_context); | 884 | hash_context = GNUNET_CRYPTO_hash_context_start (); |
884 | 885 | ||
885 | for (i = 0; i < refresh_session.kappa; i++) | 886 | for (i = 0; i < refresh_session.kappa; i++) |
886 | { | 887 | { |
@@ -903,10 +904,11 @@ TALER_MINT_handler_refresh_commit (struct RequestHandler *rh, | |||
903 | // FIXME: return 'internal error'? | 904 | // FIXME: return 'internal error'? |
904 | GNUNET_break (0); | 905 | GNUNET_break (0); |
905 | GNUNET_break (GNUNET_OK == TALER_MINT_DB_rollback (db_conn)); | 906 | GNUNET_break (GNUNET_OK == TALER_MINT_DB_rollback (db_conn)); |
907 | GNUNET_CRYPTO_hash_context_abort (hash_context); | ||
906 | return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; | 908 | return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; |
907 | } | 909 | } |
908 | 910 | ||
909 | TALER_hash_context_read (&hash_context, | 911 | GNUNET_CRYPTO_hash_context_read (hash_context, |
910 | &commit_coin.coin_ev, | 912 | &commit_coin.coin_ev, |
911 | sizeof (struct TALER_RSA_BlindedSignaturePurpose)); | 913 | sizeof (struct TALER_RSA_BlindedSignaturePurpose)); |
912 | 914 | ||
@@ -922,10 +924,11 @@ TALER_MINT_handler_refresh_commit (struct RequestHandler *rh, | |||
922 | // FIXME: return 'internal error'? | 924 | // FIXME: return 'internal error'? |
923 | GNUNET_break (0); | 925 | GNUNET_break (0); |
924 | GNUNET_break (GNUNET_OK == TALER_MINT_DB_rollback (db_conn)); | 926 | GNUNET_break (GNUNET_OK == TALER_MINT_DB_rollback (db_conn)); |
927 | GNUNET_CRYPTO_hash_context_abort (hash_context); | ||
925 | return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; | 928 | return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; |
926 | } | 929 | } |
927 | 930 | ||
928 | TALER_hash_context_read (&hash_context, | 931 | GNUNET_CRYPTO_hash_context_read (hash_context, |
929 | commit_coin.link_enc, | 932 | commit_coin.link_enc, |
930 | TALER_REFRESH_LINK_LENGTH); | 933 | TALER_REFRESH_LINK_LENGTH); |
931 | 934 | ||
@@ -940,6 +943,7 @@ TALER_MINT_handler_refresh_commit (struct RequestHandler *rh, | |||
940 | // FIXME: return 'internal error'? | 943 | // FIXME: return 'internal error'? |
941 | GNUNET_break (0); | 944 | GNUNET_break (0); |
942 | GNUNET_break (GNUNET_OK == TALER_MINT_DB_rollback (db_conn)); | 945 | GNUNET_break (GNUNET_OK == TALER_MINT_DB_rollback (db_conn)); |
946 | GNUNET_CRYPTO_hash_context_abort (hash_context); | ||
943 | return MHD_NO; | 947 | return MHD_NO; |
944 | } | 948 | } |
945 | } | 949 | } |
@@ -964,10 +968,11 @@ TALER_MINT_handler_refresh_commit (struct RequestHandler *rh, | |||
964 | { | 968 | { |
965 | GNUNET_break (GNUNET_SYSERR != res); | 969 | GNUNET_break (GNUNET_SYSERR != res); |
966 | GNUNET_break (GNUNET_OK == TALER_MINT_DB_rollback (db_conn)); | 970 | GNUNET_break (GNUNET_OK == TALER_MINT_DB_rollback (db_conn)); |
971 | GNUNET_CRYPTO_hash_context_abort (hash_context); | ||
967 | return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; | 972 | return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; |
968 | } | 973 | } |
969 | 974 | ||
970 | TALER_hash_context_read (&hash_context, | 975 | GNUNET_CRYPTO_hash_context_read (hash_context, |
971 | &commit_link.transfer_pub, | 976 | &commit_link.transfer_pub, |
972 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | 977 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); |
973 | 978 | ||
@@ -983,10 +988,11 @@ TALER_MINT_handler_refresh_commit (struct RequestHandler *rh, | |||
983 | { | 988 | { |
984 | GNUNET_break (GNUNET_SYSERR != res); | 989 | GNUNET_break (GNUNET_SYSERR != res); |
985 | GNUNET_break (GNUNET_OK == TALER_MINT_DB_rollback (db_conn)); | 990 | GNUNET_break (GNUNET_OK == TALER_MINT_DB_rollback (db_conn)); |
991 | GNUNET_CRYPTO_hash_context_abort (hash_context); | ||
986 | return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; | 992 | return (GNUNET_SYSERR == res) ? MHD_NO : MHD_YES; |
987 | } | 993 | } |
988 | 994 | ||
989 | TALER_hash_context_read (&hash_context, | 995 | GNUNET_CRYPTO_hash_context_read (hash_context, |
990 | commit_link.shared_secret_enc, | 996 | commit_link.shared_secret_enc, |
991 | TALER_REFRESH_SHARED_SECRET_LENGTH); | 997 | TALER_REFRESH_SHARED_SECRET_LENGTH); |
992 | 998 | ||
@@ -999,12 +1005,14 @@ TALER_MINT_handler_refresh_commit (struct RequestHandler *rh, | |||
999 | // FIXME: return 'internal error'? | 1005 | // FIXME: return 'internal error'? |
1000 | GNUNET_break (0); | 1006 | GNUNET_break (0); |
1001 | GNUNET_break (GNUNET_OK == TALER_MINT_DB_rollback (db_conn)); | 1007 | GNUNET_break (GNUNET_OK == TALER_MINT_DB_rollback (db_conn)); |
1008 | GNUNET_CRYPTO_hash_context_abort (hash_context); | ||
1009 | |||
1002 | return MHD_NO; | 1010 | return MHD_NO; |
1003 | } | 1011 | } |
1004 | } | 1012 | } |
1005 | } | 1013 | } |
1006 | 1014 | ||
1007 | TALER_hash_context_finish (&hash_context, &commit_hash); | 1015 | GNUNET_CRYPTO_hash_context_finish (hash_context, &commit_hash); |
1008 | 1016 | ||
1009 | { | 1017 | { |
1010 | struct RefreshCommitSignatureBody body; | 1018 | struct RefreshCommitSignatureBody body; |