/* mod = cmum1 / n (mod n) */
GNUNET_assert (0 != (mod = gcry_mpi_new (0)));
gcry_mpi_div (mod, NULL, cmum1, n, 0);
+ gcry_mpi_release (cmum1);
/* m = mod * mu mod n */
gcry_mpi_mulm (m, mod, mu, n);
+ gcry_mpi_release (mod);
gcry_mpi_release (mu);
gcry_mpi_release (n);
}
struct GNUNET_CRYPTO_PaillierCiphertext ciphertext;
struct GNUNET_CRYPTO_PaillierPublicKey public_key;
struct GNUNET_CRYPTO_PaillierPrivateKey private_key;
+ int ret = 0;
GNUNET_CRYPTO_paillier_create (&public_key,
&private_key);
&public_key,
&ciphertext,
plaintext_result);
-
if (0 != gcry_mpi_cmp (plaintext,
plaintext_result))
{
plaintext);
gcry_log_debugmpi ("\n",
plaintext_result);
- return 1;
+ ret = 1;
}
- return 0;
+ gcry_mpi_release (plaintext);
+ gcry_mpi_release (plaintext_result);
+ return ret;
}
struct GNUNET_CRYPTO_PaillierCiphertext c_result;
struct GNUNET_CRYPTO_PaillierPublicKey public_key;
struct GNUNET_CRYPTO_PaillierPrivateKey private_key;
+ int ret = 0;
GNUNET_CRYPTO_paillier_create (&public_key,
&private_key);
"GNUNET_CRYPTO_paillier failed simple math!\n");
gcry_log_debugmpi ("got ", hom_result);
gcry_log_debugmpi ("wanted ", result);
- return 1;
+ ret = 1;
}
- return 0;
+ gcry_mpi_release (m1);
+ gcry_mpi_release (m2);
+ gcry_mpi_release (result);
+ gcry_mpi_release (hom_result);
+ return ret;
}
fprintf (stderr,
"GNUNET_CRYPTO_paillier_encrypt 1 failed, should return 1 allowed operation, got %d!\n",
ret);
- return 1;
+ ret = 1;
+ goto out;
}
if (2 != (ret = GNUNET_CRYPTO_paillier_encrypt (&public_key,
m2,
fprintf (stderr,
"GNUNET_CRYPTO_paillier_encrypt 2 failed, should return 2 allowed operation, got %d!\n",
ret);
- return 1;
+ ret = 1;
+ goto out;
}
if (0 != (ret = GNUNET_CRYPTO_paillier_hom_add (&public_key,
fprintf (stderr,
"GNUNET_CRYPTO_paillier_hom_add failed, expected 0 remaining operations, got %d!\n",
ret);
- return 1;
+ ret = 1;
+ goto out;
}
GNUNET_CRYPTO_paillier_decrypt (&private_key,
"GNUNET_CRYPTO_paillier miscalculated with large numbers!\n");
gcry_log_debugmpi ("got", hom_result);
gcry_log_debugmpi ("wanted", result);
- return 1;
+ ret = 1;
}
- return 0;
+out:
+ gcry_mpi_release (m1);
+ gcry_mpi_release (m2);
+ gcry_mpi_release (result);
+ gcry_mpi_release (hom_result);
+ return ret;
}