The added structures match 802.15.4-2011 link-layer security PIBs as
closely as is reasonable. Some lists required by the standard were
modeled as bitmaps (frame_types and command_frame_ids in *llsec_key),
since using lists for those seems a bit excessive and not particularly
useful.

For the mac802154 implementation of llsec, we only need containers with
a little management info for the ieee802154* versions of these structs.

Signed-off-by: Phoebe Buckheister <phoebe.buckheis...@itwm.fraunhofer.de>
---
 include/net/ieee802154_netdev.h |   95 +++++++++++++++++++++++++++++++++++++++
 net/mac802154/llsec.h           |   77 +++++++++++++++++++++++++++++++
 2 files changed, 172 insertions(+)
 create mode 100644 net/mac802154/llsec.h

diff --git a/include/net/ieee802154_netdev.h b/include/net/ieee802154_netdev.h
index 00061e1..57ff113 100644
--- a/include/net/ieee802154_netdev.h
+++ b/include/net/ieee802154_netdev.h
@@ -242,6 +242,88 @@ static inline struct ieee802154_mac_cb 
*mac_cb_alloc(struct sk_buff *skb)
        return mac_cb(skb);
 }
 
+#define IEEE802154_LLSEC_KEY_SIZE 16
+
+struct ieee802154_llsec_key_id {
+       u8 mode;
+       u8 id;
+       union {
+               struct ieee802154_addr device_addr;
+               __le32 short_source;
+               __le64 extended_source;
+       };
+};
+
+struct ieee802154_llsec_key {
+       u8 frame_types;
+       u32 cmd_frame_ids;
+       u8 key[IEEE802154_LLSEC_KEY_SIZE];
+};
+
+struct ieee802154_llsec_key_entry {
+       struct list_head list;
+
+       struct ieee802154_llsec_key_id id;
+       struct ieee802154_llsec_key *key;
+};
+
+struct ieee802154_llsec_device_key {
+       struct list_head list;
+
+       struct ieee802154_llsec_key_id key_id;
+       u32 frame_counter;
+};
+
+enum {
+       IEEE802154_LLSEC_DEVKEY_IGNORE,
+       IEEE802154_LLSEC_DEVKEY_RESTRICT,
+
+       __IEEE802154_LLSEC_DEVKEY_MAX,
+};
+
+struct ieee802154_llsec_device {
+       struct list_head list;
+
+       __le16 pan_id;
+       __le16 short_addr;
+       __le64 hwaddr;
+       u32 frame_counter;
+       bool seclevel_exempt;
+
+       u8 key_mode;
+       struct list_head keys;
+};
+
+struct ieee802154_llsec_seclevel {
+       struct list_head list;
+
+       u8 frame_type;
+       u8 cmd_frame_id;
+       bool device_override;
+       u32 sec_levels;
+};
+
+struct ieee802154_llsec_params {
+       bool enabled;
+
+       __be32 frame_counter;
+       u8 out_level;
+       struct ieee802154_llsec_key_id out_key;
+
+       __le64 default_key_source;
+
+       __le16 pan_id;
+       __le64 hwaddr;
+       __le64 coord_hwaddr;
+       __le16 coord_shortaddr;
+};
+
+struct ieee802154_llsec_table {
+       struct list_head keys;
+       struct list_head devices;
+       struct list_head security_levels;
+};
+
 #define IEEE802154_MAC_SCAN_ED         0
 #define IEEE802154_MAC_SCAN_ACTIVE     1
 #define IEEE802154_MAC_SCAN_PASSIVE    2
@@ -260,6 +342,19 @@ struct ieee802154_mac_params {
 };
 
 struct wpan_phy;
+
+enum {
+       IEEE802154_LLSEC_PARAM_ENABLED = 1 << 0,
+       IEEE802154_LLSEC_PARAM_FRAME_COUNTER = 1 << 1,
+       IEEE802154_LLSEC_PARAM_OUT_LEVEL = 1 << 2,
+       IEEE802154_LLSEC_PARAM_OUT_KEY = 1 << 3,
+       IEEE802154_LLSEC_PARAM_KEY_SOURCE = 1 << 4,
+       IEEE802154_LLSEC_PARAM_PAN_ID = 1 << 5,
+       IEEE802154_LLSEC_PARAM_HWADDR = 1 << 6,
+       IEEE802154_LLSEC_PARAM_COORD_HWADDR = 1 << 7,
+       IEEE802154_LLSEC_PARAM_COORD_SHORTADDR = 1 << 8,
+};
+
 /*
  * This should be located at net_device->ml_priv
  *
diff --git a/net/mac802154/llsec.h b/net/mac802154/llsec.h
new file mode 100644
index 0000000..80fb4a5
--- /dev/null
+++ b/net/mac802154/llsec.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2014 Fraunhofer ITWM
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Written by:
+ * Phoebe Buckheister <phoebe.buckheis...@itwm.fraunhofer.de>
+ */
+
+#ifndef MAC802154_LLSEC_H
+#define MAC802154_LLSEC_H
+
+#include <linux/slab.h>
+#include <linux/hashtable.h>
+#include <linux/crypto.h>
+#include <linux/kref.h>
+#include <linux/spinlock.h>
+#include <net/af_ieee802154.h>
+#include <net/ieee802154_netdev.h>
+
+struct mac802154_llsec_key {
+       struct ieee802154_llsec_key key;
+
+       /* since authsize is part of the tfm, allocate tfms for 4/8/16 */
+       struct crypto_aead *tfm[3];
+       struct crypto_blkcipher *tfm0;
+
+       struct kref ref;
+};
+
+struct mac802154_llsec_device_key {
+       struct ieee802154_llsec_device_key devkey;
+
+       struct rcu_head rcu;
+};
+
+struct mac802154_llsec_device {
+       struct ieee802154_llsec_device dev;
+
+       struct hlist_node bucket_s;
+       struct hlist_node bucket_hw;
+
+       spinlock_t lock;
+
+       struct rcu_head rcu;
+};
+
+struct mac802154_llsec_seclevel {
+       struct ieee802154_llsec_seclevel level;
+
+       struct rcu_head rcu;
+};
+
+struct mac802154_llsec {
+       struct ieee802154_llsec_params params;
+       struct ieee802154_llsec_table table;
+
+       DECLARE_HASHTABLE(devices_short, 6);
+       DECLARE_HASHTABLE(devices_hw, 6);
+
+       struct mac802154_llsec_key *out_key;
+
+       spinlock_t lock;
+};
+
+#endif /* MAC802154_LLSEC_H */
-- 
1.7.9.5


------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Linux-zigbee-devel mailing list
Linux-zigbee-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

Reply via email to