ieee80211_cypto.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /****************************************************************************
  2. * net/ieee80211/ieee80211_crypto.h
  3. * 802.11 protocol crypto-related definitions.
  4. *
  5. * Copyright (c) 2007, 2008 Damien Bergamini <damien.bergamini@free.fr>
  6. *
  7. * Permission to use, copy, modify, and distribute this software for any
  8. * purpose with or without fee is hereby granted, provided that the above
  9. * copyright notice and this permission notice appear in all copies.
  10. *
  11. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  12. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  13. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  14. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  15. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  16. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  17. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  18. *
  19. ****************************************************************************/
  20. #ifndef __INCLUDE_NUTTX_WIRELESS_IEEE80211_IEEE80211_CRYPTO_H
  21. #define __INCLUDE_NUTTX_WIRELESS_IEEE80211_IEEE80211_CRYPTO_H
  22. /****************************************************************************
  23. * Included Files
  24. ****************************************************************************/
  25. #include <nuttx/config.h>
  26. /****************************************************************************
  27. * Pre-processor Definitions
  28. ****************************************************************************/
  29. #define IEEE80211_KEYBUF_SIZE 16
  30. #define IEEE80211_TKIP_HDRLEN 8
  31. #define IEEE80211_TKIP_MICLEN 8
  32. #define IEEE80211_TKIP_ICVLEN 4
  33. #define IEEE80211_CCMP_HDRLEN 8
  34. #define IEEE80211_CCMP_MICLEN 8
  35. #define IEEE80211_PMK_LEN 32
  36. /****************************************************************************
  37. * Public Types
  38. ****************************************************************************/
  39. /* 802.11 ciphers */
  40. enum ieee80211_cipher
  41. {
  42. IEEE80211_CIPHER_NONE = 0x00000000,
  43. IEEE80211_CIPHER_USEGROUP = 0x00000001,
  44. IEEE80211_CIPHER_WEP40 = 0x00000002,
  45. IEEE80211_CIPHER_TKIP = 0x00000004,
  46. IEEE80211_CIPHER_CCMP = 0x00000008,
  47. IEEE80211_CIPHER_WEP104 = 0x00000010,
  48. IEEE80211_CIPHER_BIP = 0x00000020 /* 11w */
  49. };
  50. /* 802.11 Authentication and Key Management Protocols */
  51. enum ieee80211_akm
  52. {
  53. IEEE80211_AKM_NONE = 0x00000000,
  54. IEEE80211_AKM_8021X = 0x00000001,
  55. IEEE80211_AKM_PSK = 0x00000002,
  56. IEEE80211_AKM_SHA256_8021X = 0x00000004, /* 11w */
  57. IEEE80211_AKM_SHA256_PSK = 0x00000008 /* 11w */
  58. };
  59. struct ieee80211_key
  60. {
  61. uint8_t k_id; /* Identifier (0-5) */
  62. enum ieee80211_cipher k_cipher;
  63. unsigned int k_flags;
  64. #define IEEE80211_KEY_GROUP 0x00000001 /* Group data key */
  65. #define IEEE80211_KEY_TX 0x00000002 /* Tx+Rx */
  66. #define IEEE80211_KEY_IGTK 0x00000004 /* Integrity group key */
  67. unsigned int k_len;
  68. uint64_t k_rsc[IEEE80211_NUM_TID];
  69. uint64_t k_mgmt_rsc;
  70. uint64_t k_tsc;
  71. uint8_t k_key[32];
  72. FAR void *k_priv;
  73. };
  74. /* Entry in the PMKSA cache */
  75. struct ieee80211_pmk
  76. {
  77. sq_entry_t pmk_next;
  78. enum ieee80211_akm pmk_akm;
  79. uint32_t pmk_lifetime;
  80. #define IEEE80211_PMK_INFINITE 0
  81. uint8_t pmk_pmkid[IEEE80211_PMKID_LEN];
  82. uint8_t pmk_macaddr[IEEE80211_ADDR_LEN];
  83. uint8_t pmk_key[IEEE80211_PMK_LEN];
  84. };
  85. /****************************************************************************
  86. * Inline Functions
  87. ****************************************************************************/
  88. static __inline int ieee80211_is_8021x_akm(enum ieee80211_akm akm)
  89. {
  90. return akm == IEEE80211_AKM_8021X || akm == IEEE80211_AKM_SHA256_8021X;
  91. }
  92. static __inline int ieee80211_is_sha256_akm(enum ieee80211_akm akm)
  93. {
  94. return akm == IEEE80211_AKM_SHA256_8021X || akm == IEEE80211_AKM_SHA256_PSK;
  95. }
  96. #endif /* __INCLUDE_NUTTX_WIRELESS_IEEE80211_IEEE80211_CRYPTO_H */