ieee80211_key.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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/kref.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_key {
  37. struct kref kref;
  38. union {
  39. struct {
  40. /* last used TSC */
  41. u32 iv32;
  42. u16 iv16;
  43. u16 p1k[5];
  44. int tx_initialized;
  45. /* last received RSC */
  46. u32 iv32_rx[NUM_RX_DATA_QUEUES];
  47. u16 iv16_rx[NUM_RX_DATA_QUEUES];
  48. u16 p1k_rx[NUM_RX_DATA_QUEUES][5];
  49. int rx_initialized[NUM_RX_DATA_QUEUES];
  50. } tkip;
  51. struct {
  52. u8 tx_pn[6];
  53. u8 rx_pn[NUM_RX_DATA_QUEUES][6];
  54. struct crypto_cipher *tfm;
  55. u32 replays; /* dot11RSNAStatsCCMPReplays */
  56. /* scratch buffers for virt_to_page() (crypto API) */
  57. #ifndef AES_BLOCK_LEN
  58. #define AES_BLOCK_LEN 16
  59. #endif
  60. u8 tx_crypto_buf[6 * AES_BLOCK_LEN];
  61. u8 rx_crypto_buf[6 * AES_BLOCK_LEN];
  62. } ccmp;
  63. } u;
  64. /* number of times this key has been used */
  65. int tx_rx_count;
  66. #ifdef CONFIG_MAC80211_DEBUGFS
  67. struct {
  68. struct dentry *stalink;
  69. struct dentry *dir;
  70. struct dentry *keylen;
  71. struct dentry *flags;
  72. struct dentry *keyidx;
  73. struct dentry *hw_key_idx;
  74. struct dentry *tx_rx_count;
  75. struct dentry *algorithm;
  76. struct dentry *tx_spec;
  77. struct dentry *rx_spec;
  78. struct dentry *replays;
  79. struct dentry *key;
  80. } debugfs;
  81. #endif
  82. /*
  83. * key config, must be last because it contains key
  84. * material as variable length member
  85. */
  86. struct ieee80211_key_conf conf;
  87. };
  88. #endif /* IEEE80211_KEY_H */