use GNUNET_new_array instead of calloc
This commit is contained in:
parent
f55d10d5f6
commit
f64f620b07
30
crypto.c
30
crypto.c
@ -404,11 +404,7 @@ smc_init1 (uint16_t size1)
|
|||||||
{
|
{
|
||||||
gcry_mpi_point_t *ret;
|
gcry_mpi_point_t *ret;
|
||||||
|
|
||||||
if (NULL == (ret = calloc (size1, sizeof (*ret))))
|
ret = GNUNET_new_array (size1, gcry_mpi_point_t);
|
||||||
{
|
|
||||||
weprintf ("could not alloc memory for 1 dimensional point array");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uint16_t i = 0; i < size1; i++)
|
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);
|
brandt_assert (ad && buflen);
|
||||||
*buflen = (sizeof (struct ec_mpi) + sizeof (*proof1));
|
*buflen = (sizeof (struct ec_mpi) + sizeof (*proof1));
|
||||||
if (NULL == (ret = calloc (1, *buflen)) ||
|
ret = GNUNET_new_array (*buflen, unsigned char);
|
||||||
NULL == (ad->y = smc_init1 (ad->n)))
|
if (NULL == (ad->y = smc_init1 (ad->n)))
|
||||||
{
|
{
|
||||||
weprintf ("unable to alloc memory for key shares");
|
weprintf ("unable to alloc memory for key shares");
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -701,8 +697,8 @@ smc_encrypt_bid (struct BRANDT_Auction *ad, size_t *buflen)
|
|||||||
(sizeof (struct ec_mpi) * 2 + /* alpha, beta */
|
(sizeof (struct ec_mpi) * 2 + /* alpha, beta */
|
||||||
sizeof (*proof3)) +
|
sizeof (*proof3)) +
|
||||||
sizeof (struct proof_2dle));
|
sizeof (struct proof_2dle));
|
||||||
if (NULL == (cur = (ret = calloc (1, *buflen))) ||
|
cur = ret = GNUNET_new_array (*buflen, unsigned char);
|
||||||
NULL == (ad->alpha = smc_init2 (ad->n, ad->k)) ||
|
if (NULL == (ad->alpha = smc_init2 (ad->n, ad->k)) ||
|
||||||
NULL == (ad->beta = smc_init2 (ad->n, ad->k)))
|
NULL == (ad->beta = smc_init2 (ad->n, ad->k)))
|
||||||
{
|
{
|
||||||
weprintf ("unable to alloc memory for encrypted bids");
|
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);
|
brandt_assert (ad && buflen);
|
||||||
|
|
||||||
*buflen = (ad->k * (sizeof (*gamma) + sizeof (*delta) + sizeof (*proof2)));
|
*buflen = (ad->k * (sizeof (*gamma) + sizeof (*delta) + sizeof (*proof2)));
|
||||||
if (NULL == (cur = (ret = calloc (1, *buflen))) ||
|
cur = ret = GNUNET_new_array (*buflen, unsigned char);
|
||||||
NULL == (ad->gamma2 = smc_init2 (ad->n, ad->k)) ||
|
if (NULL == (ad->gamma2 = smc_init2 (ad->n, ad->k)) ||
|
||||||
NULL == (ad->delta2 = smc_init2 (ad->n, ad->k)) ||
|
NULL == (ad->delta2 = smc_init2 (ad->n, ad->k)) ||
|
||||||
NULL == (ad->tmpa1 = smc_init1 (ad->k)) ||
|
NULL == (ad->tmpa1 = smc_init1 (ad->k)) ||
|
||||||
NULL == (ad->tmpb1 = 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);
|
brandt_assert (ad && buflen);
|
||||||
|
|
||||||
*buflen = (ad->k * (sizeof (*phi) + sizeof (*proof2)));
|
*buflen = (ad->k * (sizeof (*phi) + sizeof (*proof2)));
|
||||||
if (NULL == (cur = (ret = calloc (1, *buflen))) ||
|
cur = ret = GNUNET_new_array (*buflen, unsigned char);
|
||||||
NULL == (ad->phi2 = smc_init2 (ad->n, ad->k)))
|
if (NULL == (ad->phi2 = smc_init2 (ad->n, ad->k)))
|
||||||
{
|
{
|
||||||
weprintf ("unable to alloc memory for first price outcome decryption");
|
weprintf ("unable to alloc memory for first price outcome decryption");
|
||||||
return NULL;
|
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) */
|
*buflen = (ad->n * ad->k * /* nk * (gamma, delta, proof2) */
|
||||||
(sizeof (*gamma) + sizeof (*delta) + sizeof (*proof2)));
|
(sizeof (*gamma) + sizeof (*delta) + sizeof (*proof2)));
|
||||||
if (NULL == (cur = (ret = calloc (1, *buflen))) ||
|
cur = ret = GNUNET_new_array (*buflen, unsigned char);
|
||||||
NULL == (ad->gamma3 = smc_init3 (ad->n, ad->n, ad->k)) ||
|
if (NULL == (ad->gamma3 = smc_init3 (ad->n, ad->n, ad->k)) ||
|
||||||
NULL == (ad->delta3 = 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");
|
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);
|
brandt_assert (ad && buflen);
|
||||||
|
|
||||||
*buflen = (ad->n * ad->k * (sizeof (*phi) + sizeof (*proof2)));
|
*buflen = (ad->n * ad->k * (sizeof (*phi) + sizeof (*proof2)));
|
||||||
if (NULL == (cur = (ret = calloc (1, *buflen))) ||
|
cur = ret = GNUNET_new_array (*buflen, unsigned char);
|
||||||
NULL == (ad->phi3 = smc_init3 (ad->n, ad->n, ad->k)))
|
if (NULL == (ad->phi3 = smc_init3 (ad->n, ad->n, ad->k)))
|
||||||
{
|
{
|
||||||
weprintf ("unable to alloc memory for first price outcome decryption");
|
weprintf ("unable to alloc memory for first price outcome decryption");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user