blob: 03b766afdc395cab12fe65f083714667627b4b78 [file] [log] [blame]
Jeff Garzikb4538722005-05-12 22:48:20 -04001/*
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/*
21 * This file defines the interface to the ieee80211 crypto module.
22 */
23#ifndef IEEE80211_CRYPT_H
24#define IEEE80211_CRYPT_H
25
Arnaldo Carvalho de Melo14c85022005-12-27 02:43:12 -020026#include <linux/types.h>
27#include <linux/list.h>
28#include <asm/atomic.h>
Jeff Garzikb4538722005-05-12 22:48:20 -040029
James Ketrenos6eb6edf2005-09-22 10:34:15 +000030enum {
James Ketrenosff0037b2005-10-03 10:23:42 -050031 IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0),
James Ketrenos6eb6edf2005-09-22 10:34:15 +000032};
33
Arnaldo Carvalho de Melo14c85022005-12-27 02:43:12 -020034struct sk_buff;
35struct module;
36
Jeff Garzikb4538722005-05-12 22:48:20 -040037struct ieee80211_crypto_ops {
38 const char *name;
Christoph Hellwige3305622005-11-09 01:01:04 -050039 struct list_head list;
Jeff Garzikb4538722005-05-12 22:48:20 -040040
41 /* init new crypto context (e.g., allocate private data space,
42 * select IV, etc.); returns NULL on failure or pointer to allocated
43 * private data on success */
James Ketrenos6eb6edf2005-09-22 10:34:15 +000044 void *(*init) (int keyidx);
Jeff Garzikb4538722005-05-12 22:48:20 -040045
46 /* deinitialize crypto context and free allocated private data */
James Ketrenos74079fd2005-09-13 17:35:21 -050047 void (*deinit) (void *priv);
Jeff Garzikb4538722005-05-12 22:48:20 -040048
James Ketrenos31b59ea2005-09-21 11:58:49 -050049 int (*build_iv) (struct sk_buff * skb, int hdr_len, void *priv);
50
Jeff Garzikb4538722005-05-12 22:48:20 -040051 /* encrypt/decrypt return < 0 on error or >= 0 on success. The return
52 * value from decrypt_mpdu is passed as the keyidx value for
53 * decrypt_msdu. skb must have enough head and tail room for the
54 * encryption; if not, error will be returned; these functions are
55 * called for all MPDUs (i.e., fragments).
56 */
James Ketrenos74079fd2005-09-13 17:35:21 -050057 int (*encrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv);
58 int (*decrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv);
Jeff Garzikb4538722005-05-12 22:48:20 -040059
60 /* These functions are called for full MSDUs, i.e. full frames.
61 * These can be NULL if full MSDU operations are not needed. */
James Ketrenos74079fd2005-09-13 17:35:21 -050062 int (*encrypt_msdu) (struct sk_buff * skb, int hdr_len, void *priv);
63 int (*decrypt_msdu) (struct sk_buff * skb, int keyidx, int hdr_len,
64 void *priv);
Jeff Garzikb4538722005-05-12 22:48:20 -040065
James Ketrenos74079fd2005-09-13 17:35:21 -050066 int (*set_key) (void *key, int len, u8 * seq, void *priv);
67 int (*get_key) (void *key, int len, u8 * seq, void *priv);
Jeff Garzikb4538722005-05-12 22:48:20 -040068
69 /* procfs handler for printing out key information and possible
70 * statistics */
James Ketrenos74079fd2005-09-13 17:35:21 -050071 char *(*print_stats) (char *p, void *priv);
Jeff Garzikb4538722005-05-12 22:48:20 -040072
James Ketrenos6eb6edf2005-09-22 10:34:15 +000073 /* Crypto specific flag get/set for configuration settings */
James Ketrenosff0037b2005-10-03 10:23:42 -050074 unsigned long (*get_flags) (void *priv);
75 unsigned long (*set_flags) (unsigned long flags, void *priv);
James Ketrenos6eb6edf2005-09-22 10:34:15 +000076
Jeff Garzikb4538722005-05-12 22:48:20 -040077 /* maximum number of bytes added by encryption; encrypt buf is
78 * allocated with extra_prefix_len bytes, copy of in_buf, and
79 * extra_postfix_len; encrypt need not use all this space, but
80 * the result must start at the beginning of the buffer and correct
81 * length must be returned */
James Ketrenos1264fc02005-09-21 11:54:53 -050082 int extra_mpdu_prefix_len, extra_mpdu_postfix_len;
83 int extra_msdu_prefix_len, extra_msdu_postfix_len;
Jeff Garzikb4538722005-05-12 22:48:20 -040084
85 struct module *owner;
86};
87
88struct ieee80211_crypt_data {
James Ketrenos74079fd2005-09-13 17:35:21 -050089 struct list_head list; /* delayed deletion list */
Jeff Garzikb4538722005-05-12 22:48:20 -040090 struct ieee80211_crypto_ops *ops;
91 void *priv;
92 atomic_t refcnt;
93};
94
Arnaldo Carvalho de Melo14c85022005-12-27 02:43:12 -020095struct ieee80211_device;
96
Jeff Garzikb4538722005-05-12 22:48:20 -040097int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
98int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
James Ketrenos74079fd2005-09-13 17:35:21 -050099struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name);
Jeff Garzikb4538722005-05-12 22:48:20 -0400100void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
101void ieee80211_crypt_deinit_handler(unsigned long);
102void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
103 struct ieee80211_crypt_data **crypt);
James Ketrenos0ad0c3c2005-09-21 11:54:15 -0500104void ieee80211_crypt_quiescing(struct ieee80211_device *ieee);
Jeff Garzikb4538722005-05-12 22:48:20 -0400105
106#endif