LCOV - code coverage report
Current view: top level - util - auditor_signatures.c (source / functions) Hit Total Coverage
Test: GNU Taler exchange coverage report Lines: 0 33 0.0 %
Date: 2021-08-30 06:43:37 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 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 auditor_signatures.c
      18             :  * @brief Utility functions for Taler auditor signatures
      19             :  * @author Christian Grothoff
      20             :  */
      21             : #include "platform.h"
      22             : #include "taler_util.h"
      23             : #include "taler_signatures.h"
      24             : 
      25             : 
      26             : void
      27           0 : TALER_auditor_denom_validity_sign (
      28             :   const char *auditor_url,
      29             :   const struct GNUNET_HashCode *h_denom_pub,
      30             :   const struct TALER_MasterPublicKeyP *master_pub,
      31             :   struct GNUNET_TIME_Absolute stamp_start,
      32             :   struct GNUNET_TIME_Absolute stamp_expire_withdraw,
      33             :   struct GNUNET_TIME_Absolute stamp_expire_deposit,
      34             :   struct GNUNET_TIME_Absolute stamp_expire_legal,
      35             :   const struct TALER_Amount *coin_value,
      36             :   const struct TALER_Amount *fee_withdraw,
      37             :   const struct TALER_Amount *fee_deposit,
      38             :   const struct TALER_Amount *fee_refresh,
      39             :   const struct TALER_Amount *fee_refund,
      40             :   const struct TALER_AuditorPrivateKeyP *auditor_priv,
      41             :   struct TALER_AuditorSignatureP *auditor_sig)
      42             : {
      43           0 :   struct TALER_ExchangeKeyValidityPS kv = {
      44           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS),
      45           0 :     .purpose.size = htonl (sizeof (kv)),
      46           0 :     .start = GNUNET_TIME_absolute_hton (stamp_start),
      47           0 :     .expire_withdraw = GNUNET_TIME_absolute_hton (stamp_expire_withdraw),
      48           0 :     .expire_deposit = GNUNET_TIME_absolute_hton (stamp_expire_deposit),
      49           0 :     .expire_legal = GNUNET_TIME_absolute_hton (stamp_expire_legal),
      50             :     .denom_hash = *h_denom_pub,
      51             :     .master = *master_pub,
      52             :   };
      53             : 
      54           0 :   TALER_amount_hton (&kv.value,
      55             :                      coin_value);
      56           0 :   TALER_amount_hton (&kv.fee_withdraw,
      57             :                      fee_withdraw);
      58           0 :   TALER_amount_hton (&kv.fee_deposit,
      59             :                      fee_deposit);
      60           0 :   TALER_amount_hton (&kv.fee_refresh,
      61             :                      fee_refresh);
      62           0 :   TALER_amount_hton (&kv.fee_refund,
      63             :                      fee_refund);
      64           0 :   GNUNET_CRYPTO_hash (auditor_url,
      65           0 :                       strlen (auditor_url) + 1,
      66             :                       &kv.auditor_url_hash);
      67           0 :   GNUNET_CRYPTO_eddsa_sign (&auditor_priv->eddsa_priv,
      68             :                             &kv,
      69             :                             &auditor_sig->eddsa_sig);
      70           0 : }
      71             : 
      72             : 
      73             : enum GNUNET_GenericReturnValue
      74           0 : TALER_auditor_denom_validity_verify (
      75             :   const char *auditor_url,
      76             :   const struct GNUNET_HashCode *h_denom_pub,
      77             :   const struct TALER_MasterPublicKeyP *master_pub,
      78             :   struct GNUNET_TIME_Absolute stamp_start,
      79             :   struct GNUNET_TIME_Absolute stamp_expire_withdraw,
      80             :   struct GNUNET_TIME_Absolute stamp_expire_deposit,
      81             :   struct GNUNET_TIME_Absolute stamp_expire_legal,
      82             :   const struct TALER_Amount *coin_value,
      83             :   const struct TALER_Amount *fee_withdraw,
      84             :   const struct TALER_Amount *fee_deposit,
      85             :   const struct TALER_Amount *fee_refresh,
      86             :   const struct TALER_Amount *fee_refund,
      87             :   const struct TALER_AuditorPublicKeyP *auditor_pub,
      88             :   const struct TALER_AuditorSignatureP *auditor_sig)
      89             : {
      90           0 :   struct TALER_ExchangeKeyValidityPS kv = {
      91           0 :     .purpose.purpose = htonl (TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS),
      92           0 :     .purpose.size = htonl (sizeof (kv)),
      93           0 :     .start = GNUNET_TIME_absolute_hton (stamp_start),
      94           0 :     .expire_withdraw = GNUNET_TIME_absolute_hton (stamp_expire_withdraw),
      95           0 :     .expire_deposit = GNUNET_TIME_absolute_hton (stamp_expire_deposit),
      96           0 :     .expire_legal = GNUNET_TIME_absolute_hton (stamp_expire_legal),
      97             :     .denom_hash = *h_denom_pub,
      98             :     .master = *master_pub,
      99             :   };
     100             : 
     101           0 :   TALER_amount_hton (&kv.value,
     102             :                      coin_value);
     103           0 :   TALER_amount_hton (&kv.fee_withdraw,
     104             :                      fee_withdraw);
     105           0 :   TALER_amount_hton (&kv.fee_deposit,
     106             :                      fee_deposit);
     107           0 :   TALER_amount_hton (&kv.fee_refresh,
     108             :                      fee_refresh);
     109           0 :   TALER_amount_hton (&kv.fee_refund,
     110             :                      fee_refund);
     111           0 :   GNUNET_CRYPTO_hash (auditor_url,
     112           0 :                       strlen (auditor_url) + 1,
     113             :                       &kv.auditor_url_hash);
     114             :   return
     115           0 :     GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS,
     116             :                                 &kv,
     117             :                                 &auditor_sig->eddsa_sig,
     118             :                                 &auditor_pub->eddsa_pub);
     119             : }
     120             : 
     121             : 
     122             : /* end of auditor_signatures.c */

Generated by: LCOV version 1.14