#include <gnutls/gnutls.h>
+#include "psk.h"
+
struct mem_st {
const uint8_t *data;
size_t size;
gnutls_session_t session;
gnutls_psk_client_credentials_t pcred;
struct mem_st memdata;
- gnutls_datum_t pskkey;
+ gnutls_datum_t psk_key;
- pskkey.data = (unsigned char*)"\x8a\x77\x59\xb3\xf2\x69\x83\xc4\x53\xe4\x48\x06\x0b\xde\x89\x81";
- pskkey.size = 16;
+ psk_key.data = (unsigned char*)psk_key16;
+ psk_key.size = 16;
res = gnutls_init(&session, GNUTLS_CLIENT);
assert(res >= 0);
res = gnutls_psk_allocate_client_credentials(&pcred);
assert(res >= 0);
- res = gnutls_psk_set_client_credentials(pcred, "test", &pskkey, GNUTLS_PSK_KEY_RAW);
+ res = gnutls_psk_set_client_credentials(pcred, "test", &psk_key, GNUTLS_PSK_KEY_RAW);
assert(res >= 0);
res = gnutls_credentials_set(session, GNUTLS_CRD_PSK, pcred);
--- /dev/null
+/*
+ * Copyright (C) 2017 Nikos Mavrogiannopoulos
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef PSK_H
+# define PSK_H
+
+static const uint8_t psk_key16[] = {
+ 0x8a, 0x77, 0x59, 0xb3, 0xf2, 0x69, 0x83, 0xc4,
+ 0x53, 0xe4, 0x48, 0x06, 0x0b, 0xde, 0x89, 0x81
+};
+
+#endif