summaryrefslogtreecommitdiff
path: root/src/lib/exchange_api_handle.c
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-01-17 20:50:09 +0100
committerFlorian Dold <florian.dold@gmail.com>2020-01-17 20:50:18 +0100
commit33877b2c55be2d9a4deaf56c709a7943dd00b62c (patch)
treec254c0ae815c1bd10ed424f32d9cc197461b23de /src/lib/exchange_api_handle.c
parentfbb4256d55ed448e45527b9fb229f566d35856c4 (diff)
downloadexchange-33877b2c55be2d9a4deaf56c709a7943dd00b62c.tar.gz
exchange-33877b2c55be2d9a4deaf56c709a7943dd00b62c.tar.bz2
exchange-33877b2c55be2d9a4deaf56c709a7943dd00b62c.zip
address fixme, fix use-after-free in testing traits
Diffstat (limited to 'src/lib/exchange_api_handle.c')
-rw-r--r--src/lib/exchange_api_handle.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/lib/exchange_api_handle.c b/src/lib/exchange_api_handle.c
index c3a0598f8..d7f56bc87 100644
--- a/src/lib/exchange_api_handle.c
+++ b/src/lib/exchange_api_handle.c
@@ -2128,6 +2128,43 @@ TALER_EXCHANGE_get_denomination_key (const struct TALER_EXCHANGE_Keys *keys,
/**
+ * Create a copy of a denomination public key.
+ *
+ * @param key key to copy
+ * @returns a copy, must be freed with #TALER_EXCHANGE_destroy_denomination_key
+ */
+struct TALER_EXCHANGE_DenomPublicKey *
+TALER_EXCHANGE_copy_denomination_key (const struct
+ TALER_EXCHANGE_DenomPublicKey *key)
+{
+ struct TALER_EXCHANGE_DenomPublicKey *copy;
+
+ copy = GNUNET_new (struct TALER_EXCHANGE_DenomPublicKey);
+ *copy = *key;
+ copy->key.rsa_public_key = GNUNET_CRYPTO_rsa_public_key_dup (
+ key->key.rsa_public_key);
+
+ return copy;
+}
+
+
+/**
+ * Destroy a denomination public key.
+ * Should only be called with keys created by #TALER_EXCHANGE_copy_denomination_key.
+ *
+ * @param key key to destroy.
+ */
+void
+TALER_EXCHANGE_destroy_denomination_key (struct
+ TALER_EXCHANGE_DenomPublicKey *key)
+{
+ GNUNET_CRYPTO_rsa_public_key_free (key->key.rsa_public_key);;
+ key->key.rsa_public_key = NULL;
+ GNUNET_free (key);
+}
+
+
+/**
* Obtain the denomination key details from the exchange.
*
* @param keys the exchange's key set