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