ieee80211_crypt.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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/skbuff.h>
  25. enum {
  26. IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0),
  27. };
  28. struct ieee80211_crypto_ops {
  29. const char *name;
  30. /* init new crypto context (e.g., allocate private data space,
  31. * select IV, etc.); returns NULL on failure or pointer to allocated
  32. * private data on success */
  33. void *(*init) (int keyidx);
  34. /* deinitialize crypto context and free allocated private data */
  35. void (*deinit) (void *priv);
  36. int (*build_iv) (struct sk_buff * skb, int hdr_len, void *priv);
  37. /* encrypt/decrypt return < 0 on error or >= 0 on success. The return
  38. * value from decrypt_mpdu is passed as the keyidx value for
  39. * decrypt_msdu. skb must have enough head and tail room for the
  40. * encryption; if not, error will be returned; these functions are
  41. * called for all MPDUs (i.e., fragments).
  42. */
  43. int (*encrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv);
  44. int (*decrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv);
  45. /* These functions are called for full MSDUs, i.e. full frames.
  46. * These can be NULL if full MSDU operations are not needed. */
  47. int (*encrypt_msdu) (struct sk_buff * skb, int hdr_len, void *priv);
  48. int (*decrypt_msdu) (struct sk_buff * skb, int keyidx, int hdr_len,
  49. void *priv);
  50. int (*set_key) (void *key, int len, u8 * seq, void *priv);
  51. int (*get_key) (void *key, int len, u8 * seq, void *priv);
  52. /* procfs handler for printing out key information and possible
  53. * statistics */
  54. char *(*print_stats) (char *p, void *priv);
  55. /* Crypto specific flag get/set for configuration settings */
  56. unsigned long (*get_flags) (void *priv);
  57. unsigned long (*set_flags) (unsigned long flags, void *priv);
  58. /* maximum number of bytes added by encryption; encrypt buf is
  59. * allocated with extra_prefix_len bytes, copy of in_buf, and
  60. * extra_postfix_len; encrypt need not use all this space, but
  61. * the result must start at the beginning of the buffer and correct
  62. * length must be returned */
  63. int extra_mpdu_prefix_len, extra_mpdu_postfix_len;
  64. int extra_msdu_prefix_len, extra_msdu_postfix_len;
  65. struct module *owner;
  66. };
  67. struct ieee80211_crypt_data {
  68. struct list_head list; /* delayed deletion list */
  69. struct ieee80211_crypto_ops *ops;
  70. void *priv;
  71. atomic_t refcnt;
  72. };
  73. int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
  74. int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
  75. struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name);
  76. void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
  77. void ieee80211_crypt_deinit_handler(unsigned long);
  78. void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
  79. struct ieee80211_crypt_data **crypt);
  80. void ieee80211_crypt_quiescing(struct ieee80211_device *ieee);
  81. #endif