summaryrefslogtreecommitdiff
path: root/src/util/taler-exchange-secmod-cs.c
diff options
context:
space:
mode:
authorGian Demarmels <gian@demarmels.org>2022-01-11 21:21:18 +0100
committerGian Demarmels <gian@demarmels.org>2022-02-04 15:36:11 +0100
commit5b7e8f9ac55990823363edffa0e907256d15ce4f (patch)
tree7c0b265ea23c46a40e131ea3eea16090688b0a0c /src/util/taler-exchange-secmod-cs.c
parentdaa7fdcfb1053bdd943ad7cd1bd8eb623d1c9157 (diff)
downloadexchange-5b7e8f9ac55990823363edffa0e907256d15ce4f.tar.gz
exchange-5b7e8f9ac55990823363edffa0e907256d15ce4f.tar.bz2
exchange-5b7e8f9ac55990823363edffa0e907256d15ce4f.zip
refactoring
Diffstat (limited to 'src/util/taler-exchange-secmod-cs.c')
-rw-r--r--src/util/taler-exchange-secmod-cs.c31
1 files changed, 7 insertions, 24 deletions
diff --git a/src/util/taler-exchange-secmod-cs.c b/src/util/taler-exchange-secmod-cs.c
index d7624a0b9..8ff8dc79b 100644
--- a/src/util/taler-exchange-secmod-cs.c
+++ b/src/util/taler-exchange-secmod-cs.c
@@ -242,15 +242,15 @@ generate_response (struct DenominationKey *dk)
GNUNET_assert (sizeof(dk->denom_pub) < UINT16_MAX);
GNUNET_assert (nlen < UINT16_MAX);
- tlen = sizeof(dk->denom_pub) + nlen + sizeof (*an);
+ tlen = nlen + sizeof (*an);
GNUNET_assert (tlen < UINT16_MAX);
an = GNUNET_malloc (tlen);
an->header.size = htons ((uint16_t) tlen);
an->header.type = htons (TALER_HELPER_CS_MT_AVAIL);
- an->pub_size = htons ((uint16_t) sizeof(dk->denom_pub));
an->section_name_len = htons ((uint16_t) nlen);
an->anchor_time = GNUNET_TIME_timestamp_hton (dk->anchor);
an->duration_withdraw = GNUNET_TIME_relative_hton (denom->duration_withdraw);
+ an->denom_pub = dk->denom_pub;
TALER_exchange_secmod_cs_sign (&dk->h_cs,
denom->section,
dk->anchor,
@@ -260,9 +260,6 @@ generate_response (struct DenominationKey *dk)
an->secm_pub = TES_smpub;
p = (void *) &an[1];
memcpy (p,
- &dk->denom_pub,
- sizeof(dk->denom_pub));
- memcpy (p + sizeof(dk->denom_pub),
denom->section,
nlen);
dk->an = an;
@@ -1078,8 +1075,7 @@ update_denominations (void *cls)
static void
parse_key (struct Denomination *denom,
const char *filename,
- const void *buf,
- size_t buf_size)
+ const struct GNUNET_CRYPTO_CsPrivateKey *priv)
{
char *anchor_s;
char dummy;
@@ -1117,27 +1113,15 @@ parse_key (struct Denomination *denom,
filename);
return;
}
-
- const struct GNUNET_CRYPTO_CsPrivateKey priv
- = *((struct GNUNET_CRYPTO_CsPrivateKey *) buf);
-// memcpy (&priv, buf, sizeof(priv));
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "privkey %zu\n",
- sizeof(priv));
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "privkey %zu\n",
- buf_size);
-
{
struct GNUNET_CRYPTO_CsPublicKey pub;
struct DenominationKey *dk;
struct DenominationKey *before;
// TODO: Add check if pubkey is set?
- GNUNET_CRYPTO_cs_private_key_get_public (&priv, &pub);
+ GNUNET_CRYPTO_cs_private_key_get_public (priv, &pub);
dk = GNUNET_new (struct DenominationKey);
- dk->denom_priv = priv;
+ dk->denom_priv = *priv;
dk->denom = denom;
dk->anchor = anchor;
dk->filename = GNUNET_strdup (filename);
@@ -1270,7 +1254,7 @@ import_key (void *cls,
GNUNET_break (0 == close (fd));
return GNUNET_OK;
}
- if (sbuf.st_size > 16 * 1024)
+ if (sbuf.st_size != sizeof(struct GNUNET_CRYPTO_CsPrivateKey))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"File `%s' too big to be a private key\n",
@@ -1292,8 +1276,7 @@ import_key (void *cls,
}
parse_key (denom,
filename,
- ptr,
- (size_t) sbuf.st_size);
+ (const struct GNUNET_CRYPTO_CsPrivateKey *) ptr);
GNUNET_DISK_file_unmap (map);
GNUNET_DISK_file_close (fh);
return GNUNET_OK;