/*
This file is part of GNUnet.
- (C) 2014 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2014 GNUnet e.V.
- GNUnet 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, or (at your
- option) any later version.
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
GNUnet 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.
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
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;
}