diff --git a/.gitignore b/.gitignore index 2a416fabb8b0b6b2a912b5c1624acd6178776f9b..dfd066ca2cda1e34956bb5f9ff5bfb1591829f13 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ src/classpol src/cm src/ecpp src/ecpp-mpi +src/ecpp-check aclocal.m4 autom4te.cache/ diff --git a/src/ecpp-check.c b/src/ecpp-check.c new file mode 100644 index 0000000000000000000000000000000000000000..d9e866db4e6b41962d35f11f8f4659c36c2ec6c3 --- /dev/null +++ b/src/ecpp-check.c @@ -0,0 +1,59 @@ +/* + +ecpp-check.c - executable for verifying ECPP certificates + +Copyright (C) 2024 Andreas Enge + +This file is part of CM. + +CM 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. + +CM 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 CM; see the file COPYING. If not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "params.h" + +int main (int argc, char* argv []) +{ + char *filename; + int res, res_pari; + + cm_pari_init (); + + evaluate_parameters_ecpp_check (argc, argv, &filename); + + res = cm_pari_ecpp_file_check (filename, true, true); + + if (res == 1) + printf ("The file contains a valid ECPP certificate " + "in the CM format.\n"); + else if (res == 2) + printf ("The file contains a valid partial ECPP certificate " + "in the CM format.\n"); + else { + res_pari = cm_pari_ecpp_file_check (filename, false, true); + printf ("The certificate in the file is invalid according to the " + "CM specification.\n"); + if (res_pari == 1) + printf ("But it is valid "); + else if (res_pari == 2) + printf ("But it is a valid partial certificate "); + else + printf ("It is also invalid "); + printf ("according to the PARI/GP specification.\n"); + } + + cm_pari_clear (); + + return 0; +}