hostap_crypt.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef PRISM2_CRYPT_H
  2. #define PRISM2_CRYPT_H
  3. struct hostap_crypto_ops {
  4. char *name;
  5. /* init new crypto context (e.g., allocate private data space,
  6. * select IV, etc.); returns NULL on failure or pointer to allocated
  7. * private data on success */
  8. void * (*init)(int keyidx);
  9. /* deinitialize crypto context and free allocated private data */
  10. void (*deinit)(void *priv);
  11. /* encrypt/decrypt return < 0 on error or >= 0 on success. The return
  12. * value from decrypt_mpdu is passed as the keyidx value for
  13. * decrypt_msdu. skb must have enough head and tail room for the
  14. * encryption; if not, error will be returned; these functions are
  15. * called for all MPDUs (i.e., fragments).
  16. */
  17. int (*encrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
  18. int (*decrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
  19. /* These functions are called for full MSDUs, i.e. full frames.
  20. * These can be NULL if full MSDU operations are not needed. */
  21. int (*encrypt_msdu)(struct sk_buff *skb, int hdr_len, void *priv);
  22. int (*decrypt_msdu)(struct sk_buff *skb, int keyidx, int hdr_len,
  23. void *priv);
  24. int (*set_key)(void *key, int len, u8 *seq, void *priv);
  25. int (*get_key)(void *key, int len, u8 *seq, void *priv);
  26. /* procfs handler for printing out key information and possible
  27. * statistics */
  28. char * (*print_stats)(char *p, void *priv);
  29. /* maximum number of bytes added by encryption; encrypt buf is
  30. * allocated with extra_prefix_len bytes, copy of in_buf, and
  31. * extra_postfix_len; encrypt need not use all this space, but
  32. * the result must start at the beginning of the buffer and correct
  33. * length must be returned */
  34. int extra_prefix_len, extra_postfix_len;
  35. };
  36. int hostap_register_crypto_ops(struct hostap_crypto_ops *ops);
  37. int hostap_unregister_crypto_ops(struct hostap_crypto_ops *ops);
  38. struct hostap_crypto_ops * hostap_get_crypto_ops(const char *name);
  39. #endif /* PRISM2_CRYPT_H */