anastasis-db_store_truth.c (3080B)
1 /* 2 This file is part of Anastasis 3 Copyright (C) 2020-2022 Anastasis SARL 4 5 Anastasis 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 Anastasis 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 Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file stasis/anastasis-db_store_truth.c 18 * @brief Anastasis database: store truth 19 * @author Christian Grothoff 20 */ 21 #include "platform.h" 22 #include "anastasis-db_pg.h" 23 #include "anastasis/anastasis-database/store_truth.h" 24 #include "anastasis/anastasis-database/transaction.h" 25 #include "anastasis/anastasis-database/preflight.h" 26 #include <taler/taler_pq_lib.h> 27 28 29 /** 30 * Upload Truth, which contains the Truth and the KeyShare. 31 * 32 * @param truth_uuid the identifier for the Truth 33 * @param key_share_data contains information of an EncryptedKeyShare 34 * @param mime_type presumed mime type of data in @a encrypted_truth 35 * @param encrypted_truth contains the encrypted Truth which includes the ground truth i.e. H(challenge answer), phonenumber, SMS 36 * @param encrypted_truth_size the size of the Truth 37 * @param method name of method 38 * @param truth_expiration time till the according data will be stored 39 * @return transaction status 40 */ 41 enum GNUNET_DB_QueryStatus 42 ANASTASIS_DB_store_truth ( 43 const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid, 44 const struct ANASTASIS_CRYPTO_EncryptedKeyShareP *key_share_data, 45 const char *mime_type, 46 const void *encrypted_truth, 47 size_t encrypted_truth_size, 48 const char *method, 49 struct GNUNET_TIME_Relative truth_expiration) 50 { 51 struct GNUNET_TIME_Timestamp expiration; 52 struct GNUNET_PQ_QueryParam params[] = { 53 GNUNET_PQ_query_param_auto_from_type (truth_uuid), 54 GNUNET_PQ_query_param_auto_from_type (key_share_data), 55 GNUNET_PQ_query_param_string (method), 56 GNUNET_PQ_query_param_fixed_size (encrypted_truth, 57 encrypted_truth_size), 58 GNUNET_PQ_query_param_string (mime_type), 59 GNUNET_PQ_query_param_timestamp (&expiration), 60 GNUNET_PQ_query_param_end 61 }; 62 63 expiration = GNUNET_TIME_relative_to_timestamp (truth_expiration); 64 PREPARE ("truth_insert", 65 "INSERT INTO anastasis_truth " 66 "(truth_uuid" 67 ",key_share_data" 68 ",method_name" 69 ",encrypted_truth" 70 ",truth_mime" 71 ",expiration" 72 ") VALUES " 73 "($1, $2, $3, $4, $5, $6);"); 74 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 75 "truth_insert", 76 params); 77 } 78 79 80 /* end of anastasis-db_store_truth.c */