blob: 8e27c9ba8b84d039a0818fa35026cd3fa2800a30 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _NET_AH_H
2#define _NET_AH_H
3
Herbert Xu9409f382006-08-06 19:49:12 +10004#include <linux/crypto.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005#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
10struct 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
24static inline void
25ah_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