summaryrefslogtreecommitdiff
path: root/cesar/cp/sta/mgr
diff options
context:
space:
mode:
authorlaranjeiro2009-02-17 15:15:00 +0000
committerlaranjeiro2009-02-17 15:15:00 +0000
commite93188c6bdb24deeefbd6be2fb42d5886716e8fe (patch)
tree793a440fe84e461acec49c14e9f2e68a1ecc5fd9 /cesar/cp/sta/mgr
parent7cfdcfd86d0689fe16da1d41169dbc698f83fa0c (diff)
cp/sta/mgr: Added the function to store and get the TEK.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@4020 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cp/sta/mgr')
-rw-r--r--cesar/cp/sta/mgr/inc/sta_own_data.h5
-rw-r--r--cesar/cp/sta/mgr/src/sta_own_data.c16
-rw-r--r--cesar/cp/sta/mgr/sta_own_data.h16
-rw-r--r--cesar/cp/sta/mgr/test/src/sta-test.c28
4 files changed, 65 insertions, 0 deletions
diff --git a/cesar/cp/sta/mgr/inc/sta_own_data.h b/cesar/cp/sta/mgr/inc/sta_own_data.h
index 26972b0d17..0e955cd50f 100644
--- a/cesar/cp/sta/mgr/inc/sta_own_data.h
+++ b/cesar/cp/sta/mgr/inc/sta_own_data.h
@@ -86,6 +86,11 @@ struct cp_sta_own_data_private_t
* The station SNID.
*/
cp_snid_t snid;
+
+ /**
+ * The current TEK.
+ */
+ cp_key_t tek;
};
#endif /* cp_sta_data_inc_sta_own_data_h */
diff --git a/cesar/cp/sta/mgr/src/sta_own_data.c b/cesar/cp/sta/mgr/src/sta_own_data.c
index 1eca249716..3da78dfff1 100644
--- a/cesar/cp/sta/mgr/src/sta_own_data.c
+++ b/cesar/cp/sta/mgr/src/sta_own_data.c
@@ -518,3 +518,19 @@ cp_sta_own_data_get_snid (cp_t *ctx)
return ctx->sta_mgr.sta_own_data.snid;
}
+void
+cp_sta_own_data_set_tek (cp_t *ctx, const cp_key_t key)
+{
+ dbg_assert (ctx);
+
+ memcpy (&ctx->sta_mgr.sta_own_data.tek, &key, sizeof (cp_key_t));
+}
+
+cp_key_t
+cp_sta_own_data_get_tek (cp_t *ctx)
+{
+ dbg_assert (ctx);
+
+ return ctx->sta_mgr.sta_own_data.tek;
+}
+
diff --git a/cesar/cp/sta/mgr/sta_own_data.h b/cesar/cp/sta/mgr/sta_own_data.h
index 3a47ba4b5d..78ffd93a51 100644
--- a/cesar/cp/sta/mgr/sta_own_data.h
+++ b/cesar/cp/sta/mgr/sta_own_data.h
@@ -339,6 +339,22 @@ cp_sta_own_data_set_snid (cp_t *ctx, cp_snid_t snid);
cp_snid_t
cp_sta_own_data_get_snid (cp_t *ctx);
+/**
+ * Set the current TEK.
+ * \param ctx the module context.
+ * \param key the TEK.
+ */
+void
+cp_sta_own_data_set_tek (cp_t *ctx, const cp_key_t key);
+
+/**
+ * Get the current TEK.
+ * \param ctx the module context.
+ * \return the TEK.
+ */
+cp_key_t
+cp_sta_own_data_get_tek (cp_t *ctx);
+
END_DECLS
#endif /* cp_sta_data_sta_own_data_h */
diff --git a/cesar/cp/sta/mgr/test/src/sta-test.c b/cesar/cp/sta/mgr/test/src/sta-test.c
index e0bedf12aa..0f098752c6 100644
--- a/cesar/cp/sta/mgr/test/src/sta-test.c
+++ b/cesar/cp/sta/mgr/test/src/sta-test.c
@@ -460,6 +460,33 @@ test_case_cp_sta_own_data__snid (test_t test)
test_end;
}
+void
+test_case_cp_sta_own_data__tek (test_t test)
+{
+ test_case_begin (test, "Set the TEK");
+
+ test_begin (test, "TEK")
+ {
+ cp_t cp;
+ cp_key_t key;
+ uint i;
+ cp_key_t tek;
+
+ cp_sta_mgr_init (&cp);
+
+ key.key[0] = 0x12345678;
+ key.key[1] = 0x12345678;
+ key.key[2] = 0x12345678;
+ key.key[3] = 0x12345678;
+
+ cp_sta_own_data_set_tek (&cp, key);
+
+ tek = cp_sta_own_data_get_tek (&cp);
+
+ test_fail_unless (memcmp (&tek, &key, sizeof (cp_key_t)) == 0);
+ }
+ test_end;
+}
int
main (void)
@@ -485,6 +512,7 @@ main (void)
test_case_cp_sta_own_data__authenticated_status (test);
test_case_cp_sta_own_data__nid (test);
test_case_cp_sta_own_data__snid (test);
+ test_case_cp_sta_own_data__tek (test);
test_result (test);
return test_nb_failed (test) == 0 ? 0 : 1;