]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Add self test gendh to check DH generation.
authorSimon Josefsson <simon@josefsson.org>
Thu, 14 Oct 2010 20:30:23 +0000 (22:30 +0200)
committerSimon Josefsson <simon@josefsson.org>
Thu, 14 Oct 2010 20:30:23 +0000 (22:30 +0200)
tests/Makefile.am
tests/gendh.c [new file with mode: 0644]

index 875173e46587007274e5f3c20ec6a32477ec190f..4a42a098d64938adcc264a8acf632a0cb872174e 100644 (file)
@@ -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 (file)
index 0000000..e3732bb
--- /dev/null
@@ -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");
+}