aboutsummaryrefslogtreecommitdiff
path: root/test_crypto.c
diff options
context:
space:
mode:
Diffstat (limited to 'test_crypto.c')
-rw-r--r--test_crypto.c176
1 files changed, 88 insertions, 88 deletions
diff --git a/test_crypto.c b/test_crypto.c
index 0517e52..9e84fee 100644
--- a/test_crypto.c
+++ b/test_crypto.c
@@ -31,130 +31,130 @@
static int
test_serialization ()
{
- gcry_mpi_point_t oldp = gcry_mpi_point_new (0);
- gcry_mpi_point_t newp = gcry_mpi_point_new (0);
- gcry_mpi_t oldi = gcry_mpi_new (256);
- gcry_mpi_t newi = gcry_mpi_new (256);
- struct ec_mpi serp;
- struct ec_mpi seri;
+ gcry_mpi_point_t oldp = gcry_mpi_point_new (0);
+ gcry_mpi_point_t newp = gcry_mpi_point_new (0);
+ gcry_mpi_t oldi = gcry_mpi_new (256);
+ gcry_mpi_t newi = gcry_mpi_new (256);
+ struct ec_mpi serp;
+ struct ec_mpi seri;
- ec_keypair_create (oldp, oldi);
+ ec_keypair_create (oldp, oldi);
- ec_point_serialize (&serp, oldp);
- mpi_serialize (&seri, oldi);
+ ec_point_serialize (&serp, oldp);
+ mpi_serialize (&seri, oldi);
- ec_point_parse (newp, &serp);
- mpi_parse (newi, &seri);
+ ec_point_parse (newp, &serp);
+ mpi_parse (newi, &seri);
- CHECK (!ec_point_cmp (oldp, newp), "serialization changed point");
- CHECK (!gcry_mpi_cmp (oldi, newi), "serialization changed mpi");
+ CHECK (! ec_point_cmp (oldp, newp), "serialization changed point");
+ CHECK (! gcry_mpi_cmp (oldi, newi), "serialization changed mpi");
- mpi_serialize (&seri, GCRYMPI_CONST_ONE);
- mpi_parse (newi, &seri);
- CHECK (!gcry_mpi_cmp (GCRYMPI_CONST_ONE, newi), "serializing mpi 1 fail");
+ mpi_serialize (&seri, GCRYMPI_CONST_ONE);
+ mpi_parse (newi, &seri);
+ CHECK (! gcry_mpi_cmp (GCRYMPI_CONST_ONE, newi), "serializing mpi 1 fail");
- gcry_mpi_point_release (oldp);
- gcry_mpi_point_release (newp);
- gcry_mpi_release (oldi);
- gcry_mpi_release (newi);
- return 1;
+ gcry_mpi_point_release (oldp);
+ gcry_mpi_point_release (newp);
+ gcry_mpi_release (oldi);
+ gcry_mpi_release (newi);
+ return 1;
}
static int
test_smc_zkp_dl ()
{
- struct proof_dl proof;
- gcry_mpi_t x = gcry_mpi_new (256);
- gcry_mpi_point_t v = gcry_mpi_point_new (0);
+ struct proof_dl proof;
+ gcry_mpi_t x = gcry_mpi_new (256);
+ gcry_mpi_point_t v = gcry_mpi_point_new (0);
- ec_skey_create (x);
+ ec_skey_create (x);
- smc_zkp_dl (v, x, &proof);
- CHECK (gcry_mpi_ec_curve_point (v, ec_ctx), "not on curve");
- CHECK (!smc_zkp_dl_check (v, &proof), "zkp dl wrong");
+ smc_zkp_dl (v, x, &proof);
+ CHECK (gcry_mpi_ec_curve_point (v, ec_ctx), "not on curve");
+ CHECK (! smc_zkp_dl_check (v, &proof), "zkp dl wrong");
- gcry_mpi_release (x);
- gcry_mpi_point_release (v);
- return 1;
+ gcry_mpi_release (x);
+ gcry_mpi_point_release (v);
+ return 1;
}
static int
test_smc_zkp_2dle ()
{
- struct proof_2dle proof;
- gcry_mpi_t x = gcry_mpi_new (256);
- gcry_mpi_point_t g1 = gcry_mpi_point_new (0);
- gcry_mpi_point_t g2 = gcry_mpi_point_new (0);
- gcry_mpi_point_t v = gcry_mpi_point_new (0);
- gcry_mpi_point_t w = gcry_mpi_point_new (0);
-
- ec_keypair_create (g1, x);
- ec_keypair_create (g2, x);
-
- smc_zkp_2dle (v, w, g1, g2, x, &proof);
- CHECK (gcry_mpi_ec_curve_point (g1, ec_ctx), "not on curve");
- CHECK (gcry_mpi_ec_curve_point (g2, ec_ctx), "not on curve");
- CHECK (gcry_mpi_ec_curve_point (v, ec_ctx), "not on curve");
- CHECK (gcry_mpi_ec_curve_point (w, ec_ctx), "not on curve");
- CHECK (!smc_zkp_2dle_check (v, w, g1, g2, &proof), "zkp 2dle wrong");
-
- gcry_mpi_release (x);
- gcry_mpi_point_release (g1);
- gcry_mpi_point_release (g2);
- gcry_mpi_point_release (v);
- gcry_mpi_point_release (w);
- return 1;
+ struct proof_2dle proof;
+ gcry_mpi_t x = gcry_mpi_new (256);
+ gcry_mpi_point_t g1 = gcry_mpi_point_new (0);
+ gcry_mpi_point_t g2 = gcry_mpi_point_new (0);
+ gcry_mpi_point_t v = gcry_mpi_point_new (0);
+ gcry_mpi_point_t w = gcry_mpi_point_new (0);
+
+ ec_keypair_create (g1, x);
+ ec_keypair_create (g2, x);
+
+ smc_zkp_2dle (v, w, g1, g2, x, &proof);
+ CHECK (gcry_mpi_ec_curve_point (g1, ec_ctx), "not on curve");
+ CHECK (gcry_mpi_ec_curve_point (g2, ec_ctx), "not on curve");
+ CHECK (gcry_mpi_ec_curve_point (v, ec_ctx), "not on curve");
+ CHECK (gcry_mpi_ec_curve_point (w, ec_ctx), "not on curve");
+ CHECK (! smc_zkp_2dle_check (v, w, g1, g2, &proof), "zkp 2dle wrong");
+
+ gcry_mpi_release (x);
+ gcry_mpi_point_release (g1);
+ gcry_mpi_point_release (g2);
+ gcry_mpi_point_release (v);
+ gcry_mpi_point_release (w);
+ return 1;
}
static int
test_smc_zkp_0og ()
{
- struct proof_0og proof;
- gcry_mpi_point_t y = gcry_mpi_point_new (0);
- gcry_mpi_point_t alpha = gcry_mpi_point_new (0);
- gcry_mpi_point_t beta = gcry_mpi_point_new (0);
-
- /* get random public key point. We don't need the secret key to check the
- * proof here */
- ec_keypair_create (y, NULL);
-
- smc_zkp_0og (tests_run % 2, y, NULL, alpha, beta, &proof);
- CHECK (gcry_mpi_ec_curve_point (alpha, ec_ctx), "not on curve");
- CHECK (gcry_mpi_ec_curve_point (beta, ec_ctx), "not on curve");
- CHECK (!smc_zkp_0og_check (y, alpha, beta, &proof), "zkp 0og is wrong");
-
- gcry_mpi_point_release (y);
- gcry_mpi_point_release (alpha);
- gcry_mpi_point_release (beta);
- return 1;
+ struct proof_0og proof;
+ gcry_mpi_point_t y = gcry_mpi_point_new (0);
+ gcry_mpi_point_t alpha = gcry_mpi_point_new (0);
+ gcry_mpi_point_t beta = gcry_mpi_point_new (0);
+
+ /* get random public key point. We don't need the secret key to check the
+ * proof here */
+ ec_keypair_create (y, NULL);
+
+ smc_zkp_0og (tests_run % 2, y, NULL, alpha, beta, &proof);
+ CHECK (gcry_mpi_ec_curve_point (alpha, ec_ctx), "not on curve");
+ CHECK (gcry_mpi_ec_curve_point (beta, ec_ctx), "not on curve");
+ CHECK (! smc_zkp_0og_check (y, alpha, beta, &proof), "zkp 0og is wrong");
+
+ gcry_mpi_point_release (y);
+ gcry_mpi_point_release (alpha);
+ gcry_mpi_point_release (beta);
+ return 1;
}
int
main (int argc, char *argv[])
{
- int repeat = 1;
- struct GNUNET_CRYPTO_EccDlogContext *edc;
+ int repeat = 1;
+ struct GNUNET_CRYPTO_EccDlogContext *edc;
- if (GNUNET_OK != GNUNET_log_setup ("test_crypto", "WARNING", NULL))
- return 1;
+ if (GNUNET_OK != GNUNET_log_setup ("test_crypto", "WARNING", NULL))
+ return 1;
- edc = GNUNET_CRYPTO_ecc_dlog_prepare (1024, 16);
- BRANDT_init (edc);
+ edc = GNUNET_CRYPTO_ecc_dlog_prepare (1024, 16);
+ BRANDT_init (edc);
- /* tests that need to run only once */
- RUN (test_serialization);
+ /* tests that need to run only once */
+ RUN (test_serialization);
- for (tests_run = 0; tests_run < repeat; tests_run++)
- {
- RUN (test_smc_zkp_dl);
- RUN (test_smc_zkp_2dle);
- RUN (test_smc_zkp_0og);
- }
+ for (tests_run = 0; tests_run < repeat; tests_run++)
+ {
+ RUN (test_smc_zkp_dl);
+ RUN (test_smc_zkp_2dle);
+ RUN (test_smc_zkp_0og);
+ }
- GNUNET_CRYPTO_ecc_dlog_release (edc);
- return ret;
+ GNUNET_CRYPTO_ecc_dlog_release (edc);
+ return ret;
}