summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2010-10-14 22:30:23 +0200
committerSimon Josefsson <simon@josefsson.org>2010-10-14 22:30:23 +0200
commit4e3b72b5f159f072c8aea584342cf1d0e6efec4a (patch)
treed3bddd059b5e1e4d473ce5128733516be2e6cdb6
parent0e765c6a84d488936a07f8f2968d68d312b57e56 (diff)
downloadgnutls-4e3b72b5f159f072c8aea584342cf1d0e6efec4a.tar.gz
Add self test gendh to check DH generation.
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/gendh.c48
2 files changed, 49 insertions, 1 deletions
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 <config.h>
+#endif
+
+#include <stdio.h>
+
+#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");
+}