aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crypto.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/crypto.c b/crypto.c
index 71ee706..e96fd0e 100644
--- a/crypto.c
+++ b/crypto.c
@@ -404,11 +404,7 @@ smc_init1 (uint16_t size1)
{
gcry_mpi_point_t *ret;
- if (NULL == (ret = calloc (size1, sizeof (*ret))))
- {
- weprintf ("could not alloc memory for 1 dimensional point array");
- return NULL;
- }
+ ret = GNUNET_new_array (size1, gcry_mpi_point_t);
for (uint16_t i = 0; i < size1; i++)
{
@@ -629,8 +625,8 @@ smc_gen_keyshare (struct BRANDT_Auction *ad, size_t *buflen)
brandt_assert (ad && buflen);
*buflen = (sizeof (struct ec_mpi) + sizeof (*proof1));
- if (NULL == (ret = calloc (1, *buflen)) ||
- NULL == (ad->y = smc_init1 (ad->n)))
+ ret = GNUNET_new_array (*buflen, unsigned char);
+ if (NULL == (ad->y = smc_init1 (ad->n)))
{
weprintf ("unable to alloc memory for key shares");
return NULL;
@@ -701,8 +697,8 @@ smc_encrypt_bid (struct BRANDT_Auction *ad, size_t *buflen)
(sizeof (struct ec_mpi) * 2 + /* alpha, beta */
sizeof (*proof3)) +
sizeof (struct proof_2dle));
- if (NULL == (cur = (ret = calloc (1, *buflen))) ||
- NULL == (ad->alpha = smc_init2 (ad->n, ad->k)) ||
+ cur = ret = GNUNET_new_array (*buflen, unsigned char);
+ if (NULL == (ad->alpha = smc_init2 (ad->n, ad->k)) ||
NULL == (ad->beta = smc_init2 (ad->n, ad->k)))
{
weprintf ("unable to alloc memory for encrypted bids");
@@ -829,8 +825,8 @@ fp_pub_compute_outcome (struct BRANDT_Auction *ad, size_t *buflen)
brandt_assert (ad && buflen);
*buflen = (ad->k * (sizeof (*gamma) + sizeof (*delta) + sizeof (*proof2)));
- if (NULL == (cur = (ret = calloc (1, *buflen))) ||
- NULL == (ad->gamma2 = smc_init2 (ad->n, ad->k)) ||
+ cur = ret = GNUNET_new_array (*buflen, unsigned char);
+ if (NULL == (ad->gamma2 = smc_init2 (ad->n, ad->k)) ||
NULL == (ad->delta2 = smc_init2 (ad->n, ad->k)) ||
NULL == (ad->tmpa1 = smc_init1 (ad->k)) ||
NULL == (ad->tmpb1 = smc_init1 (ad->k)))
@@ -1018,8 +1014,8 @@ fp_pub_decrypt_outcome (struct BRANDT_Auction *ad, size_t *buflen)
brandt_assert (ad && buflen);
*buflen = (ad->k * (sizeof (*phi) + sizeof (*proof2)));
- if (NULL == (cur = (ret = calloc (1, *buflen))) ||
- NULL == (ad->phi2 = smc_init2 (ad->n, ad->k)))
+ cur = ret = GNUNET_new_array (*buflen, unsigned char);
+ if (NULL == (ad->phi2 = smc_init2 (ad->n, ad->k)))
{
weprintf ("unable to alloc memory for first price outcome decryption");
return NULL;
@@ -1171,8 +1167,8 @@ fp_priv_compute_outcome (struct BRANDT_Auction *ad, size_t *buflen)
*buflen = (ad->n * ad->k * /* nk * (gamma, delta, proof2) */
(sizeof (*gamma) + sizeof (*delta) + sizeof (*proof2)));
- if (NULL == (cur = (ret = calloc (1, *buflen))) ||
- NULL == (ad->gamma3 = smc_init3 (ad->n, ad->n, ad->k)) ||
+ cur = ret = GNUNET_new_array (*buflen, unsigned char);
+ if (NULL == (ad->gamma3 = smc_init3 (ad->n, ad->n, ad->k)) ||
NULL == (ad->delta3 = smc_init3 (ad->n, ad->n, ad->k)))
{
weprintf ("unable to alloc memory for first price outcome computation");
@@ -1363,8 +1359,8 @@ fp_priv_decrypt_outcome (struct BRANDT_Auction *ad, size_t *buflen)
brandt_assert (ad && buflen);
*buflen = (ad->n * ad->k * (sizeof (*phi) + sizeof (*proof2)));
- if (NULL == (cur = (ret = calloc (1, *buflen))) ||
- NULL == (ad->phi3 = smc_init3 (ad->n, ad->n, ad->k)))
+ cur = ret = GNUNET_new_array (*buflen, unsigned char);
+ if (NULL == (ad->phi3 = smc_init3 (ad->n, ad->n, ad->k)))
{
weprintf ("unable to alloc memory for first price outcome decryption");
return NULL;