ieee80211_key.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright 2002-2004, Instant802 Networks, Inc.
  3. * Copyright 2005, Devicescape Software, Inc.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #ifndef IEEE80211_KEY_H
  10. #define IEEE80211_KEY_H
  11. #include <linux/types.h>
  12. #include <linux/list.h>
  13. #include <linux/crypto.h>
  14. #include <net/mac80211.h>
  15. /* ALG_TKIP
  16. * struct ieee80211_key::key is encoded as a 256-bit (32 byte) data block:
  17. * Temporal Encryption Key (128 bits)
  18. * Temporal Authenticator Tx MIC Key (64 bits)
  19. * Temporal Authenticator Rx MIC Key (64 bits)
  20. */
  21. #define WEP_IV_LEN 4
  22. #define WEP_ICV_LEN 4
  23. #define ALG_TKIP_KEY_LEN 32
  24. /* Starting offsets for each key */
  25. #define ALG_TKIP_TEMP_ENCR_KEY 0
  26. #define ALG_TKIP_TEMP_AUTH_TX_MIC_KEY 16
  27. #define ALG_TKIP_TEMP_AUTH_RX_MIC_KEY 24
  28. #define TKIP_IV_LEN 8
  29. #define TKIP_ICV_LEN 4
  30. #define ALG_CCMP_KEY_LEN 16
  31. #define CCMP_HDR_LEN 8
  32. #define CCMP_MIC_LEN 8
  33. #define CCMP_TK_LEN 16
  34. #define CCMP_PN_LEN 6
  35. #define NUM_RX_DATA_QUEUES 17
  36. struct ieee80211_local;
  37. struct ieee80211_sub_if_data;
  38. struct sta_info;
  39. #define KEY_FLAG_UPLOADED_TO_HARDWARE (1<<0)
  40. struct ieee80211_key {
  41. struct ieee80211_local *local;
  42. struct ieee80211_sub_if_data *sdata;
  43. struct sta_info *sta;
  44. struct list_head list;
  45. unsigned int flags;
  46. union {
  47. struct {
  48. /* last used TSC */
  49. u32 iv32;
  50. u16 iv16;
  51. u16 p1k[5];
  52. int tx_initialized;
  53. /* last received RSC */
  54. u32 iv32_rx[NUM_RX_DATA_QUEUES];
  55. u16 iv16_rx[NUM_RX_DATA_QUEUES];
  56. u16 p1k_rx[NUM_RX_DATA_QUEUES][5];
  57. int rx_initialized[NUM_RX_DATA_QUEUES];
  58. } tkip;
  59. struct {
  60. u8 tx_pn[6];
  61. u8 rx_pn[NUM_RX_DATA_QUEUES][6];
  62. struct crypto_cipher *tfm;
  63. u32 replays; /* dot11RSNAStatsCCMPReplays */
  64. /* scratch buffers for virt_to_page() (crypto API) */
  65. #ifndef AES_BLOCK_LEN
  66. #define AES_BLOCK_LEN 16
  67. #endif
  68. u8 tx_crypto_buf[6 * AES_BLOCK_LEN];
  69. u8 rx_crypto_buf[6 * AES_BLOCK_LEN];
  70. } ccmp;
  71. } u;
  72. /* number of times this key has been used */
  73. int tx_rx_count;
  74. #ifdef CONFIG_MAC80211_DEBUGFS
  75. struct {
  76. struct dentry *stalink;
  77. struct dentry *dir;
  78. struct dentry *keylen;
  79. struct dentry *flags;
  80. struct dentry *keyidx;
  81. struct dentry *hw_key_idx;
  82. struct dentry *tx_rx_count;
  83. struct dentry *algorithm;
  84. struct dentry *tx_spec;
  85. struct dentry *rx_spec;
  86. struct dentry *replays;
  87. struct dentry *key;
  88. struct dentry *ifindex;
  89. } debugfs;
  90. #endif
  91. /*
  92. * key config, must be last because it contains key
  93. * material as variable length member
  94. */
  95. struct ieee80211_key_conf conf;
  96. };
  97. struct ieee80211_key *ieee80211_key_alloc(struct ieee80211_sub_if_data *sdata,
  98. struct sta_info *sta,
  99. enum ieee80211_key_alg alg,
  100. int idx,
  101. size_t key_len,
  102. const u8 *key_data);
  103. void ieee80211_key_free(struct ieee80211_key *key);
  104. void ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, int idx);
  105. void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata);
  106. void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata);
  107. void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata);
  108. #endif /* IEEE80211_KEY_H */