]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - include/net/ah.h
8e27c9ba8b84d039a0818fa35026cd3fa2800a30
[linux-2.6-omap-h63xx.git] / include / net / ah.h
1 #ifndef _NET_AH_H
2 #define _NET_AH_H
3
4 #include <linux/crypto.h>
5 #include <net/xfrm.h>
6
7 /* This is the maximum truncated ICV length that we know of. */
8 #define MAX_AH_AUTH_LEN 12
9
10 struct ah_data
11 {
12         u8                      *key;
13         int                     key_len;
14         u8                      *work_icv;
15         int                     icv_full_len;
16         int                     icv_trunc_len;
17
18         void                    (*icv)(struct ah_data*,
19                                        struct sk_buff *skb, u8 *icv);
20
21         struct crypto_tfm       *tfm;
22 };
23
24 static inline void
25 ah_hmac_digest(struct ah_data *ahp, struct sk_buff *skb, u8 *auth_data)
26 {
27         struct crypto_tfm *tfm = ahp->tfm;
28
29         memset(auth_data, 0, ahp->icv_trunc_len);
30         crypto_hmac_init(tfm, ahp->key, &ahp->key_len);
31         skb_icv_walk(skb, tfm, 0, skb->len, crypto_hmac_update);
32         crypto_hmac_final(tfm, ahp->key, &ahp->key_len, ahp->work_icv);
33         memcpy(auth_data, ahp->work_icv, ahp->icv_trunc_len);
34 }
35
36 #endif