diff options
| author | Christian Grothoff <grothoff@gnunet.org> | 2022-12-27 11:49:41 +0100 | 
|---|---|---|
| committer | Christian Grothoff <grothoff@gnunet.org> | 2022-12-27 11:49:41 +0100 | 
| commit | 8d0bf81801acfca1b2007b8300bf80deafed5a00 (patch) | |
| tree | 8160f426c0da53f4da198daba808344036cd1151 /src/util | |
| parent | 704f791d0c47a9e5f9a6c076df50dd338487bb43 (diff) | |
-new crypto functions
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/offline_signatures.c | 91 | ||||
| -rw-r--r-- | src/util/wallet_signatures.c | 53 | 
2 files changed, 144 insertions, 0 deletions
| diff --git a/src/util/offline_signatures.c b/src/util/offline_signatures.c index d0b644e7..d6638998 100644 --- a/src/util/offline_signatures.c +++ b/src/util/offline_signatures.c @@ -27,6 +27,97 @@ GNUNET_NETWORK_STRUCT_BEGIN  /**   * @brief Signature made by the exchange offline key over the information of + * an AML officer status change. + */ +struct TALER_MasterAmlOfficerStatusPS +{ + +  /** +   * Purpose is #TALER_SIGNATURE_MASTER_AML_KEY.   Signed +   * by a `struct TALER_MasterPublicKeyP` using EdDSA. +   */ +  struct GNUNET_CRYPTO_EccSignaturePurpose purpose; + +  /** +   * Time of the change. +   */ +  struct GNUNET_TIME_TimestampNBO change_date; + +  /** +   * Public key of the AML officer. +   */ +  struct TALER_AmlOfficerPublicKeyP officer_pub; + +  /** +   * Hash over the AML officer's name. +   */ +  struct GNUNET_HashCode h_officer_name GNUNET_PACKED; + +  /** +   * 1 if enabled, 0 if disabled, in NBO. +   */ +  uint32_t is_active GNUNET_PACKED; +}; +GNUNET_NETWORK_STRUCT_END + + +void +TALER_exchange_offline_aml_officer_status_sign ( +  const struct TALER_AmlOfficerPublicKeyP *officer_pub, +  const char *officer_name, +  struct GNUNET_TIME_Timestamp change_date, +  bool is_active, +  const struct TALER_MasterPrivateKeyP *master_priv, +  struct TALER_MasterSignatureP *master_sig) +{ +  struct TALER_MasterAmlOfficerStatusPS as = { +    .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_AML_KEY), +    .purpose.size = htonl (sizeof (as)), +    .change_date = GNUNET_TIME_timestamp_hton (change_date), +    .officer_pub = *officer_pub, +    .is_active = htonl (is_active ? 1 : 0) +  }; + +  GNUNET_CRYPTO_hash (officer_name, +                      strlen (officer_name) + 1, +                      &as.h_officer_name); +  GNUNET_CRYPTO_eddsa_sign (&master_priv->eddsa_priv, +                            &as, +                            &master_sig->eddsa_signature); +} + + +enum GNUNET_GenericReturnValue +TALER_exchange_offline_aml_officer_status_verify ( +  const struct TALER_AmlOfficerPublicKeyP *officer_pub, +  const char *officer_name, +  struct GNUNET_TIME_Timestamp change_date, +  bool is_active, +  const struct TALER_MasterPublicKeyP *master_pub, +  const struct TALER_MasterSignatureP *master_sig) +{ +  struct TALER_MasterAmlOfficerStatusPS as = { +    .purpose.purpose = htonl (TALER_SIGNATURE_MASTER_AML_KEY), +    .purpose.size = htonl (sizeof (as)), +    .change_date = GNUNET_TIME_timestamp_hton (change_date), +    .officer_pub = *officer_pub, +    .is_active = htonl (is_active ? 1 : 0) +  }; + +  GNUNET_CRYPTO_hash (officer_name, +                      strlen (officer_name) + 1, +                      &as.h_officer_name); +  return GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MASTER_AML_KEY, +                                     &as, +                                     &master_sig->eddsa_signature, +                                     &master_pub->eddsa_pub); +} + + +GNUNET_NETWORK_STRUCT_BEGIN + +/** + * @brief Signature made by the exchange offline key over the information of   * an auditor to be added to the exchange's set of auditors.   */  struct TALER_MasterAddAuditorPS diff --git a/src/util/wallet_signatures.c b/src/util/wallet_signatures.c index 6866ca19..b74a9fea 100644 --- a/src/util/wallet_signatures.c +++ b/src/util/wallet_signatures.c @@ -907,6 +907,59 @@ TALER_wallet_purse_create_verify (  } +GNUNET_NETWORK_STRUCT_BEGIN + +/** + * Message signed to delete a purse. + */ +struct TALER_PurseDeletePS +{ + +  /** +   * Purpose is #TALER_SIGNATURE_WALLET_PURSE_DELETE +   */ +  struct GNUNET_CRYPTO_EccSignaturePurpose purpose; + +}; + + +GNUNET_NETWORK_STRUCT_END + + +void +TALER_wallet_purse_delete_sign ( +  const struct TALER_PurseContractPrivateKeyP *purse_priv, +  struct TALER_PurseContractSignatureP *purse_sig) +{ +  struct TALER_PurseDeletePS pm = { +    .purpose.size = htonl (sizeof (pm)), +    .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_PURSE_DELETE) +  }; + +  GNUNET_CRYPTO_eddsa_sign (&purse_priv->eddsa_priv, +                            &pm, +                            &purse_sig->eddsa_signature); +} + + +enum GNUNET_GenericReturnValue +TALER_wallet_purse_delete_verify ( +  const struct TALER_PurseContractPublicKeyP *purse_pub, +  const struct TALER_PurseContractSignatureP *purse_sig) +{ +  struct TALER_PurseDeletePS pm = { +    .purpose.size = htonl (sizeof (pm)), +    .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_PURSE_DELETE) +  }; + +  return GNUNET_CRYPTO_eddsa_verify ( +    TALER_SIGNATURE_WALLET_PURSE_DELETE, +    &pm, +    &purse_sig->eddsa_signature, +    &purse_pub->eddsa_pub); +} + +  void  TALER_wallet_purse_status_sign (    const struct TALER_PurseContractPrivateKeyP *purse_priv, | 
