From: Simon Josefsson Date: Thu, 14 Oct 2010 20:30:23 +0000 (+0200) Subject: Add self test gendh to check DH generation. X-Git-Tag: gnutls_2_11_4~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4e3b72b5f159f072c8aea584342cf1d0e6efec4a;p=thirdparty%2Fgnutls.git Add self test gendh to check DH generation. --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 875173e465..4a42a098d6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -60,7 +60,7 @@ ctests = simple gc set_pkcs12_cred certder certuniqueid mpi \ crq_key_id x509sign-verify cve-2009-1415 cve-2009-1416 \ crq_apis init_roundtrip pkcs12_s2k_pem dn2 mini-eagain \ nul-in-x509-names x509_altname pkcs12_encode mini-x509 \ - mini-x509-rehandshake + mini-x509-rehandshake gendh if ENABLE_OPENSSL ctests += openssl diff --git a/tests/gendh.c b/tests/gendh.c new file mode 100644 index 0000000000..e3732bb4c5 --- /dev/null +++ b/tests/gendh.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2010 Free Software Foundation, Inc. + * + * Author: Simon Josefsson + * + * This file is part of GnuTLS. + * + * GnuTLS 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. + * + * GnuTLS 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 GnuTLS; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "utils.h" + +void +doit (void) +{ + gnutls_dh_params_t dh_params = NULL; + int rc; + + rc = gnutls_global_init (); + if (rc) + fail ("gnutls_global_init\n"); + + if (gnutls_dh_params_init (&dh_params) < 0) + fail ("Error in dh parameter initialization\n"); + + if (gnutls_dh_params_generate2 (dh_params, 1024) < 0) + fail ("Error in prime generation\n"); + + success ("generated DH params OK\n"); +}