summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Josefsson <simon@josefsson.org>2008-04-08 17:14:54 +0200
committerSimon Josefsson <simon@josefsson.org>2008-04-08 17:14:54 +0200
commit4b83b60210bc97468af59c7f76505a9b4be6c1f4 (patch)
tree24b0cca7e8435952078a54422577465aee7d6e20
parent5d0fcb10f8c30fd474c4201583fe200705e4d8df (diff)
downloadgnutls-4b83b60210bc97468af59c7f76505a9b4be6c1f4.tar.gz
Starting pointer for NETCONF-PSK support.
-rw-r--r--tests/netconf-psk.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/netconf-psk.c b/tests/netconf-psk.c
new file mode 100644
index 0000000000..33b8d9b2e0
--- /dev/null
+++ b/tests/netconf-psk.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2008 Free Software Foundation
+ *
+ * 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
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <gnutls/gnutls.h>
+
+#include "utils.h"
+
+void
+doit (void)
+{
+ gnutls_datum_t key;
+ char *known = "foobarfoobarfoobarfoobar";
+ int rc;
+
+ gnutls_global_init ();
+
+ if (gnutls_psk_netconf_derive_key ("password", "psk_identity",
+ "psk_identity_hint", &key) == 0)
+ success ("success: gnutls_psk_netconf_derive_key\n");
+ else
+ fail ("gnutls_psk_netconf_derive_key failure\n");
+
+ if (key->size == 20 && memcmp (key->data, known, 20) == 0)
+ success ("success: match.\n");
+ else
+ fail ("FAIL: key differ.\n");
+
+ gnutls_free (key->data);
+
+ gnutls_global_deinit ();
+}