ieee80211_crypt.h 3.2 KB

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