diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2021-10-25 13:54:38 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-10-27 09:23:13 +0200 |
commit | 58ea04167ca46e7ef82d25900cae731741854279 (patch) | |
tree | c322cab80cddb21cad4e809b5d8fda41b4b48819 /src/util/denom.c | |
parent | 201d6ea5c9eac6f8e02cfcff996eb5e871d3b53f (diff) | |
download | exchange-58ea04167ca46e7ef82d25900cae731741854279.tar.xz |
-fix misc FTBFS
Diffstat (limited to 'src/util/denom.c')
-rw-r--r-- | src/util/denom.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/util/denom.c b/src/util/denom.c index 694f5ff88..5ea4aca29 100644 --- a/src/util/denom.c +++ b/src/util/denom.c @@ -169,4 +169,58 @@ TALER_denom_sig_free (struct TALER_DenominationSignature *denom_sig) } +/** + * Make a (deep) copy of the given @a denom_src to + * @a denom_dst. + * + * @param[out] denom_dst target to copy to + * @param denom_str public key to copy + */ +void +TALER_denom_pub_deep_copy (struct TALER_DenominationPublicKey *denom_dst, + const struct TALER_DenominationPublicKey *denom_src) +{ + *denom_dst = *denom_src; /* shallow copy */ + switch (denom_src->cipher) + { + case TALER_DENOMINATION_RSA: + denom_dst->details.rsa_public_key + = GNUNET_CRYPTO_rsa_public_key_dup ( + denom_src->details.rsa_public_key); + return; + // TODO: add case for Clause-Schnorr + default: + GNUNET_assert (0); + } +} + + +/** + * Compare two denomination public keys. + * + * @param denom1 first key + * @param denom2 second key + * @return 0 if the keys are equal, otherwise -1 or 1 + */ +int +TALER_denom_pub_cmp (const struct TALER_DenominationPublicKey *denom1, + const struct TALER_DenominationPublicKey *denom2) +{ + if (denom1->cipher != denom2->cipher) + return (denom1->cipher > denom2->cipher) ? 1 : -1; + if (denom1->age_mask != denom2->age_mask) + return (denom1->age_mask > denom2->age_mask) ? 1 : -1; + switch (denom1->cipher) + { + case TALER_DENOMINATION_RSA: + return GNUNET_CRYPTO_rsa_public_key_cmp (denom1->details.rsa_public_key, + denom2->details.rsa_public_key); + // TODO: add case for Clause-Schnorr + default: + GNUNET_assert (0); + } + return -2; +} + + /* end of denom.c */ |