qr.c (2251B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2024 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU 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 General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file qr.c 18 * @brief Utility functions for donation statement QR Code 19 * @author Lukas Matyja 20 */ 21 #include "donau_config.h" 22 #include <taler/taler_util.h> 23 #include "donau_util.h" 24 #include "donau_service.h" 25 26 // FIXME: remove public key, only needed for testing. 27 // The verification app should get the public key directly from the Donau. 28 char * 29 DONAU_generate_qr_string (const struct DONAU_DonauPublicKeyP *pub_key, 30 const struct DONAU_DonationStatement * 31 donation_statement) 32 { 33 /* The string will be structured as follows: YEAR/TOTALAMOUNT/TAXID/TAXIDSALT/ED25519SIGNATURE/PUBKEY */ 34 char *end_sig; 35 char *end_pub; 36 char sig_str[sizeof (struct DONAU_DonauSignatureP) * 2]; 37 char pub_str[sizeof (struct DONAU_DonauPublicKeyP) * 2]; 38 char *qr_string; 39 40 end_sig = GNUNET_STRINGS_data_to_string ( 41 &donation_statement->donation_statement_sig, 42 sizeof (struct DONAU_DonauSignatureP), 43 sig_str, 44 sizeof (sig_str)); 45 *end_sig = '\0'; 46 end_pub = GNUNET_STRINGS_data_to_string ( 47 pub_key, 48 sizeof (struct DONAU_DonauPublicKeyP), 49 pub_str, 50 sizeof (pub_str)); 51 *end_pub = '\0'; 52 GNUNET_asprintf (&qr_string, 53 "%llu/%s/%s/%s/%s/%s", 54 (unsigned long long) 55 donation_statement->year, 56 TALER_amount2s (&donation_statement->total_amount), 57 donation_statement->donor_tax_id, 58 donation_statement->salt, 59 sig_str, 60 pub_str); 61 return qr_string; 62 }