ieee80211_crypt.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Original code based on Host AP (software wireless LAN access point) driver
  3. * for Intersil Prism2/2.5/3.
  4. *
  5. * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
  6. * <jkmaline@cc.hut.fi>
  7. * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
  8. *
  9. * Adaption to a generic IEEE 802.11 stack by James Ketrenos
  10. * <jketreno@linux.intel.com>
  11. *
  12. * Copyright (c) 2004, Intel Corporation
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License version 2 as
  16. * published by the Free Software Foundation. See README and COPYING for
  17. * more details.
  18. */
  19. /*
  20. * This file defines the interface to the ieee80211 crypto module.
  21. */
  22. #ifndef IEEE80211_CRYPT_H
  23. #define IEEE80211_CRYPT_H
  24. #include <linux/types.h>
  25. #include <linux/list.h>
  26. #include <net/ieee80211.h>
  27. #include <asm/atomic.h>
  28. enum {
  29. IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0),
  30. };
  31. struct sk_buff;
  32. struct module;
  33. struct ieee80211_crypto_ops {
  34. const char *name;
  35. struct list_head list;
  36. /* init new crypto context (e.g., allocate private data space,
  37. * select IV, etc.); returns NULL on failure or pointer to allocated
  38. * private data on success */
  39. void *(*init) (int keyidx);
  40. /* deinitialize crypto context and free allocated private data */
  41. void (*deinit) (void *priv);
  42. int (*build_iv) (struct sk_buff * skb, int hdr_len,
  43. u8 *key, int keylen, void *priv);
  44. /* encrypt/decrypt return < 0 on error or >= 0 on success. The return
  45. * value from decrypt_mpdu is passed as the keyidx value for
  46. * decrypt_msdu. skb must have enough head and tail room for the
  47. * encryption; if not, error will be returned; these functions are
  48. * called for all MPDUs (i.e., fragments).
  49. */
  50. int (*encrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv);
  51. int (*decrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv);
  52. /* These functions are called for full MSDUs, i.e. full frames.
  53. * These can be NULL if full MSDU operations are not needed. */
  54. int (*encrypt_msdu) (struct sk_buff * skb, int hdr_len, void *priv);
  55. int (*decrypt_msdu) (struct sk_buff * skb, int keyidx, int hdr_len,
  56. void *priv);
  57. int (*set_key) (void *key, int len, u8 * seq, void *priv);
  58. int (*get_key) (void *key, int len, u8 * seq, void *priv);
  59. /* procfs handler for printing out key information and possible
  60. * statistics */
  61. char *(*print_stats) (char *p, void *priv);
  62. /* Crypto specific flag get/set for configuration settings */
  63. unsigned long (*get_flags) (void *priv);
  64. unsigned long (*set_flags) (unsigned long flags, void *priv);
  65. /* maximum number of bytes added by encryption; encrypt buf is
  66. * allocated with extra_prefix_len bytes, copy of in_buf, and
  67. * extra_postfix_len; encrypt need not use all this space, but
  68. * the result must start at the beginning of the buffer and correct
  69. * length must be returned */
  70. int extra_mpdu_prefix_len, extra_mpdu_postfix_len;
  71. int extra_msdu_prefix_len, extra_msdu_postfix_len;
  72. struct module *owner;
  73. };
  74. struct ieee80211_crypt_data {
  75. struct list_head list; /* delayed deletion list */
  76. struct ieee80211_crypto_ops *ops;
  77. void *priv;
  78. atomic_t refcnt;
  79. };
  80. struct ieee80211_device;
  81. int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
  82. int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
  83. struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name);
  84. void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
  85. void ieee80211_crypt_deinit_handler(unsigned long);
  86. void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
  87. struct ieee80211_crypt_data **crypt);
  88. void ieee80211_crypt_quiescing(struct ieee80211_device *ieee);
  89. #endif