Johannes Berg | 1f5a7e4 | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2002-2005, Instant802 Networks, Inc. |
| 3 | * Copyright 2005-2006, Devicescape Software, Inc. |
| 4 | * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | |
| 11 | #include <net/mac80211.h> |
| 12 | #include "ieee80211_i.h" |
| 13 | #include "debugfs_key.h" |
| 14 | #include "aes_ccm.h" |
| 15 | |
Johannes Berg | 1f5a7e4 | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 16 | struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata, |
| 17 | int idx, size_t key_len, gfp_t flags) |
| 18 | { |
| 19 | struct ieee80211_key *key; |
| 20 | |
| 21 | key = kzalloc(sizeof(struct ieee80211_key) + key_len, flags); |
| 22 | if (!key) |
| 23 | return NULL; |
Johannes Berg | 1f5a7e4 | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 24 | return key; |
| 25 | } |
| 26 | |
Johannes Berg | 1f5a7e4 | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 27 | void ieee80211_key_free(struct ieee80211_key *key) |
| 28 | { |
Johannes Berg | 8f37171 | 2007-08-28 17:01:54 -0400 | [diff] [blame^] | 29 | if (!key) |
| 30 | return; |
| 31 | |
| 32 | if (key->conf.alg == ALG_CCMP) |
| 33 | ieee80211_aes_key_free(key->u.ccmp.tfm); |
| 34 | ieee80211_debugfs_key_remove(key); |
| 35 | kfree(key); |
Johannes Berg | 1f5a7e4 | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 36 | } |