aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--brandt.c2
-rw-r--r--brandt.h1
-rw-r--r--crypto.c55
-rw-r--r--crypto.h6
-rw-r--r--internals.h1
-rw-r--r--test.h1
-rw-r--r--test_crypto.c10
-rw-r--r--util.c1
-rw-r--r--util.h22
9 files changed, 66 insertions, 33 deletions
diff --git a/brandt.c b/brandt.c
index 6a9f7c8..c5d5a61 100644
--- a/brandt.c
+++ b/brandt.c
@@ -17,6 +17,7 @@
/**
* @file brandt.c
* @brief \todo
+ * @author Markus Teich
*/
#include <gcrypt.h>
@@ -42,6 +43,5 @@ BRANDT_init ()
gcry_strerror (err));
gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
- brandt_rand_poll ();
brandt_crypto_init ();
}
diff --git a/brandt.h b/brandt.h
index a3ccc30..e66866d 100644
--- a/brandt.h
+++ b/brandt.h
@@ -17,6 +17,7 @@
/**
* @file brandt.h
* @brief This Header defines the external interface of libbrandt.
+ * @author Markus Teich
*/
#ifndef _BRANDT_BRANDT_H
diff --git a/crypto.c b/crypto.c
index d7aafef..b8e995e 100644
--- a/crypto.c
+++ b/crypto.c
@@ -17,6 +17,7 @@
/**
* @file crypto.c
* @brief Implementation of the crypto primitives.
+ * @author Markus Teich
*/
@@ -86,18 +87,6 @@ brandt_crypto_init ()
}
-/* --- RANDOM --- */
-
-void
-brandt_rand_poll ()
-{
- static unsigned char rand_amount = 255;
-
- if (!(rand_amount--))
- gcry_fast_random_poll ();
-}
-
-
/* --- HASHING --- */
/**
@@ -299,8 +288,11 @@ mpi_parse (gcry_mpi_t dst, const struct ec_mpi *src)
gcry_mpi_t ret;
gcry_error_t rc;
- rc = gcry_mpi_scan (&ret, GCRYMPI_FMT_USG,
- src, sizeof (struct ec_mpi), NULL);
+ rc = gcry_mpi_scan (&ret,
+ GCRYMPI_FMT_USG,
+ src,
+ sizeof (struct ec_mpi),
+ NULL);
brandt_assert_gpgerr (rc);
gcry_mpi_snatch (dst, ret);
@@ -369,6 +361,7 @@ ec_point_parse (gcry_mpi_point_t dst, const struct ec_mpi *src)
brandt_assert (ret);
gcry_ctx_release (ctx);
gcry_mpi_ec_mul (dst, GCRYMPI_CONST_ONE, ret, ec_ctx);
+ gcry_mpi_point_release (ret);
}
@@ -382,7 +375,8 @@ ec_point_parse (gcry_mpi_point_t dst, const struct ec_mpi *src)
static void
smc_free2 (gcry_mpi_point_t **dst, uint16_t size1, uint16_t size2)
{
- uint16_t i, j;
+ uint16_t i;
+ uint16_t j;
if (NULL == dst)
return;
@@ -406,7 +400,8 @@ smc_free2 (gcry_mpi_point_t **dst, uint16_t size1, uint16_t size2)
static gcry_mpi_point_t **
smc_init2 (uint16_t size1, uint16_t size2)
{
- uint16_t i, j;
+ uint16_t i;
+ uint16_t j;
gcry_mpi_point_t **ret;
gcry_mpi_point_t *data;
@@ -449,7 +444,9 @@ smc_free3 (gcry_mpi_point_t ***dst,
uint16_t size2,
uint16_t size3)
{
- uint16_t i, j, k;
+ uint16_t i;
+ uint16_t j;
+ uint16_t k;
if (NULL == dst)
return;
@@ -475,7 +472,9 @@ smc_free3 (gcry_mpi_point_t ***dst,
static gcry_mpi_point_t ***
smc_init3 (uint16_t size1, uint16_t size2, uint16_t size3)
{
- uint16_t i, j, k;
+ uint16_t i;
+ uint16_t j;
+ uint16_t k;
gcry_mpi_point_t ***ret;
gcry_mpi_point_t **layer1;
gcry_mpi_point_t *layer2;
@@ -667,8 +666,12 @@ smc_encrypt_bid (struct AuctionData *ad, size_t *buflen)
for (j = 0; j < ad->k; j++)
{
proof3 = (struct proof_0og *)(cur + 2 * sizeof (struct ec_mpi));
- smc_zkp_0og (j == ad->b, ad->Y, r_part,
- ad->alpha[ad->i][j], ad->beta[ad->i][j], proof3);
+ smc_zkp_0og (j == ad->b,
+ ad->Y,
+ r_part,
+ ad->alpha[ad->i][j],
+ ad->beta[ad->i][j],
+ proof3);
ec_point_serialize ((struct ec_mpi *)cur, ad->alpha[ad->i][j]);
ec_point_serialize (&((struct ec_mpi *)cur)[1], ad->beta[ad->i][j]);
gcry_mpi_addm (r_sum, r_sum, r_part, ec_n);
@@ -726,7 +729,10 @@ smc_recv_encrypted_bid (struct AuctionData *ad,
}
gcry_mpi_ec_sub (alpha_sum, alpha_sum, ec_gen, ec_ctx);
- if (smc_zkp_2dle_check (alpha_sum, beta_sum, ad->Y, ec_gen,
+ if (smc_zkp_2dle_check (alpha_sum,
+ beta_sum,
+ ad->Y,
+ ec_gen,
(struct proof_2dle *)cur))
{
weprintf ("wrong zkp2 for alpha, beta received");
@@ -757,7 +763,8 @@ quit:
void
smc_compute_outcome (struct AuctionData *ad)
{
- uint16_t i, j;
+ uint16_t i;
+ uint16_t j;
// create temporary table with partial sums
@@ -900,8 +907,8 @@ smc_zkp_2dle (gcry_mpi_point_t v,
gcry_mpi_t c = gcry_mpi_new (0);
gcry_mpi_t z = gcry_mpi_new (0);
- rv = (NULL == v) ? rv = gcry_mpi_point_new (0) : v;
- rw = (NULL == w) ? rw = gcry_mpi_point_new (0) : w;
+ rv = (NULL == v) ? gcry_mpi_point_new (0) : v;
+ rw = (NULL == w) ? gcry_mpi_point_new (0) : w;
/* v = x*g1 */
gcry_mpi_ec_mul (rv, x, g1, ec_ctx);
diff --git a/crypto.h b/crypto.h
index d00a138..77e1848 100644
--- a/crypto.h
+++ b/crypto.h
@@ -17,6 +17,7 @@
/**
* @file crypto.h
* @brief Interface of the crypto primitives.
+ * @author Markus Teich
*/
#ifndef _BRANDT_CRYPTO_H
@@ -30,11 +31,6 @@
void brandt_crypto_init ();
-/* --- RANDOM --- */
-
-void brandt_rand_poll ();
-
-
/* --- HASHING --- */
struct brandt_hash_code {
diff --git a/internals.h b/internals.h
index 06ec88c..1e6eb18 100644
--- a/internals.h
+++ b/internals.h
@@ -17,6 +17,7 @@
/**
* @file internals.h
* @brief This header contains library internal structs.
+ * @author Markus Teich
*/
#ifndef _BRANDT_INTERNALS_H
diff --git a/test.h b/test.h
index da9485e..9e93b25 100644
--- a/test.h
+++ b/test.h
@@ -17,6 +17,7 @@
/**
* @file test.h
* @brief Some helpers for running tests
+ * @author Markus Teich
*/
#ifndef _BRANDT_TEST_H
#define _BRANDT_TEST_H
diff --git a/test_crypto.c b/test_crypto.c
index 33b9a9b..c0e9740 100644
--- a/test_crypto.c
+++ b/test_crypto.c
@@ -17,6 +17,7 @@
/**
* @file test_crypto.c
* @brief testing crypto and smc functions.
+ * @author Markus Teich
*/
/* For testing static functions and variables we include the whole source */
@@ -259,10 +260,13 @@ test_round1 ()
void
cleanup_auction_data ()
{
- uint16_t i;
-
- for (i = 0; i < bidders; i++)
+ for (uint16_t i = 0; i < bidders; i++)
{
+ for (uint16_t h = 0; h < bidders; h++)
+ gcry_mpi_point_release (ad[i].y[h]);
+
+ gcry_mpi_point_release (ad[i].Y);
+ gcry_mpi_release (ad[i].x);
free (ad[i].y);
smc_free2 (ad[i].alpha, ad[i].n, ad[i].k);
smc_free2 (ad[i].beta, ad[i].n, ad[i].k);
diff --git a/util.c b/util.c
index 5eebd3c..2b44710 100644
--- a/util.c
+++ b/util.c
@@ -17,6 +17,7 @@
/**
* @file util.c
* @brief \todo
+ * @author Markus Teich
*/
#include <stdarg.h>
#include <stdio.h>
diff --git a/util.h b/util.h
index 7e4df86..4af3f74 100644
--- a/util.h
+++ b/util.h
@@ -1,3 +1,25 @@
+/* This file is part of libbrandt.
+ * Copyright (C) 2016 GNUnet e.V.
+ *
+ * libbrandt is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * libbrandt is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * libbrandt. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @file util.h
+ * @brief \todo
+ * @author Markus Teich
+ */
+
#ifndef _BRANDT_UTIL_H
#define _BRANDT_UTIL_H