Linux 5.7.7
[linux/fpc-iii.git] / net / mac802154 / llsec.h
blobddeb792282040db2acf4cd209880011cb9b43d2a
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (C) 2014 Fraunhofer ITWM
5 * Written by:
6 * Phoebe Buckheister <phoebe.buckheister@itwm.fraunhofer.de>
7 */
9 #ifndef MAC802154_LLSEC_H
10 #define MAC802154_LLSEC_H
12 #include <linux/slab.h>
13 #include <linux/hashtable.h>
14 #include <linux/kref.h>
15 #include <linux/spinlock.h>
16 #include <net/af_ieee802154.h>
17 #include <net/ieee802154_netdev.h>
19 struct mac802154_llsec_key {
20 struct ieee802154_llsec_key key;
22 /* one tfm for each authsize (4/8/16) */
23 struct crypto_aead *tfm[3];
24 struct crypto_sync_skcipher *tfm0;
26 struct kref ref;
29 struct mac802154_llsec_device_key {
30 struct ieee802154_llsec_device_key devkey;
32 struct rcu_head rcu;
35 struct mac802154_llsec_device {
36 struct ieee802154_llsec_device dev;
38 struct hlist_node bucket_s;
39 struct hlist_node bucket_hw;
41 /* protects dev.frame_counter and the elements of dev.keys */
42 spinlock_t lock;
44 struct rcu_head rcu;
47 struct mac802154_llsec_seclevel {
48 struct ieee802154_llsec_seclevel level;
50 struct rcu_head rcu;
53 struct mac802154_llsec {
54 struct ieee802154_llsec_params params;
55 struct ieee802154_llsec_table table;
57 DECLARE_HASHTABLE(devices_short, 6);
58 DECLARE_HASHTABLE(devices_hw, 6);
60 /* protects params, all other fields are fine with RCU */
61 rwlock_t lock;
64 void mac802154_llsec_init(struct mac802154_llsec *sec);
65 void mac802154_llsec_destroy(struct mac802154_llsec *sec);
67 int mac802154_llsec_get_params(struct mac802154_llsec *sec,
68 struct ieee802154_llsec_params *params);
69 int mac802154_llsec_set_params(struct mac802154_llsec *sec,
70 const struct ieee802154_llsec_params *params,
71 int changed);
73 int mac802154_llsec_key_add(struct mac802154_llsec *sec,
74 const struct ieee802154_llsec_key_id *id,
75 const struct ieee802154_llsec_key *key);
76 int mac802154_llsec_key_del(struct mac802154_llsec *sec,
77 const struct ieee802154_llsec_key_id *key);
79 int mac802154_llsec_dev_add(struct mac802154_llsec *sec,
80 const struct ieee802154_llsec_device *dev);
81 int mac802154_llsec_dev_del(struct mac802154_llsec *sec,
82 __le64 device_addr);
84 int mac802154_llsec_devkey_add(struct mac802154_llsec *sec,
85 __le64 dev_addr,
86 const struct ieee802154_llsec_device_key *key);
87 int mac802154_llsec_devkey_del(struct mac802154_llsec *sec,
88 __le64 dev_addr,
89 const struct ieee802154_llsec_device_key *key);
91 int mac802154_llsec_seclevel_add(struct mac802154_llsec *sec,
92 const struct ieee802154_llsec_seclevel *sl);
93 int mac802154_llsec_seclevel_del(struct mac802154_llsec *sec,
94 const struct ieee802154_llsec_seclevel *sl);
96 int mac802154_llsec_encrypt(struct mac802154_llsec *sec, struct sk_buff *skb);
97 int mac802154_llsec_decrypt(struct mac802154_llsec *sec, struct sk_buff *skb);
99 #endif /* MAC802154_LLSEC_H */