summaryrefslogtreecommitdiff
path: root/cesar/cp/eoc/cco/action/test/utest_eoc/src/cp_stub.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/cp/eoc/cco/action/test/utest_eoc/src/cp_stub.c')
-rw-r--r--cesar/cp/eoc/cco/action/test/utest_eoc/src/cp_stub.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/cesar/cp/eoc/cco/action/test/utest_eoc/src/cp_stub.c b/cesar/cp/eoc/cco/action/test/utest_eoc/src/cp_stub.c
new file mode 100644
index 0000000000..5114e52c33
--- /dev/null
+++ b/cesar/cp/eoc/cco/action/test/utest_eoc/src/cp_stub.c
@@ -0,0 +1,51 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file eoc/sta/action/test/utest/src/cp_stub.c
+ * \brief cp/cp.c stub
+ * \ingroup test
+ *
+ */
+#include "common/std.h"
+#include "cp/cp.h"
+#include "cp/mme.h"
+#include "cp/inc/context.h"
+#include "cp/msg/inc/cc_assoc.h"
+#include "cp/sta/mgr/inc/sta.h"
+#include "cp/eoc/sta/mgr/sta_mgr.h"
+
+/**
+ * Compute the NID and the NMK from the network password.
+ * \param ctx the CP context.
+ * \param npw the network password.
+ * \param sl the security level of the station.
+ *
+ * This function will generate the NID and the NMK from the NPW and store it
+ * in the station own data.
+ */
+void
+cp_compute_nmk_and_nid_from_npw (cp_t *ctx, const char *npw,
+ cp_security_level_t sl)
+{
+ u64 nid;
+ cp_key_t nmk;
+ uint length;
+
+ dbg_assert (ctx);
+ dbg_assert (npw);
+
+ length = strlen (npw);
+
+ nmk = cp_secu_npw2nmk (ctx, (const u8*) npw, length);
+ nid = cp_secu_nmk2nid (ctx, nmk, sl);
+
+ /* Store the nid and the nmk to the station own data. */
+ cp_sta_own_data_set_nid (ctx, nid);
+ cp_sta_own_data_set_nmk (ctx, nmk,
+ CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_NID);
+}