pmksa_cache.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * wpa_supplicant - WPA2/RSN PMKSA cache functions
  3. * Copyright (c) 2003-2009, 2011-2012, Jouni Malinen <j@w1.fi>
  4. *
  5. * This software may be distributed under the terms of the BSD license.
  6. * See README for more details.
  7. */
  8. #ifndef PMKSA_CACHE_H
  9. #define PMKSA_CACHE_H
  10. /**
  11. * struct rsn_pmksa_cache_entry - PMKSA cache entry
  12. */
  13. struct rsn_pmksa_cache_entry {
  14. struct rsn_pmksa_cache_entry *next;
  15. u8 pmkid[PMKID_LEN];
  16. u8 pmk[PMK_LEN];
  17. size_t pmk_len;
  18. os_time_t expiration;
  19. int akmp; /* WPA_KEY_MGMT_* */
  20. u8 aa[ETH_ALEN];
  21. os_time_t reauth_time;
  22. /**
  23. * network_ctx - Network configuration context
  24. *
  25. * This field is only used to match PMKSA cache entries to a specific
  26. * network configuration (e.g., a specific SSID and security policy).
  27. * This can be a pointer to the configuration entry, but PMKSA caching
  28. * code does not dereference the value and this could be any kind of
  29. * identifier.
  30. */
  31. void *network_ctx;
  32. int opportunistic;
  33. };
  34. struct rsn_pmksa_cache;
  35. enum pmksa_free_reason {
  36. PMKSA_FREE,
  37. PMKSA_REPLACE,
  38. PMKSA_EXPIRE,
  39. };
  40. #ifdef IEEE8021X_EAPOL
  41. struct rsn_pmksa_cache *
  42. pmksa_cache_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry,
  43. void *ctx, enum pmksa_free_reason reason),
  44. void *ctx, struct wpa_sm *sm);
  45. void pmksa_cache_deinit(struct rsn_pmksa_cache *pmksa);
  46. struct rsn_pmksa_cache_entry * pmksa_cache_get(struct rsn_pmksa_cache *pmksa,
  47. const u8 *aa, const u8 *pmkid,
  48. const void *network_ctx);
  49. int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf, size_t len);
  50. struct rsn_pmksa_cache_entry *
  51. pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len,
  52. const u8 *kck, size_t kck_len,
  53. const u8 *aa, const u8 *spa, void *network_ctx, int akmp);
  54. struct rsn_pmksa_cache_entry * pmksa_cache_get_current(struct wpa_sm *sm);
  55. void pmksa_cache_clear_current(struct wpa_sm *sm);
  56. int pmksa_cache_set_current(struct wpa_sm *sm, const u8 *pmkid,
  57. const u8 *bssid, void *network_ctx,
  58. int try_opportunistic);
  59. struct rsn_pmksa_cache_entry *
  60. pmksa_cache_get_opportunistic(struct rsn_pmksa_cache *pmksa,
  61. void *network_ctx, const u8 *aa);
  62. void pmksa_cache_flush(struct rsn_pmksa_cache *pmksa, void *network_ctx,
  63. const u8 *pmk, size_t pmk_len);
  64. #else /* IEEE8021X_EAPOL */
  65. static inline struct rsn_pmksa_cache *
  66. pmksa_cache_init(void (*free_cb)(struct rsn_pmksa_cache_entry *entry,
  67. void *ctx, enum pmksa_free_reason reason),
  68. void *ctx, struct wpa_sm *sm)
  69. {
  70. return (void *) -1;
  71. }
  72. static inline void pmksa_cache_deinit(struct rsn_pmksa_cache *pmksa)
  73. {
  74. }
  75. static inline struct rsn_pmksa_cache_entry *
  76. pmksa_cache_get(struct rsn_pmksa_cache *pmksa, const u8 *aa, const u8 *pmkid,
  77. const void *network_ctx)
  78. {
  79. return NULL;
  80. }
  81. static inline struct rsn_pmksa_cache_entry *
  82. pmksa_cache_get_current(struct wpa_sm *sm)
  83. {
  84. return NULL;
  85. }
  86. static inline int pmksa_cache_list(struct rsn_pmksa_cache *pmksa, char *buf,
  87. size_t len)
  88. {
  89. return -1;
  90. }
  91. static inline struct rsn_pmksa_cache_entry *
  92. pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len,
  93. const u8 *kck, size_t kck_len,
  94. const u8 *aa, const u8 *spa, void *network_ctx, int akmp)
  95. {
  96. return NULL;
  97. }
  98. static inline void pmksa_cache_clear_current(struct wpa_sm *sm)
  99. {
  100. }
  101. static inline int pmksa_cache_set_current(struct wpa_sm *sm, const u8 *pmkid,
  102. const u8 *bssid,
  103. void *network_ctx,
  104. int try_opportunistic)
  105. {
  106. return -1;
  107. }
  108. static inline void pmksa_cache_flush(struct rsn_pmksa_cache *pmksa,
  109. void *network_ctx,
  110. const u8 *pmk, size_t pmk_len)
  111. {
  112. }
  113. #endif /* IEEE8021X_EAPOL */
  114. #endif /* PMKSA_CACHE_H */