taler-exchange-httpd_post-management-denominations-H_DENOM_PUB-revoke.c (3220B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2020 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU Affero General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. 12 13 You should have received a copy of the GNU Affero General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file taler-exchange-httpd_post-management-denominations-H_DENOM_PUB-revoke.c 18 * @brief Handle denomination revocation requests. 19 * @author Christian Grothoff 20 */ 21 #include <gnunet/gnunet_util_lib.h> 22 #include <gnunet/gnunet_json_lib.h> 23 #include <jansson.h> 24 #include <microhttpd.h> 25 #include <pthread.h> 26 #include "taler/taler_json_lib.h" 27 #include "taler/taler_mhd_lib.h" 28 #include "taler-exchange-httpd_secmod-helpers.h" 29 #include "taler-exchange-httpd_management.h" 30 #include "taler-exchange-httpd_responses.h" 31 #include "taler-exchange-httpd_get-keys.h" 32 #include "exchange-database/insert_denomination_revocation.h" 33 34 35 enum MHD_Result 36 TEH_handler_management_denominations_HDP_revoke ( 37 struct MHD_Connection *connection, 38 const struct TALER_DenominationHashP *h_denom_pub, 39 const json_t *root) 40 { 41 struct TALER_MasterSignatureP master_sig; 42 struct GNUNET_JSON_Specification spec[] = { 43 GNUNET_JSON_spec_fixed_auto ("master_sig", 44 &master_sig), 45 GNUNET_JSON_spec_end () 46 }; 47 enum GNUNET_DB_QueryStatus qs; 48 49 { 50 enum GNUNET_GenericReturnValue res; 51 52 res = TALER_MHD_parse_json_data (connection, 53 root, 54 spec); 55 if (GNUNET_SYSERR == res) 56 return MHD_NO; /* hard failure */ 57 if (GNUNET_NO == res) 58 return MHD_YES; /* failure */ 59 } 60 TEH_METRICS_num_verifications[TEH_MT_SIGNATURE_EDDSA]++; 61 if (GNUNET_OK != 62 TALER_exchange_offline_denomination_revoke_verify ( 63 h_denom_pub, 64 &TEH_master_public_key, 65 &master_sig)) 66 { 67 GNUNET_break_op (0); 68 return TALER_MHD_reply_with_error ( 69 connection, 70 MHD_HTTP_FORBIDDEN, 71 TALER_EC_EXCHANGE_MANAGEMENT_DENOMINATION_REVOKE_SIGNATURE_INVALID, 72 NULL); 73 } 74 qs = TALER_EXCHANGEDB_insert_denomination_revocation (TEH_pg, 75 h_denom_pub, 76 &master_sig); 77 if (qs < 0) 78 { 79 GNUNET_break (0); 80 return TALER_MHD_reply_with_error (connection, 81 MHD_HTTP_INTERNAL_SERVER_ERROR, 82 TALER_EC_GENERIC_DB_STORE_FAILED, 83 "denomination revocation"); 84 } 85 TEH_SECMOD_denom_revoke (h_denom_pub); 86 return TALER_MHD_reply_static ( 87 connection, 88 MHD_HTTP_NO_CONTENT, 89 NULL, 90 NULL, 91 0); 92 } 93 94 95 /* end of taler-exchange-httpd_management_denominations_HDP_revoke.c */