ieee80211_key.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. int hw_key_idx; /* filled and used by low-level driver */
  39. ieee80211_key_alg alg;
  40. union {
  41. struct {
  42. /* last used TSC */
  43. u32 iv32;
  44. u16 iv16;
  45. u16 p1k[5];
  46. int tx_initialized;
  47. /* last received RSC */
  48. u32 iv32_rx[NUM_RX_DATA_QUEUES];
  49. u16 iv16_rx[NUM_RX_DATA_QUEUES];
  50. u16 p1k_rx[NUM_RX_DATA_QUEUES][5];
  51. int rx_initialized[NUM_RX_DATA_QUEUES];
  52. } tkip;
  53. struct {
  54. u8 tx_pn[6];
  55. u8 rx_pn[NUM_RX_DATA_QUEUES][6];
  56. struct crypto_cipher *tfm;
  57. u32 replays; /* dot11RSNAStatsCCMPReplays */
  58. /* scratch buffers for virt_to_page() (crypto API) */
  59. #ifndef AES_BLOCK_LEN
  60. #define AES_BLOCK_LEN 16
  61. #endif
  62. u8 tx_crypto_buf[6 * AES_BLOCK_LEN];
  63. u8 rx_crypto_buf[6 * AES_BLOCK_LEN];
  64. } ccmp;
  65. } u;
  66. int tx_rx_count; /* number of times this key has been used */
  67. int keylen;
  68. /* if the low level driver can provide hardware acceleration it should
  69. * clear this flag */
  70. unsigned int force_sw_encrypt:1;
  71. unsigned int default_tx_key:1; /* This key is the new default TX key
  72. * (used only for broadcast keys). */
  73. s8 keyidx; /* WEP key index */
  74. #ifdef CONFIG_MAC80211_DEBUGFS
  75. struct {
  76. struct dentry *stalink;
  77. struct dentry *dir;
  78. struct dentry *keylen;
  79. struct dentry *force_sw_encrypt;
  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. } debugfs;
  89. #endif
  90. u8 key[0];
  91. };
  92. #endif /* IEEE80211_KEY_H */